Skip to content

Commit

Permalink
Adding setting to control MCNP / ENDF library (#1989)
Browse files Browse the repository at this point in the history
  • Loading branch information
john-science authored Nov 26, 2024
1 parent 9ce112f commit 1c8b1d0
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 18 deletions.
8 changes: 8 additions & 0 deletions armi/physics/neutronics/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
CONF_INNERS_ = "inners"
CONF_LOADING_FILE = "loadingFile"
CONF_NEUTRONICS_KERNEL = "neutronicsKernel"
CONF_MCNP_LIB_BASE = "mcnpLibraryVersion"
CONF_NEUTRONICS_TYPE = "neutronicsType"
CONF_NUMBER_MESH_PER_EDGE = "numberMeshPerEdge"
CONF_OUTERS_ = "outers"
Expand Down Expand Up @@ -172,6 +173,13 @@ def defineSettings():
options=[],
enforcedOptions=True,
),
setting.Setting(
CONF_MCNP_LIB_BASE,
default="ENDF/B-VII.1",
description="Library name for MCNP cross sections. ENDF/B-VII.1 is the default library.",
label="ENDF data library version to use for MCNP Analysis",
options=["ENDF/B-V.0", "ENDF/B-VII.0", "ENDF/B-VII.1", "ENDF/B-VIII.0"],
),
setting.Setting(
CONF_NEUTRONICS_TYPE,
default="real",
Expand Down
12 changes: 6 additions & 6 deletions armi/reactor/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1992,12 +1992,12 @@ def setPinPowers(self, powers, powerKeySuffix=""):

def rotate(self, rad: float):
"""
Rotates a block's spatially-varying parameters by a specified angle in the counter-clockwise
Rotates a block's spatially varying parameters by a specified angle in the counter-clockwise
direction.
The parameters must have a ParamLocation of either CORNERS or EDGES and must be a list of
length 6 in order to be eligible for rotation; all parameters that do not meet these two
criteria are not rotated.
The parameters must have a ParamLocation of either CORNERS or EDGES and must be a Python
list of length 6 in order to be eligible for rotation; all parameters that do not meet these
two criteria are not rotated.
.. impl:: Rotating a hex block updates parameters on the boundary, the orientation
parameter, and the spatial coordinates on contained objects.
Expand All @@ -2006,9 +2006,9 @@ def rotate(self, rad: float):
Parameters
----------
rad: float
rad: float, required
Angle of counter-clockwise rotation in units of radians. Rotations must be in 60-degree
increments (i.e., PI/6, PI/3, PI, 2 * PI/3, 5 * PI/6, and 2 * PI).
increments (i.e., PI/6, PI/3, PI, 2 * PI/3, 5 * PI/6, and 2 * PI)
"""
rotNum = round((rad % (2 * math.pi)) / math.radians(60))
self._rotateChildLocations(rad, rotNum)
Expand Down
23 changes: 12 additions & 11 deletions armi/reactor/blueprints/isotopicOptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
CONF_FISSION_PRODUCT_LIBRARY_NAME,
)
from armi.physics.neutronics.settings import (
CONF_MCNP_LIB_BASE,
CONF_NEUTRONICS_KERNEL,
CONF_XS_KERNEL,
)
Expand Down Expand Up @@ -456,7 +457,6 @@ def getDefaultNuclideFlags():
We will include B10 and B11 without depletion, sodium, and structural elements.
We will include LFPs with depletion.
"""
nuclideFlags = {}
actinides = {
Expand Down Expand Up @@ -511,7 +511,6 @@ def eleExpandInfoBasedOnCodeENDF(cs):
For example: {oxygen: [oxygen16]} indicates that all
oxygen should be expanded to O16, ignoring natural
O17 and O18. (variables are Natural/NuclideBases)
"""
elementalsToKeep = set()
oxygenElementals = [nuclideBases.byName["O"]]
Expand All @@ -536,20 +535,22 @@ def eleExpandInfoBasedOnCodeENDF(cs):

if "MCNP" in cs[CONF_NEUTRONICS_KERNEL]:
expansionStrings.update(mcnpExpansions)
if int(cs["mcnpLibrary"]) == 50:
if cs[CONF_MCNP_LIB_BASE] == "ENDF/B-V.0":
# ENDF/B V.0
elementalsToKeep.update(nuclideBases.instances) # skip expansion
# ENDF/B VII.0
elif 70 <= int(cs["mcnpLibrary"]) <= 79:
elif cs[CONF_MCNP_LIB_BASE] == "ENDF/B-VII.0":
# ENDF/B VII.0
elementalsToKeep.update(endf70Elementals)
# ENDF/B VII.1
elif 80 <= int(cs["mcnpLibrary"]) <= 89:
elif cs[CONF_MCNP_LIB_BASE] == "ENDF/B-VII.1":
# ENDF/B VII.1
elementalsToKeep.update(endf71Elementals)
elif cs[CONF_MCNP_LIB_BASE] == "ENDF/B-VIII.0":
# ENDF/B VIII.0
elementalsToKeep.update(endf80Elementals)
else:
raise InputError(
"Failed to determine nuclides for modeling. "
"The `mcnpLibrary` setting value ({}) is not supported.".format(
cs["mcnpLibrary"]
)
"Failed to determine nuclides for modeling. The `mcnpLibraryVersion` "
f"setting value ({cs[CONF_MCNP_LIB_BASE]}) is not supported."
)

