armi.reactor.armiObject module

Definition of the Component interface for the composite design pattern underlying the reactor package, which ARMI calls ArmiObject.

This follows the principles of the Composite Design Pattern to allow the construction of a part/whole hierarchy representing a physical nuclear reactor in a tree strucutre. The ArmiObject class defines a shared abstract interface to other child classes (this is the Component class in Gang of Four). This design was chosen because of the close analogy of the model to the physical nature of nuclear reactors.

See also

Developer Docs. armi.reactor.composites.Composite armi.reactor.components.component.Component

class armi.reactor.armiObject.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.

version: str | None = '1'
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.armiObject.ArmiObjectModelType(name, bases, attrs)[source]

Bases: ResolveParametersMeta

Metaclass for tracking subclasses of ArmiObject.

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.

TYPES: Dict[str, Type]

Dictionary mapping class name to class object for all subclasses.

class armi.reactor.armiObject.ArmiObjectModelTypeABC(name, bases, namespace, /, **kwargs)[source]

Bases: ABCMeta, ArmiObjectModelType

Metaclass that combines ArmiObjectModelType with ABCMeta to allow ArmiObject to be an ABC.

class armi.reactor.armiObject.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

  • 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 create ParameterCollection subclasses for storing parameters associated with any particular subclass of ArmiObject. Defining a pDefs 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’s pDefs as well as the definitions for all of its parents. A new paramCollectionType class attribute will be added to the ArmiObject subclass to reflect which type of parameter collection should be used.

Implementation: Parameters are accessible throughout the armi tree. I_ARMI_PARAM1
signature: ArmiObject
requirements: R_ARMI_PARAM

An ARMI reactor model is composed of collections of ARMIObject objects. These objects are combined in a hierarchical manner. Each level of the composite tree is able to be assigned parameters which define it, such as temperature, flux, or keff values. This class defines an attribute of type ParameterCollection, which contains all the functionality of an ARMI Parameter object. Because the entire model is composed of ARMIObjects at the most basic level, each level of the Composite tree contains this parameter attribute and can thus be queried.

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

paramCollectionType

alias of ArmiObjectParameterCollection

pDefs = <armi.reactor.parameters.parameterDefinitions.ParameterDefinitionCollection object>
property nuclideBases
clearCache()[source]

Clear the cache so all new values are recomputed.

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

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 the paramCollectionType 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 given ArmiObject, 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.

Implementation: Composites (and all ARMI objects) have parameter collections. I_ARMI_CMP_PARAMS
signature: getParameterCollection
requirements: R_ARMI_CMP_PARAMS

This class method allows a user to obtain the paramCollection object, which is the object containing the interface for all parameters of an ARMI object.

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)

getName()[source]

Get ArmiObject name.

setName(name)[source]
hasFlags(typeID: Flag | auto | Sequence[Flag | auto] | None, exact=False)[source]

Determine if this object is of a certain type.

Implementation: Composites have queryable flags. I_ARMI_CMP_FLAG0
signature: hasFlags
requirements: R_ARMI_CMP_FLAG

This method queries the flags (i.e. the typeID) of the Composite for a given type, returning a boolean representing whether or not the candidate flag is present in this ArmiObject. Candidate flags cannot be passed as a string type and must be of a type Flag. If no flags exist in the object then False is returned.

If a list of flags is provided, then all input flags will be checked against the flags of the object. If exact is False, then the object must have at least one of candidates exactly. If it is True then the object flags and candidates must match exactly.

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:

bool

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, and FUEL 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
getType()[source]

Return the object type.

setType(typ, flags: Flags | None = None)[source]

Set the object type.

Implementation: Composites have modifiable flags. I_ARMI_CMP_FLAG1
signature: setType
requirements: R_ARMI_CMP_FLAG

This method allows for the setting of flags parameter of the Composite.

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.

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

abstract getVolume()[source]

Get the volume of the ArmiObject.

abstract getArea(cold=False)[source]

Get the area of the ArmiObject.

getVolumeFraction()[source]

Return the volume fraction that this object takes up in its parent.

abstract getMass(nuclideNames: None | str | list[str] = None) → float[source]

Determine the mass in grams of nuclide(s) and/or elements in this object.

Parameters:

nuclideNames – The nuclide/element specifier to get the mass of in the object. If omitted, total mass is returned.

Returns:

mass – The mass in grams.

Return type:

float

getMassFrac(nucName)[source]

Get the mass fraction of a nuclide.

Notes

If you need multiple mass fractions, use getMassFracs.

getMicroSuffix()[source]
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)

abstract getNuclideNumberDensities(nucNames)[source]

Return a list of number densities in atoms/barn-cm for the nuc names requested.

Parameters:

nucNames (list of str) – Nuclide names to get number densities for, e.g. [‘U233’, ‘U235’, ‘Pu239’]

abstract getNumberDensity(nucName)[source]

