Skip to content

Commit 4a1e366

Browse files
committed
Add test for cell complement
1 parent cb80e92 commit 4a1e366

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

tests/test_geometry.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from textwrap import dedent
2+
3+
from pytest import mark
4+
from openmc_mcnp_adapter import mcnp_str_to_model
5+
6+
7+
@mark.parametrize("whitespace", ["", " ", "\t"])
8+
def test_cell_complement(whitespace):
9+
# Cell 2 corresponds to r < 2 intersected with z > 0
10+
mcnp_str = dedent(f"""
11+
title
12+
100 1.0 +1 : -2
13+
2 1.0 #{whitespace}100
14+
15+
1 so 2.0
16+
2 pz 0.0
17+
18+
m1 1001.80c 1.0
19+
""")
20+
model = mcnp_str_to_model(mcnp_str)
21+
cell = model.geometry.get_all_cells()[2]
22+
23+
# Check various points
24+
assert (0., 0., 0.1) in cell.region
25+
assert (0., 0., -0.1) not in cell.region
26+
assert (0., 0., 1.99) in cell.region
27+
assert (0., 0., 2.01) not in cell.region
28+
assert (1., 1., 1.) in cell.region
29+
assert (2., 0., 1.) not in cell.region

0 commit comments

Comments
 (0)