Skip to content

Commit

Permalink
Ensure that two surfaces with different boundary type are not conside…
Browse files Browse the repository at this point in the history
…red redundant (#2942)
  • Loading branch information
paulromano authored Apr 11, 2024
1 parent 569c087 commit 256150f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion openmc/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions tests/unit_tests/test_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 256150f

Please sign in to comment.