From 256150f5675f4d1c61f9c07b5e29cdb8293cffc0 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Thu, 11 Apr 2024 15:00:41 +0200 Subject: [PATCH] Ensure that two surfaces with different boundary type are not considered redundant (#2942) --- openmc/geometry.py | 2 +- tests/unit_tests/test_geometry.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/openmc/geometry.py b/openmc/geometry.py index 8815f2c8380..175cef2bf37 100644 --- a/openmc/geometry.py +++ b/openmc/geometry.py @@ -701,7 +701,7 @@ def remove_redundant_surfaces(self) -> typing.Dict[int, openmc.Surface]: coeffs = tuple(round(surf._coefficients[k], self.surface_precision) for k in surf._coeff_keys) - key = (surf._type,) + coeffs + key = (surf._type, surf._boundary_type) + coeffs redundancies[key].append(surf) redundant_surfaces = {replace.id: keep diff --git a/tests/unit_tests/test_geometry.py b/tests/unit_tests/test_geometry.py index f5a1bd7db69..6cc577c820c 100644 --- a/tests/unit_tests/test_geometry.py +++ b/tests/unit_tests/test_geometry.py @@ -390,3 +390,16 @@ def test_get_all_nuclides(): c2 = openmc.Cell(fill=m2, region=+s) geom = openmc.Geometry([c1, c2]) assert geom.get_all_nuclides() == ['Be9', 'Fe56'] + + +def test_redundant_surfaces(): + # Make sure boundary condition is accounted for + s1 = openmc.Sphere(r=5.0) + s2 = openmc.Sphere(r=5.0, boundary_type="vacuum") + c1 = openmc.Cell(region=-s1) + c2 = openmc.Cell(region=+s1) + u_lower = openmc.Universe(cells=[c1, c2]) + c3 = openmc.Cell(fill=u_lower, region=-s2) + geom = openmc.Geometry([c3]) + redundant_surfs = geom.remove_redundant_surfaces() + assert len(redundant_surfs) == 0