armi.reactor.grids.locations module
- class armi.reactor.grids.locations.LocationBase(i: int, j: int, k: int, grid: Optional[Grid])[source]
Bases:
ABC
A namedtuple-like object for storing location information.
It’s immutable (you can’t set things after construction) and has names.
Notes
This was originally a namedtuple but there was a somewhat unbelievable bug in Python 2.7.8 where unpickling a reactor full of these ended up inexplicably replacing one of them with an AssemblyParameterCollection. The bug did not show up in Python 3.
Converting to this class solved that problem.
- abstract property indices: ndarray
Get the non-grid indices (i,j,k) of this locator.
This strips off the annoying
grid
tagalong which is there to ensure proper equality (i.e. (0,0,0) in a storage rack is not equal to (0,0,0) in a core).It is a numpy array for two reasons:
It can be added and subtracted for the recursive computations through different coordinate systems
It can be written/read from the database.
- class armi.reactor.grids.locations.IndexLocation(i: int, j: int, k: int, grid: Optional[Grid])[source]
Bases:
LocationBase
An immutable location representing one cell in a grid.
The locator is intimately tied to a grid and together, they represent a grid cell somewhere in the coordinate system of the grid.
grid
is not in the constructor (must be added after construction ) because the extra argument (grid) gives an inconsistency between __init__ and __new__. Unfortunately this decision makes whipping up IndexLocations on the fly awkward. But perhaps that’s ok because they should only be created by their grids.TODO Is the above correct still? The constructor has an optional
Grid
- detachedCopy() IndexLocation [source]
Make a copy of this locator that is not associated with a grid.
See also
armi.reactor.reactors.detach
uses this
- property parentLocation
Get the spatialLocator of the ArmiObject that this locator’s grid is anchored to.
For example, if this is one of many spatialLocators in a 2-D grid representing a reactor, then the
parentLocation
is the spatialLocator of the reactor, which will often be aCoordinateLocation
.
- property indices: ndarray
Get the non-grid indices (i,j,k) of this locator.
This strips off the annoying
grid
tagalong which is there to ensure proper equality (i.e. (0,0,0) in a storage rack is not equal to (0,0,0) in a core).It is a numpy array for two reasons:
It can be added and subtracted for the recursive computations through different coordinate systems
It can be written/read from the database.
- getCompleteIndices() Tuple[int, int, int] [source]
Transform the indices of this object up to the top mesh.
The top mesh is either the one where there’s no more parent (true top) or when an axis gets added twice. Unlike with coordinates, you can only add each index axis one time. Thus a complete set of indices is one where an index for each axis has been defined by a set of 1, 2, or 3 nested grids.
This is useful for getting the reactor-level (i,j,k) indices of an object in a multi-layered 2-D(assemblies in core)/1-D(blocks in assembly) mesh like the one mapping blocks up to reactor in Hex reactors.
The benefit of that particular mesh over a 3-D one is that different assemblies can have different axial meshes, a common situation.
It will just return local indices for pin-meshes inside of blocks.
A tuple is returned so that it is easy to compare pairs of indices.
- getLocalCoordinates(nativeCoords=False)[source]
Return the coordinates of the center of the mesh cell here in cm.
- getGlobalCoordinates(nativeCoords=False)[source]
Get coordinates in global 3D space of the centroid of this object.
- getGlobalCellBase()[source]
Return the cell base (i.e. “bottom left”), in global coordinate system.
- getSymmetricEquivalents()[source]
Get symmetrically-equivalent locations, based on Grid symmetry.
See also
Grid.getSymmetricEquivalents
- distanceTo(other: IndexLocation) float [source]
Return the distance from this locator to another.
- class armi.reactor.grids.locations.MultiIndexLocation(grid: Grid)[source]
Bases:
IndexLocation
A collection of index locations that can be used as a spatialLocator.
This allows components with multiplicity>1 to have location information within a parent grid. The implication is that there are multiple discrete components, each one residing in one of the actual locators underlying this collection.
This class contains an implementation that allows a multi-index location to be used in the ARMI data model similar to a individual IndexLocation.
- detachedCopy() MultiIndexLocation [source]
- append(location: IndexLocation)[source]
- extend(locations: List[IndexLocation])[source]
- pop(location: IndexLocation)[source]
- property indices: List[ndarray]
Return indices for all locations.
Notes
Notice that this returns a list of all of the indices, unlike the
indices()
implementation forIndexLocation
. This is intended to make the behavior of getting the indices from the Locator symmetric with passing a list of indices to the Grid’s__getitem__()
function, which constructs and returns aMultiIndexLocation
containing those indices.
- class armi.reactor.grids.locations.CoordinateLocation(i: int, j: int, k: int, grid: Optional[Grid])[source]
Bases:
IndexLocation
A triple representing a point in space.
This is still associated with a grid. The grid defines the continuous coordinate space and axes that the location is within. This also links to the composite tree.
- armi.reactor.grids.locations.addingIsValid(myGrid: Grid, parentGrid: Grid)[source]
True if adding a indices from one grid to another is considered valid.
In ARMI we allow the addition of a 1-D axial grid with a 2-D grid. We do not allow any other kind of adding. This enables the 2D/1D grid layout in Assemblies/Blocks but does not allow 2D indexing in pins to become inconsistent.