Skip to content

Commit

Permalink
Skip auto DEPLETABLE if flags set explicitly on Component blueprint
Browse files Browse the repository at this point in the history
  • Loading branch information
youngmit committed May 8, 2020
1 parent 10deedc commit b0368f5
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 9 deletions.
9 changes: 8 additions & 1 deletion armi/reactor/blueprints/componentBlueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,16 @@ def construct(self, blueprint, matMods):
runLog.debug("Constructing component {}".format(self.name))
kwargs = self._conformKwargs(blueprint, matMods)
component = components.factory(self.shape.strip().lower(), [], kwargs)

# the component __init__ calls setType(), which gives us our initial guess at
# what the flags should be.
if self.flags is not None:
# override the flags from __init__ with the ones from the blueprint
component.p.flags = Flags.fromString(self.flags)
_insertDepletableNuclideKeys(component, blueprint)
else:
# potentially add the DEPLETABLE flag. Don't do this if we set flags
# explicitly
_insertDepletableNuclideKeys(component, blueprint)
return component

def _conformKwargs(self, blueprint, matMods):
Expand Down
66 changes: 58 additions & 8 deletions armi/reactor/blueprints/tests/test_componentBlueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class TestComponentBlueprint(unittest.TestCase):
blocks:
block: &block
component:
flags: fuel test
flags: {flags}
shape: Hexagon
material: {material} # This is being used to format a string to allow for different materials to be added
{isotopics} # This is being used to format a string to allow for different isotopics to be added
Expand Down Expand Up @@ -71,7 +71,7 @@ def test_componentInitializationIncompleteBurnChain(self):
)
bp = blueprints.Blueprints.load(
nuclideFlagsFuelWithBurn
+ self.componentString.format(material="UZr", isotopics="")
+ self.componentString.format(material="UZr", isotopics="", flags="")
)
cs = settings.Settings()
with self.assertRaises(ValueError):
Expand Down Expand Up @@ -101,7 +101,38 @@ def test_componentInitializationControlCustomIsotopics(self):
)
bp = blueprints.Blueprints.load(
nuclideFlags
+ self.componentString.format(material="Custom", isotopics="isotopics: B4C")
+ self.componentString.format(material="Custom", isotopics="isotopics: B4C",
flags="")
)
cs = settings.Settings()
a = bp.constructAssem("hex", cs, "assembly")

def test_autoDepletable(self):
nuclideFlags = (
inspect.cleandoc(
r"""
nuclide flags:
U234: {burn: true, xs: true}
U235: {burn: true, xs: true}
U238: {burn: true, xs: true}
B10: {burn: true, xs: true}
B11: {burn: true, xs: true}
C: {burn: true, xs: true}
DUMP1: {burn: true, xs: true}
custom isotopics:
B4C:
input format: number densities
B10: 1.0
B11: 1.0
C: 1.0
"""
)
+ "\n"
)
bp = blueprints.Blueprints.load(
nuclideFlags
+ self.componentString.format(material="Custom", isotopics="isotopics: B4C",
flags="")
)
cs = settings.Settings()
a = bp.constructAssem("hex", cs, "assembly")
Expand All @@ -113,8 +144,26 @@ def test_componentInitializationControlCustomIsotopics(self):
self.assertNotIn(nuc, a[0][0].getNuclides())

c = a[0][0]
# Watch out, depletion is adding DEPLETABLE, so this can be a bit brittle
self.assertEqual(c.p.flags, Flags.FUEL|Flags.DEPLETABLE|Flags.TEST)

# Since we didn't supply flags, we should get the DEPLETABLE flag added
# automatically, since this one has depletable nuclides
self.assertEqual(c.p.flags, Flags.DEPLETABLE)
# More robust test, but worse unittest.py output when it fails
self.assertTrue(c.hasFlags(Flags.DEPLETABLE))


# repeat the process with some flags set explicitly
bp = blueprints.Blueprints.load(
nuclideFlags
+ self.componentString.format(material="Custom", isotopics="isotopics: B4C",
flags="fuel test")
)
cs = settings.Settings()
a = bp.constructAssem("hex", cs, "assembly")
c = a[0][0]

# Since we supplied flags, we should NOT get the DEPLETABLE flag added
self.assertEqual(c.p.flags, Flags.FUEL|Flags.TEST)
# More robust test, but worse unittest.py output when it fails
self.assertTrue(c.hasFlags(Flags.FUEL|Flags.TEST))

Expand Down Expand Up @@ -169,7 +218,8 @@ def test_componentInitializationAmericiumCustomIsotopics(self):
)
bp = blueprints.Blueprints.load(
nuclideFlags
+ self.componentString.format(material="Custom", isotopics="isotopics: AM")
+ self.componentString.format(material="Custom", isotopics="isotopics: AM",
flags="")
)
cs = settings.Settings()
a = bp.constructAssem("hex", cs, "assembly")
Expand Down Expand Up @@ -259,7 +309,7 @@ def test_componentInitializationThoriumBurnCustomIsotopics(self):
bp = blueprints.Blueprints.load(
nuclideFlags
+ self.componentString.format(
material="Custom", isotopics="isotopics: Thorium"
material="Custom", isotopics="isotopics: Thorium", flags=""
)
)
cs = settings.Settings()
Expand All @@ -285,7 +335,7 @@ def test_componentInitializationThoriumNoBurnCustomIsotopics(self):
bp = blueprints.Blueprints.load(
nuclideFlags
+ self.componentString.format(
material="Custom", isotopics="isotopics: Thorium"
material="Custom", isotopics="isotopics: Thorium", flags=""
)
)
cs = settings.Settings()
Expand Down

0 comments on commit b0368f5

Please sign in to comment.