Skip to content

Commit

Permalink
Responding to comments
Browse files Browse the repository at this point in the history
  • Loading branch information
john-science committed Nov 27, 2023
1 parent 68543aa commit bce37a6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 66 deletions.
21 changes: 17 additions & 4 deletions armi/physics/neutronics/crossSectionGroupManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -840,8 +840,8 @@ def __init__(self, r, cs):
def interactBOL(self):
"""Called at the Beginning-of-Life of a run, before any cycles start.
.. impl:: The lattice physics interface and XSGM are connected in when they run.
:id: I_ARMI_XSGM_FREQ
.. impl:: The lattice physics interface and XSGM are connected at BOL.
:id: I_ARMI_XSGM_FREQ0
:implements: R_ARMI_XSGM_FREQ
"""
# now that all cs settings are loaded, apply defaults to compound XS settings
Expand All @@ -865,6 +865,10 @@ def interactBOC(self, cycle=None):
"""
Update representative blocks and block burnup groups.
.. impl:: The lattice physics interface and XSGM are connected at BOC.
:id: I_ARMI_XSGM_FREQ1
:implements: R_ARMI_XSGM_FREQ
Notes
-----
The block list each each block collection cannot be emptied since it is used to derive nuclide temperatures.
Expand All @@ -873,20 +877,29 @@ def interactBOC(self, cycle=None):
self.createRepresentativeBlocks()

def interactEOC(self, cycle=None):
"""
EOC interaction.
"""EOC interaction.
Clear out big dictionary of all blocks to avoid memory issues and out-of-date representers.
"""
self.clearRepresentativeBlocks()

def interactEveryNode(self, cycle=None, tn=None):
"""Interactino at every time now.
.. impl:: The lattice physics interface and XSGM are connected at every time node.
:id: I_ARMI_XSGM_FREQ2
:implements: R_ARMI_XSGM_FREQ
"""
if self._latticePhysicsFrequency >= LatticePhysicsFrequency.everyNode:
self.createRepresentativeBlocks()

