From b436537edfed991e6ff560a1d1b2d4b018507db1 Mon Sep 17 00:00:00 2001 From: Michael Jarrett Date: Fri, 4 Oct 2024 09:32:26 -0700 Subject: [PATCH] Improving the robustness of HexBlock._rotatePins() (#1859) --- armi/reactor/blocks.py | 14 ++++++++------ doc/release/0.4.rst | 1 + 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/armi/reactor/blocks.py b/armi/reactor/blocks.py index bef0ade54..cc18826a0 100644 --- a/armi/reactor/blocks.py +++ b/armi/reactor/blocks.py @@ -2136,10 +2136,12 @@ def _rotatePins(self, rotNum, justCompute=False): "Cannot rotate {0} to rotNum {1}. Must be 0-5. ".format(self, rotNum) ) - # Pin numbers start at 1. Number of pins in the block is assumed to be based on - # cladding count. - numPins = self.getNumComponents(Flags.CLAD) - rotateIndexLookup = dict(zip(range(1, numPins + 1), range(1, numPins + 1))) + numPins = self.getNumPins() + hexRings = hexagon.numRingsToHoldNumCells(numPins) + fullNumPins = hexagon.totalPositionsUpToRing(hexRings) + rotateIndexLookup = dict( + zip(range(1, fullNumPins + 1), range(1, fullNumPins + 1)) + ) # Look up the current orientation and add this to it. The math below just rotates # from the reference point so we need a total rotation. @@ -2147,7 +2149,7 @@ def _rotatePins(self, rotNum, justCompute=False): # non-trivial rotation requested # start at 2 because pin 1 never changes (it's in the center!) - for pinNum in range(2, numPins + 1): + for pinNum in range(2, fullNumPins + 1): if rotNum == 0: # Rotation to reference orientation. Pin locations are pin IDs. pass @@ -2162,7 +2164,7 @@ def _rotatePins(self, rotNum, justCompute=False): if not justCompute: self.setRotationNum(rotNum) self.p["pinLocation"] = [ - rotateIndexLookup[pinNum] for pinNum in range(1, numPins + 1) + rotateIndexLookup[pinNum] for pinNum in range(1, fullNumPins + 1) ] return rotateIndexLookup diff --git a/doc/release/0.4.rst b/doc/release/0.4.rst index d2374817f..973d91cf0 100644 --- a/doc/release/0.4.rst +++ b/doc/release/0.4.rst @@ -12,6 +12,7 @@ New Features #. Removing the ``tabulate`` dependency by ingesting it to ``armi.utils.tabulate``. (`PR#1811 `_) #. Adding ``--skip-inspection`` flag to ``CompareCases`` CLI. (`PR#1842 `_) #. Allow merging a component with zero area into another component (`PR#1858 `_) +#. Use ``Block.getNumPins()`` in ``HexBlock._rotatePins()``. (`PR#1859 `_) #. Provide utilities for determining location of a rotated object in a hexagonal lattice (``getIndexOfRotatedCell``). (`PR#1846 `_) #. Provide ``Parameter.hasCategory`` for quickly checking if a parameter is defined with a given category. (`PR#1899 `_)