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

Fix application of custom isotopics to work with Fluid classes #2071

Merged
merged 6 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
33 changes: 21 additions & 12 deletions armi/reactor/blueprints/componentBlueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,20 +290,29 @@ def _setComponentCustomDensity(
"Cannot apply custom densities to materials without density."
)

# Apply a density scaling to account for the temperature change between Tinput
# Thot. There may be a better place in the initialization to determine
# if the block height will be interpreted as hot dimensions, which would
# allow us to not have to pass the case settings down this far
dLL = comp.material.linearExpansionFactor(
Tc=comp.temperatureInC, T0=comp.inputTemperatureInC
)
if inputHeightsConsideredHot:
f = 1.0 / (1 + dLL) ** 2
# Apply a density scaling to account for the temperature change between
# Tinput and Thot
if isinstance(mat, materials.Fluid):
densityRatio = densityFromCustomIsotopic / mat.density(
Tc=comp.inputTemperatureInC
)
else:
f = 1.0 / (1 + dLL) ** 3
# for solids we need to consider if the input heights are hot or
# cold, in order to get the density correct.
# There may be a better place in the initialization to determine
# if the block height will be interpreted as hot dimensions, which would
# allow us to not have to pass the case settings down this far
dLL = mat.linearExpansionFactor(
Tc=comp.temperatureInC, T0=comp.inputTemperatureInC
)
if inputHeightsConsideredHot:
f = 1.0 / (1 + dLL) ** 2
else:
f = 1.0 / (1 + dLL) ** 3

scaledDensity = comp.density() / f
densityRatio = densityFromCustomIsotopic / scaledDensity

scaledDensity = comp.density() / f
densityRatio = densityFromCustomIsotopic / scaledDensity
comp.changeNDensByFactor(densityRatio)

runLog.important(
Expand Down
55 changes: 55 additions & 0 deletions armi/reactor/blueprints/tests/test_customIsotopics.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import yamlize

from armi import runLog, settings
from armi.materials import Fluid, Sodium
from armi.physics.neutronics.settings import (
CONF_MCNP_LIB_BASE,
CONF_NEUTRONICS_KERNEL,
Expand All @@ -42,6 +43,7 @@ class TestCustomIsotopics(unittest.TestCase):
AL: {burn: false, xs: true}
FE: {burn: false, xs: true}
C: {burn: false, xs: true}
NA: {burn: false, xs: true}
DUMP2: {burn: true, xs: true}
DUMP1: {burn: true, xs: true}
LFP35: {burn: true, xs: true}
Expand Down Expand Up @@ -118,6 +120,11 @@ class TestCustomIsotopics(unittest.TestCase):
C: 0.3
density: 7.0

sodium custom isotopics:
input format: mass fractions
NA: 1
density: 666

"""

yamlGoodBlocks = r"""
Expand All @@ -141,6 +148,25 @@ class TestCustomIsotopics(unittest.TestCase):
mult: 1.0
od: 10.0

sodium1:
shape: Circle
material: Sodium
Tinput: 25
Thot: 600
id: 0
mult: 1
od: 1

sodium2:
shape: Circle
material: Sodium
isotopics: sodium custom isotopics
Tinput: 25
Thot: 600
id: 0
mult: 1
od: 1

uranium fuel from isotopic mass fractions : &block_1
fuel:
<<: *basic_fuel
Expand Down Expand Up @@ -381,6 +407,35 @@ def test_densitiesAppliedToNonCustomMaterials(self):
self.assertEqual(fuel6.material.name, fuel0.material.name)
self.assertEqual("UZr", fuel0.material.name)

def test_densitiesAppliedToNonCustomMaterialsFluid(self):
"""
Ensure that a density can be set in custom isotopics for components using library materials,
specifically in the case of a fluid component. In this case, inputHeightsConsideredHot
does not matter, and the material has a zero dLL value.
"""
# The template block
sodium1 = self.a[0].getComponentByName("sodium1")
sodium2 = self.a[0].getComponentByName("sodium2")

self.assertEqual(sodium1.material.name, "Sodium")
self.assertEqual(sodium2.material.name, "Sodium")
self.assertTrue(isinstance(sodium1.material, Fluid))
self.assertTrue(isinstance(sodium2.material, Fluid))
self.assertEqual(sodium1.p.customIsotopicsName, "")
self.assertEqual(sodium2.p.customIsotopicsName, "sodium custom isotopics")

# show that, even though the two components have the same material class
# and the same temperatures, their densities are different
self.assertNotEqual(sodium1.density(), sodium2.density())

# show that sodium1 has a density from the material class, while sodium2
# has a density from the blueprint and adjusted from Tinput -> Thot
s = Sodium()
self.assertAlmostEqual(sodium1.density(), s.density(Tc=600))
self.assertAlmostEqual(
sodium2.density(), s.density(Tc=600) * (666 / s.density(Tc=25))
)

def test_customDensityLogsAndErrors(self):
"""Test that the right warning messages and errors are emitted when applying custom densities."""
# Check for warnings when specifying both TD_frac and custom isotopics
Expand Down
7 changes: 6 additions & 1 deletion armi/reactor/blueprints/tests/test_reactorBlueprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,12 @@ def test_construct(self):

def test_materialDataSummary(self):
"""Test that the material data summary for the core is valid as a printout to the stdout."""
expectedMaterialData = [("Custom", "ARMI"), ("HT9", "ARMI"), ("UZr", "ARMI")]
expectedMaterialData = [
("Custom", "ARMI"),
("HT9", "ARMI"),
("Sodium", "ARMI"),
("UZr", "ARMI"),
]
core, _sfp, _evst = self._setupReactor()
materialData = reactorBlueprint.summarizeMaterialData(core)
for actual, expected in zip(materialData, expectedMaterialData):
Expand Down
1 change: 1 addition & 0 deletions doc/release/0.5.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Bug Fixes
---------
#. Fixing check for jagged arrays during ``_writeParams``. (`PR#2051 <https://github.com/terrapower/armi/pull/2051>`_)
#. Fixing BP-section ignoring tool in ``PassiveDBLoadPlugin``. (`PR#2055 <https://github.com/terrapower/armi/pull/2055>`_)
#. Fixing number densities when custom isotopics are combined with Fluid components. (`PR#2071 <https://github.com/terrapower/armi/pull/2071>`_)
#. Fixing scaling of volume-integrated parameters on edge assemblies. (`PR#2060 <https://github.com/terrapower/armi/pull/2060>`_)
#. Fixing strictness of ``HexGrid`` rough equality check. (`PR#2058 <https://github.com/terrapower/armi/pull/2058>`_)
#. TBD
Expand Down