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: Developer Docs.

class armi.reactor.composites.FlagSerializer[source]

Bases: armi.reactor.parameters.parameterDefinitions.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 = '1'
static pack(data)[source]

Flags are represented as a 2-D 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.

static _packImpl(data, flagCls: Type[armi.utils.flags.Flag])[source]

Implement the pack operation given a target output Flag class.

This is kept separate from the public interface to permit testing of the functionality without having to do unholy things to ARMI’s actual set of reactor.flags.Flags.

static _remapBits(inp: int, mapping: Dict[int, int])[source]

Given an input bitfield, map each bit to the appropriate new bit position based on the passed mapping.

Parameters
  • inp (int) – input bitfield

  • mapping (dict) – dictionary mapping from old bit position -> new bit position

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.

classmethod _unpackImpl(data, version, attrs, flagCls: Type[armi.utils.flags.Flag])[source]

Implement the unpack operation given a target output Flag class.

This is kept separate from the public interface to permit testing of the functionality without having to do unholy things to ARMI’s actual set of reactor.flags.Flags.

If the set of flags for the currently-configured App match the input set of flags, they are read in directly, which is good and cheap. However, if the set of flags differ from the input and the current App, we will try to convert them (as long as all of the input flags exist in the current App). Conversion is done by forming a map from all input bit positions to the current-App bit positions of the same meaning. E.g., if FUEL flag used to be the 3rd bit position, but now it is the 6th bit position, the map will contain map[3] = 6. Then for each bitfield that is read in, each bit position is queried and if present, mapped to the proper corresponding new bit position. The result of this mapping is used to construct the Flags object.

armi.reactor.composites._defineBaseParameters()[source]

Return parameter definitions that all ArmiObjects must have to function properly.

For now, this pretty much just includes flags, since these are used throughout the composite model to filter which objects are considered when traversing the reactor model.

Note also that the base ParameterCollection class also has a serialNum parameter. These are defined in different locations, since serialNum is a guaranteed feature of a ParameterCollection (for serialization to the database and history tracking), while the flags parameter is more a feature of the composite model.

Important

Notice that the flags parameter is not written to the database. This is for a couple of reasons: * Flags are derived from an ArmiObject’s name. Since the name is stored on the DB, it is possible to recover the flags from that. * Storing flags to the DB may be complicated, since it is easier to imagine a number of flags that is greater than the width of natively-supported integer types, requiring some extra tricks to store the flages in an HDF5 file. * Allowing flags to be modified by plugins further complicates things, in that it is important to ensure that the meaning of all bits in the flag value are consistent between a database state and the current ARMI environment. This may require encoding these meanings in to the database as some form of metadata.

class armi.reactor.composites.CompositeModelType[source]

Bases: armi.reactor.parameters.resolveCollections.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.

