armi.reactor.grids.grid module

class armi.reactor.grids.grid.Grid(geomType: str | GeomType = '', symmetry: str | SymmetryType = '', armiObject: ArmiObject | None = None)[source]

Bases: ABC

Base class that defines the interface for grids.

Most work will be done with structured grids, e.g., hexagonal grid, Cartesian grids, but some physics codes accept irregular or unstructured grids. Consider a Cartesian grid but with variable stepping between cells, where dx may not be constant.

So here, we define an interface so things that rely on grids can worry less about how the location data are stored.

Implementation: Grids can nest. I_ARMI_GRID_NEST
signature: Grid
requirements: R_ARMI_GRID_NEST

The reactor will usually have (i,j,k) coordinates to define a simple mesh for locating objects in the reactor. But inside that mesh can be a smaller mesh to define the layout of pins in a reactor, or fuel pellets in a pin, or the layout of some intricate ex-core structure.

Every time the armi.reactor.grids.locations.IndexLocation of an object in the reactor is returned, ARMI will look to see if the grid this object is in has a parent, and if so, ARMI will try to sum the indices of the two nested grids to give a resultant, more finely-grained grid position. ARMI can only handle grids nested 3 deep.

Parameters:
armiObject: ArmiObject | None
property geomType: GeomType

Geometric representation.

property symmetry: str

Symmetry applied to the grid.

Implementation: Grids shall be able to repesent 1/3 and full core symmetries. I_ARMI_GRID_SYMMETRY0
signature: symmetry
requirements: R_ARMI_GRID_SYMMETRY

Every grid contains a armi.reactor.geometry.SymmetryType or string that defines a grid as full core or a partial core: 1/3, 1/4, 1/8, or 1/16 core. The idea is that the user can define 1/3 or 1/4 of the reactor, so the analysis can be run faster on a smaller reactor. And if a non-full core reactor grid is defined, the boundaries of the grid can be reflective or periodic, to determine what should happen at the boundaries of the reactor core.

It is important to note, that not all of these geometries will apply to every reactor or core. If your core is made of hexagonal assemblies, then a 1/3 core grid would make sense, but not if your reactor core was made up of square assemblies. Likewise, a hexagonal core would not make be able to support a 1/4 grid. You want to leave assemblies (and other objects) whole when dividing a grid up fractionally.

abstract property isAxialOnly: bool

Indicate to parts of ARMI if this Grid handles only axial cells.

abstract items() Iterable[Tuple[Tuple[int, int, int], IndexLocation]][source]

Return list of ((i, j, k), IndexLocation) tuples.

abstract locatorInDomain(locator: LocationBase, symmetryOverlap: bool | None = False) bool[source]

Return whether the passed locator is in the domain represented by the Grid.

For instance, if we have a 1/3rd core hex grid, this would return False for locators that are outside of the first third of the grid.

Parameters:
  • locator (LocationBase) – The location to test

  • symmetryOverlap (bool, optional) – Whether grid locations along the symmetry line should be considered “in the represented domain”. This can be useful when assemblies are split along the domain boundary, with fractions of the assembly on either side.

Returns:

If the given locator is within the given grid

Return type:

bool

abstract getSymmetricEquivalents(indices: Tuple[int, int]) List[Tuple[int, int]][source]

Return a list of grid indices that contain matching contents based on symmetry.

The length of the list will depend on the type of symmetry being used, and potentially the location of the requested indices. E.g., third-core will return the two sets of indices at the matching location in the other two thirds of the grid, unless it is the central location, in which case no indices will be returned.

abstract overlapsWhichSymmetryLine(indices: Tuple[int, int]) int | None[source]

Return lines of symmetry position at a given index can be found.

Parameters:

indices (tuple of [int, int]) – Indices for the requested object

Returns:

None if not line of symmetry goes through the object at the requested index. Otherwise, some grid constants like BOUNDARY_CENTER will be returned.

Return type:

None or int

abstract getCoordinates(indices: Tuple[int, int, int] | List[Tuple[int, int, int]], nativeCoords: bool = False) ndarray[source]
abstract backUp()[source]

Subclasses should modify the internal backup variable.

abstract restoreBackup()[source]

Restore state from backup.

abstract getCellBase(indices: Tuple[int, int, int]) ndarray[source]

Return the lower left case of this cell in cm.

abstract getCellTop(indices: Tuple[int, int, int]) ndarray[source]

Get the upper right of this cell in cm.

static getLabel(indices)[source]

Get a string label from a 0-based spatial locator.

Returns a string representing i, j, and k indices of the locator

abstract reduce() Tuple[Hashable, ...][source]

Return the set of arguments used to create this Grid.

This is very much like the argument tuple from __reduce__, but we do not implement __reduce__ for real, because we are generally happy with __getstate__ and __setstate__ for pickling purposes. However, getting these arguments to __init__ is useful for storing Grids to the database, as they are more stable (less likely to change) than the actual internal state of the objects.

The return value should be hashable, such that a set of these can be created.

The return type should be symmetric such that a similar grid can be created just with the outputs of Grid.reduce, e.g., type(grid)(*grid.reduce())

Notes

For consistency, the second to last argument must be the geomType