armi.utils.densityTools module
Assorted utilities to help with basic density calculations.
- armi.utils.densityTools.getNDensFromMasses(rho, massFracs, normalize=False)[source]
Convert density (g/cc) and massFracs vector into a number densities vector (#/bn-cm).
Loops over all provided nuclides (given as keys in the
massFracsvector) and calculates number densities of each, at a given materialdensity. Mass fractions can be provided either as normalized to 1, or as unnormalized with subsequent normalization callingnormalizeNuclideListvia thenormalizeflag.- Parameters:
rho (float) – density in (g/cc)
massFracs (dict) – vector of mass fractions – normalized to 1 – keyed by their nuclide name
- Returns:
nuclides (np.ndarray[np.bytes_]) – vector of nuclide names as byte strings
numberDensities (np.ndarray[np.float64]) – vector of number densities (#/bn-cm) for each nuclide in nuclides
- armi.utils.densityTools.getMassFractions(numberDensities)[source]
Convert number densities (#/bn-cm) into mass fractions.
- Parameters:
numberDensities (dict) – number densities (#/bn-cm) keyed by their nuclide name
- Returns:
massFracs – mass fractions – normalized to 1 – keyed by their nuclide name
- Return type:
dict
- armi.utils.densityTools.calculateMassDensity(numberDensities)[source]
Calculates the mass density.
- Parameters:
numberDensities (dict) – vector of number densities (atom/bn-cm) indexed by nuclides names
- Returns:
rho – density in (g/cc)
- Return type:
float
- armi.utils.densityTools.calculateNumberDensity(nucName, mass, volume)[source]
Calculates the number density.
- Parameters:
mass (float)
volume (volume)
nucName (armi nuclide name -- e.g. 'U235')
- Returns:
number density – number density (#/bn-cm)
- Return type:
float
See also
armi.reactor.blocks.Block.setMass
- armi.utils.densityTools.getMassInGrams(nucName: str, volume: float, numberDensity: float | None = None) float[source]
Gets mass of a nuclide of a known volume and know number density.
- Parameters:
nucName – name of nuclide – e.g. ‘U235’
volume – volume in (cm3)
numberDensity – number density in (at/bn-cm)
- Returns:
mass of nuclide (g)
- Return type:
mass
- armi.utils.densityTools.formatMaterialCard(densities, matNum=0, minDens=1e-15, sigFigs=8, mcnp6Compatible=False, mcnpLibrary=None)[source]
Formats nuclides and densities into a MCNP material card.
Loops over a vector of nuclides (of type
nuclideBase) provided indensitiesand formats them into a list of strings consistent with MCNP material card syntax, skipping dummy nuclides and LFPs.A
matNummay optionally be provided for the created material card: if not provided, it is left blank. The desired number of significant figures for the created card can be optionally provided bysigFigs. Nuclides whose number density falls below a threshold (optionally specified byminDens) are set to the threshold value.The boolean
mcnp6Compatiblemay optionally be provided to include the nuclide library at the end of the vector of individual nuclides using the “nlib=” syntax leveraged by MCNP. If this boolean is turned on, the associated valuemcnpLibraryshould generally also be provided, as otherwise, the library will be left blank in the resulting material card string.- Parameters:
densities (dict) – number densities indexed by nuclideBase
matNum (int) – mcnp material number
minDens (float) – minimum density
sigFigs (int) – significant figures for the material card
- Returns:
mCard – list of material card strings
- Return type:
list
- armi.utils.densityTools.filterNuclideList(nuclideVector, nuclides)[source]
Filter out nuclides not in the nuclide vector.
- Parameters:
nuclideVector (dict) – dictionary of values indexed by nuclide identifiers – e.g. nucNames or nuclideBases
nuclides (list) – list of nuclide identifiers
- Returns:
nuclideVector – dictionary of values indexed by nuclide identifiers – e.g. nucNames or nuclideBases
- Return type:
dict
- armi.utils.densityTools.normalizeNuclideList(nuclideVector, normalization=1.0)[source]
Normalize the nuclide vector.
- Parameters:
nuclideVector (dict) – dictionary of values – e.g. floats, ints – indexed by nuclide identifiers – e.g. nucNames or nuclideBases
normalization (float)
- Returns:
nuclideVector – dictionary of values indexed by nuclide identifiers – e.g. nucNames or nuclideBases
- Return type:
dict
- armi.utils.densityTools.expandElementalMassFracsToNuclides(massFracs: dict, elementExpansionPairs: Tuple[Element, List[NuclideBase]])[source]
Expand elemental mass fractions to natural nuclides.
Modifies the input
massFracsin place to contain nuclides.Notes
This indirectly updates number densities through mass fractions.
Given a vector of elements and nuclides with associated mass fractions (
massFracs), expands the elements in-place into a set of nuclides usingexpandElementalNuclideMassFracs. Isotopes to expand into are provided for each element by specifying them withelementExpansionPairs, which maps each element to a list of particular NuclideBases; if left unspecified, all naturally-occurring isotopes are included.Explicitly specifying the expansion isotopes provides a way for particular naturally-occurring isotopes to be excluded from the expansion, e.g. excluding O-18 from an expansion of elemental oxygen.
- Parameters:
massFracs (dict(str, float)) – dictionary of nuclide or element names with mass fractions. Elements will be expanded in place using natural isotopics.
elementExpansionPairs ((Element, [NuclideBase]) pairs) – element objects to expand (from nuclidBase.element) and list of NuclideBases to expand into (or None for all natural)
- armi.utils.densityTools.expandElementalNuclideMassFracs(element: Element, massFrac: float, isotopicSubset: List[NuclideBase] = None)[source]
Return a dictionary of nuclide names to isotopic mass fractions.
If an isotopic subset is passed in, the mass fractions get scaled up s.t. the total mass fraction remains constant.
- Parameters:
element (Element) – The element to expand to natural isotopics
massFrac (float) – Mass fraction of the initial element
isotopicSubset (list of NuclideBases) – Natural isotopes to include in the expansion. Useful e.g. for excluding O18 from an expansion of Oxygen.
- armi.utils.densityTools.getChemicals(nuclideInventory)[source]
Groups the inventories of nuclides by their elements.
- Parameters:
nuclideInventory (dict) – nuclide inventories indexed by nuc – either nucNames or nuclideBases
- Returns:
chemicals – inventory of elements indexed by element symbol – e.g. ‘U’ or ‘PU’
- Return type:
dict
- armi.utils.densityTools.applyIsotopicsMix(material, enrichedMassFracs: Dict[str, float], fertileMassFracs: Dict[str, float])[source]
Update material heavy metal mass fractions based on its enrichment and two nuclide feeds.
This will remix the heavy metal in a Material object based on the object’s
class1_wt_fracparameter and the input nuclide information.This can be used for inputting mixtures of two external custom isotopic feeds as well as for fabricating assemblies from two closed-cycle collections of material.
See also
- Parameters:
material (material.Material) – The object to modify. Must have a
class1_wt_fracparam setenrichedMassFracs (dict) – Nuclide names and weight fractions of the class 1 nuclides
fertileMassFracs (dict) – Nuclide names and weight fractions of the class 2 nuclides