def interactCoupled(self, iteration):
"""Update XS groups on each physics coupling iteration to get latest temperatures.
.. impl:: The lattice physics interface and XSGM are connected during coupling.
:id: I_ARMI_XSGM_FREQ3
:implements: R_ARMI_XSGM_FREQ
Notes
-----
Updating the XS on only the first (i.e., iteration == 0) timenode can be a reasonable approximation to
Expand Down
78 changes: 16 additions & 62 deletions armi/physics/neutronics/tests/test_crossSectionManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
from armi.physics.neutronics.const import CONF_CROSS_SECTION
from armi.physics.neutronics.crossSectionGroupManager import (
BlockCollection,
CylindricalComponentsAverageBlockCollection,
FluxWeightedAverageBlockCollection,
)
from armi.physics.neutronics.crossSectionGroupManager import (
Expand Down Expand Up @@ -98,65 +97,6 @@ def test_createRepresentativeBlock(self):
self.assertAlmostEqual(avgB.p.percentBu, 50.0)


class TestCylindricalComponentsAverageBlockCollection(unittest.TestCase):
@classmethod
def setUpClass(cls):
fpFactory = test_lumpedFissionProduct.getDummyLFPFile()
cls.blockList = makeBlocks(5)
for bi, b in enumerate(cls.blockList):
b.setType("fuel")
b.p.percentBu = bi / 4.0 * 100
b.setLumpedFissionProducts(fpFactory.createLFPsFromFile())
# put some trace Fe-56 and Na-23 into the fuel
# zero out all fuel nuclides except U-235 (for mass-weighting of component temperature)
fuelComp = b.getComponent(Flags.FUEL)
for nuc in fuelComp.getNuclides():
b.setNumberDensity(nuc, 0.0)
b.setNumberDensity("U235", bi)
fuelComp.setNumberDensity("FE56", 1e-15)
fuelComp.setNumberDensity("NA23", 1e-15)
b.p.gasReleaseFraction = bi * 2 / 8.0
for c in b:
if c.hasFlags(Flags.FUEL):
c.temperatureInC = 600.0 + bi
elif c.hasFlags([Flags.CLAD, Flags.DUCT, Flags.WIRE]):
c.temperatureInC = 500.0 + bi
elif c.hasFlags([Flags.BOND, Flags.COOLANT, Flags.INTERCOOLANT]):
c.temperatureInC = 400.0 + bi

def setUp(self):
self.bc = CylindricalComponentsAverageBlockCollection(
self.blockList[0].r.blueprints.allNuclidesInProblem
)
self.bc.extend(self.blockList)
self.bc.averageByComponent = True

def test_createRepresentativeBlock(self):
"""Test creation of a representative block.
.. test:: Create representative blocks using custom cylindrical averaging.
:id: T_ARMI_XSGM_CREATE_REPR_BLOCKS1
:tests: R_ARMI_XSGM_CREATE_REPR_BLOCKS
"""
avgB = self.bc.createRepresentativeBlock()
self.assertNotIn(avgB, self.bc)
# (0 + 1 + 2 + 3 + 4) / 5 = 10/5 = 2.0
self.assertAlmostEqual(avgB.getNumberDensity("U235"), 2.00018, delta=0.0001)
# (0 + 1/4 + 2/4 + 3/4 + 4/4) / 5 * 100.0 = 50.0
self.assertEqual(avgB.p.percentBu, 50.0)

# check that a new block collection of the representative block has right temperatures
# this is required for Doppler coefficient calculations
newBc = AverageBlockCollection(
self.blockList[0].r.blueprints.allNuclidesInProblem
)
newBc.append(avgB)
newBc.calcAvgNuclideTemperatures()
self.assertAlmostEqual(newBc.avgNucTemperatures["U235"], 602.0)
self.assertAlmostEqual(newBc.avgNucTemperatures["FE56"], 502.0)
self.assertAlmostEqual(newBc.avgNucTemperatures["NA23"], 402.0)


class TestBlockCollectionAverage(unittest.TestCase):
@classmethod
def setUpClass(cls):
Expand Down Expand Up @@ -559,6 +499,10 @@ def test_ComponentAverage1DCylinder(self):
and component area correctly.
Order of components is also checked since in 1D cases the order of the components matters.
.. test:: Create representative blocks using custom cylindrical averaging.
:id: T_ARMI_XSGM_CREATE_REPR_BLOCKS1
:tests: R_ARMI_XSGM_CREATE_REPR_BLOCKS
"""
xsgm = self.o.getInterface("xsGroups")

Expand Down Expand Up @@ -947,7 +891,12 @@ def test_interactEveryNode(self):
self.assertTrue(self.csm.representativeBlocks)

def test_interactFirstCoupledIteration(self):
"""Test `firstCoupledIteration` lattice physics update frequency."""
"""Test `firstCoupledIteration` lattice physics update frequency.
.. test:: The XSGM frequency depends on the LPI frequency during first coupled iteration.
:id: T_ARMI_XSGM_FREQ3
:tests: R_ARMI_XSGM_FREQ
"""
self.csm.cs[CONF_LATTICE_PHYSICS_FREQUENCY] = "everyNode"
self.csm.interactBOL()
self.csm.interactCoupled(iteration=0)
Expand All @@ -958,7 +907,12 @@ def test_interactFirstCoupledIteration(self):
self.assertTrue(self.csm.representativeBlocks)

def test_interactAllCoupled(self):
"""Test `all` lattice physics update frequency."""
"""Test `all` lattice physics update frequency.
.. test:: The XSGM frequency depends on the LPI frequency during coupling.
:id: T_ARMI_XSGM_FREQ4
:tests: R_ARMI_XSGM_FREQ
"""
self.csm.cs[CONF_LATTICE_PHYSICS_FREQUENCY] = "firstCoupledIteration"
self.csm.interactBOL()
self.csm.interactCoupled(iteration=1)
Expand Down

0 comments on commit bce37a6

Please sign in to comment.