From c7995865ca66d97eefaeb958148aa758358e479c Mon Sep 17 00:00:00 2001 From: bdlafleur Date: Wed, 15 Nov 2023 09:44:37 -0500 Subject: [PATCH] Adding impl/test crumbs for blueprints (#1476) --- armi/reactor/blueprints/assemblyBlueprint.py | 4 ++++ armi/reactor/blueprints/blockBlueprint.py | 7 ++++++- armi/reactor/blueprints/componentBlueprint.py | 4 ++++ armi/reactor/blueprints/gridBlueprint.py | 11 +++++++++- armi/reactor/blueprints/reactorBlueprint.py | 8 ++++++++ .../tests/test_assemblyBlueprints.py | 7 +++++++ .../blueprints/tests/test_blockBlueprints.py | 20 ++++++++++++++++--- .../blueprints/tests/test_blueprints.py | 7 ++++++- .../blueprints/tests/test_gridBlueprints.py | 20 +++++++++++++++++++ .../tests/test_reactorBlueprints.py | 16 ++++++++++++++- 10 files changed, 97 insertions(+), 7 deletions(-) diff --git a/armi/reactor/blueprints/assemblyBlueprint.py b/armi/reactor/blueprints/assemblyBlueprint.py index 99fd33293..4864c64d2 100644 --- a/armi/reactor/blueprints/assemblyBlueprint.py +++ b/armi/reactor/blueprints/assemblyBlueprint.py @@ -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) diff --git a/armi/reactor/blueprints/blockBlueprint.py b/armi/reactor/blueprints/blockBlueprint.py index 68443f8af..33df26448 100644 --- a/armi/reactor/blueprints/blockBlueprint.py +++ b/armi/reactor/blueprints/blockBlueprint.py @@ -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 diff --git a/armi/reactor/blueprints/componentBlueprint.py b/armi/reactor/blueprints/componentBlueprint.py index 6ef83be55..51ba17857 100644 --- a/armi/reactor/blueprints/componentBlueprint.py +++ b/armi/reactor/blueprints/componentBlueprint.py @@ -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) diff --git a/armi/reactor/blueprints/gridBlueprint.py b/armi/reactor/blueprints/gridBlueprint.py index 1cc6eb1d7..2ce46b968 100644 --- a/armi/reactor/blueprints/gridBlueprint.py +++ b/armi/reactor/blueprints/gridBlueprint.py @@ -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 @@ -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 diff --git a/armi/reactor/blueprints/reactorBlueprint.py b/armi/reactor/blueprints/reactorBlueprint.py index 6a67b7e45..7667404d7 100644 --- a/armi/reactor/blueprints/reactorBlueprint.py +++ b/armi/reactor/blueprints/reactorBlueprint.py @@ -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 ` object. diff --git a/armi/reactor/blueprints/tests/test_assemblyBlueprints.py b/armi/reactor/blueprints/tests/test_assemblyBlueprints.py index 1031de24b..1197f41bd 100644 --- a/armi/reactor/blueprints/tests/test_assemblyBlueprints.py +++ b/armi/reactor/blueprints/tests/test_assemblyBlueprints.py @@ -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() diff --git a/armi/reactor/blueprints/tests/test_blockBlueprints.py b/armi/reactor/blueprints/tests/test_blockBlueprints.py index 36882a74d..02988516f 100644 --- a/armi/reactor/blueprints/tests/test_blockBlueprints.py +++ b/armi/reactor/blueprints/tests/test_blockBlueprints.py @@ -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 @@ -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() @@ -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 ) @@ -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)) diff --git a/armi/reactor/blueprints/tests/test_blueprints.py b/armi/reactor/blueprints/tests/test_blueprints.py index 118e54e99..ffd3540f9 100644 --- a/armi/reactor/blueprints/tests/test_blueprints.py +++ b/armi/reactor/blueprints/tests/test_blueprints.py @@ -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) diff --git a/armi/reactor/blueprints/tests/test_gridBlueprints.py b/armi/reactor/blueprints/tests/test_gridBlueprints.py index 6735888f7..6e8f52a91 100644 --- a/armi/reactor/blueprints/tests/test_gridBlueprints.py +++ b/armi/reactor/blueprints/tests/test_gridBlueprints.py @@ -314,6 +314,13 @@ 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) @@ -321,6 +328,13 @@ def test_roundTrip(self): 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) @@ -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() diff --git a/armi/reactor/blueprints/tests/test_reactorBlueprints.py b/armi/reactor/blueprints/tests/test_reactorBlueprints.py index 20cc9666b..b13ccdf05 100644 --- a/armi/reactor/blueprints/tests/test_reactorBlueprints.py +++ b/armi/reactor/blueprints/tests/test_reactorBlueprints.py @@ -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 @@ -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 = [