Skip to content

Commit

Permalink
Adding impl/test crumbs for blueprints (#1476)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdlafleur authored Nov 15, 2023
1 parent 5b3555c commit c799586
Show file tree
Hide file tree
Showing 10 changed files with 97 additions and 7 deletions.
4 changes: 4 additions & 0 deletions armi/reactor/blueprints/assemblyBlueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ class AssemblyBlueprint(yamlize.Object):
This class utilizes ``yamlize`` to enable serialization to and from the
blueprints YAML file.
.. impl:: Create assembly from blueprint file
:id: I_ARMI_BP_ASSEM
:implements: R_ARMI_BP_ASSEM
"""

name = yamlize.Attribute(type=str)
Expand Down
7 changes: 6 additions & 1 deletion armi/reactor/blueprints/blockBlueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ def _configureGeomOptions():


class BlockBlueprint(yamlize.KeyedList):
"""Input definition for Block."""
"""Input definition for Block.
.. impl:: Create a Block from blueprint file
:id: I_ARMI_BP_BLOCK
:implements: R_ARMI_BP_BLOCK
"""

item_type = componentBlueprint.ComponentBlueprint
key_attr = componentBlueprint.ComponentBlueprint.name
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 @@ -119,6 +119,10 @@ class ComponentBlueprint(yamlize.Object):
"""
This class defines the inputs necessary to build ARMI component objects. It uses ``yamlize`` to enable serialization
to and from YAML.
.. impl:: Construct component from blueprint file
:id: I_ARMI_BP_COMP
:implements: R_ARMI_BP_COMP
"""

name = yamlize.Attribute(type=str)
Expand Down
11 changes: 10 additions & 1 deletion armi/reactor/blueprints/gridBlueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,12 @@ def readFromLatticeMap(self, value):
self._readFromLatticeMap = value

def construct(self):
"""Build a Grid from a grid definition."""
"""Build a Grid from a grid definition.
.. impl:: Define a lattice map in reactor core
:id: I_ARMI_BP_GRID
:implements: R_ARMI_BP_GRID
"""
self._readGridContents()
grid = self._constructSpatialGrid()
return grid
Expand Down Expand Up @@ -534,6 +539,10 @@ def saveToStream(stream, bluep, full=False, tryMap=False):
full: bool ~ Is this a full output file, or just a partial/grids?
tryMap: regardless of input form, attempt to output as a lattice map. let's face it;
they're prettier.
.. impl:: Write a blueprint file from a blueprint object
:id: I_ARMI_BP_TO_DB
:implements: R_ARMI_BP_TO_DB
"""
# To save, we want to try our best to output our grid blueprints in the lattice
# map style. However, we do not want to wreck the state that the current
Expand Down
8 changes: 8 additions & 0 deletions armi/reactor/blueprints/reactorBlueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ def _resolveSystemType(typ: str):
def construct(self, cs, bp, reactor, geom=None, loadAssems=True):
"""Build a core/IVS/EVST/whatever and fill it with children.
.. impl:: Build core and spent fuel pool from blueprint
:id: I_ARMI_BP_SYSTEMS
:implements: R_ARMI_BP_SYSTEMS
.. impl:: Create core object with blueprint
:id: I_ARMI_BP_CORE
:implements: R_ARMI_BP_CORE
Parameters
----------
cs : :py:class:`Settings <armi.settings.Settings>` object.
Expand Down
7 changes: 7 additions & 0 deletions armi/reactor/blueprints/tests/test_assemblyBlueprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,13 @@ def loadCustomAssembly(self, assemblyInput):
return design.assemblies["fuel a"]

def test_checkParamConsistency(self):
"""
Load assembly from a blueprint file.
.. test:: Create assembly from blueprint file
:id: T_ARMI_BP_ASSEM
:tests: R_ARMI_BP_ASSEM
"""
# make sure a good example doesn't error
a = self.loadCustomAssembly(self.twoBlockInput_correct)
blockAxialMesh = a.getAxialMesh()
Expand Down
20 changes: 17 additions & 3 deletions armi/reactor/blueprints/tests/test_blockBlueprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
op: 16.75
other fuel: &block_fuel_other
grid name: fuelgrid
flags: fuel test
flags: fuel test depletable
fuel:
shape: Circle
material: UZr
Expand Down Expand Up @@ -255,7 +255,12 @@


class TestGriddedBlock(unittest.TestCase):
"""Tests for a block that has components in a lattice."""
"""Tests for a block that has components in a lattice.
.. test:: Create block with blueprint file
:id: T_ARMI_BP_BLOCK
:tests: R_ARMI_BP_BLOCK
"""

def setUp(self):
self.cs = settings.Settings()
Expand Down Expand Up @@ -301,6 +306,13 @@ def test_nonLatticeComponentHasRightMult(self):
self.assertEqual(duct.getDimension("mult"), 1.0)

def test_explicitFlags(self):
"""
Test flags are created from blueprint file.
.. test:: Test depletable nuc flags
:id: T_ARMI_BP_NUC_FLAGS
:tests: R_ARMI_BP_NUC_FLAGS
"""
a1 = self.blueprints.assemDesigns.bySpecifier["IC"].construct(
self.cs, self.blueprints
)
Expand All @@ -312,7 +324,9 @@ def test_explicitFlags(self):
)

self.assertTrue(b1.hasFlags(Flags.FUEL, exact=True))
self.assertTrue(b2.hasFlags(Flags.FUEL | Flags.TEST, exact=True))
self.assertTrue(
b2.hasFlags(Flags.FUEL | Flags.TEST | Flags.DEPLETABLE, exact=True)
)

self.assertEqual(a1.p.flags, Flags.FUEL)
self.assertTrue(a1.hasFlags(Flags.FUEL, exact=True))
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 @@ -87,7 +87,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."""
"""Tests that the user can specify the dimensions of a component with arbitrary fidelity.
.. test:: Test that a component can be correctly created from a blueprint file
:id: T_ARMI_BP_COMP
:tests: R_ARMI_BP_COMP
"""
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 Down
20 changes: 20 additions & 0 deletions armi/reactor/blueprints/tests/test_gridBlueprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,27 @@ def test_contents(self):
self.assertIn("core", self.grids)

def test_roundTrip(self):
"""
Test saving blueprint data to a stream.
.. test:: Write blueprints settings to disk
:id: T_ARMI_BP_TO_DB
:tests: R_ARMI_BP_TO_DB
"""
stream = io.StringIO()
saveToStream(stream, self.grids, False, True)
stream.seek(0)
gridBp = Grids.load(stream)
self.assertIn("third", gridBp["core"].symmetry)

def test_tiny_map(self):
"""
Test that a lattice map can be defined, written, and read in from blueprint file.
.. test:: Define a lattice map in reactor core
:id: T_ARMI_BP_GRID1
:tests: R_ARMI_BP_GRID
"""
grid = Grids.load(TINY_GRID)
stream = io.StringIO()
saveToStream(stream, grid, full=True, tryMap=True)
Expand Down Expand Up @@ -381,6 +395,12 @@ def test_simpleRead(self):
self.assertEqual(gridDesign4.gridContents[-4, -3], "1")

def test_simpleReadLatticeMap(self):
"""Read lattice map and create a grid.
.. test:: Define a lattice map in reactor core
:id: T_ARMI_BP_GRID0
:tests: R_ARMI_BP_GRID
"""
# Cartesian full, even/odd hybrid
gridDesign4 = self.grids["sfp even"]
_grid = gridDesign4.construct()
Expand Down
16 changes: 15 additions & 1 deletion armi/reactor/blueprints/tests/test_reactorBlueprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
import os
import unittest

from armi.reactor.assemblyLists import SpentFuelPool
from armi.reactor import blueprints
from armi.reactor.reactors import Core
from armi import settings
from armi.reactor import reactors
from armi.reactor.blueprints import reactorBlueprint
Expand Down Expand Up @@ -101,11 +103,23 @@ def _setupReactor(self):
return core, sfp

def test_construct(self):
"""Actually construct some reactor systems."""
"""Actually construct some reactor systems.
.. test:: Create core and spent fuel pool with blueprint
:id: T_ARMI_BP_SYSTEMS
:tests: R_ARMI_BP_SYSTEMS
.. test:: Create core object with blueprint
:id: T_ARMI_BP_CORE
:tests: R_ARMI_BP_CORE
"""
core, sfp = self._setupReactor()
self.assertEqual(len(core), 2)
self.assertEqual(len(sfp), 4)

self.assertIsInstance(core, Core)
self.assertIsInstance(sfp, SpentFuelPool)

def test_materialDataSummary(self):
"""Test that the material data summary for the core is valid as a printout to the stdout."""
expectedMaterialData = [
Expand Down

0 comments on commit c799586

Please sign in to comment.