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

Adding unit tests for CylindricalComponentsDuctHetAverageBlockCollection #1991

Merged
merged 3 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions armi/physics/neutronics/tests/test_crossSectionManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,68 @@ def test_ComponentAverage1DCylinder(self):
f"{nuc} temperature does not match expected value of {compTemp}",
)

def test_ComponentAverageDuctHet1DCylinder(self):
"""
Tests that the cross-section group manager calculates the expected component atom density,
component area, and average nuclide temperature correctly for a duct heterogeneous cylindrical
block collection.
"""
self.o.cs[CONF_CROSS_SECTION]["ZA"].ductHeterogeneous = True
xsgm = self.o.getInterface("xsGroups")

xsgm.interactBOL()

# Check that the correct defaults are propagated after the interactBOL
# from the cross section group manager is called.
xsOpt = self.o.cs[CONF_CROSS_SECTION]["ZA"]
self.assertEqual(xsOpt.blockRepresentation, "ComponentAverage1DCylinder")

xsgm.createRepresentativeBlocks()
xsgm.updateNuclideTemperatures()

representativeBlockList = list(xsgm.representativeBlocks.values())
representativeBlockList.sort(key=lambda repB: repB.getMass() / repB.getVolume())
reprBlock = xsgm.representativeBlocks["ZA"]
self.assertEqual(reprBlock.name, "1D_CYL_DUCT_HET_AVG_ZA")
self.assertEqual(reprBlock.p.percentBu, 0.0)

refTemps = {"fuel": 600.0, "coolant": 450.0, "structure": 462.4565}

for c, compDensity, compArea in zip(
reprBlock, self.expectedComponentDensities, self.expectedComponentAreas
):
self.assertEqual(compArea, c.getArea())
cNucs = c.getNuclides()
for nuc in cNucs:
self.assertAlmostEqual(
c.getNumberDensity(nuc), compDensity.get(nuc, 0.0)
)
if "fuel" in c.getType():
compTemp = refTemps["fuel"]
elif any(sodium in c.getType() for sodium in ["bond", "coolant"]):
compTemp = refTemps["coolant"]
else:
compTemp = refTemps["structure"]

if any(comp in c.getType() for comp in ["fuel", "bond", "coolant"]):
# only 1 fuel component, and bond and coolant are both at same temperature
# the component temp should match the avg nuc temp
self.assertAlmostEqual(
compTemp,
xsgm.avgNucTemperatures["ZA"][nuc],
2,
f"{nuc} temperature does not match expected value of {compTemp} for component {c}",
)
else:
# steel components are at different temperatures
# the temperatures should be different
diff = abs(compTemp - xsgm.avgNucTemperatures["ZA"][nuc])
self.assertGreater(
diff,
1.0,
f"{nuc} temperature should be different from {compTemp} for component {c}",
)

def test_checkComponentConsistency(self):
xsgm = self.o.getInterface("xsGroups")
xsgm.interactBOL()
Expand Down
15 changes: 15 additions & 0 deletions armi/reactor/converters/tests/test_blockConverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import os
import unittest

import math
import numpy as np

from armi.physics.neutronics.isotopicDepletion.isotopicDepletionInterface import (
Expand Down Expand Up @@ -184,6 +185,20 @@ def test_build_NthRing(self):
clad.getArea() * numPinsInRing / clad.getDimension("mult"),
)

def test_buildInsideDuct(self):
"""Test building inside the duct."""
block = loadTestBlock(cold=False)
block.spatialGrid = grids.HexGrid.fromPitch(1.0)
converter = blockConverters.HexComponentsToCylConverter(block)
converter._buildInsideDuct()
insideBlock = converter.convertedBlock
ductIP = block.getComponent(Flags.DUCT).getDimension("ip")
bondMass = block.getComponent(Flags.BOND).getMass("NA")
coolantMass = block.getComponent(Flags.COOLANT).getMass("NA")
self.assertAlmostEqual(insideBlock.getMass("U235"), block.getMass("U235"))
self.assertAlmostEqual(insideBlock.getMass("NA"), bondMass + coolantMass)
self.assertAlmostEqual(insideBlock.getArea(), ductIP**2 * math.sqrt(3) / 2)

def test_convert(self):
"""Test conversion with no fuel driver.

Expand Down
Loading