openmc.HexLattice¶
-
class
openmc.
HexLattice
(lattice_id=None, name='')[source]¶ A lattice consisting of hexagonal prisms.
To completely define a hexagonal lattice, the
HexLattice.center
,HexLattice.pitch
,HexLattice.universes
, andHexLattice.outer
properties need to be set.Most methods for this class use a natural indexing scheme wherein elements are assigned an index corresponding to their position relative to skewed \((x,\alpha,z)\) axes as described fully in Hexagonal Lattice Indexing. However, note that when universes are assigned to lattice elements using the
HexLattice.universes
property, the array indices do not correspond to natural indices.Parameters: Variables: - id (int) – Unique identifier for the lattice
- name (str) – Name of the lattice
- pitch (Iterable of float) – Pitch of the lattice in cm. The first item in the iterable specifies the pitch in the radial direction and, if the lattice is 3D, the second item in the iterable specifies the pitch in the axial direction.
- outer (openmc.Universe) – A universe to fill all space outside the lattice
- universes (Nested Iterable of openmc.Universe) – A two- or three-dimensional list/array of universes filling each element
of the lattice. Each sub-list corresponds to one ring of universes and
should be ordered from outermost ring to innermost ring. The universes
within each sub-list are ordered from the “top” and proceed in a
clockwise fashion. The
HexLattice.show_indices()
method can be used to help figure out indices for this property. - center (Iterable of float) – Coordinates of the center of the lattice. If the lattice does not have axial sections then only the x- and y-coordinates are specified
- indices (list of tuple) – A list of all possible (z,r,i) or (r,i) lattice element indices that are possible, where z is the axial index, r is in the ring index (starting from the outermost ring), and i is the index with a ring starting from the top and proceeding clockwise.
- num_rings (int) – Number of radial ring positions in the xy-plane
- num_axial (int) – Number of positions along the z-axis.
-
find_element
(point)[source]¶ Determine index of lattice element and local coordinates for a point
Parameters: point (Iterable of float) – Cartesian coordinates of point Returns: - 3-tuple of int – Indices of corresponding lattice element in \((x,\alpha,z)\) bases
- numpy.ndarray – Carestian coordinates of the point in the corresponding lattice element coordinate system
-
get_local_coordinates
(point, idx)[source]¶ Determine local coordinates of a point within a lattice element
Parameters: - point (Iterable of float) – Cartesian coordinates of point
- idx (Iterable of int) – Indices of lattice element in \((x,\alpha,z)\) bases
Returns: Cartesian coordinates of point in the lattice element coordinate system
Return type: 3-tuple of float
-
get_universe_index
(idx)[source]¶ Return index in the universes array corresponding to a lattice element index
Parameters: idx (Iterable of int) – Lattice element indices in the \((x,\alpha,z)\) coordinate system Returns: Indices used when setting the HexLattice.universes
propertyReturn type: 2- or 3-tuple of int
-
is_valid_index
(idx)[source]¶ Determine whether lattice element index is within defined range
Parameters: idx (Iterable of int) – Lattice element indices in the \((x,\alpha,z)\) coordinate system Returns: Whether index is valid Return type: bool
-
static
show_indices
(num_rings)[source]¶ Return a diagram of the hexagonal lattice layout with indices.
This method can be used to show the proper indices to be used when setting the
HexLattice.universes
property. For example, running this method with num_rings=3 will return the following diagram:(0, 0) (0,11) (0, 1) (0,10) (1, 0) (0, 2) (1, 5) (1, 1) (0, 9) (2, 0) (0, 3) (1, 4) (1, 2) (0, 8) (1, 3) (0, 4) (0, 7) (0, 5) (0, 6)
Parameters: num_rings (int) – Number of rings in the hexagonal lattice Returns: Diagram of the hexagonal lattice showing indices Return type: str