From be7a9c375a7763fed3c529cfb4263543d0309940 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Wed, 6 Sep 2023 04:25:47 +0100 Subject: [PATCH] cylindrical mesh lower left Z value corrected (#2684) --- openmc/mesh.py | 2 +- tests/unit_tests/test_mesh.py | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/openmc/mesh.py b/openmc/mesh.py index d075f735e0..60a1c0c939 100644 --- a/openmc/mesh.py +++ b/openmc/mesh.py @@ -1320,7 +1320,7 @@ class CylindricalMesh(StructuredMesh): return np.array(( self.origin[0] - self.r_grid[-1], self.origin[1] - self.r_grid[-1], - self.origin[2] - self.z_grid[-1] + self.origin[2] + self.z_grid[0] )) @property diff --git a/tests/unit_tests/test_mesh.py b/tests/unit_tests/test_mesh.py index 480104154d..77b40b44fe 100644 --- a/tests/unit_tests/test_mesh.py +++ b/tests/unit_tests/test_mesh.py @@ -56,21 +56,26 @@ def test_cylindrical_mesh_bounding_box(): origin=(0, 0, 0) ) np.testing.assert_array_equal(mesh.upper_right, (1, 1, 1)) - np.testing.assert_array_equal(mesh.lower_left, (-1, -1, -1)) + np.testing.assert_array_equal(mesh.lower_left, (-1, -1, 0.1)) bb = mesh.bounding_box assert isinstance(bb, openmc.BoundingBox) - np.testing.assert_array_equal(bb.lower_left, (-1, -1, -1)) + np.testing.assert_array_equal(bb.lower_left, (-1, -1, 0.1)) np.testing.assert_array_equal(bb.upper_right, (1, 1, 1)) # test with mesh at origin (3, 5, 7) mesh.origin = (3, 5, 7) np.testing.assert_array_equal(mesh.upper_right, (4, 6, 8)) - np.testing.assert_array_equal(mesh.lower_left, (2, 4, 6)) + np.testing.assert_array_equal(mesh.lower_left, (2, 4, 7.1)) bb = mesh.bounding_box assert isinstance(bb, openmc.BoundingBox) - np.testing.assert_array_equal(bb.lower_left, (2, 4, 6)) + np.testing.assert_array_equal(bb.lower_left, (2, 4, 7.1)) np.testing.assert_array_equal(bb.upper_right, (4, 6, 8)) + # changing z grid to contain negative numbers + mesh.z_grid = [-10, 0, 10] + np.testing.assert_array_equal(mesh.lower_left, (2, 4, -3)) + np.testing.assert_array_equal(mesh.upper_right, (4, 6, 17)) + def test_spherical_mesh_bounding_box(): # test with mesh at origin (0, 0, 0)