glow.support package

Submodules

glow.support.types module

Module containing enumeration classes for expressing different types (e.g. BCs, geometry, etc.) used throughout the source code.

class BoundaryType(*values)[source]

Bases: Enum

Enumeration for defining the types of the boundary conditions applied to the borders of the geometry layout.

AXIAL_SYMMETRY: int = 4

Indicating an axial symmetry BC.

CENTRAL_SYMMETRY: int = 5

Indicating a central symmetry BC.

REFL: int = 1

Indicating a specular reflection BC.

ROTATION: int = 3

Indicating a rotation BC.

TRANSLATION: int = 2

Indicating a translation BC.

VOID: int = 0

Indicating a vacuum + albedo BC.

class EdgeType(*values)[source]

Bases: Enum

Enumeration for identifying each type of edge object with an index.

ARC_CIRCLE: int = 3

Identifying an arc of circle-type edge.

CIRCLE: int = 2

Identifying a circle-type edge.

SEGMENT: int = 1

Identifying a segment-type edge.

class GeometryType(*values)[source]

Bases: Enum

Enumeration for identifying the type of geometry layout. Available values are the technological geometry, which describes the layout in terms of the regions identified by the different materials, and the refined geometry.

SECTORIZED: int = 1

Identifying the sectorized geometry of the layout.

TECHNOLOGICAL: int = 0

Identifying the technological geometry of the layout.

class LayoutGeometryType(*values)[source]

Bases: Enum

Enumeration for defining the geometry types of the layout as requested by the SALT: module of DRAGON5. Values higher than 2, i.e. ROTATION, refer to geometry layouts for which a cycling tracking needs to be applied (TSPC type). The values from 0 to 2 included, refer to geometry layouts for which a uniform tracking needs to be applied (TISO type).

HEXAGON_TRAN: int = 9

Hexagonal geometry with translations on all sides.

ISOTROPIC: int = 0

Generic geometry with vacuum or isotropic reflection.

R120: int = 11

Lozenge geometry with rotation and translation.

RA60: int = 10

Isosceles triangle geometry with rotation and translation.

RECTANGLE_EIGHT: int = 7

1/8 rectangular assembly with symmetries on all sides.

RECTANGLE_SYM: int = 6

Rectangular geometry with symmetry on all sides.

RECTANGLE_TRAN: int = 5

Rectangular geometry with translation on all sides.

ROTATION: int = 2

Generic geometry with rotation of angle 2*pi/n, n>1.

S30: int = 12

Triangle geometry identifying a symmetry of 1/12 of the layout.

SA60: int = 8

Isosceles triangle geometry with symmetries on all sides.

SYMMETRIES_TWO: int = 1

Generic geometry with symmetries of two axis of angle pi/n, n>0.

class LayoutType(*values)[source]

Bases: Enum

Enumeration for defining the geometric types of the layout.

GENERIC: int = 2

Identifying a generic layout.

HEX: int = 1

Identifying a hexagonal layout.

RECT: int = 0

Identifying a cartesian (i.e. rectangular) layout.

class PropertyType(*values)[source]

Bases: Enum

Enumeration for defining the property types that can be associated to each region of the technological geometry layout.

MACRO: int = 1

Identifying the macro region a region belongs to.

MATERIAL: int = 0

Identifying the material property type.

class SymmetryType(*values)[source]

Bases: Enum

Enumeration for defining the symmetry types of the layout.

DIAG: int = 13

Identifying an half of the layout along its diagonal.

EIGHTH: int = 8

Identifying an eighth of the layout.

FULL: int = 0

Identifying a complete layout.

HALF: int = 2

Identifying an half of the layout.

QUARTER: int = 4

Identifying a quarter of the layout.

SIXTH: int = 6

Identifying a sixth of the layout.

THIRD: int = 3

Identifying a third of the layout.

TWELFTH: int = 12

Identifying an twelfth of the layout.

glow.support.utility module