TYPES = {'Alloy200': <class 'armi.materials.alloy200.Alloy200'>, 'ArmiObject': <class 'armi.reactor.composites.ArmiObject'>, 'Assembly': <class 'armi.reactor.assemblies.Assembly'>, 'AssemblyList': <class 'armi.reactor.assemblyLists.AssemblyList'>, 'B4C': <class 'armi.materials.b4c.B4C'>, 'Be9': <class 'armi.materials.be9.Be9'>, 'Block': <class 'armi.reactor.blocks.Block'>, 'CaH2': <class 'armi.materials.caH2.CaH2'>, 'Californium': <class 'armi.materials.californium.Californium'>, 'CartesianAssembly': <class 'armi.reactor.assemblies.CartesianAssembly'>, 'CartesianBlock': <class 'armi.reactor.blocks.CartesianBlock'>, 'Circle': <class 'armi.reactor.components.basicShapes.Circle'>, 'Component': <class 'armi.reactor.components.component.Component'>, 'Composite': <class 'armi.reactor.composites.Composite'>, 'Concrete': <class 'armi.materials.concrete.Concrete'>, 'Core': <class 'armi.reactor.reactors.Core'>, 'Cs': <class 'armi.materials.cs.Cs'>, 'Cu': <class 'armi.materials.copper.Cu'>, 'Cube': <class 'armi.reactor.components.volumetricShapes.Cube'>, 'Custom': <class 'armi.materials.custom.Custom'>, 'DerivedShape': <class 'armi.reactor.components.DerivedShape'>, 'DifferentialRadialSegment': <class 'armi.reactor.components.volumetricShapes.DifferentialRadialSegment'>, 'Fluid': <class 'armi.materials.material.Fluid'>, 'FuelMaterial': <class 'armi.materials.material.FuelMaterial'>, 'Graphite': <class 'armi.materials.graphite.Graphite'>, 'HT9': <class 'armi.materials.ht9.HT9'>, 'Hafnium': <class 'armi.materials.hafnium.Hafnium'>, 'HastelloyN': <class 'armi.materials.hastelloyN.HastelloyN'>, 'Helix': <class 'armi.reactor.components.complexShapes.Helix'>, 'HexAssembly': <class 'armi.reactor.assemblies.HexAssembly'>, 'HexBlock': <class 'armi.reactor.blocks.HexBlock'>, 'Hexagon': <class 'armi.reactor.components.basicShapes.Hexagon'>, 'HoledHexagon': <class 'armi.reactor.components.complexShapes.HoledHexagon'>, 'HoledRectangle': <class 'armi.reactor.components.complexShapes.HoledRectangle'>, 'HoledSquare': <class 'armi.reactor.components.complexShapes.HoledSquare'>, 'Inconel': <class 'armi.materials.inconel.Inconel'>, 'Inconel600': <class 'armi.materials.inconel600.Inconel600'>, 'Inconel625': <class 'armi.materials.inconel625.Inconel625'>, 'Inconel800': <class 'armi.materials.inconel800.Inconel800'>, 'InconelPE16': <class 'armi.materials.inconelPE16.InconelPE16'>, 'InconelX750': <class 'armi.materials.inconelX750.InconelX750'>, 'Lead': <class 'armi.materials.lead.Lead'>, 'LeadBismuth': <class 'armi.materials.leadBismuth.LeadBismuth'>, 'Leaf': <class 'armi.reactor.composites.Leaf'>, 'Lithium': <class 'armi.materials.lithium.Lithium'>, 'MOX': <class 'armi.materials.mox.MOX'>, 'Magnesium': <class 'armi.materials.magnesium.Magnesium'>, 'Material': <class 'armi.materials.material.Material'>, 'MgO': <class 'armi.materials.mgO.MgO'>, 'Molybdenum': <class 'armi.materials.molybdenum.Molybdenum'>, 'NZ': <class 'armi.materials.nZ.NZ'>, 'NaCl': <class 'armi.materials.sodiumChloride.NaCl'>, 'NullComponent': <class 'armi.reactor.components.NullComponent'>, 'Point': <class 'armi.reactor.blocks.Point'>, 'PositiveOrNegativeVolumeComponent': <class 'armi.reactor.components.PositiveOrNegativeVolumeComponent'>, 'Potassium': <class 'armi.materials.potassium.Potassium'>, 'RZAssembly': <class 'armi.reactor.assemblies.RZAssembly'>, 'RadialSegment': <class 'armi.reactor.components.volumetricShapes.RadialSegment'>, 'Reactor': <class 'armi.reactor.reactors.Reactor'>, 'Rectangle': <class 'armi.reactor.components.basicShapes.Rectangle'>, 'SaturatedSteam': <class 'armi.materials.water.SaturatedSteam'>, 'SaturatedWater': <class 'armi.materials.water.SaturatedWater'>, 'Sc2O3': <class 'armi.materials.scandiumOxide.Sc2O3'>, 'ShapedComponent': <class 'armi.reactor.components.component.ShapedComponent'>, 'SiC': <class 'armi.materials.siC.SiC'>, 'Sodium': <class 'armi.materials.sodium.Sodium'>, 'SolidRectangle': <class 'armi.reactor.components.basicShapes.SolidRectangle'>, 'SpentFuelPool': <class 'armi.reactor.assemblyLists.SpentFuelPool'>, 'Sphere': <class 'armi.reactor.components.volumetricShapes.Sphere'>, 'Square': <class 'armi.reactor.components.basicShapes.Square'>, 'Sulfur': <class 'armi.materials.sulfur.Sulfur'>, 'TZM': <class 'armi.materials.tZM.TZM'>, 'Tantalum': <class 'armi.materials.tantalum.Tantalum'>, 'ThRZAssembly': <class 'armi.reactor.assemblies.ThRZAssembly'>, 'ThRZBlock': <class 'armi.reactor.blocks.ThRZBlock'>, 'ThU': <class 'armi.materials.thU.ThU'>, 'Thorium': <class 'armi.materials.thorium.Thorium'>, 'ThoriumOxide': <class 'armi.materials.thoriumOxide.ThoriumOxide'>, 'Torus': <class 'armi.reactor.components.volumetricShapes.Torus'>, 'Triangle': <class 'armi.reactor.components.basicShapes.Triangle'>, 'UO2': <class 'armi.materials.uraniumOxide.UO2'>, 'UThZr': <class 'armi.materials.uThZr.UThZr'>, 'UZr': <class 'armi.materials.uZr.UZr'>, 'UnshapedComponent': <class 'armi.reactor.components.UnshapedComponent'>, 'UnshapedVolumetricComponent': <class 'armi.reactor.components.UnshapedVolumetricComponent'>, 'Uranium': <class 'armi.materials.uranium.Uranium'>, 'UraniumOxide': <class 'armi.materials.uraniumOxide.UraniumOxide'>, 'Void': <class 'armi.materials.void.Void'>, 'Water': <class 'armi.materials.water.Water'>, 'Y2O3': <class 'armi.materials.yttriumOxide.Y2O3'>, 'ZeroMassComponent': <class 'armi.reactor.components.ZeroMassComponent'>, 'ZnO': <class 'armi.materials.zincOxide.ZnO'>, 'Zr': <class 'armi.materials.zr.Zr'>}
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 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.

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.

