Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing a couple of plots to use initial block height #1998

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
12 changes: 8 additions & 4 deletions armi/utils/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ def plotAssemblyTypes(
maxAssems = numAssems

if yAxisLabel is None:
yAxisLabel = "THERMALLY EXPANDED AXIAL HEIGHTS (CM)"
yAxisLabel = "Thermally Expanded Axial Heights (cm)"
john-science marked this conversation as resolved.
Show resolved Hide resolved

if title is None:
title = "Assembly Designs"
Expand Down Expand Up @@ -864,9 +864,11 @@ 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:
john-science marked this conversation as resolved.
Show resolved Hide resolved
blockHeight = b.getHeight()
john-science marked this conversation as resolved.
Show resolved Hide resolved

# Get the basic text label for the block
try:
Expand All @@ -881,6 +883,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)
Expand All @@ -901,6 +904,7 @@ def _plotBlocksInAssembly(
ls="solid",
)
axis.add_patch(blockPatch)
yBlockCenterLoc = yBlockLoc + blockHeight / 2.5
axis.text(
xTextLoc,
yBlockCenterLoc,
Expand Down
16 changes: 12 additions & 4 deletions armi/utils/reportPlotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,11 +416,19 @@ 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:
assert False
john-science marked this conversation as resolved.
Show resolved Hide resolved
avgHeight += b.getHeight()
avgHeight /= len(fuelA)

radius = r.core.getCoreRadius()
labels, vals = list(
zip(
*[
john-science marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
20 changes: 20 additions & 0 deletions armi/utils/tests/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import os
import unittest

import matplotlib.pyplot as plt
import numpy as np

from armi import settings
Expand Down Expand Up @@ -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)
Expand Down
33 changes: 33 additions & 0 deletions armi/utils/tests/test_reportPlotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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], "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"
Expand Down
Loading