openmc.RectLattice

class openmc.RectLattice(lattice_id=None, name='')[source]

A lattice consisting of rectangular prisms.

To completely define a rectangular lattice, the RectLattice.lower_left RectLattice.pitch, RectLattice.outer, and RectLattice.universes 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 the (x,y,z) axes in a Cartesian coordinate system, i.e., an index of (0,0,0) in the lattice gives the element whose x, y, and z coordinates are the smallest. However, note that when universes are assigned to lattice elements using the RectLattice.universes property, the array indices do not correspond to natural indices.

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 the x, y, and (if applicable) z directions in cm.
  • outer (openmc.Universe) – A universe to fill all space outside the lattice
  • universes (Iterable of Iterable of openmc.Universe) – A two- or three-dimensional list/array of universes filling each element of the lattice. The first dimension corresponds to the z-direction (if applicable), the second dimension corresponds to the y-direction, and the third dimension corresponds to the x-direction. Note that for the y-direction, a higher index corresponds to a lower physical y-value. Each z-slice in the array can be thought of as a top-down view of the lattice.
  • lower_left (Iterable of float) – The Cartesian coordinates of the lower-left corner of the lattice. If the lattice is two-dimensional, only the x- and y-coordinates are specified.
  • indices (list of tuple) – A list of all possible (z,y,x) or (y,x) lattice element indices. These indices correspond to indices in the RectLattice.universes property.
  • ndim (int) – The number of dimensions of the lattice
  • shape (Iterable of int) – An array of two or three integers representing the number of lattice cells in the x- and y- (and z-) directions, respectively.
find(point)[source]

Find cells/universes/lattices which contain a given point

Parameters:point (3-tuple of float) – Cartesian coordinatesof the point
Returns:Sequence of universes, cells, and lattices which are traversed to find the given point
Return type:list
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:
  • 2- or 3-tuple of int – A tuple of the corresponding (x,y,z) lattice element indices
  • 3-tuple of float – 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) – (x,y,z) indices of lattice element. If the lattice is 2D, the z index can be omitted.
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,y,z)\) coordinate system
Returns:Indices used when setting the RectLattice.universes property
Return 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,y,z)\) coordinate system
Returns:Whether index is valid
Return type:bool