name

Object name

Type

str

parent

The object’s parent in a hierarchical tree

Type

ArmiObject

cached

Some cached values for performance

Type

dict

p

The state variables

Type

ParameterCollection

spatialGrid

The spatial grid that this object contains

Type

grids.Grid

spatialLocator

The location of this object in its parent grid, or global space

Type

grids.LocationBase

paramCollectionType

alias of armi.reactor.parameters.parameterCollections.ArmiObjectParameterCollection

pDefs = <armi.reactor.parameters.parameterDefinitions.ParameterDefinitionCollection object>
__lt__(other)[source]

Implement the less-than operator.

Implementing this on the ArmiObject allows most objects, under most circumstances to be sorted. This is useful from the context of the Database classes, so that they can produce a stable layout of the serialized composite structure.

By default, this sorts using the spatial locator, in K, J, I order, which should give a relatively intuitive order. For safety, it makes sure that the objects being sorted live in the same grid, since it probably doesn’t make sense to sort things across containers or scopes. If this ends up being too restrictive, it can probably be relaxed or overridden on specific classes.

__getstate__()[source]

Python method for reducing data before pickling.

This removes links to parent objects, which allows one to, for example, pickle an assembly without pickling the entire reactor. Likewise, one could MPI_COMM.bcast an assembly without broadcasting the entire reactor.

Notes

Special treatment of parent is not enough, since the spatialGrid also contains a reference back to the armiObject. Consequently, the spatialGrid needs to be reassigned in __setstate__.

__setstate__(state)[source]

Sets the state of this ArmiObject.

Notes

This ArmiObject may have lost a reference to its parent. If the parent was also pickled (serialized), then the parent should update the .parent attribute during its own __setstate__. That means within the context of __setstate__ one should not rely upon self.parent.

__bool__()[source]

Flag that says this is non-zero in a boolean context

Notes

The default behavior for not [obj] that has a __len__ defined is to see if the length is zero. However, for these composites, we’d like Assemblies, etc. to be considered non-zero even if they don’t have any blocks. This is important for parent resolution, etc. If one of these objects exists, it is non-zero, regardless of its contents.

__nonzero__()

Flag that says this is non-zero in a boolean context

Notes

The default behavior for not [obj] that has a __len__ defined is to see if the length is zero. However, for these composites, we’d like Assemblies, etc. to be considered non-zero even if they don’t have any blocks. This is important for parent resolution, etc. If one of these objects exists, it is non-zero, regardless of its contents.

__add__(other)[source]

Return a list of all children in this and another 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.

clearCache()[source]

Clear the cache so all new values are recomputed.

_getCached(name)[source]

Obtain a value from the cache.

Cached values can be used to temporarily store frequently read but long-to-compute values. The practice is generally discouraged because it’s challenging to make sure to properly invalidate the cache when the state changes.

_setCache(name, val)[source]

Set a value in the cache.

See also

_getCached()

returns a previously-cached value

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: Union[armi.utils.flags.Flag, armi.utils.flags.auto, Sequence[Union[armi.utils.flags.Flag, armi.utils.flags.auto]], None], exactMatch=True)[source]

Get all children that have given flags.

