armi.reactor.composites module
This module contains the basic composite pattern underlying the reactor package.
This follows the principles of the Composite Design Pattern to allow the construction of a part/whole hierarchy representing a physical nuclear reactor. The composite objects act somewhat like lists: they can be indexed, iterated over, appended, extended, inserted, etc. Each member of the hierarchy knows its children and its parent, so full access to the hierarchy is available from everywhere. This design was chosen because of the close analogy of the model to the physical nature of nuclear reactors.
Warning
Because each member of the hierarchy is linked to the entire tree, it is often unsafe to save references to individual members; it can cause large and unexpected memory inefficiencies.
See also
- class armi.reactor.composites.FlagSerializer[source]
Bases:
Serializer
Serializer implementation for Flags.
This operates by converting each set of Flags (too large to fit in a uint64) into a sequence of enough uint8 elements to represent all flags. These constitute a dimension of a 2-D numpy array containing all Flags for all objects provided to the
pack()
function.- static pack(data)[source]
Flags are represented as a 2D numpy array of uint8 (single-byte, unsigned integers), where each row contains the bytes representing a single Flags instance. We also store the list of field names so that we can verify that the reader and the writer can agree on the meaning of each bit.
Under the hood, this calls the private implementation providing the
armi.reactor.flags.Flags
class as the target output class.
- classmethod unpack(data, version, attrs)[source]
Reverse the pack operation.
This will allow for some degree of conversion from old flags to a new set of flags, as long as all of the source flags still exist in the current set of flags.
Under the hood, this calls the private implementation providing the
armi.reactor.flags.Flags
class as the target output class.
- class armi.reactor.composites.CompositeModelType(name, bases, attrs)[source]
Bases:
ResolveParametersMeta
Metaclass for tracking subclasses of ArmiObject subclasses.
It is often useful to have an easily-accessible collection of all classes that participate in the ARMI composite reactor model. This metaclass maintains a collection of all defined subclasses, called TYPES.
- class armi.reactor.composites.ArmiObject(name)[source]
Bases:
object
The abstract base class for all composites and leaves.
This:
declares the interface for objects in the composition
implements default behavior for the interface common to all classes
Declares an interface for accessing and managing child objects
Defines an interface for accessing parents.
Called “component” in gang of four, this is an ArmiObject here because the word component was already taken in ARMI.
The
armi.reactor.parameters.ResolveParametersMeta
metaclass is used to automatically createParameterCollection
subclasses for storing parameters associated with any particular subclass of ArmiObject. Defining apDefs
class attribute in the definition of a subclass of ArmiObject will lead to the creation of a new subclass of py:class:armi.reactor.parameters.ParameterCollection, which will contain the definitions from that class’spDefs
as well as the definitions for all of its parents. A newparamCollectionType
class attribute will be added to the ArmiObject subclass to reflect which type of parameter collection should be used.Warning
This class has far too many public methods. We are in the midst of a composite tree cleanup that will likely break these out onto a number of separate functional classes grouping things like composition, location, shape/dimensions, and various physics queries. Methods are being collected here from the various specialized subclasses (Block, Assembly) in preparation for this next step. As a result, the public API on this method should be considered unstable.
- Variables:
name (str) – Object name
parent (ArmiObject) – The object’s parent in a hierarchical tree
cached (dict) – Some cached values for performance
p (ParameterCollection) – The state variables
spatialGrid (grids.Grid) – The spatial grid that this object contains
spatialLocator (grids.LocationBase) – The location of this object in its parent grid, or global space
See also
- paramCollectionType
alias of
ArmiObjectParameterCollection
- pDefs = <armi.reactor.parameters.parameterDefinitions.ParameterDefinitionCollection object>
- duplicate()[source]
Make a clean copy of this object.
Warning
Be careful with inter-object dependencies. If one object contains a reference to another object which contains links to the entire hierarchical tree, memory can fill up rather rapidly. Weak references are designed to help with this problem.
- copyParamsFrom(other)[source]
Overwrite this object’s params with other object’s.
- Parameters:
other (ArmiObject) – The object to copy params from
- updateParamsFrom(new)[source]
Update this object’s params with a new object’s.
- Parameters:
new (ArmiObject) – The object to copy params from
- getChildren(deep=False, generationNum=1, includeMaterials=False)[source]
Return the children of this object.
- getChildrenWithFlags(typeSpec: Optional[Union[Flag, auto, Sequence[Union[Flag, auto]]]], exactMatch=True)[source]
Get all children that have given flags.
- getComponents(typeSpec: Optional[Union[Flag, auto, Sequence[Union[Flag, auto]]]] = None, exact=False)[source]
Return all armi.reactor.component.Component within this Composite.
- Parameters:
typeSpec (TypeSpec) – Component flags. Will restrict Components to specific ones matching the flags specified.
exact (bool, optional) – Only match exact component labels (names). If True, ‘coolant’ will not match ‘interCoolant’. This has no impact if compLabel is None.
- Returns:
items matching compLabel and exact criteria
- Return type:
list of Component
- iterComponents(typeSpec: Optional[Union[Flag, auto, Sequence[Union[Flag, auto]]]] = None, exact=False)[source]
Yield components one by one in a generator.
- doChildrenHaveFlags(typeSpec: Optional[Union[Flag, auto, Sequence[Union[Flag, auto]]]], deep=False)[source]
Generator that yields True if the next child has given flags.
- Parameters:
typeSpec (TypeSpec) – Requested type of the child
- containsAtLeastOneChildWithFlags(typeSpec: Optional[Union[Flag, auto, Sequence[Union[Flag, auto]]]])[source]
Return True if any of the children are of a given type.
- Parameters:
typeSpec (TypeSpec) – Requested type of the children
See also
self.doChildrenHaveFlags
,self.containsOnlyChildrenWithFlags
- containsOnlyChildrenWithFlags(typeSpec: Optional[Union[Flag, auto, Sequence[Union[Flag, auto]]]])[source]
Return True if all of the children are of a given type.
- Parameters:
typeSpec (TypeSpec) – Requested type of the children
See also
self.doChildrenHaveFlags
,self.containsAtLeastOneChildWithFlags
- copyParamsToChildren(paramNames)[source]
Copy param values in paramNames to all children.
- Parameters:
paramNames (list) – List of param names to copy to children
- classmethod getParameterCollection()[source]
Return a new instance of the specific ParameterCollection type associated with this object.
This has the same effect as
obj.paramCollectionType()
. Getting a new instance through a class method like this is useful in situations where theparamCollectionType
is not a top-level object and therefore cannot be trivially pickled. Since we know that by the time we want to make any instances of/unpickle a givenArmiObject
, such a class attribute will have been created and associated. So, we use this top-level method to dig dynamically down to the underlying parameter collection type.See also
armi.reactor.parameters.parameterCollections.ParameterCollection.__reduce__()
- getParamNames()[source]
Get a list of parameters keys that are available on this object.
Will not have any corner, edge, or timenode dependence.
- nameContains(s)[source]
True if s is in this object’s name (eg. nameContains(‘fuel’)==True for ‘testfuel’.
Notes
Case insensitive (all gets converted to lower)
- hasFlags(typeID: Optional[Union[Flag, auto, Sequence[Union[Flag, auto]]]], exact=False)[source]
Determine if this object is of a certain type.
- Parameters:
typeID (TypeSpec) – Flags to test the object against, to see if it contains them. If a list is provided, each element is treated as a “candidate” set of flags. Return True if any of candidates match. When exact is True, the object must match one of the candidates exactly. If exact is False, the object must have at least the flags contained in a candidate for that candidate to be a match; extra flags on the object are permitted. None matches all objects if exact is False, or no objects if exact is True.
exact (bool, optional) – Require the type of the object to fully match the provided typeID(s)
- Returns:
hasFlags – True if this object is in the typeID list.
- Return type:
Notes
Type comparisons use bitwise comparisons using valid flags.
If you have an ‘inner control’ assembly, then this will evaluate True for the INNER | CONTROL flag combination. If you just want all FUEL, simply use FUEL with no additional qualifiers. For more complex comparisons, use bitwise operations.
Always returns true if typeID is none and exact is False, allowing for default parameters to be passed in when the method does not care about the object type. If the typeID is none and exact is True, this will always return False.
Examples
If you have an object with the
INNER
,DRIVER
, andFUEL
flags, then>>> obj.getType() [some integer]
>>> obj.hasFlags(Flags.FUEL) True
>>> obj.hasFlags(Flags.INNER | Flags.DRIVER | Flags.FUEL) True
>>> obj.hasFlags(Flags.OUTER | Flags.DRIVER | Flags.FUEL) False
>>> obj.hasFlags(Flags.INNER | Flags.FUEL) True
>>> obj.hasFlags(Flags.INNER | Flags.FUEL, exact=True) False
>>> obj.hasFlags([Flags.INNER | Flags.DRIVER | Flags.FUEL, ... Flags.OUTER | Flags.DRIVER | Flags.FUEL], exact=True) False
- setType(typ, flags: Optional[Flags] = None)[source]
Set the object type.
- Parameters:
typ (str) – The desired “type” for the object. Type describes the general class of the object, and typically corresponds to the name of the blueprint that created it.
flags (Flags, optional) – The set of Flags to apply to the object. If these are omitted, then Flags will be derived from the
typ
.
Warning
We are in the process of developing more robust definitions for things like “name” and “type”. “type” will generally refer to the name of the blueprint that created a particular object. When present, a “name” will refer to a specific instance of an object of a particular “type”. Think unique names for each assembly in a core, even if they are all created from the same blueprint and therefore have the same “type”. When this work is complete, it will be strongly discouraged, or even disallowed to change the type of an object after it has been created, and
setType()
may be removed entirely.
- getVolumeFractions()[source]
Return volume fractions of each child.
Sets volume or area of missing piece (like coolant) if it exists. Caching would be nice here.
- Returns:
fracs – list of (component, volFrac) tuples
- Return type:
See also
test_block.Block_TestCase.test_consistentAreaWithOverlappingComponents
Notes
void areas can be negative in gaps between fuel/clad/liner(s), but these negative areas are intended to account for overlapping positive areas to insure the total area of components inside the clad is accurate. See test_block.Block_TestCase.test_consistentAreaWithOverlappingComponents
- getMass(nuclideNames=None)[source]
Determine the mass in grams of nuclide(s) and/or elements in this object.
- getMassFrac(nucName)[source]
Get the mass fraction of a nuclide.
Notes
If you need multiple mass fractions, use
getMassFracs
.
- getMassFracs()[source]
Get mass fractions of all nuclides in object.
Ni [1/cm3] * Ai [g/mole] ~ mass
- setMassFrac(nucName, val)[source]
Adjust the composition of this object so the mass fraction of nucName is val.
See also
setMassFracs
efficiently set multiple mass fractions at the same time.
- setMassFracs(massFracs)[source]
Apply one or more adjusted mass fractions.
This will adjust the total mass of the object, as the mass of everything designated will change, while anything else will not.
\[ \begin{align}\begin{aligned}m_i = \frac{M_i}{\sum_j(M_j)}\\(M_{j \ne i} + M_i) m_i = M_i\\\frac{m_i M_{j \ne i}}{1-m_i} = M_i\\\frac{m_i M_{j \ne i}}{V(1-m_i)} = M_i/V = m_i \rho\\N_i = \frac{m_i \rho N_A}{A_i}\\N_i = \frac{m_i M_{j \ne i} N_A}{V (1-m_i) {A_i}}\\\frac{M_{j \ne i}}{V} = m_{j \ne i} \rho\\m_{j \ne i} = 1 - m_i\end{aligned}\end{align} \]Notes
You can’t just change one mass fraction though, you have scale all others to fill the remaining frac.
- Parameters:
massFracs (dict) – nucName : new mass fraction pairs.
- adjustMassFrac(nuclideToAdjust=None, elementToAdjust=None, nuclideToHoldConstant=None, elementToHoldConstant=None, val=0.0)[source]
Set the initial Zr mass fraction while maintaining Uranium enrichment, but general purpose.
- Parameters:
nuclideToAdjust (str, optional) – The nuclide name to adjust
elementToAdjust (str, optional) – The element to adjust. All isotopes in this element will adjust
nuclideToHoldconstant (str, optional) – A nuclide to hold constant
elementToHoldConstant (str) – Same
val (float) – The value to set the adjust mass fraction to be.
Notes
If you use this for two elements one after the other, you will probably get something wrong. For instance, if you have U-10Zr and add Pu at 10% mass fraction, the Zr fraction will drop below 10% of the total. The U-Zr fractions will remain constant though. So this is mostly useful if you have U-10Zr and want to change it to U-5Zr.
Theory:
Mass fraction of each nuclide to be adjusted = Ai where A1+A2+A…+AI = A Mass fraction of nuclides to be held constant = Ci where sum = C Mass fraction of other nuclides is Oi, sum = O new value for A is v
A+C+O = 1.0 A’=v. If A>0, then A’=A*f1=v where f1 = v/A If A=0, then Ai’ = v/len(A), distributing the value evenly among isotopes
Now, to adjust the other nuclides, we know A’+C+O’ = 1.0 , or v+C+O’ = 1.0 So, O’= 1.0-v-C We can scale each Oi evenly by multiplying by the factor f2 Oi’ = Oi * (1-C-v)/O = Oi * f2 where f2= (1-C-v)
See also
- adjustMassEnrichment(massFraction)[source]
Adjust the enrichment of this object.
If it’s Uranium, enrichment means U-235 fraction. If it’s Boron, enrichment means B-10 fraction, etc.
- Parameters:
newEnrich (float) – The new enrichment as a fraction.
- getNumberDensity(nucName)[source]
Return the number density of a nuclide in atoms/barn-cm.
Notes
This can get called very frequently and has to do volume computations so should use some kind of caching that is invalidated by any temperature, composition, etc. changes. Even with caching the volume calls are still somewhat expensive so prefer the methods in see also.
See also
ArmiObject.getNuclideNumberDensities
More efficient for >1 specific nuc density is needed.
ArmiObject.getNumberDensities
More efficient for when all nucs in object is needed.
- getNuclideNumberDensities(nucNames)[source]
Return a list of number densities in atoms/barn-cm for the nuc names requested.
- getNumberDensities(expandFissionProducts=False)[source]
Retrieve the number densities in atoms/barn-cm of all nuclides (or those requested) in the object.
- getAncestor(fn)[source]
Return the first ancestor that satisfies the supplied predicate.
- Parameters:
fn (Function-like object) – The predicate used to test the validity of an ancestor. Should return true if the ancestor satisfies the caller’s requirements
- getAncestorAndDistance(fn, _distance=0) Optional[Tuple[ArmiObject, int]] [source]
Return the first ancestor that satisfies the supplied predicate, along with how many levels above self the ancestor lies.
- Parameters:
fn (Function-like object) – The predicate used to test the validity of an ancestor. Should return true if the ancestor satisfies the caller’s requirements
- getAncestorWithFlags(typeSpec: Optional[Union[Flag, auto, Sequence[Union[Flag, auto]]]], exactMatch=False)[source]
Return the first ancestor that matches the passed flags.
- Parameters:
typeSpec (TypeSpec) – A collection of flags to match on candidate parents
exactMatch (bool) – Whether the flags match should be exact
- Returns:
the first ancestor up the chain of parents that matches the passed flags
- Return type:
armi.composites.ArmiObject
See also
- getTotalNDens()[source]
Return the total number density of all atoms in this object.
- Returns:
nTot – Total ndens of all nuclides in atoms/bn-cm. Not homogenized.
- Return type:
- setNumberDensity(nucName, val)[source]
Set the number density of this nuclide to this value.
This distributes atom density evenly across all children that contain nucName. If the nuclide doesn’t exist in any of the children, then that’s actually an error. This would only happen if some unnatural nuclide like Pu239 built up in fresh UZr. That should be anticipated and dealt with elsewhere.
- setNumberDensities(numberDensities)[source]
Set one or more multiple number densities. Reset any non-listed nuclides to 0.0.
- Parameters:
numberDensities (dict) – nucName: ndens pairs.
Notes
We’d like to not have to call setNumberDensity for each nuclide because we don’t want to call
getVolumeFractions
for each nuclide (it’s inefficient).
- updateNumberDensities(numberDensities)[source]
Set one or more multiple number densities. Leaves unlisted number densities alone.
This changes a nuclide number density only on children that already have that nuclide, thereby allowing, for example, actinides to stay in the fuel component when setting block-level values.
The complication is that various number densities are distributed among various components. This sets the number density for each nuclide evenly across all components that contain it.
- Parameters:
numberDensities (dict) – nucName: ndens pairs.
- changeNDensByFactor(factor)[source]
Change the number density of all nuclides within the object by a multiplicative factor.
- clearNumberDensities()[source]
Reset all the number densities to nearly zero.
Set to almost zero, so components remember which nuclides are where.
- getLumpedFissionProductCollection()[source]
Get collection of LFP objects. Will work for global or block-level LFP models.
- Returns:
lfps – lfpName keys , lfp object values
- Return type:
LumpedFissionProduct
- calcTotalParam(param, objs=None, volumeIntegrated=False, addSymmetricPositions=False, typeSpec: Optional[Union[Flag, auto, Sequence[Union[Flag, auto]]]] = None, generationNum=1, calcBasedOnFullObj=False)[source]
Sums up a parameter throughout the object’s children or list of objects.
- Parameters:
param (str) – Name of the block parameter to sum
objs (iterable, optional) – A list of objects to sum over. If none, all children in object will be used
volumeIntegrated (bool, optional) – Integrate over volume
addSymmetricPositions (bool, optional) – If True, will multiply by the symmetry factor of the core (3 for 1/3 models, 1 for full core models)
typeSpec (TypeSpec) – object types to restrict to
generationNum (int, optional) – Which generation to consider. 1 means direct children, 2 means children of children. Default: Just return direct children.
calcBasedOnFullObj (bool, optional) – Some assemblies or blocks, such as the center assembly in a third core model, are not modeled as full assemblies or blocks. In the third core model objects at these postions are modeled as having 1/3 the volume and thus 1/3 the power. Setting this argument to True will apply the full value of the parameter as if it was a full block or assembly.
- calcAvgParam(param, typeSpec: Optional[Union[Flag, auto, Sequence[Union[Flag, auto]]]] = None, weightingParam=None, volumeAveraged=True, absolute=True, generationNum=1)[source]
Calculate the child-wide average of a parameter.
- Parameters:
param (str) – The ARMI block parameter that you want the average from
typeSpec (TypeSpec) – The child types that should be included in the calculation. Restrict average to a certain child type with this parameter.
weightingParam (None or str, optional) – An optional block param that the average will be weighted against
volumeAveraged (bool, optional) – volume (or height, or area) average this param
absolute (bool, optional) – Returns the average of the absolute value of param
generationNum (int, optional) – Which generation to average over (1 for children, 2 for grandchildren)
The weighted sum is:
\[\left<\text{x}\right> = \frac{\sum_{i} x_i w_i}{\sum_i w_i}\]where \(i\) is each child, \(x_i\) is the param value of the i-th child, and \(w_i\) is the weighting param value of the i-th child.
Warning
If a param is unset/zero on any of the children, this will be included in the average and may significantly perturb results.
- Returns:
The average parameter value.
- Return type:
- getMaxParam(param, typeSpec: Optional[Union[Flag, auto, Sequence[Union[Flag, auto]]]] = None, absolute=True, generationNum=1, returnObj=False)[source]
Find the maximum value for the parameter in this container.
- Parameters:
param (str) – block parameter that will be sought.
typeSpec (TypeSpec) – restricts the search to cover a variety of block types.
absolute (bool) – looks for the largest magnitude value, regardless of sign, default: true
returnObj (bool, optional) – If true, returns the child object as well as the value.
- Returns:
maxVal (float) – The maximum value of the parameter asked for
obj (child object) – The object that has the max (only returned if
returnObj==True
)
- getMinParam(param, typeSpec: Optional[Union[Flag, auto, Sequence[Union[Flag, auto]]]] = None, absolute=True, generationNum=1, returnObj=False)[source]
Find the minimum value for the parameter in this container.
See also
getMaxParam
details
- getNuclides()[source]
Determine which nuclides are present in this armi object.
- Returns:
List of nuclide names that exist in this
- Return type:
- getHMMoles()[source]
Get the number of moles of heavy metal in this object in full symmetry.
Notes
If an object is on a symmetry line, the number of moles will be scaled up by the symmetry factor. This is done because this is typically used for tracking burnup, and BOL moles are computed in full objects too so there are no complications as things move on and off of symmetry lines.
Warning
getHMMoles is different than every other get mass call since it multiplies by symmetry factor but getVolume() on the block level divides by symmetry factor causing them to cancel out.
This was needed so that HM moles mass did not change based on if the block/assembly was on a symmetry line or not.
- getHMDens()[source]
Compute the total heavy metal density of this object.
- Returns:
hmDens – The total heavy metal number (atom) density in atoms/bn-cm.
- Return type:
- getAtomicWeight()[source]
Calculate the atomic weight of this object in g/mole of atoms.
Warning
This is not the molecular weight, which is grams per mole of molecules (grams/gram-molecule). That requires knowledge of the chemical formula. Don’t be surprised when you run this on UO2 and find it to be 90; there are a lot of Oxygen atoms in UO2.
\[A = \frac{\sum_i N_i A_i }{\sum_i N_i}\]
- getMasses()[source]
Return a dictionary of masses indexed by their nuclide names.
Notes
Implemented to get number densities and then convert to mass because getMass is too slow on a large tree.
- getMgFlux(adjoint=False, average=False, volume=None, gamma=False)[source]
Return the multigroup neutron flux in [n/cm^2/s].
The first entry is the first energy group (fastest neutrons). Each additional group is the next energy group, as set in the ISOTXS library.
On blocks, it is stored integrated over volume on <block>.p.mgFlux
- Parameters:
adjoint (bool, optional) – Return adjoint flux instead of real
average (bool, optional) – If true, will return average flux between latest and previous. Doesn’t work for pin detailed yet
volume (float, optional) – If average=True, the volume-integrated flux is divided by volume before being returned. The user may specify a volume here, or the function will obtain the block volume directly.
gamma (bool, optional) – Whether to return the neutron flux or the gamma flux.
- Returns:
flux – multigroup neutron flux in [n/cm^2/s]
- Return type:
np.ndarray
- addMasses(masses)[source]
Adds a vector of masses.
- Parameters:
masses (dict) – a dictionary of masses (g) indexed by nucNames (string)
- setMasses(masses)[source]
Set a vector of masses.
- Parameters:
masses (dict) – a dictionary of masses (g) indexed by nucNames (string)
- getSymmetryFactor()[source]
Return a scaling factor due to symmetry on the area of the object or its children.
See also
armi.reactor.blocks.HexBlock.getSymmetryFactor
concrete implementation
- getBoundingIndices()[source]
Find the 3-D index bounds (min, max) of all children in the spatial grid of this object.
- Returns:
bounds – ((minI, maxI), (minJ, maxJ), (minK, maxK))
- Return type:
- getComponentsOfShape(shapeClass)[source]
Return list of components in this block of a particular shape.
- Parameters:
shapeClass (Component) – The class of component, e.g. Circle, Helix, Hexagon, etc.
- Returns:
param – List of components in this block that are of the given shape.
- Return type:
- getComponentsOfMaterial(material=None, materialName=None)[source]
Return list of components in this block that are made of a particular material.
Only one of the selectors may be used
- Parameters:
material (armi.materials.material.Material, optional) – The material to match
materialName (str, optional) – The material name to match.
- Returns:
componentsWithThisMat
- Return type:
- hasComponents(typeSpec: Union[Flag, auto, Sequence[Union[Flag, auto]], None, List[Optional[Union[Flag, auto, Sequence[Union[Flag, auto]]]]]], exact=False)[source]
Return true if components matching all TypeSpec exist in this object.
- Parameters:
typeSpec (Flags or iterable of Flags) – Component flags to check for
- getComponentByName(name)[source]
Gets a particular component from this object, based on its name.
- Parameters:
name (str) – The blueprint name of the component to return
- getComponent(typeSpec: Optional[Union[Flag, auto, Sequence[Union[Flag, auto]]]], exact=False, quiet=False)[source]
Get a particular component from this object.
- Parameters:
typeSpec (flags.Flags or list of Flags) – The type specification of the component to return
exact (boolean, optional) – Demand that the component flags be exactly equal to the typespec. Default: False
quiet (boolean, optional) – Warn if the component is not found. Default: False
object (Careful with multiple similar names in one) –
- Returns:
Component
- Return type:
The component that matches the critera or None
- getNumComponents(typeSpec: Optional[Union[Flag, auto, Sequence[Union[Flag, auto]]]], exact=False)[source]
Get the number of components that have these flags, taking into account multiplicity. Useful for getting nPins even when there are pin detailed cases.
- Parameters:
typeSpec (Flags) – Expected flags of the component to get. e.g. Flags.FUEL
- Returns:
total – the number of components of this type in this object, including multiplicity.
- Return type:
- setComponentDimensionsReport()[source]
Makes a summary of the dimensions of the components in this object.
- expandElementalToIsotopics(elementalNuclide)[source]
Expands the density of a specific elemental nuclides to its natural isotopics.
- Parameters:
elementalNuclide (
armi.nucDirectory.nuclideBases.NaturalNuclide
) – natural nuclide to replace.
- getAverageTempInC(typeSpec: Optional[Union[Flag, auto, Sequence[Union[Flag, auto]]]] = None, exact=False)[source]
Return the average temperature of the ArmiObject in C by averaging all components.
- getDominantMaterial(typeSpec: Optional[Union[Flag, auto, Sequence[Union[Flag, auto]]]] = None, exact=False)[source]
Return the first sample of the most dominant material (by volume) in this object.
- Parameters:
typeSpec (Flags or iterable of Flags, optional) – The types of components to consider (e.g.
[Flags.FUEL, Flags.CONTROL]
)exact (bool, optional) – Whether or not the TypeSpec is exact
- Returns:
mat – the first instance of the most dominant material (by volume) in this object.
- Return type:
See also
getComponentsOfMaterial
Gets components that are made of a particular material
gatherMaterialsByVolume
Classifies all materials by volume
- class armi.reactor.composites.Composite(name)[source]
Bases:
ArmiObject
An ArmiObject that has children.
This is a fundamental ARMI state object that generally represents some piece of the nuclear reactor that is made up of other smaller pieces. This object can cache information about its children to help performance.
Details about spatial representation
Spatial representation of a
Composite
is handled through a combination of thespatialLocator
andspatialGrid
parameters. ThespatialLocator
is a numpy triple representing either:1. Indices in the parent’s
spatialGrid
(for lattices, etc.), used when the dtype is int.Coordinates in the parent’s universe in cm, used when the dtype is float.
The top parent of any composite must have a coordinate-based
spatialLocator
. For example, a Reactor an a Pump should both have coordinates based on how far apart they are.The traversal of indices and grids is recursive. The Reactor/Core/Assembly/Block model is handled by putting a 2-D grid (either Theta-R, Hex, or Cartesian) on the Core and individual 1-D Z-meshes on the assemblies. Then, Assemblies have 2-D spatialLocators (i,j,0) and Blocks have 1-D spatiaLocators (0,0,k). These get added to form the global indices. This way, if an assembly is moved, all the blocks immediately and naturally move with it. Individual children may have coordinate-based spatialLocators mixed with siblings in a grid. This allows mixing grid-representation with explicit representation, often useful in advanced assemblies and thermal reactors.
The traversal of indices and grids is recursive. The Reactor/Core/Assembly/Block model is handled by putting a 2-D grid (either Theta-R, Hex, or Cartesian) on the Core and individual 1-D Z-meshes on the assemblies. Then, Assemblies have 2-D spatialLocators (i,j,0) and Blocks have 1-D spatiaLocators (0,0,k). These get added to form the global indices. This way, if an assembly is moved, all the blocks immediately and naturally move with it. Individual children may have coordinate-based spatialLocators mixed with siblings in a grid. This allows mixing grid-representation with explicit representation, often useful in advanced assemblies and thermal reactors.
- getChildren(deep=False, generationNum=1, includeMaterials=False, predicate=None)[source]
Return the children objects of this composite.
- Parameters:
deep (boolean, optional) – Return all children of all levels.
generationNum (int, optional) – Which generation to return. 1 means direct children, 2 means children of children. Setting this parameter will only return children of this generation, not their parents. Default: Just return direct children.
includeMaterials (bool, optional) – Include the material properties
predicate (callable, optional) – An optional unary predicate to use for filtering results. This can be used to request children of specific types, or with desired attributes. Not all ArmiObjects have the same methods and members, so care should be taken to make sure that the predicate executes gracefully in all cases (e.g., use
getattr(obj, "attribute", None)
to access instance attributes). Failure to meet the predicate only affects the object in question; children will still be considered.
Examples
>>> obj.getChildren() [child1, child2, child3]
>>> obj.getChildren(generationNum=2) [grandchild1, grandchild2, grandchild3]
>>> obj.getChildren(deep=True) [child1, child2, child3, grandchild1, grandchild2, grandchild3]
# Assuming that grandchild1 and grandchild3 are Component objects >>> obj.getChildren(deep=True, predicate=lambda o: isinstance(o, Component)) [grandchild1, grandchild3]
- getChildrenWithFlags(typeSpec: Optional[Union[Flag, auto, Sequence[Union[Flag, auto]]]], exactMatch=False)[source]
Get all children of a specific type.
- getComponents(typeSpec: Optional[Union[Flag, auto, Sequence[Union[Flag, auto]]]] = None, exact=False)[source]
- iterComponents(typeSpec: Optional[Union[Flag, auto, Sequence[Union[Flag, auto]]]] = None, exact=False)[source]
Return an iterator of armi.reactor.component.Component objects within this Composite.
- Parameters:
typeSpec (TypeSpec) – Component flags. Will restrict Components to specific ones matching the flags specified.
exact (bool, optional) – Only match exact component labels (names). If True, ‘coolant’ will not match ‘interCoolant’. This has no impact if typeSpec is None.
- Returns:
items matching typeSpec and exact criteria
- Return type:
iterator of Component
- syncMpiState()[source]
Synchronize all parameters of this object and all children to all worker nodes over the network using MPI.
In parallelized runs, if each process has its own copy of the entire reactor hierarchy, this method synchronizes the state of all parameters on all objects.
- Returns:
number of parameters synchronized over all components
- Return type:
- retainState(paramsToApply=None)[source]
Restores a state before and after some operation.
- Parameters:
paramsToApply (iterable) – Parameters that should be applied to the state after existing the state retainer. All others will be reverted to their values upon entering.
Notes
This should be used in a with statement.
- backUp()[source]
Create and store a backup of the state.
This needed to be overridden due to linked components which actually have a parameter value of another ARMI component.
- restoreBackup(paramsToApply)[source]
Restore the parameters from previously created backup.
- Parameters:
paramsToApply (list of ParmeterDefinitions) – restores the state of all parameters not in paramsToApply
- getLumpedFissionProductsIfNecessary(nuclides=None)[source]
Return Lumped Fission Product objects that belong to this object or any of its children.
- getLumpedFissionProductCollection()[source]
Get collection of LFP objects. Will work for global or block-level LFP models.
- Returns:
lfps – lfpName keys, lfp object values
- Return type:
- requiresLumpedFissionProducts(nuclides=None)[source]
True if any of the nuclides in this object are Lumped nuclides.
- getIntegratedMgFlux(adjoint=False, gamma=False)[source]
Returns the multigroup neutron tracklength in [n-cm/s].
The first entry is the first energy group (fastest neutrons). Each additional group is the next energy group, as set in the ISOTXS library.
- getReactionRates(nucName, nDensity=None)[source]
Get the reaction rates of a certain nuclide on this ArmiObject.
- Parameters:
- Returns:
rxnRates – reaction rates (1/s) for nG, nF, n2n, nA and nP
- Return type:
Notes
This is volume integrated NOT (1/cm3-s).
If you set nDensity to 1 this makes 1-group cross section generation easier.
- printContents(includeNuclides=True)[source]
Display information about all the comprising children in this object.
- getBoundingCircleOuterDiameter(Tc=None, cold=False)[source]
Get sum circle bound.
Used to roughly approximate relative size vs. other objects
- paramCollectionType
alias of
ArmiObjectParameterCollection
- class armi.reactor.composites.StateRetainer(composite, paramsToApply=None)[source]
Bases:
object
Retains state during some operations.
This can be used to temporarily cache state, perform an operation, extract some info, and then revert back to the original state.
A state retainer is faster than restoring state from a database as it reduces the number of IO reads; however, it does use more memory.
This can be used on any object within the composite pattern via with
[rabc].retainState([list], [of], [parameters], [to], [retain]):
. Use on an object up in the hierarchy applies to all objects below as well.This is intended to work across MPI, so that if you were to broadcast the reactor the state would be correct; however the exact implication on
parameters
may be unclear.
Create an instance of a StateRetainer.
- Parameters:
composite (Composite) – composite object to retain state (recursively)
paramsToApply (iterable of parameters.Parameter) – Iterable of parameters.Parameter to retain updated values after __exit__. All other parameters are reverted to the original state, i.e. retained at the original value.
- armi.reactor.composites.gatherMaterialsByVolume(objects: List[ArmiObject], typeSpec: Optional[Union[Flag, auto, Sequence[Union[Flag, auto]]]] = None, exact=False)[source]
Compute the total volume of each material in a set of objects and give samples.
- Parameters:
objects (list of ArmiObject) – Objects to look within. This argument allows clients to search though some subset of the three (e.g. when you’re looking for all CLADDING components within FUEL blocks)
typeSpec (TypeSpec) – Flags for the components to look at
exact (bool) – Whether or not the TypeSpec is exact
Notes
This helper method is outside the main ArmiObject tree for the special clients that need to filter both by container type (e.g. Block type) with one set of flags, and Components with another set of flags.
Warning
This is a composition related helper method that will likely be filed into classes/modules that deal specifically with the composition of things in the data model. Thus clients that use it from here should expect to need updates soon.
- armi.reactor.composites.getDominantMaterial(objects: List[ArmiObject], typeSpec: Optional[Union[Flag, auto, Sequence[Union[Flag, auto]]]] = None, exact=False)[source]
Return the first sample of the most dominant material (by volume) in a set of objects.
Warning
This is a composition related helper method that will likely be filed into classes/modules that deal specifically with the composition of things in the data model. Thus clients that use it from here should expect to need updates soon.
- armi.reactor.composites.getReactionRateDict(nucName, lib, xsSuffix, mgFlux, nDens)[source]
- Parameters:
nucName (str) – nuclide name – e.g. ‘U235’, ‘PU239’, etc. Not to be confused with the nuclide _label_, see the nucDirectory module for a description of the difference.
lib (isotxs) – cross section library
xsSuffix (str) – cross section suffix, consisting of the type followed by the burnup group, e.g. ‘AB’ for the second burnup group of type A
mgFlux (np.ndarray) – integrated mgFlux (n-cm/s)
nDens (float) – number density (atom/bn-cm)
- Returns:
dictionary of reaction rates (rxn/s) for nG, nF, n2n, nA and nP
- Return type:
rxnRates - dict
Notes
Assume there is no n3n cross section in ISOTXS