Module containing utility functions to support the construction and analysis of the geometry layouts.

are_same_shapes(shape1: Any, shape2: Any, shapes_type: ShapeType) bool[source]

Function that determines whether two shapes are the same based on their geometric properties (perimeter, area and volume), a cut operation, and the shape type.

Parameters:
  • shape1 (Any) – The first shape to compare.

  • shape2 (Any) – The second shape to compare.

  • shapes_type (ShapeType) – The type of sub-shapes to check for after the cut operation.

Returns:

True if the two shapes are considered the same (i.e., they have the same geometric properties and the cut result does not contain any sub-shapes of the specified type), False otherwise.

Return type:

bool

Raises:

RuntimeError – If the two shapes are not of the same type.

build_arcs_for_rounded_corners(rounded_corners: List[Tuple[int, float]], center: Tuple[float, float, float], height: float, width: float) List[Any][source]

Function that builds the arcs (as GEOM edge objects) that represent the rounded corners of a rectangle with given dimensions. The information about which corners are rounded and the corresponding radius is provided by the rounded_corners input list.

Parameters:
  • rounded_corners (List[Tuple[int, float]]) – List of tuples containing the rectangle corner ID and the corresponding radius.

  • center (Tuple[float, float, float]) – The XYZ coordinates of the center of the rectangle.

  • height (float) – The height of the rectangle.

  • width (float) – The width of the rectangle.

Returns:

A list of GEOM edge objects representing the arcs of circle for the rounded corners on the borders of the rectangle.

Return type:

List[Any]

Raises:

RuntimeError – In case any of the radii of the corners is greater than the maximum allowed radius being the minimum between the rectangle’s halved width or height.

build_compound_borders(cmpd: Any) List[Any][source]

Function that extracts the external borders of the given compound object and returns them as a list of edge objects.

Parameters:

cmpd (Any) – The compound object whose borders to extract.

Returns:

A list of edge objects representing the given compound external boundary.

Return type:

List[Any]

Raises:

RuntimeError – If no closed boundaries could be extracted from the given compound object.

build_contiguous_edges(vertices: List[Any]) List[Any][source]

Function that builds a list of contiguous edge objects each sharing one of the vertices to form a closed path.

Parameters:

vertices (List[Any]) – List of vertex objects representing the start-end points of the contiguous edges.

Returns:

The list of contiguous edge objects.

Return type:

List[Any]

Raises:
  • RuntimeError – If less than 3 vertices are provided.

  • RuntimeError – If two consecutive vertices in the list are the same, as no edge could be built from them.

build_subdvision_vertices_on_edge(no_vertices: int, edge: Any, i_0: float = 0.0)[source]

Function that builds and returns a list of vertex objects placed at subdivision points along the given edge object. Each position is determined by the number of evenly spaced vertices to derive starting from an initial given position.

Parameters:
  • no_vertices (int) – The number of evenly spaced vertices to subdivide the edge into.

  • edge (Any) – The edge object on which vertices are derived.

  • i_0 (float = 0.0) – The starting position along the edge from which points are built. It must be expressed as fraction of the edge’s length.

Returns:

A list of vertex objects built on the given edge.

Return type:

List[Any]

Raises:

ValueError – If the starting position is not in the [0-1) range.

build_z_axis_from_vertex(vertex: Any) Any[source]

Function that builds an axis originating from the given GEOM vertex and being perpendicular to the XY plane.

Parameters:

vertex (Any) – The GEOM vertex being the origin point of the Z-axis.

Returns:

The GEOM edge being the Z-axis originating from the given vertex.

Return type:

Any

check_shape_expected_types(shape: Any, expected_types: List[ShapeType]) None[source]

Function that checks if the type of the given shape matches any of the expected types.

Parameters:
  • shape (Any) – The shape object whose type is to be checked.

  • expected_types (List[ShapeType]) – A list of expected shape types.

Raises:

