Skip to content

Commit

Permalink
Tracking ARMI Requirements (#590)
Browse files Browse the repository at this point in the history
  • Loading branch information
john-science committed Mar 7, 2022
1 parent 035711a commit 6dcedac
Show file tree
Hide file tree
Showing 31 changed files with 420 additions and 186 deletions.
5 changes: 2 additions & 3 deletions armi/bookkeeping/report/reportingUtils.py
Expand Up @@ -383,7 +383,7 @@ def writeCycleSummary(core):
core: armi.reactor.reactors.Core
cs: armi.settings.caseSettings.Settings
"""
## would io be worth considering for this?
# would io be worth considering for this?
cycle = core.r.p.cycle
str_ = []
runLog.important("Cycle {0} Summary:".format(cycle))
Expand Down Expand Up @@ -583,7 +583,7 @@ def summarizePower(core):

# calculate total power
tot = sum(sums.values()) or float("inf")
## NOTE: if tot is 0.0, set to infinity to prevent ZeroDivisionError
# NOTE: if tot is 0.0, set to infinity to prevent ZeroDivisionError

runLog.important("Power summary")
for atype, val in sums.items():
Expand Down Expand Up @@ -870,7 +870,6 @@ def _setGeneralSimulationData(core, cs, coreDesignTable):
)


## Block Design Report
def makeBlockDesignReport(r):
r"""Summarize the block designs from the loading file
Expand Down
5 changes: 1 addition & 4 deletions armi/bookkeeping/report/tests/test_report.py
Expand Up @@ -61,10 +61,7 @@ def test_setData(self):
self.assertEqual(filled_instance["banana_3"], ["sundae", "chocolate"])

def test_printReports(self):
"""testing testing
:ref:`REQ86d884bb-6133-4078-8804-5a334c935338`
"""
"""testing printReports method"""
repInt = reportInterface.ReportInterface(None, None)
rep = repInt.printReports()

Expand Down
16 changes: 13 additions & 3 deletions armi/cases/tests/test_suiteBuilder.py
Expand Up @@ -15,13 +15,23 @@
"""
Unit tests for the SuiteBuilder
"""
import os
import unittest
from armi.cases.inputModifiers.inputModifiers import SamplingInputModifier

from armi import cases, settings
from armi.cases.inputModifiers.inputModifiers import SamplingInputModifier
from armi.cases.suiteBuilder import LatinHyperCubeSuiteBuilder


cs = settings.Settings("armi/tests/tutorials/anl-afci-177.yaml")
cs = settings.Settings(
os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"..",
"..",
"tests",
"tutorials",
"anl-afci-177.yaml",
)
)
case = cases.Case(cs)


Expand Down
10 changes: 5 additions & 5 deletions armi/cli/__init__.py
Expand Up @@ -156,18 +156,18 @@ def listCommands(self):

sub = re.compile(r"\s+").sub

## given a string, condense white space into a single space
# given a string, condense white space into a single space
condense = lambda s: sub(" ", s.strip())

commands = self._entryPoints.values()

formatter = "{name:<{width}}{desc}".format
print("\ncommands:")
for cmd in sorted(commands, key=lambda cmd: cmd.name):
## Each command can optionally define a class attribute `description`
## as documentation. If description is not defined (default=None since
## it should inherit from EntryPoint), then the docstring is used.
## If the docstring is also None, then fall back to an empty string.
"""Each command can optionally define a class attribute `description`
as documentation. If description is not defined (default=None since
it should inherit from EntryPoint), then the docstring is used.
If the docstring is also None, then fall back to an empty string."""
desc = condense(cmd.description or cmd.__doc__ or "")
print(wrapper.fill(formatter(width=indent, name=cmd.name, desc=desc)))

