Skip to content

Commit

Permalink
Loosening tolerance on HexGrid roughly equal check (#2058)
Browse files Browse the repository at this point in the history
  • Loading branch information
drewj-tp authored Feb 3, 2025
1 parent 13c2dbb commit cf9106d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions armi/reactor/grids/hexagonal.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from collections import deque
from math import sqrt
from math import isclose, sqrt
from typing import List, Optional, Tuple

import numpy as np
Expand Down Expand Up @@ -639,6 +639,6 @@ def _roughlyEqual(self, other) -> bool:
return True
return (
isinstance(other, HexGrid)
and other.pitch == self.pitch
and isclose(self.pitch, other.pitch, rel_tol=1e-4)
and other.cornersUp == self.cornersUp
)
11 changes: 11 additions & 0 deletions armi/reactor/grids/tests/test_grids.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,17 @@ def test_rotatedIndexGridAssignment(self):
postRotate = base.rotateIndex(loc, rotations=2)
self.assertIs(postRotate.grid, loc.grid)

def test_rotatedIndexRoughEqualPitch(self):
"""Test indices can be rotated in close but not exactly equal grids."""
base = grids.HexGrid.fromPitch(1.345)
other = grids.HexGrid.fromPitch(base.pitch * 1.00001)

for i, j in ((0, 0), (1, 1), (2, 1), (-1, 3)):
loc = grids.IndexLocation(i, j, k=0, grid=base)
fromBase = base.rotateIndex(loc, rotations=2)
fromOther = other.rotateIndex(loc, rotations=2)
self.assertEqual((fromBase.i, fromBase.j), (fromOther.i, fromOther.j))


class TestBoundsDefinedGrid(unittest.TestCase):
def test_positions(self):
Expand Down
3 changes: 2 additions & 1 deletion doc/release/0.5.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ Bug Fixes
---------
#. Fixing check for jagged arrays during ``_writeParams``. (`PR#2051 <https://github.com/terrapower/armi/pull/2051>`_)
#. Fixing BP-section ignoring tool in ``PassiveDBLoadPlugin``. (`PR#2055 <https://github.com/terrapower/armi/pull/2055>`_)
#. Fixing scaling of volume-integrated parameters on edge assembleis. (`PR#2060 <https://github.com/terrapower/armi/pull/2060>`_)
#. Fixing scaling of volume-integrated parameters on edge assemblies. (`PR#2060 <https://github.com/terrapower/armi/pull/2060>`_)
#. Fixing strictness of ``HexGrid`` rough equality check. (`PR#2058 <https://github.com/terrapower/armi/pull/2058>`_)
#. TBD

Quality Work
Expand Down

0 comments on commit cf9106d

Please sign in to comment.