Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom densities #1745

Merged
merged 23 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7c782c7
adjust component densities when given custom isotopics with density
bsculac Jun 20, 2024
acb5599
improve component density modification info message
bsculac Jun 21, 2024
bc4f089
add tests for custom density on library materials
bsculac Jun 21, 2024
cd4e648
Merge branch 'terrapower:main' into customDensities
bsculac Jun 21, 2024
a579ff7
fix linting
bsculac Jun 21, 2024
a3a44b6
modify tests for readability
bsculac Jun 21, 2024
817dd95
clarify isotopicOptions log message
bsculac Jun 21, 2024
abacdf0
add separate test for custom density
bsculac Jun 21, 2024
cfe6a3f
remove test for bad custom materials in tutorial input
bsculac Jun 24, 2024
dec063f
remove commented material isotopics
bsculac Jun 24, 2024
82d458a
update expected fissile mass in test
bsculac Jun 24, 2024
0c9142a
add log messages, errors, and tests for them
bsculac Jun 24, 2024
a776846
Merge branch 'main' into customDensities
bsculac Jun 24, 2024
9e4dda2
add more error tests for custom density
bsculac Jun 24, 2024
674a568
add test for number-density-only input
bsculac Jun 25, 2024
4b9dbfc
clean up and modularize test yaml input
bsculac Jun 25, 2024
eef6dcc
add documentation and release note
bsculac Jun 25, 2024
6384505
Apply anti-runlog bloat suggestions from code review
bsculac Jun 26, 2024
fbf1295
black
bsculac Jun 26, 2024
4e8cda8
Merge branch 'main' into customDensities
john-science Jun 26, 2024
eae1175
add catch and test for zero and negative densities
bsculac Jun 26, 2024
daafdaa
Adding some whitespace
john-science Jun 27, 2024
d6a3f94
Apply suggestions from code review
bsculac Jun 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions armi/reactor/blueprints/componentBlueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,66 @@ class can then use to modify the isotopics as necessary.
constructedObject = components.factory(shape, [], kwargs)
_setComponentFlags(constructedObject, self.flags, blueprint)
insertDepletableNuclideKeys(constructedObject, blueprint)

# set the custom density for non-custom material components after construction
self.setCustomDensity(constructedObject, blueprint, matMods)

return constructedObject

def setCustomDensity(self, constructedComponent, blueprint, matMods):
"""Apply a custom density to a material with custom isotopics but not a 'custom material'."""
if self.isotopics is None:
# No custom isotopics specified
return

density = blueprint.customIsotopics[self.isotopics].density
if density is None:
# Nothing to do
return

if density <= 0:
runLog.error(
"A zero or negative density was specified in a custom isotopics input. "
"This is not permitted, if a 0 density material is needed, use 'Void'. "
"The component is {} and the isotopics entry is {}.".format(
constructedComponent, self.isotopics
)
)
raise ValueError(
"A zero or negative density was specified in the custom isotopics for a component"
)

mat = materials.resolveMaterialClassByName(self.material)()
if not isinstance(mat, materials.Custom):
# check for some problem cases
if "TD_frac" in matMods.keys():
runLog.warning(
"Both TD_frac and a custom density (custom isotopics) has been specified for "
"material {}. The custom density will override the density calculated using "
"TD_frac.".format(self.material)
)
if not mat.density(Tc=self.Tinput) > 0:
runLog.error(
"A custom density has been assigned to material '{}', which has no baseline "
"density. Only materials with a starting density may be assigned a density. "
"This comes up e.g. if isotopics are assigned to 'Void'.".format(
self.material
)
)
raise ValueError(
"Cannot apply custom densities to materials without density."
)

densityRatio = density / constructedComponent.density()
constructedComponent.changeNDensByFactor(densityRatio)

runLog.important(
"A custom material density was specified in the custom isotopics for non-custom "
"material {}. The component density has been altered to "
"{}.".format(mat, constructedComponent.density()),
single=True,
)

def _conformKwargs(self, blueprint, matMods):
"""This method gets the relevant kwargs to construct the component."""
kwargs = {"mergeWith": self.mergeWith or "", "isotopics": self.isotopics or ""}
Expand Down
15 changes: 6 additions & 9 deletions armi/reactor/blueprints/isotopicOptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,15 +393,12 @@ def apply(self, material):
material.massFrac = dict(self.massFracs)
if self.density is not None:
if not isinstance(material, materials.Custom):
runLog.warning(
"You either specified a custom mass density or number densities "
"(which implies a mass density) on `{}` with custom isotopics `{}`. "
"This has no effect on this Material class; you can only "
"override mass density on `Custom` "
"materials. Consider switching to number fraction input. "
"Continuing to use {} mass density.".format(
material, self.name, material
)
runLog.important(
"A custom density or number densities has been specified for non-custom "
"material {}. The material object's density will not be updated to prevent unintentional "
"density changes across the model. Only custom materials may have a density "
"specified.".format(material),
single=True,
)
# specifically, non-Custom materials only use refDensity and dLL, mat.customDensity has no effect
return
Expand Down
Loading
Loading