Return the number density of a nuclide in atoms/barn-cm.

Parameters:

nucName (str) – Nuclide name to get number density for, e.g. ‘U233’.

getNumberDensities(expandFissionProducts=False)[source]

Retrieve the number densities in atoms/barn-cm of all nuclides (or those requested) in the object.

Implementation: Number density of composite is retrievable. I_ARMI_CMP_NUC
signature: getNumberDensities
requirements: R_ARMI_CMP_NUC

This method provides a way for retrieving the number densities of all nuclides within the Composite. It does this by leveraging the _getNdensHelper method, which invokes the getNuclideNumberDensities method. This method considers the nuclides within each child Composite of this composite (if they exist). If the expandFissionProducts flag is True, then the lumped fission products are expanded to include their constituent elements via the _expandLFPs method.

Parameters:

expandFissionProducts (bool (optional)) – expand the fission product number densities

Returns:

numberDensities – nucName keys, number density values (atoms/bn-cm)

Return type:

dict

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) → Tuple[ArmiObject, int] | None[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: Flag | auto | Sequence[Flag | auto] | None, exactMatch=False, excludeSelf=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

  • excludeSelf (bool) – Whether to exclude the reciever object in the ancestor tree.

Returns:

the first ancestor up the chain of parents that matches the passed flags

Return type:

armi.composites.ArmiObject

Warning

The receiver object will return itself if it contains the flags in typeSpec and excludeSelf is False.

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:

float

abstract setNumberDensity(nucName, val)[source]

Set the number density of this nuclide to this value.

Parameters:
  • nucName (str) – Nuclide number density to modify

  • val (float) – Number density to set in atoms/bn-cm (heterogeneous)

abstract setNumberDensities(numberDensities)[source]

Set one or more multiple number densities. Reset any non-listed nuclides to 0.0.

Parameters:

numberDensities (dict) – nucName: ndens pairs.

abstract updateNumberDensities(numberDensities)[source]

Set one or more multiple number densities. Leaves unlisted number densities alone.

Parameters:

numberDensities (dict) – nucName: ndens pairs.

abstract 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.

density()[source]

Returns the mass density of the object in g/cc.

getNumberOfAtoms(nucName)[source]

Return the number of atoms of nucName in this object.

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

setLumpedFissionProducts(lfpCollection)[source]
getFissileMassEnrich()[source]

Returns the fissile mass enrichment.

getUraniumNumEnrich()[source]

Returns fissile uranium number fraction.

isFuel()[source]

True if this is a fuel block.

abstract getNuclides()[source]

Determine which nuclides are present in this armi object.

Returns:

nucs – Nuclide names that exist in this ArmiObject

Return type:

list of str

getFissileMass()[source]

Returns fissile mass in grams.

getHMMass()[source]

Returns heavy metal mass in grams.

getHMMoles()[source]

Get the number of moles of heavy metal in this object.

Notes

If an object is on a symmetry line, the volume reported by getVolume is reduced to reflect that the block is not wholly within the reactor. This reduction in volume reduces the reported HM moles.

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:

float

getFPMass()[source]

Returns mass of fission products in this block in grams.

abstract getFuelMass()[source]

Returns mass of fuel in grams.

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.

abstract getIntegratedMgFlux(adjoint=False, gamma=False)[source]

Return 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.

Parameters:
  • adjoint (bool, optional) – Return adjoint flux instead of real

  • gamma (bool, optional) – Whether to return the neutron flux or the gamma flux.

Returns:

integratedFlux

Return type:

multigroup neutron tracklength in [n-cm/s]

getMgFlux(adjoint=False, average=False, 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

  • 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

removeMass(nucName, mass)[source]
addMass(nucName, mass)[source]

Add mass to a particular nuclide.

Parameters:
  • nucName (str) – nuclide name e.g. ‘U235’

  • mass (float) – mass in grams of nuclide to be added to this armi Object

addMasses(masses)[source]

Adds a vector of masses.

Parameters:

masses (dict) – a dictionary of masses (g) indexed by nucNames (string)

setMass(nucName, mass)[source]

Set the mass in an object by adjusting the ndens of the nuclides.

Parameters:
  • nucName (str) – Nuclide name to set mass of

  • mass (float) – Mass in grams to set.

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

expandAllElementalsToIsotopics()[source]
abstract expandElementalToIsotopics(elementalNuclide)[source]

Expand the density of a specific element to its natural isotopic distribution.

Parameters:

elementalNuclide (armi.nucDirectory.nuclideBases.NaturalNuclide element to) – expand into natural isotopic distribution.

abstract getReactionRates(nucName, nDensity=None)[source]

Get the reaction rates of a certain nuclide on this ArmiObject.

Parameters:
  • nucName (str) – nuclide name – e.g. ‘U235’

  • nDensity (float) – number Density

Returns:

rxnRates – reaction rates (1/s) for nG, nF, n2n, nA and nP

Return type:

dict