Skip to content

Commit

Permalink
add function and fix init
Browse files Browse the repository at this point in the history
  • Loading branch information
onufer committed Feb 5, 2025
1 parent f587e74 commit 94a0414
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions armi/reactor/components/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,20 @@ def applyMaterialMassFracsToNumberDensities(self):
# `density` is 3D density
# call getProperty to cache and improve speed
density = self.material.getProperty("pseudoDensity", Tc=self.temperatureInC)

self.p.numberDensities = densityTools.getNDensFromMasses(
density, self.material.massFrac
)

# Sometimes the material thermal expansion depends on its parents composition (eg Pu frac) so
# setting number densities can sometimes change thermal expansion behavior.
# so call again so that the material has access to its parents comp when providing the reference initial density.
densityBasedOnParentComposition = self.material.getProperty(
"pseudoDensity", Tc=self.temperatureInC
)
self.p.numberDensities = densityTools.getNDensFromMasses(
densityBasedOnParentComposition, self.material.massFrac
)

# material needs to be expanded from the material's cold temp to hot,
# not components cold temp, so we don't use mat.linearExpansionFactor or
# component.getThermalExpansionFactor.
Expand Down Expand Up @@ -715,12 +724,7 @@ def setNumberDensity(self, nucName, val):
val : float
Number density to set in atoms/bn-cm (heterogeneous)
"""
self.p.numberDensities[nucName] = val
self.p.assigned = parameters.SINCE_ANYTHING
# necessary for syncMpiState
parameters.ALL_DEFINITIONS[
"numberDensities"
].assigned = parameters.SINCE_ANYTHING
self.updateNumberDensities({nucName: val})

def setNumberDensities(self, numberDensities):
"""
Expand Down Expand Up @@ -804,7 +808,7 @@ def updateNumberDensities(self, numberDensities):
factor = area / self.getArea()
self.changeNDensByFactor(factor)

# since we're updating the object the param points to but not the param itself, we have to inform
# since we're calling update on the object the param points to, but not the param itself, we have to inform
# the param system to flag it as modified so it properly syncs during ``syncMpiState``.
self.p.assigned = parameters.SINCE_ANYTHING
self.p.paramDefs["numberDensities"].assigned = parameters.SINCE_ANYTHING
Expand Down

0 comments on commit 94a0414

Please sign in to comment.