getComponents(typeSpec: Union[armi.utils.flags.Flag, armi.utils.flags.auto, Sequence[Union[armi.utils.flags.Flag, armi.utils.flags.auto]], None] = 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: Union[armi.utils.flags.Flag, armi.utils.flags.auto, Sequence[Union[armi.utils.flags.Flag, armi.utils.flags.auto]], None] = None, exact=False)[source]

Yield components one by one in a generator.

doChildrenHaveFlags(typeSpec: Union[armi.utils.flags.Flag, armi.utils.flags.auto, Sequence[Union[armi.utils.flags.Flag, armi.utils.flags.auto]], None], deep=False)[source]

Generator that yields True if the next child has given flags.

Parameters

typeSpec (TypeSpec) – Requested type of the child

containsAtLeastOneChildWithFlags(typeSpec: Union[armi.utils.flags.Flag, armi.utils.flags.auto, Sequence[Union[armi.utils.flags.Flag, armi.utils.flags.auto]], None])[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: Union[armi.utils.flags.Flag, armi.utils.flags.auto, Sequence[Union[armi.utils.flags.Flag, armi.utils.flags.auto]], None])[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 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 class method to dig dynamically down to the underlying parameter collection type.

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]
setName(name)[source]
hasFlags(typeID: Union[armi.utils.flags.Flag, armi.utils.flags.auto, Sequence[Union[armi.utils.flags.Flag, armi.utils.flags.auto]], None], 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

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: Optional[armi.reactor.flags.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.

getVolume()[source]
_updateVolume()[source]

Recompute and store volume.

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

list

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

getVolumeFraction()[source]

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

getMaxArea()[source]

” The maximum area of this object if it were totally full.

getMaxVolume()[source]

The maximum volume of this object if it were totally full.

Returns

vol – volume in cm^3.

Return type

float

getMass(nuclideNames=None)[source]

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

Parameters

nuclideNames (str, optional) – 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]
_getNuclidesFromSpecifier(nucSpec)[source]

Convert a nuclide specification to a list of valid nuclide/element keys.

nucSpecnuclide specifier

Can be a string name of a nuclide or element, or a list of such strings.

This might get Zr isotopes when ZR is passed in if they exist, or it will get elemental ZR if that exists. When expanding elements, all known nuclides are returned, not just the natural ones.

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)

Since massFracs is not necessarily normalized, A+C+O actually = self.p.massFracNorm

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.

_getNdensHelper()[source]

Return a number densities dict with unexpanded lfps.

Notes

This is implemented more simply on the component level.

getNumberDensities(expandFissionProducts=False)[source]

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

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

  • nuclideNames (iterable (optional)) – nuclide names to get number densities

Returns

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

Return type

dict

getNeutronEnergyDepositionConstants()[source]

Get the neutron energy deposition group constants for a composite.

Returns

energyDepConstants – Neutron energy generation group constants (in Joules/cm)

Return type

numpy.array

Raises

RuntimeError: – Reports if a cross section library is not assigned to a reactor.

getGammaEnergyDepositionConstants()[source]

Get the gamma energy deposition group constants for a composite.

Returns

energyDepConstants – Energy generation group constants (in Joules/cm)

Return type

numpy.array

Raises

RuntimeError: – Reports if a cross section library is not assigned to a reactor.

getTotalEnergyGenerationConstants()[source]

Get the total energy generation group constants for a composite.

Gives the total energy generation rates when multiplied by the multigroup flux.

Returns

totalEnergyGenConstant – Total (fission + capture) energy generation group constants (Joules/cm)

Return type

numpy.array

getFissionEnergyGenerationConstants()[source]

Get the fission energy generation group constants for a composite.

Gives the fission energy generation rates when multiplied by the multigroup flux.

Returns

fissionEnergyGenConstant – Energy generation group constants (Joules/cm)

Return type

numpy.array

Raises

RuntimeError: – Reports if a cross section library is not assigned to a reactor.

getCaptureEnergyGenerationConstants()[source]

Get the capture energy generation group constants for a composite.

Gives the capture energy generation rates when multiplied by the multigroup flux.

Returns

fissionEnergyGenConstant – Energy generation group constants (Joules/cm)

Return type

numpy.array

Raises

RuntimeError: – Reports if a cross section library is not assigned to a reactor.

_expandLFPs(numberDensities)[source]

Expand the LFPs on the numberDensities dictionary using this composite’s lumpedFissionProductCollection.

getChildrenWithNuclides(nucNames)[source]