Expand Down
6 changes: 0 additions & 6 deletions armi/nuclearDataIO/cccc/tests/test_nhflux.py
Expand Up @@ -96,8 +96,6 @@ def test_fluxMoments(self):
The 5 flux moments values are manually verified for two nodes. The indices
are converted to zero based from the original by subtracting one.
:req:`REQ77f06870-5923-429c-b3c7-d42f5a24f404`
"""
# node 1 (ring=1, position=1), axial=3, group=2
i = 0 # first one in node map (ring=1, position=1)
Expand Down Expand Up @@ -131,8 +129,6 @@ def test_xyPartialCurrents(self):
The surface partial currents can be used to reconstruct the surface
flux and corner flux values. This test shows that the outgoing current
in one hex is identical to the incoming current in the adjacent hex.
:req:`REQ77f06870-5923-429c-b3c7-d42f5a24f404`
"""
# node 2 (ring=3, position=1), axial=4, group=2, surface=4, outgoing
iNode, iSurf, iz, ig = 1, 3, 3, 1 # zero based
Expand All @@ -154,8 +150,6 @@ def test_zPartialCurrents(self):
The Z-directed partial currents are manually checked for one node
surface.
:req:`REQ77f06870-5923-429c-b3c7-d42f5a24f404`
"""
# node 15 (ring=2, position=3), axial=3, group=3, j=1 (z-plus)
iNode, iz, ig, j = 14, 2, 2, 0
Expand Down
18 changes: 11 additions & 7 deletions armi/operators/operator.py
Expand Up @@ -21,6 +21,10 @@
This is analogous to a real reactor operating over some period of time,
often from initial startup, through the various cycles, and out to
the end of plant life.
.. impl:: ARMI controls the time flow of the reactor, by running a sequence of Interfaces at each time step.
:id: IMPL_EVOLVING_STATE_0
:links: REQ_EVOLVING_STATE
"""
import time
import shutil
Expand All @@ -29,16 +33,16 @@

import armi
from armi import context
from armi import interfaces
from armi import runLog
from armi.bookkeeping import memoryProfiler
from armi.utils.mathematics import expandRepeatedFloats
from armi.utils import codeTiming
from armi.utils import pathTools
from armi import settings
from armi.bookkeeping import memoryProfiler
from armi.bookkeeping.report import reportingUtils
from armi.operators import settingsValidation
from armi.operators.runTypes import RunTypes
from armi import interfaces
from armi.bookkeeping.report import reportingUtils
from armi.utils import codeTiming
from armi.utils import pathTools
from armi.utils.mathematics import expandRepeatedFloats


class Operator: # pylint: disable=too-many-public-methods
Expand Down Expand Up @@ -419,7 +423,7 @@ def _checkCsConsistency(self):

def interactAllInit(self):
"""Call interactInit on all interfaces in the stack after they are initialized."""
allInterfaces = self.interfaces[:] ## copy just in case
allInterfaces = self.interfaces[:] # copy just in case
self._interactAll("Init", allInterfaces)

def interactAllBOL(self, excludedInterfaceNames=()):
Expand Down
1 change: 1 addition & 0 deletions armi/operators/tests/test_operators.py
Expand Up @@ -40,6 +40,7 @@ class InterfaceC(Interface):
name = "Third"


# TODO: Add a test that shows time evolution of Reactor (REQ_EVOLVING_STATE)
class OperatorTests(unittest.TestCase):
def test_addInterfaceSubclassCollision(self):
self.cs = settings.Settings()
Expand Down
2 changes: 1 addition & 1 deletion armi/physics/neutronics/settings.py
Expand Up @@ -342,7 +342,7 @@ def defineSettings():
return settings


## OLD STYLE settings rules from settingsRules.py. Prefer validators moving forward.
# OLD STYLE settings rules from settingsRules.py. Prefer validators moving forward.


@include_as_rule("genXS")
Expand Down
8 changes: 7 additions & 1 deletion armi/reactor/blueprints/__init__.py
Expand Up @@ -173,7 +173,13 @@ def __new__(mcs, name, bases, attrs):


