diff --git a/armi/utils/plotting.py b/armi/utils/plotting.py index 5e99c48a4..147e1c20c 100644 --- a/armi/utils/plotting.py +++ b/armi/utils/plotting.py @@ -766,7 +766,7 @@ def plotAssemblyTypes( maxAssems = numAssems if yAxisLabel is None: - yAxisLabel = "THERMALLY EXPANDED AXIAL HEIGHTS (CM)" + yAxisLabel = "Axial Heights (cm)" if title is None: title = "Assembly Designs" @@ -864,9 +864,12 @@ def _plotBlocksInAssembly( xBlockLoc = xAssemLoc xTextLoc = xBlockLoc + blockWidth / 20.0 for b in assem: - blockHeight = b.getHeight() - blockXsId = b.p.xsType - yBlockCenterLoc = yBlockLoc + blockHeight / 2.5 + # get block height + try: + blockHeight = b.getInputHeight() + except AttributeError: + runLog.debug(f"No ancestor of {b} has blueprints", single=True) + blockHeight = b.getHeight() # Get the basic text label for the block try: @@ -881,6 +884,7 @@ def _plotBlocksInAssembly( color = "grey" # Get the detailed text label for the block + blockXsId = b.p.xsType dLabel = "" if b.hasFlags(Flags.FUEL): dLabel = " {:0.2f}%".format(b.getFissileMassEnrich() * 100) @@ -901,6 +905,7 @@ def _plotBlocksInAssembly( ls="solid", ) axis.add_patch(blockPatch) + yBlockCenterLoc = yBlockLoc + blockHeight / 2.5 axis.text( xTextLoc, yBlockCenterLoc, diff --git a/armi/utils/reportPlotting.py b/armi/utils/reportPlotting.py index 936bbec1d..a0de0f807 100644 --- a/armi/utils/reportPlotting.py +++ b/armi/utils/reportPlotting.py @@ -416,15 +416,22 @@ def _getMechanicalVals(r): def _getPhysicalVals(r): avgHeight = 0.0 fuelA = r.core.getAssemblies(Flags.FUEL) - avgHeight = sum( - b.getHeight() for a in fuelA for b in a.getBlocks(Flags.FUEL) - ) / len(fuelA) - radius = r.core.getCoreRadius() + # get average height + avgHeight = 0 + for a in fuelA: + for b in a.getBlocks(Flags.FUEL): + try: + avgHeight += b.getInputHeight() + except AttributeError: + avgHeight += b.getHeight() + avgHeight /= len(fuelA) + + radius = r.core.getCoreRadius() labels, vals = list( zip( *[ - ("Fuel height", avgHeight), + ("Cold fuel height", avgHeight), ("Fuel assems", len(fuelA)), ("Assem weight", r.core.getFirstAssembly(Flags.FUEL).getMass()), ("Core radius", radius), diff --git a/armi/utils/tests/test_plotting.py b/armi/utils/tests/test_plotting.py index bc28b5991..2c930b91e 100644 --- a/armi/utils/tests/test_plotting.py +++ b/armi/utils/tests/test_plotting.py @@ -16,6 +16,7 @@ import os import unittest +import matplotlib.pyplot as plt import numpy as np from armi import settings @@ -83,6 +84,25 @@ def test_plotAssemblyTypes(self): if os.path.exists(plotPath): os.remove(plotPath) + def test_plotBlocksInAssembly(self): + _fig, ax = plt.subplots(figsize=(15, 15), dpi=300) + xBlockLoc, yBlockHeights, yBlockAxMesh = plotting._plotBlocksInAssembly( + ax, + self.r.core.getFirstAssembly(Flags.FUEL), + True, + [], + set(), + 0.5, + 5.6, + True, + ) + self.assertEqual(xBlockLoc, 0.5) + self.assertEqual(yBlockHeights[0], 25.0) + yBlockAxMesh = list(yBlockAxMesh)[0] + self.assertIn(10.0, yBlockAxMesh) + self.assertIn(25.0, yBlockAxMesh) + self.assertIn(1, yBlockAxMesh) + def test_plotBlockFlux(self): with TemporaryDirectoryChanger(): xslib = isotxs.readBinary(ISOAA_PATH) diff --git a/armi/utils/tests/test_reportPlotting.py b/armi/utils/tests/test_reportPlotting.py index 5e0268bff..3c09f1a62 100644 --- a/armi/utils/tests/test_reportPlotting.py +++ b/armi/utils/tests/test_reportPlotting.py @@ -18,10 +18,12 @@ import numpy as np +from armi.reactor.flags import Flags from armi.reactor.tests import test_reactors from armi.tests import TEST_ROOT from armi.utils.directoryChangers import TemporaryDirectoryChanger from armi.utils.reportPlotting import ( + _getPhysicalVals, createPlotMetaData, keffVsTime, movesVsCycle, @@ -47,6 +49,37 @@ def test_radar(self): """Test execution of radar plot. Note this has no asserts and is therefore a smoke test.""" r2 = copy.deepcopy(self.r) plotCoreOverviewRadar([self.r, r2], ["Label1", "Label2"]) + self.assertTrue(os.path.exists("reactor_comparison.png")) + + def test_getPhysicalVals(self): + dims, labels, vals = _getPhysicalVals(self.r) + self.assertEqual(dims, "Dimensions") + + self.assertEqual(labels[0], "Cold fuel height") + self.assertEqual(labels[1], "Fuel assems") + self.assertEqual(labels[2], "Assem weight") + self.assertEqual(labels[3], "Core radius") + self.assertEqual(labels[4], "Core aspect ratio") + self.assertEqual(labels[5], "Fissile mass") + self.assertEqual(len(labels), 6) + + self.assertEqual(vals[0], 25.0) + self.assertEqual(vals[1], 1) + self.assertAlmostEqual(vals[2], 52474.8927038, delta=1e-5) + self.assertEqual(vals[3], 16.8) + self.assertAlmostEqual(vals[5], 4290.60340961, delta=1e-5) + self.assertEqual(len(vals), 6) + + # this test will use getInputHeight() instead of getHeight() + radius = self.r.core.getCoreRadius() + avgHeight = 0 + fuelA = self.r.core.getAssemblies(Flags.FUEL) + for a in fuelA: + for b in a.getBlocks(Flags.FUEL): + avgHeight += b.getInputHeight() + avgHeight /= len(fuelA) + coreAspectRatio = (2 * radius) / avgHeight + self.assertEqual(vals[4], coreAspectRatio) def test_createPlotMetaData(self): title = "test_createPlotMetaData"