Return children that contain any nuclides in nucNames.

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[armi.reactor.composites.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: Union[armi.utils.flags.Flag, armi.utils.flags.auto, Sequence[Union[armi.utils.flags.Flag, armi.utils.flags.auto]], None], 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

Notes

This will throw an error if no ancestor can be found that matches the typeSpec

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

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.

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]
setChildrenLumpedFissionProducts(lfpCollection)[source]
getFissileMassEnrich()[source]

returns the fissile mass enrichment.

getBoronMassEnrich()[source]

Return B-10 mass fraction.

getUraniumMassEnrich()[source]

returns U-235 mass fraction assuming U-235 and U-238 only.

getUraniumNumEnrich()[source]

Returns U-235 number fraction.

getPuN()[source]

Returns total number density of Pu isotopes

calcTotalParam(param, objs=None, volumeIntegrated=False, addSymmetricPositions=False, typeSpec: Union[armi.utils.flags.Flag, armi.utils.flags.auto, Sequence[Union[armi.utils.flags.Flag, armi.utils.flags.auto]], None] = 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: Union[armi.utils.flags.Flag, armi.utils.flags.auto, Sequence[Union[armi.utils.flags.Flag, armi.utils.flags.auto]], None] = 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)

  • weighted sum is (The) –

  • math:: (.) – left<text{x}right> = frac{sum_{i} x_i w_i}{sum_i w_i}

:param where \(i\) is each child, \(x_i\) is the param value of the i-th child,: :param 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

float

getMaxParam(param, typeSpec: Union[armi.utils.flags.Flag, armi.utils.flags.auto, Sequence[Union[armi.utils.flags.Flag, armi.utils.flags.auto]], None] = 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: Union[armi.utils.flags.Flag, armi.utils.flags.auto, Sequence[Union[armi.utils.flags.Flag, armi.utils.flags.auto]], None] = None, absolute=True, generationNum=1, returnObj=False)[source]

Find the minimum value for the parameter in this container.

See also

getMaxParam()

details

_minMaxHelper(param, typeSpec: Union[armi.utils.flags.Flag, armi.utils.flags.auto, Sequence[Union[armi.utils.flags.Flag, armi.utils.flags.auto]], None], absolute, generationNum, returnObj, startingNum, compartor)[source]

Helper for getMinParam and getMaxParam.

getChildParamValues(param)[source]

Get the child parameter values in a numpy array.

isFuel()[source]

True if this is a fuel block.

containsHeavyMetal()[source]

True if this has HM

getNuclides()[source]

Determine which nuclides are present in this armi object.

Returns

List of nuclide names that exist in this

Return type

list

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

float

getPuMass()[source]

Get the mass of Pu in this object in grams.

getPuFrac()[source]

Compute the Pu/HM mass fraction in this object.

Returns

puFrac – The pu mass fraction in heavy metal in this assembly

Return type

float

getZrFrac()[source]

return the total zr/(hm+zr) fraction in this assembly

getMaxUraniumMassEnrich()[source]
getFPMass()[source]

Returns mass of fission products in this block in grams

getFuelMass()[source]

returns mass of fuel in grams.

constituentReport()[source]

A print out of some pertinent constituent information

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.

getIntegratedMgFlux(adjoint=False, gamma=False)[source]
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

numpy.array

removeMass(nucName, mass)[source]
addMass(nucName, mass)[source]
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

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

tuple

getComponentNames()[source]

Get all unique component names of this Composite.

Returns

A set of all unique component names found in this Composite.

Return type

set or str

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

list

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 (Material object, optional) – The material to match

  • materialName (str, optional) – The material name to match.

Returns

componentsWithThisMat

Return type

list

