Skip to content

Commit

Permalink
Adding impl/test crumbs for requirements (#1507)
Browse files Browse the repository at this point in the history
  • Loading branch information
john-science authored Nov 29, 2023
1 parent 0c4d5f4 commit 7de33eb
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 18 deletions.
11 changes: 10 additions & 1 deletion armi/physics/neutronics/energyGroups.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@


def getFastFluxGroupCutoff(eGrpStruc):
"""Given a constant "fast" energy threshold, return which ARMI energy group index contains this threshold."""
"""Given a constant "fast" energy threshold, return which ARMI energy group index contains this threshold.
.. impl:: Return the energy group index which contains a given energy threshold.
:id: I_ARMI_EG_FE
:implements: R_ARMI_EG_FE
"""
gThres = -1
for g, eV in enumerate(eGrpStruc):
if eV < FAST_FLUX_THRESHOLD_EV:
Expand Down Expand Up @@ -67,6 +72,10 @@ def getGroupStructure(name):
"""
Return descending neutron energy group upper bounds in eV for a given structure name.
.. impl:: Provide the neutron energy group bounds for a given group structure.
:id: I_ARMI_EG_NE
:implements: R_ARMI_EG_NE
Notes
-----
Copy of the group structure is return so that modifications of the energy bounds does
Expand Down
9 changes: 7 additions & 2 deletions armi/physics/neutronics/globalFlux/globalFluxInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,13 @@ def interactEOC(self, cycle=None):
* units.ABS_REACTIVITY_TO_PCM
)

def _checkEnergyBalance(self):
"""Check that there is energy balance between the power generated and the specified power is the system."""
def checkEnergyBalance(self):
"""Check that there is energy balance between the power generated and the specified power.
.. impl:: Validate the energy generate matches user specifications.
:id: I_ARMI_FLUX_CHECK_POWER
:implements: R_ARMI_FLUX_CHECK_POWER
"""
powerGenerated = (
self.r.core.calcTotalParam(
"power", calcBasedOnFullObj=False, generationNum=2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,7 @@ def test_getHistoryParams(self):
self.assertIn("detailedDpa", params)

def test_checkEnergyBalance(self):
"""
Test energy balance check.
"""Test energy balance check.
.. test:: Block-wise power is consistent with reactor data model power.
:id: T_ARMI_FLUX_CHECK_POWER
Expand All @@ -190,7 +189,7 @@ def test_checkEnergyBalance(self):
cs = settings.Settings()
_o, r = test_reactors.loadTestReactor()
gfi = MockGlobalFluxInterface(r, cs)
gfi._checkEnergyBalance()
gfi.checkEnergyBalance()


class TestGlobalFluxInterfaceWithExecuters(unittest.TestCase):
Expand Down
11 changes: 10 additions & 1 deletion armi/physics/neutronics/tests/test_energyGroups.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@

class TestEnergyGroups(unittest.TestCase):
def test_invalidGroupStructureType(self):
"""Test that the reverse lookup fails on non-existent energy group bounds."""
"""Test that the reverse lookup fails on non-existent energy group bounds.
.. test:: Check the neutron energy group bounds logic fails correctly for the wrong structure.
:id: T_ARMI_EG_NE0
:tests: R_ARMI_EG_NE
"""
modifier = 1e-5
for groupStructureType in energyGroups.GROUP_STRUCTURE:
energyBounds = energyGroups.getGroupStructure(groupStructureType)
Expand All @@ -32,6 +37,10 @@ def test_consistenciesBetweenGroupStructureAndGroupStructureType(self):
"""
Test that the reverse lookup of the energy group structures work.
.. test:: Check the neutron energy group bounds for a given group structure.
:id: T_ARMI_EG_NE1
:tests: R_ARMI_EG_NE
Notes
-----
Several group structures point to the same energy group structure so the reverse lookup will fail to
Expand Down
9 changes: 7 additions & 2 deletions armi/reactor/assemblies.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ def add(self, obj: blocks.Block):
.. impl:: Assemblies are made up of type Block.
:id: I_ARMI_ASSEM_BLOCKS
:implements: R_ARMI_ASSEM_BLOCKS
"""
composites.Composite.add(self, obj)
obj.spatialLocator = self.spatialGrid[0, 0, len(self) - 1]
Expand Down Expand Up @@ -227,7 +226,6 @@ def getLocation(self):
.. impl:: Assembly location is retrievable.
:id: I_ARMI_ASSEM_POSI0
:implements: R_ARMI_ASSEM_POSI
"""
# just use ring and position, not axial (which is 0)
if not self.parent:
Expand Down Expand Up @@ -1229,6 +1227,13 @@ def rotate(self, rad):


class HexAssembly(Assembly):
"""Placeholder, so users can explicitly define a hex-based assembly.
.. impl:: Assembly of hex blocks.
:id: I_ARMI_ASSEM_HEX
:implements: R_ARMI_ASSEM_HEX
"""

pass


Expand Down
4 changes: 4 additions & 0 deletions armi/reactor/blueprints/componentBlueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@ def insertDepletableNuclideKeys(c, blueprint):
"""
Auto update number density keys on all DEPLETABLE components.
.. impl:: Insert any depletable blueprint flags onto this component.
:id: I_ARMI_BP_NUC_FLAGS0
:implements: R_ARMI_BP_NUC_FLAGS
Notes
-----
This should be moved to a neutronics/depletion plugin hook but requires some
Expand Down
4 changes: 4 additions & 0 deletions armi/reactor/blueprints/isotopicOptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ class NuclideFlag(yamlize.Object):
physics option. However, restarting from that case with different
cross section needs is challenging.
.. impl:: The blueprint object that represents a nuclide flag.
:id: I_ARMI_BP_NUC_FLAGS1
:implements: R_ARMI_BP_NUC_FLAGS
Attributes
----------
nuclideName : str
Expand Down
2 changes: 1 addition & 1 deletion armi/reactor/blueprints/tests/test_blockBlueprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def test_explicitFlags(self):
Test flags are created from blueprint file.
.. test:: Nuc flags can define depletable objects.
:id: T_ARMI_BP_NUC_FLAGS
:id: T_ARMI_BP_NUC_FLAGS0
:tests: R_ARMI_BP_NUC_FLAGS
"""
a1 = self.blueprints.assemDesigns.bySpecifier["IC"].construct(
Expand Down
7 changes: 6 additions & 1 deletion armi/reactor/blueprints/tests/test_blueprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,12 @@ def test_componentDimensions(self):
self.assertAlmostEqual(fuel.getDimension("mult"), 169)

def test_traceNuclides(self):
"""Ensure that armi.reactor.blueprints.componentBlueprint.insertDepletableNuclideKeys runs."""
"""Ensure that armi.reactor.blueprints.componentBlueprint.insertDepletableNuclideKeys runs.
.. test:: Users marking components as depletable will affect number densities.
:id: T_ARMI_BP_NUC_FLAGS1
:tests: R_ARMI_BP_NUC_FLAGS
"""
fuel = (
self.blueprints.constructAssem(self.cs, "igniter fuel")
.getFirstBlock(Flags.FUEL)
Expand Down
4 changes: 4 additions & 0 deletions armi/reactor/converters/axialExpansionChanger.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ class AxialExpansionChanger:
:id: I_ARMI_AXIAL_EXP
:implements: R_ARMI_AXIAL_EXP
.. impl:: Preserve the total height of an ARMI assembly, during expansion.
:id: I_ARMI_ASSEM_HEIGHT_PRES
:implements: R_ARMI_ASSEM_HEIGHT_PRES
Attributes
----------
linked : :py:class:`AssemblyAxialLinkage`
Expand Down
10 changes: 7 additions & 3 deletions armi/reactor/converters/geometryConverters.py
Original file line number Diff line number Diff line change
Expand Up @@ -1194,11 +1194,15 @@ def reset(self):


class HexToRZConverter(HexToRZThetaConverter):
r"""
"""
Create a new reactor with R-Z coordinates from the Hexagonal-Z reactor.
This is a subclass of the HexToRZThetaConverter. See the HexToRZThetaConverter for explanation and setup of
the converterSettings.
This is a subclass of the HexToRZThetaConverter. See the HexToRZThetaConverter for
explanation and setup of the converterSettings.
.. impl:: Tool to convert a hex core to an RZTheta core.
:id: I_ARMI_CONV_3DHEX_TO_2DRZ
:implements: R_ARMI_CONV_3DHEX_TO_2DRZ
"""

_GEOMETRY_TYPE = geometry.GeomType.RZ
Expand Down
10 changes: 8 additions & 2 deletions armi/reactor/converters/tests/test_geometryConverters.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def setUp(self):
self.cs = self.o.cs

def test_addRing(self):
r"""Tests that the addRing method adds the correct number of fuel assemblies to the test reactor."""
"""Tests that the addRing method adds the correct number of fuel assemblies to the test reactor."""
converter = geometryConverters.FuelAssemNumModifier(self.cs)
converter.numFuelAssems = 7
converter.ringsToAdd = 1 * ["radial shield"]
Expand All @@ -65,7 +65,7 @@ def test_addRing(self):
) # should wind up with 11 reflector assemblies per 1/3rd core

def test_setNumberOfFuelAssems(self):
r"""Tests that the setNumberOfFuelAssems method properly changes the number of fuel assemblies."""
"""Tests that the setNumberOfFuelAssems method properly changes the number of fuel assemblies."""
# tests ability to add fuel assemblies
converter = geometryConverters.FuelAssemNumModifier(self.cs)
converter.numFuelAssems = 60
Expand Down Expand Up @@ -142,6 +142,12 @@ def tearDown(self):
del self.r

def test_convert(self):
"""Test the HexToRZConverter.
.. test:: Convert a 3D hex reactor core to an RZ-Theta core.
:id: T_ARMI_CONV_3DHEX_TO_2DRZ
:tests: R_ARMI_CONV_3DHEX_TO_2DRZ
"""
# make the reactor smaller, because of a test parallelization edge case
for ring in [9, 8, 7, 6, 5, 4, 3]:
self.r.core.removeAssembliesInRing(ring, self.o.cs)
Expand Down
4 changes: 2 additions & 2 deletions armi/reactor/grids/structuredgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,9 @@ def restoreBackup(self):
def getCoordinates(self, indices, nativeCoords=False) -> numpy.ndarray:
"""Return the coordinates of the center of the mesh cell at the given indices in cm.
.. test:: Get the coordinates from a location in a grid.
.. impl:: Get the coordinates from a location in a grid.
:id: I_ARMI_GRID_GLOBAL_POS
:tests: R_ARMI_GRID_GLOBAL_POS
:implements: R_ARMI_GRID_GLOBAL_POS
"""
indices = numpy.array(indices)
return self._evaluateMesh(
Expand Down

0 comments on commit 7de33eb

Please sign in to comment.