Skip to content

Commit

Permalink
Check the pitch in HexGrids
Browse files Browse the repository at this point in the history
  • Loading branch information
john-science committed Feb 27, 2024
1 parent 4261b82 commit b982f9d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions armi/reactor/grids/tests/test_grids.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,18 +183,21 @@ def test_label(self):

def test_isAxialOnly(self):
grid = grids.HexGrid.fromPitch(1.0, numRings=3)
self.assertEqual(grid.pitch, 1.0)
self.assertEqual(grid.isAxialOnly, False)

grid2 = grids.AxialGrid.fromNCells(10)
self.assertEqual(grid2.isAxialOnly, True)

def test_lookupFactory(self):
grid = grids.HexGrid.fromPitch(1.0, numRings=3)
self.assertEqual(grid.pitch, 1.0)
self.assertEqual(grid[10, 5, 0].i, 10)

def test_quasiReduce(self):
"""Make sure our DB-friendly version of reduce works."""
grid = grids.HexGrid.fromPitch(1.0, numRings=3)
self.assertEqual(grid.pitch, 1.0)
reduction = grid.reduce()
self.assertAlmostEqual(reduction[0][1][1], 1.0)

Expand All @@ -208,6 +211,7 @@ def test_getitem(self):
:tests: R_ARMI_GRID_ELEM_LOC
"""
grid = grids.HexGrid.fromPitch(1.0, numRings=0)
self.assertEqual(grid.pitch, 1.0)
self.assertNotIn((0, 0, 0), grid._locations)
_ = grid[0, 0, 0]
self.assertIn((0, 0, 0), grid._locations)
Expand Down Expand Up @@ -236,6 +240,7 @@ class TestHexGrid(unittest.TestCase):

def test_positions(self):
grid = grids.HexGrid.fromPitch(1.0)
self.assertEqual(grid.pitch, 1.0)
side = 1.0 / math.sqrt(3)
assert_allclose(grid.getCoordinates((0, 0, 0)), (0.0, 0.0, 0.0))
assert_allclose(grid.getCoordinates((1, 0, 0)), (1.5 * side, 0.5, 0.0))
Expand Down Expand Up @@ -360,10 +365,13 @@ def test_cornersUpFlatsUp(self):
:id: T_ARMI_GRID_HEX_TYPE
:tests: R_ARMI_GRID_HEX_TYPE
"""
tipsUp = grids.HexGrid.fromPitch(1.0, cornersUp=True)
cornersUp = grids.HexGrid.fromPitch(1.0, cornersUp=True)
self.assertAlmostEqual(cornersUp.pitch, math.sqrt(3) / 2)

flatsUp = grids.HexGrid.fromPitch(1.0, cornersUp=False)
self.assertEqual(flatsUp.pitch, 1.0)

self.assertEqual(tipsUp._unitSteps[0][0], 0.5)
self.assertEqual(cornersUp._unitSteps[0][0], 0.5)
self.assertAlmostEqual(flatsUp._unitSteps[0][0], 0.8660254037844388)

def test_triangleCoords(self):
Expand Down

0 comments on commit b982f9d

Please sign in to comment.