RuntimeError – If the type of the shape is not in the list of expected types.

check_type_geo_consistency(type_geo: LayoutGeometryType, layout_type: LayoutType, symmetry_type: SymmetryType) None[source]

Function that checks if the given type of geometry is valid for the indicated type of layout and the type of symmetry.

Parameters:
  • type_geo (LatticeGeometryType) – The type of geometry of the lattice.

  • layout_type (LayoutType) – The type of layout.

  • symmetry_type (SymmetryType) – The type of symmetry.

Raises:

RuntimeError – If the given layout type of geometry does not match with the indicated layout and symmetry types.

compute_point_by_reference(point: Any, ref_point: Any, new_ref_coords: Tuple[float, float, float]) Tuple[float, float, float][source]

Function that calculates the new coordinates of the given vertex object so that it keeps the same relative vector (i.e., same distance and direction) from a reference point which is moved in another position. The coordinates of the reference point before and after its translation are provided.

Parameters:
  • point (Any) – The vertex object whose new coordinates must be evaluated.

  • ref_point (Any) – The reference vertex object the point is relative to.

  • new_ref_coords (Tuple[float, float, float]) – The XYZ coordinates of the reference point after translation.

Returns:

The new coordinates of the given point so that it preserves its relative position with respect to its translated reference point.

Return type:

Tuple[float, float, float]

flatten_list(nested_list: List[Any]) Generator[Any, Any, None][source]

Function that recursively flattens an arbitrarily nested structure of lists into a one-dimensional generator of elements.

This function performs a depth-first traversal over the given list of nested elements, yielding non-list elements in the order they are encountered. Nested lists are recursively expanded, while None values are skipped.

Parameters:

nested_list (list of Any) – A list of arbitrarily nested list of objects. Elements may themselves be lists, in which case they are recursively traversed and flattened.

Yields:

Any – The next non-list element found during the depth-first traversal.

generate_unique_random_colors(no_colors: int) List[Tuple[int, int, int]][source]

Function for generating a specified number of random unique RGB colors.

Parameters:

no_colors (int) – The number of RGB colors to generate.

Returns:

A list of tuples, each providing the 3 integer values identifying an RGB color.

Return type:

List[Tuple[int, int, int]]

Raises:

RuntimeError – If requesting more colors than the ones available.

get_angle_between_points(point1: Tuple[float, float, float], point2: Tuple[float, float, float], to_degrees: bool = False) float[source]

Function that, given two points, calculates the angle between the line connecting the two points and the X-axis. If indicated, the output angle is provided in degrees, otherwise in radians.

Parameters:
  • point1 (Tuple[float, float, float]) – First point.

  • point2 (Tuple[float, float, float]) – Second point.

Returns:

The angle, by default in radians, between the line connecting the two points and the X-axis.

Return type:

float

get_id_from_name(name: str) int[source]

Function that extracts the index of the shape whose name is provided. The shape’s name must be defined as <name>_<id>.

Parameters:

name (str) – The name of the shape in the SALOME viewer.

Raises:

RuntimeError – If no integer index can be extracted from the given name.

Returns:

An integer being the global index associated to the shape whose name is given as input.

Return type:

int

get_id_from_shape(shape: Any) int[source]

Function that extracts the index of the given shape from its name. The shape’s name must have been previously assigned as <name>_<id>.

Parameters:

shape (Any) – The generic GEOM shape object to get its ID, if any.

Raises:

RuntimeError – If no name has been assigned to the shape, or no integer index can be extracted from the shape’s name.

Returns:

An integer being the global index associated to the given shape.

Return type:

int

get_vertex_polar_position(point: Any, origin: Any, ref_vec: Tuple[float, float] = (1, 0), is_cw: bool = True) Tuple[float, float][source]

Function returning the angle and the distance of the given GEOM vertex wrt the indicated origin, and starting from the direction of the reference vector. The angle is calculated according to the is_cw parameter, a flag stating whether a clockwise or a counterclockwise order is considered.

