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, and HexLattice.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)\) or \((\alpha,y,z)\) bases, depending on the lattice orientation, 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.

Changed in version 0.11: The orientation of the lattice can now be changed with the orientation attribute.

Parameters
  • lattice_id (int, optional) – Unique identifier for the lattice. If not specified, an identifier will automatically be assigned.

  • name (str, optional) – Name of the lattice. If not specified, the name is the empty string.

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.UniverseBase) – A universe to fill all space outside the lattice

  • universes (Nested Iterable of openmc.UniverseBase) – 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.

  • orientation ({'x', 'y'}) – str by default ‘y’ orientation of main lattice diagonal another option - ‘x’

  • 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)\) or \((\alpha,y,z)\) bases

  • numpy.ndarray – Carestian coordinates of the point in the corresponding lattice element coordinate system

classmethod from_hdf5(group, universes)[source]

Create rectangular lattice from HDF5 group

Parameters
  • group (h5py.Group) – Group in HDF5 file

  • universes (dict) – Dictionary mapping universe IDs to instances of openmc.UniverseBase.

Returns

Hexagonal lattice

Return type

openmc.HexLattice

classmethod from_xml_element(elem, get_universe)[source]

Generate hexagonal lattice from XML element

Parameters
  • elem (lxml.etree._Element) – <hex_lattice> element

  • get_universe (function) – Function returning universe (defined in openmc.Geometry.from_xml())

Returns

Hexagonal lattice

Return type

HexLattice

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)\) or \((\alpha,y,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 in ‘y’ orientation case, or indices in the \((\alpha,y,z)\) coordinate system in ‘x’ one

Returns

  • 2- or 3-tuple of int

  • Indices used when setting the HexLattice.universes

  • property

is_valid_index(idx)[source]

Determine whether lattice element index is within defined range

Parameters

idx (Iterable of int) – Lattice element indices in the both \((x,\alpha,z)\) and \((\alpha,y,z)\) coordinate system

Returns

Whether index is valid

Return type

bool

static show_indices(num_rings, orientation='y')[source]

Return a diagram of the hexagonal lattice layout with indices.

Parameters
  • num_rings (int) – Number of rings in the hexagonal lattice

  • orientation ({"x", "y"}) – Orientation of the hexagonal lattice

Returns

Diagram of the hexagonal lattice showing indices

Return type

str