Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rotation of hexagons in block diagrams #1648

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions armi/reactor/grids/hexagonal.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,16 @@ 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".

See the armi.reactor.grids.HexGrid class documentation for an
illustration of the two types of grid indexing.
"""
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
keckler marked this conversation as resolved.
Show resolved Hide resolved
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):
keckler marked this conversation as resolved.
Show resolved Hide resolved
keckler marked this conversation as resolved.
Show resolved Hide resolved
"""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:
keckler marked this conversation as resolved.
Show resolved Hide resolved
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
Loading