Parameters:
  • point (Any) – The GEOM vertex whose angle and distance wrt the origin is calculated.

  • origin (Any) – The GEOM vertex representing the origin.

  • ref_vec (Tuple[float, float] = (1, 0)) – The XY components of the reference vector indicating the starting position.

  • is_cw (bool = True) – Flag indicating whether a clockwise or a counterclockwise order is considered.

Returns:

The angle and the distance of the given GEOM vertex wrt the origin.

Return type:

Tuple[float, float]

Raises:

ValueError – If the indicated reference vector have a zero length.

Notes

The result can be used as sorting key for clockwise (default behaviour) or counterclockwise ordering of vertices around an origin.

get_vertices_on_edges(edges_1: List[Any], edges_2: List[Any], ref_vertex: Any) List[Any][source]

Function that extracts vertices from the first list of edges that lie on the edges of the second list. These vertices are returned sorted in counterclockwise order around a reference vertex.

Parameters:
  • edges_1 (List[Any]) – A list of GEOM edge objects from which vertices are extracted.

  • edges_2 (List[Any]) – A list of GEOM edge objects representing the reference edges. Vertices from edges_1 are checked against these edges to determine the vertices lying on them.

  • ref_vertex (Any) – The reference vertex used to sort the resulting vertices in counterclockwise order.

Returns:

A list of GEOM vertex objects that lie on the edges of edges_2, sorted in counterclockwise order around ref_vertex.

Return type:

List[Any]

is_vertex_on_edge(vertex: Any, edge: Any) bool[source]

Function that checks if a GEOM vertex belongs (within a tolerance) to a GEOM edge. The tolerance adopted for the check is calculated as the maximum tolerance for the vertex and the edge, which is, in turn, evaluated by combining the bounding box of the edge, scaled by a fixed factor, its length, scaled by another factor, and the tolerances adopted by GEOM.

Parameters:
  • vertex (Any) – The GEOM vertex whose distance from the edge has to be checked.

  • edge (Any) – The GEOM edge relative to which the distance of the vertex is calculated.

Returns:

True in case the vertex is on the edge (within the calculated tolerance), False otherwise.

Return type:

bool

retrieve_selected_object(error_msg: str) Any[source]

Function that retrieves the geometrical object currently selected in the SALOME study. If more than one or none is selected, an exception with the given message is raised.

Parameters:

error_msg (str) – The error message to display when the incorrect number of shapes is selected.

Returns:

The GEOM object currently selected in the SALOME study.

Return type:

Any

Raises:
  • RuntimeError – If this function is called outside of the SALOME GUI.

  • RuntimeError – If no GEOM object could be retrieved from the current SALOME study.

sort_shapes_from_vertex(shapes: List[Any], vertex: Any, reverse: bool = False) List[Any][source]

Function that sorts the given shapes based on their minimum distance from a given vertex.

Parameters:
  • shapes (List[Any]) – A list of shape objects to sort.

  • vertex (Any) – The reference vertex used to compute distances.

  • reverse (bool = False) – The sorting order. It defaults to False meaning an ascending order is considered.

Returns:

A new list of shapes sorted (by default in ascending order) according to their minimum distance from the given vertex.

Return type:

List[Any]

translate_wrt_reference(shape: Any, old_ref_point: Any, new_ref_coords: Tuple[float, float, float]) Any[source]

Function that translates a geometric shape so that it keeps its relative distance from a reference point, whose previous position is provided as a vertex object, while its new position by means of its XYZ coordinates.

Parameters:
  • shape (Any) – The geometric shape to be translated.

  • old_ref_point (Any) – A vertex object identifying the previous reference point of the shape.

  • new_ref_coords (Tuple[float, float, float]) – The coordinates of the reference point for the shape after its translation.

Returns:

The given shape translated so that it keeps its relative distance from the new reference point.

Return type:

Any