Skip to content

Commit

Permalink
Improving the robustness of HexBlock._rotatePins() (#1859)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgjarrett authored Oct 4, 2024
1 parent 484c708 commit b436537
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
14 changes: 8 additions & 6 deletions armi/reactor/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2136,18 +2136,20 @@ 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.
rotNum = int((self.getRotationNum() + rotNum) % 6)

# 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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions doc/release/0.4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ New Features
#. Removing the ``tabulate`` dependency by ingesting it to ``armi.utils.tabulate``. (`PR#1811 <https://github.com/terrapower/armi/pull/1811>`_)
#. Adding ``--skip-inspection`` flag to ``CompareCases`` CLI. (`PR#1842 <https://github.com/terrapower/armi/pull/1842>`_)
#. Allow merging a component with zero area into another component (`PR#1858 <https://github.com/terrapower/armi/pull/1858>`_)
#. Use ``Block.getNumPins()`` in ``HexBlock._rotatePins()``. (`PR#1859 <https://github.com/terrapower/armi/pull/1859>`_)
#. Provide utilities for determining location of a rotated object in a hexagonal lattice (``getIndexOfRotatedCell``). (`PR#1846 <https://github.com/terrapower/armi/1846`)
#. Allow merging a component with zero area into another component. (`PR#1858 <https://github.com/terrapower/armi/pull/1858>`_)
#. Provide ``Parameter.hasCategory`` for quickly checking if a parameter is defined with a given category. (`PR#1899 <https://github.com/terrapower/armi/pull/1899>`_)
Expand Down

0 comments on commit b436537

Please sign in to comment.