Skip to content

Commit

Permalink
Add cornersUp property to HexGrid.
Browse files Browse the repository at this point in the history
  • Loading branch information
mgjarrett committed Feb 15, 2024
1 parent 0668e8c commit 0532559
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
18 changes: 18 additions & 0 deletions armi/reactor/grids/hexagonal.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,24 @@ def pitch(self) -> float:
"""
return self._unitSteps[1][1]

@property
def cornersUp(self) -> bool:
"""
Check whether the hexagonal grid is "corners up" or "flats up"
Corners up corners:
*
* *
* *
*
Flats up hexagon corners:
* *
* *
* *
"""
return self._unitSteps[0][1] != 0.0

@staticmethod
def indicesToRingPos(i: int, j: int) -> Tuple[int, int]:
"""
Expand Down
15 changes: 11 additions & 4 deletions armi/utils/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,14 @@ def _makeBlockPinPatches(block, cold):

# goes through each location
# want to place a patch at that location
blockPatches = _makeComponentPatch(component, (x, y), cold)
if isinstance(block.spatialGrid, grids.HexGrid):
hexRotation = 30 if block.spatialGrid.cornersUp else 0
else:
hexRotation = 0

blockPatches = _makeComponentPatch(
component, (x, y), cold, hexRotation=hexRotation
)
for element in blockPatches:
patches.append(element)

Expand All @@ -1227,7 +1234,7 @@ def _makeBlockPinPatches(block, cold):
return patches, data, names


def _makeComponentPatch(component, position, cold):
def _makeComponentPatch(component, position, cold, hexRotation=30):
"""Makes a component shaped patch to later be used for making block diagrams.
Parameters
Expand Down Expand Up @@ -1283,10 +1290,10 @@ def _makeComponentPatch(component, position, cold):
elif isinstance(component, Hexagon):
if component.getDimension("ip", cold=cold) != 0:
innerPoints = numpy.array(
hexagon.corners(30) * component.getDimension("ip", cold=cold)
hexagon.corners(hexRotation) * component.getDimension("ip", cold=cold)
)
outerPoints = numpy.array(
hexagon.corners(30) * component.getDimension("op", cold=cold)
hexagon.corners(hexRotation) * component.getDimension("op", cold=cold)
)
blockPatch = []
for n in range(6):
Expand Down

0 comments on commit 0532559

Please sign in to comment.