Skip to content

Commit

Permalink
Checks on class1/class2 material modifications (terrapower#524)
Browse files Browse the repository at this point in the history
  • Loading branch information
keckler authored and scottyak committed Oct 27, 2022
1 parent f1b696b commit 74d0efe
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 5 deletions.
30 changes: 26 additions & 4 deletions armi/materials/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,11 +704,33 @@ def applyInputParams(
kinds of parameters to coolants and structural material, which are often
not parameterized with any kind of enrichment.
"""
# Save class data for future reconstructions (e.g. in closed cycles)
self.p.class1_wt_frac = class1_wt_frac
self.p.class1_custom_isotopics = class1_custom_isotopics
self.p.class2_custom_isotopics = class2_custom_isotopics
if class1_wt_frac:
if not 0 <= class1_wt_frac <= 1:
raise ValueError(
"class1_wt_frac must be between 0 and 1 (inclusive)."
f" Right now it is {class1_wt_frac}."
)

validIsotopics = customIsotopics.keys()
errMsg = "{} '{}' not found in the defined custom isotopics."
if class1_custom_isotopics not in validIsotopics:
raise KeyError(
errMsg.format("class1_custom_isotopics", class1_custom_isotopics)
)
if class2_custom_isotopics not in validIsotopics:
raise KeyError(
errMsg.format("class2_custom_isotopics", class2_custom_isotopics)
)
if class1_custom_isotopics == class2_custom_isotopics:
runLog.warning(
"The custom isotopics specified for the class1/class2 materials"
f" are both '{class1_custom_isotopics}'. You are not actually blending anything!"
)

self.p.class1_wt_frac = class1_wt_frac
self.p.class1_custom_isotopics = class1_custom_isotopics
self.p.class2_custom_isotopics = class2_custom_isotopics

self._applyIsotopicsMixFromCustomIsotopicsInput(customIsotopics)

def _applyIsotopicsMixFromCustomIsotopicsInput(self, customIsotopics):
Expand Down
86 changes: 85 additions & 1 deletion armi/materials/tests/test_materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@

from numpy import testing

from armi import materials
from armi import materials, settings
from armi.utils import units
from armi.nucDirectory import nuclideBases
from armi.reactor import blueprints


class _Material_Test:
Expand Down Expand Up @@ -1145,5 +1146,88 @@ def test02_linearExpansionPercent(self):
self.assertAlmostEqual(cur, ref, delta=10e-3, msg=errorMsg)


class FuelMaterial_TestCase(unittest.TestCase):
baseInput = r"""
nuclide flags:
U: {burn: false, xs: true}
ZR: {burn: false, xs: true}
custom isotopics:
customIsotopic1:
input format: mass fractions
density: 1
U: 1
customIsotopic2:
input format: mass fractions
density: 1
ZR: 1
blocks:
fuel: &block_fuel
fuel1: &component_fuel_fuel1
shape: Hexagon
material: UZr
Tinput: 600.0
Thot: 600.0
ip: 0.0
mult: 1
op: 10.0
fuel2: &component_fuel_fuel2
shape: Hexagon
material: UZr
Tinput: 600.0
Thot: 600.0
ip: 0.0
mult: 1
op: 10.0
assemblies:
fuel a: &assembly_a
specifier: IC
blocks: [*block_fuel]
height: [1.0]
axial mesh points: [1]
xs types: [A]
"""

def loadAssembly(self, materialModifications):
yamlString = self.baseInput + "\n" + materialModifications
design = blueprints.Blueprints.load(yamlString)
design._prepConstruction(settings.getMasterCs())
return design.assemblies["fuel a"]

def test_class1Class2_class1_wt_frac(self):
# should error because class1_wt_frac not in (0,1)
with self.assertRaises(ValueError):
a = self.loadAssembly(
"""
material modifications:
class1_wt_frac: [2.0]
class1_custom_isotopics: [customIsotopic1]
class2_custom_isotopics: [customIsotopic2]
"""
)

def test_class1Class2_classX_custom_isotopics(self):
# should error because class1_custom_isotopics doesn't exist
with self.assertRaises(KeyError):
a = self.loadAssembly(
"""
material modifications:
class1_wt_frac: [0.5]
class1_custom_isotopics: [fakeIsotopic]
class2_custom_isotopics: [customIsotopic2]
"""
)

# should error because class2_custom_isotopics doesn't exist
with self.assertRaises(KeyError):
a = self.loadAssembly(
"""
material modifications:
class1_wt_frac: [0.5]
class1_custom_isotopics: [customIsotopic1]
class2_custom_isotopics: [fakeIsotopic]
"""
)


if __name__ == "__main__":
unittest.main()

0 comments on commit 74d0efe

Please sign in to comment.