class Blueprints(yamlize.Object, metaclass=_BlueprintsPluginCollector):
"""Base Blueprintsobject representing all the subsections in the input file."""
"""
Base Blueprintsobject representing all the subsections in the input file.
.. impl:: ARMI represents a user-specified reactor by providing a "Blueprint" YAML interface.
:id: IMPL_REACTOR_0
:links: REQ_REACTOR
"""

nuclideFlags = yamlize.Attribute(
key="nuclide flags", type=isotopicOptions.NuclideFlags, default=None
Expand Down
39 changes: 23 additions & 16 deletions armi/reactor/blueprints/tests/test_blueprints.py
Expand Up @@ -45,7 +45,6 @@ class TestBlueprints(unittest.TestCase):
TODO: see the above note, and try to test blueprints on a wider range of input
files, touching on each failure case.
"""

@classmethod
Expand All @@ -65,7 +64,12 @@ def tearDownClass(cls):
cls.directoryChanger.close()

def test_nuclides(self):
"""Tests the available sets of nuclides work as expected"""
"""Tests the available sets of nuclides work as expected
.. test:: Tests that users can define their nuclides of interest.
:id: TEST_REACTOR_0
:links: REQ_REACTOR
"""
actives = set(self.blueprints.activeNuclides)
inerts = set(self.blueprints.inertNuclides)
self.assertEqual(
Expand All @@ -87,6 +91,12 @@ def test_specialIsotopicVectors(self):
self.assertAlmostEqual(mox["PU239"], 0.00286038)

def test_componentDimensions(self):
"""Tests that the user can specifiy the dimensions of a component with arbitray fidelity.
.. test:: Tests that the user can specify the dimensions of a component with arbitrary fidelity.
:id: TEST_REACTOR_1
:links: REQ_REACTOR
"""
fuelAssem = self.blueprints.constructAssem(self.cs, name="igniter fuel")
fuel = fuelAssem.getComponents(Flags.FUEL)[0]
self.assertAlmostEqual(fuel.getDimension("od", cold=True), 0.86602)
Expand All @@ -109,7 +119,7 @@ def test_traceNuclides(self):
class TestBlueprintsSchema(unittest.TestCase):
"""Test the blueprint schema checks"""

yamlString = r"""blocks:
_yamlString = r"""blocks:
fuel: &block_fuel
fuel: &component_fuel_fuel
shape: Hexagon
Expand All @@ -120,17 +130,17 @@ class TestBlueprintsSchema(unittest.TestCase):
mult: 1.0
op: 10.0
fuel2: &block_fuel2
group1:
group1:
shape: Group
duct:
duct:
shape: Hexagon
material: UZr
Tinput: 25.0
Thot: 600.0
ip: 9.0
mult: 1.0
op: 10.0
matrix:
matrix:
shape: DerivedShape
material: Graphite
Tinput: 25.0
Expand Down Expand Up @@ -191,7 +201,7 @@ class TestBlueprintsSchema(unittest.TestCase):

def test_assemblyParameters(self):
cs = settings.Settings()
design = blueprints.Blueprints.load(self.yamlString)
design = blueprints.Blueprints.load(self._yamlString)
fa = design.constructAssem(cs, name="fuel a")
fb = design.constructAssem(cs, name="fuel b")
for paramDef in fa.p.paramDefs.inCategory(
Expand All @@ -211,12 +221,12 @@ def test_assemblyParameters(self):
self.assertEqual(fb.p.hotChannelFactors, "Reactor")

def test_nuclidesMc2v2(self):
"""Tests that ZR is not expanded to its isotopics for this setting.."""
"""Tests that ZR is not expanded to its isotopics for this setting."""
cs = settings.Settings()
newSettings = {"xsKernel": "MC2v2"}
cs = cs.modified(newSettings=newSettings)

design = blueprints.Blueprints.load(self.yamlString)
design = blueprints.Blueprints.load(self._yamlString)
design._prepConstruction(cs)
self.assertTrue(
set({"U238", "U235", "ZR"}).issubset(set(design.allNuclidesInProblem))
Expand All @@ -233,7 +243,7 @@ def test_nuclidesMc2v3(self):
newSettings = {"xsKernel": "MC2v3"}
cs = cs.modified(newSettings=newSettings)

design = blueprints.Blueprints.load(self.yamlString)
design = blueprints.Blueprints.load(self._yamlString)
design._prepConstruction(cs)

# 93 and 95 are not naturally occurring.
Expand Down Expand Up @@ -532,7 +542,7 @@ def test_topLevelComponentInput(self):
without requiring a parent.
"""
cs = settings.Settings()
design = blueprints.Blueprints.load(self.yamlString)
design = blueprints.Blueprints.load(self._yamlString)
# The following is needed to prep customisotopics
# which is required during construction of a component
design._resolveNuclides(cs)
Expand All @@ -543,15 +553,12 @@ def test_topLevelComponentInput(self):
self.assertGreater(topComponent.getMass("U235"), 0.0)

def test_componentGroupInput(self):
"""
Make sure component groups can be input in blueprints.
"""
design = blueprints.Blueprints.load(self.yamlString)
"""Make sure component groups can be input in blueprints."""
design = blueprints.Blueprints.load(self._yamlString)
componentGroup = design.componentGroups["group1"]
self.assertEqual(componentGroup["freefuel"].name, "freefuel")
self.assertEqual(componentGroup["freefuel"].mult, 1.0)


if __name__ == "__main__":
# import sys;sys.argv = ['', 'TestBlueprints.test_nuclides']]
unittest.main()
8 changes: 7 additions & 1 deletion armi/reactor/components/basicShapes.py
Expand Up @@ -17,8 +17,14 @@
Many reactor components can be described in 2D by circles, hexagons, rectangles, etc. These
are defined in this subpackage.
"""
.. impl:: ARMI supports a reasonable set of basic shapes.
:id: IMPL_REACTOR_SHAPES_0
:links: REQ_REACTOR_SHAPES
Here ARMI implements its support for: Circles, Hexagons, Rectangles, Solid Rectangles,
Squares, and Triangles.
"""
import math

from armi.reactor.components import ShapedComponent
Expand Down
7 changes: 7 additions & 0 deletions armi/reactor/components/complexShapes.py
Expand Up @@ -14,6 +14,13 @@

"""
Components represented by complex shapes, and typically less widely used.
.. impl:: ARMI supports a reasonable set of basic shapes.
:id: IMPL_REACTOR_SHAPES_1
:links: REQ_REACTOR_SHAPES
Here ARMI implements its support for: Holed Hexagons, Holed Rectangles,
Holed Squares, and Helixes.
"""

import math
Expand Down
6 changes: 5 additions & 1 deletion armi/reactor/components/component.py
Expand Up @@ -17,8 +17,8 @@
This module contains the abstract definition of a Component.
"""
import re
import copy
import re

import numpy

Expand Down Expand Up @@ -180,6 +180,10 @@ class Component(composites.Composite, metaclass=ComponentType):
Temperature in C to which dimensions were thermally-expanded upon input.
material : str or material.Material
The material object that makes up this component and give it its thermo-mechanical properties.
.. impl:: ARMI allows for thermal expansion of all components by user-defined custom curves.
:id: IMPL_REACTOR_THERMAL_EXPANSION_0
:links: REQ_REACTOR_THERMAL_EXPANSION
"""

DIMENSION_NAMES = tuple() # will be assigned by ComponentType
Expand Down
10 changes: 9 additions & 1 deletion armi/reactor/components/volumetricShapes.py
Expand Up @@ -12,7 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""3-dimensional shapes."""
"""3-dimensional shapes
.. impl:: ARMI supports a reasonable set of basic shapes.
:id: IMPL_REACTOR_SHAPES_2
:links: REQ_REACTOR_SHAPES
Here ARMI implements its support for: Spheres, Cubes, Toruses, and more.
"""

import math

Expand Down

0 comments on commit 6dcedac

Please sign in to comment.