hasComponents(typeSpec: Union[armi.utils.flags.Flag, armi.utils.flags.auto, Sequence[Union[armi.utils.flags.Flag, armi.utils.flags.auto]], None, List[Union[armi.utils.flags.Flag, armi.utils.flags.auto, Sequence[Union[armi.utils.flags.Flag, armi.utils.flags.auto]], None]]], 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: Union[armi.utils.flags.Flag, armi.utils.flags.auto, Sequence[Union[armi.utils.flags.Flag, armi.utils.flags.auto]], None], exact=False, returnNull=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

  • with multiple similar names in one object (Careful) –

Returns

Component

Return type

The component that matches the critera or None

getNumComponents(typeSpec: Union[armi.utils.flags.Flag, armi.utils.flags.auto, Sequence[Union[armi.utils.flags.Flag, armi.utils.flags.auto]], None], 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

int

setComponentDimensionsReport()[source]

Makes a summary of the dimensions of the components in this object.

printDensities(expandFissionProducts=False)[source]

Get lines that have the number densities of a object.

expandAllElementalsToIsotopics()[source]
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: Union[armi.utils.flags.Flag, armi.utils.flags.auto, Sequence[Union[armi.utils.flags.Flag, armi.utils.flags.auto]], None] = None, exact=False)[source]

Return the average temperature of the ArmiObject in C by averaging all components

getDominantMaterial(typeSpec: Union[armi.utils.flags.Flag, armi.utils.flags.auto, Sequence[Union[armi.utils.flags.Flag, armi.utils.flags.auto]], None] = 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

Material

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: armi.reactor.composites.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 the spatialLocator and spatialGrid parameters. The spatialLocator is a numpy triple representing either:

1. Indices in the parent’s spatialGrid (for lattices, etc.), used when the dtype is int.

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

__contains__(item)[source]

Membership check.

This does not use quality checks for membership checking because equality operations can be fairly heavy. Rather, this only checks direct identity matches.

index(obj)[source]

Obtain the list index of a particular child.

append(obj)[source]

Append a child to this object.

extend(seq)[source]

Add a list of children to this object.

add(obj)[source]

Add one new child.

remove(obj)[source]

Remove a particular child.

moveTo(locator)[source]

Move to specific location in parent. Often in a grid.

insert(index, obj)[source]

Insert an object into the list of children at a particular index.

removeAll()[source]

Remove all children.

setChildren(items)[source]

Clear this container and fills it with new children.

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: Union[armi.utils.flags.Flag, armi.utils.flags.auto, Sequence[Union[armi.utils.flags.Flag, armi.utils.flags.auto]], None], exactMatch=False)[source]

Get all children of a specific type.

getChildrenOfType(typeName)[source]

Get children that have a specific input type name.

getComponents(typeSpec: Union[armi.utils.flags.Flag, armi.utils.flags.auto, Sequence[Union[armi.utils.flags.Flag, armi.utils.flags.auto]], None] = 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: Union[armi.utils.flags.Flag, armi.utils.flags.auto, Sequence[Union[armi.utils.flags.Flag, armi.utils.flags.auto]], None] = 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

int

_syncParameters(allSyncData, errors)[source]
_markSynchronized()[source]

Mark the composite and child parameters as synchronized across MPI.

We clear SINCE_LAST_DISTRIBUTE_STATE so that anything after this point will set the SINCE_LAST_DISTRIBUTE_STATE flag, indicating it has been modified SINCE_LAST_DISTRIBUTE_STATE.

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

object

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.

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 – multigroup neutron tracklength in [n-cm/s]

Return type

numpy.array

getReactionRates(nucName, nDensity=None)[source]

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

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

  • - float (nDensity) – number Density

Returns

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

Return type

dict

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.

isOnWhichSymmetryLine()[source]
_genChildByLocationLookupTable()[source]

Update the childByLocation lookup table.

paramCollectionType

alias of armi.reactor.parameters.parameterCollections.ArmiObjectParameterCollection

class armi.reactor.composites.Leaf(name)[source]

Bases: armi.reactor.composites.Composite

Defines behavior for primitive objects in the composition.

getChildren(deep=False, generationNum=1, includeMaterials=False, predicate=None)[source]

Return empty list, representing that this object has no children.

getChildrenWithFlags(typeSpec: Union[armi.utils.flags.Flag, armi.utils.flags.auto, Sequence[Union[armi.utils.flags.Flag, armi.utils.flags.auto]], None], exactMatch=True)[source]

Return empty list, representing that this object has no children.

paramCollectionType

alias of armi.reactor.parameters.parameterCollections.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.

_enterExitHelper(func)[source]

Helper method for __enter__ and __exit__. func is a lambda to either backUp() or restoreBackup()

armi.reactor.composites.gatherMaterialsByVolume(objects: List[armi.reactor.composites.ArmiObject], typeSpec: Union[armi.utils.flags.Flag, armi.utils.flags.auto, Sequence[Union[armi.utils.flags.Flag, armi.utils.flags.auto]], None] = 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[armi.reactor.composites.ArmiObject], typeSpec: Union[armi.utils.flags.Flag, armi.utils.flags.auto, Sequence[Union[armi.utils.flags.Flag, armi.utils.flags.auto]], None] = 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.