elif cs[CONF_XS_KERNEL] == "SERPENT":
Expand Down
60 changes: 59 additions & 1 deletion armi/reactor/blueprints/tests/test_customIsotopics.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@

import yamlize

from armi import runLog
from armi import settings
from armi.physics.neutronics.settings import CONF_MCNP_LIB_BASE
from armi.physics.neutronics.settings import CONF_NEUTRONICS_KERNEL
from armi.physics.neutronics.settings import CONF_XS_KERNEL
from armi.reactor import blueprints
from armi.reactor.blueprints import isotopicOptions
from armi.reactor.flags import Flags
from armi import runLog
from armi.tests import mockRunLogs
from armi.utils.customExceptions import InputError
from armi.utils.directoryChangers import TemporaryDirectoryChanger


class TestCustomIsotopics(unittest.TestCase):
Expand Down Expand Up @@ -529,6 +533,8 @@ class TestNuclideFlagsExpansion(unittest.TestCase):
SI: {burn: true, xs: true}
MO: {burn: true, xs: true}
W: {burn: true, xs: true}
ZN: {burn: true, xs: true}
O: {burn: true, xs: true}
blocks:
uzr fuel: &block_0
fuel:
Expand All @@ -546,6 +552,14 @@ class TestNuclideFlagsExpansion(unittest.TestCase):
id: 0.0
mult: 1.0
od: 10.0
dummy:
shape: Circle
material: ZnO
Tinput: 25.0
Thot: 600.0
id: 0.0
mult: 1.0
od: 10.0
assemblies:
fuel a:
specifier: IC
Expand All @@ -568,3 +582,47 @@ def test_expandedNatural(self):
self.assertNotIn("FE56", nd) # natural isotopic not requested
self.assertNotIn("FE51", nd) # un-natural
self.assertNotIn("FE", nd)

def test_eleExpandInfoBasedOnCodeENDF(self):
with TemporaryDirectoryChanger():
# Reference elements to expand by library
ref_E70_elem = ["C", "V", "ZN"]
ref_E71_elem = ["C"]
ref_E80_elem = []

# Load settings and set neutronics kernel to MCNP
cs = settings.Settings()
cs = cs.modified(newSettings={CONF_NEUTRONICS_KERNEL: "MCNP"})

# Set ENDF/B-VII.0 as MCNP cross section library base
cs = cs.modified(newSettings={CONF_MCNP_LIB_BASE: "ENDF/B-VII.0"})
eleToKeep, expansions = isotopicOptions.eleExpandInfoBasedOnCodeENDF(cs)
E70_elem = [x.label for x in eleToKeep]

# Set ENDF/B-VII.1 as MCNP cross section library base
cs = cs.modified(newSettings={CONF_MCNP_LIB_BASE: "ENDF/B-VII.1"})
eleToKeep, expansions = isotopicOptions.eleExpandInfoBasedOnCodeENDF(cs)
E71_elem = [x.label for x in eleToKeep]

# Set ENDF/B-VIII.0 as MCNP cross section library base
cs = cs.modified(newSettings={CONF_MCNP_LIB_BASE: "ENDF/B-VIII.0"})
eleToKeep, expansions = isotopicOptions.eleExpandInfoBasedOnCodeENDF(cs)
E80_elem = [x.label for x in eleToKeep]

# Assert equality of returned elements to reference elements
self.assertEqual(sorted(E70_elem), sorted(ref_E70_elem))
self.assertEqual(sorted(E71_elem), sorted(ref_E71_elem))
self.assertEqual(sorted(E80_elem), sorted(ref_E80_elem))

# Disallowed inputs
not_allowed = ["ENDF/B-VIIII.0", "ENDF/B-VI.0", "JEFF-3.3"]
# Assert raise InputError in case of invalid library setting
for x in not_allowed:
with self.assertRaises(InputError) as context:
cs = cs.modified(newSettings={CONF_MCNP_LIB_BASE: x})
_ = isotopicOptions.eleExpandInfoBasedOnCodeENDF(cs)

self.assertTrue(
"Failed to determine nuclides for modeling"
in str(context.exception)
)
1 change: 1 addition & 0 deletions doc/release/0.5.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ New Features
#. Adding data models for ex-core structures in ARMI. (`PR#1891 <https://github.com/terrapower/armi/pull/1891>`_)
#. Opening some DBs without the ``App`` that created them. (`PR#1917 <https://github.com/terrapower/armi/pull/1917>`_)
#. Adding support for ENDF/B-VII.1-based MC2-3 libraries. (`PR#1982 <https://github.com/terrapower/armi/pull/1982>`_)
#. Adding setting ``mcnpLibraryVersion`` to chosen ENDF library for MCNP. (`PR#1989 <https://github.com/terrapower/armi/pull/1989>`_)
#. Removing the ``tabulate`` dependency by ingesting it to ``armi.utils.tabulate``. (`PR#1811 <https://github.com/terrapower/armi/pull/1811>`_)
#. ``HexBlock.rotate`` updates the spatial locator for children of that block. (`PR#1943 <https://github.com/terrapower/armi/pull/1943>`_)
#. Provide ``Block.getInputHeight`` for determining the height of a block from blueprints. (`PR#1927 <https://github.com/terrapower/armi/pull/1927>`_)
Expand Down

0 comments on commit 1c8b1d0

Please sign in to comment.