Skip to content

Commit

Permalink
Remove rotation-related usage on block burnup parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
drewj-tp committed Oct 31, 2024
1 parent 921781e commit 234396f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 66 deletions.
4 changes: 2 additions & 2 deletions armi/physics/fuelCycle/hexAssemblyFuelMgmtUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import numpy as np

from armi import runLog
from armi.physics.fuelCycle.utils import maxBurnupFuelPinLocation, maxBurnupBlock
from armi.physics.fuelCycle.utils import maxBurnupBlock, maxBurnupLocator
from armi.utils.mathematics import findClosest

if typing.TYPE_CHECKING:
Expand Down Expand Up @@ -94,7 +94,7 @@ def getOptimalAssemblyOrientation(a: "HexAssembly", aPrev: "HexAssembly") -> int
raise ValueError(
f"Block {maxBuBlock} in {a} does not have a spatial grid. Cannot rotate."
)
maxBuPinLocation = maxBurnupFuelPinLocation(maxBuBlock)
maxBuPinLocation = maxBurnupLocator(maxBuBlock)
# No need to rotate if max burnup pin is the center
if maxBuPinLocation.i == 0 and maxBuPinLocation.j == 0:
return 0
Expand Down
18 changes: 2 additions & 16 deletions armi/physics/fuelCycle/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,6 @@ def setUp(self):
# Force no fuel flags
self.fuel.p.flags = Flags.PIN

def test_maxBurnupPinLocationBlockParameter(self):
"""Test that the ``Block.p.percentBuMaxPinLocation`` parameter gets the location."""
# Zero-indexed pin index, pin number is this plus one
pinLocationIndex = 3
self.block.p.percentBuMaxPinLocation = pinLocationIndex + 1
locations = [IndexLocation(i, 0, 0, None) for i in range(pinLocationIndex + 5)]
self.block.getPinLocations = mock.Mock(return_value=locations)
expected = locations[pinLocationIndex]
actual = utils.maxBurnupFuelPinLocation(self.block)
self.assertIs(actual, expected)

def test_maxBurnupLocationFromComponents(self):
"""Test that the ``Component.p.pinPercentBu`` parameter can reveal max burnup location."""
self.fuel.spatialLocator = MultiIndexLocation(None)
Expand All @@ -68,7 +57,7 @@ def test_maxBurnupLocationFromComponents(self):
maxBuIndex = self.N_PINS // 3
self.fuel.p.pinPercentBu[maxBuIndex] *= 2
expectedLoc = locations[maxBuIndex]
actual = utils.maxBurnupFuelPinLocation(self.block)
actual = utils.maxBurnupLocator(self.block)
self.assertEqual(actual, expectedLoc)

def test_singleLocatorWithBurnup(self):
Expand All @@ -80,7 +69,7 @@ def test_singleLocatorWithBurnup(self):
freeComp.p.pinPercentBu = [
0.01,
]
loc = utils.getMaxBurnupLocationFromChildren([freeComp])
loc = utils.maxBurnupLocator([freeComp])
self.assertIs(loc, freeComp.spatialLocator)

def test_assemblyHasPinPower(self):
Expand Down Expand Up @@ -122,6 +111,3 @@ def test_assemblyHasPinBurnups(self):
self.assertFalse(self.fuel.hasFlags(Flags.FUEL))
self.fuel.p.pinPercentBu = np.arange(self.N_PINS, dtype=float)
self.assertFalse(utils.assemblyHasFuelPinBurnup(fakeAssem))
# No pin component burnup, but a pin burnup location parameter => yes assembly burnup
self.block.p.percentBuMaxPinLocation = 3
self.assertTrue(utils.assemblyHasFuelPinBurnup(fakeAssem))
51 changes: 3 additions & 48 deletions armi/physics/fuelCycle/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,8 @@ def assemblyHasFuelPinBurnup(a: typing.Iterable["Block"]) -> bool:
Notes
-----
Checks two parameters on a fuel block to determine if there is burnup:
1. ``Block.p.percentBuMaxPinLocation``, or
2. ``Component.p.pinPercentBu`` on a fuel component in the block.
Checks if any `Component.p.pinPercentBu`` is set and contains non-zero data
on a fuel component in the block.
"""
# Avoid using Assembly.getChildrenWithFlags(Flags.FUEL)
# because that creates an entire list where we may just need the first
Expand All @@ -78,50 +76,12 @@ def assemblyHasFuelPinBurnup(a: typing.Iterable["Block"]) -> bool:
b.hasFlags(Flags.FUEL)
and (
any(c.hasFlags(Flags.FUEL) and np.any(c.p.pinPercentBu) for c in b)
or b.p.percentBuMaxPinLocation
)
for b in a
)


def maxBurnupFuelPinLocation(b: "Block") -> IndexLocation:
"""Find the grid position for the highest burnup fuel pin.
Parameters
----------
b : Block
Block in question
Returns
-------
IndexLocation
The spatial location in the block corresponding to the pin with the
highest burnup.
See Also
--------
* :func:`getMaxBurnupLocationFromChildren` looks just at the children of this
block, e.g., looking at pins. This function also looks at the block parameter
``Block.p.percentBuMaxPinLocation`` in case the max burnup location cannot be
determined from the child pins.
"""
# If we can't find any burnup from the children, that's okay. We have
# another way to find the max burnup location.
with contextlib.suppress(ValueError):
return getMaxBurnupLocationFromChildren(b)
# Should be an integer, that's what the description says. But a couple places
# set it to a float like 1.0 so it's still int-like but not something we can slice
buMaxPinNumber = int(b.p.percentBuMaxPinLocation)
if buMaxPinNumber < 1:
raise ValueError(f"{b.p.percentBuMaxPinLocation=} must be greater than zero")
pinLocations = b.getPinLocations()
# percentBuMaxPinLocation corresponds to the "pin number" which is one indexed
# and can be found at ``maxBuBlock.getPinLocations()[pinNumber - 1]``
maxBuPinLocation = pinLocations[buMaxPinNumber - 1]
return maxBuPinLocation


def getMaxBurnupLocationFromChildren(
def maxBurnupLocator(
children: typing.Iterable["Component"],
) -> IndexLocation:
"""Find the location of the pin with highest burnup by looking at components.
Expand All @@ -140,11 +100,6 @@ def getMaxBurnupLocationFromChildren(
------
ValueError
If no children have burnup, or the burnup and locators differ.
See Also
--------
* :func:`maxBurnupFuelPinLocation` uses this. You should use that method more generally,
unless you **know** you will always have ``Component.p.pinPercentBu`` defined.
"""
maxBu = 0
maxLocation = None
Expand Down

0 comments on commit 234396f

Please sign in to comment.