Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that two surfaces with different boundary type are not considered redundant #2942

Merged
merged 2 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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