Skip to content

Commit 5f767e5

Browse files
committed
Add tests for TRCL
1 parent 844e411 commit 5f767e5

1 file changed

Lines changed: 79 additions & 1 deletion

File tree

tests/test_geometry.py

Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from textwrap import dedent
22

3-
from pytest import mark, approx
3+
from pytest import mark, approx, param
44
from openmc_mcnp_adapter import mcnp_str_to_model
55

66

@@ -55,3 +55,81 @@ def test_likenbut():
5555
assert (0.0, 0.0, 0.0) not in cell.region
5656
assert (2.0, 0.9, 0.0) in cell.region
5757
assert (2.0, 1.1, 0.0) not in cell.region
58+
59+
60+
@mark.parametrize(
61+
"cell_card, surface_cards, points_inside, points_outside",
62+
[
63+
(
64+
"1 1 -1.0 -1 TRCL=(2.0 0.0 0.0)",
65+
("1 so 1.0",),
66+
[
67+
(2.0, 0.0, 0.0),
68+
(2.0, 0.9, 0.0),
69+
(2.0, 0.0, 0.9),
70+
],
71+
[
72+
(0.9, 0.0, 0.0),
73+
(2.0, 1.1, 0.0),
74+
(2.0, 0.0, 1.1),
75+
],
76+
),
77+
(
78+
"1 0 -1 TRCL=(1.0 0.0 0.0 0.0 -1.0 0.0 1.0 0.0 0.0 0.0 0.0 1.0)",
79+
("1 rpp -0.5 0.5 -0.25 0.25 -0.1 0.1",),
80+
[
81+
(1.0, 0.0, 0.0),
82+
(1.2, 0.0, 0.0),
83+
(1.0, 0.4, 0.0),
84+
(1.0, -0.4, 0.0),
85+
],
86+
[
87+
(0.7, 0.0, 0.0),
88+
(1.3, 0.0, 0.0),
89+
(1.0, 0.6, 0.0),
90+
(1.0, 0.0, 0.2),
91+
],
92+
),
93+
(
94+
"1 0 -1 *TRCL=(1.0 0.0 0.0 90.0 180.0 90.0 0.0 90.0 90.0 90.0 90.0 0.0)",
95+
("1 rpp -0.5 0.5 -0.25 0.25 -0.1 0.1",),
96+
[
97+
(1.0, 0.0, 0.0),
98+
(1.2, 0.0, 0.0),
99+
(1.0, 0.4, 0.0),
100+
(1.0, -0.4, 0.0),
101+
],
102+
[
103+
(0.7, 0.0, 0.0),
104+
(1.3, 0.0, 0.0),
105+
(1.0, 0.6, 0.0),
106+
(1.0, 0.0, 0.2),
107+
],
108+
),
109+
param(
110+
"1 0 -1 TRCL=(0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 -1)",
111+
("1 rpp -0.5 0.5 -0.25 0.25 -0.1 0.1",),
112+
[],
113+
[],
114+
marks=mark.xfail(reason="13-parameter TRCL not yet supported"),
115+
),
116+
],
117+
)
118+
def test_trcl(cell_card, surface_cards, points_inside, points_outside):
119+
surface_block = "\n".join(surface_cards)
120+
mcnp_str = dedent(f"""
121+
title
122+
{cell_card}
123+
124+
{surface_block}
125+
126+
m1 1001.80c 1.0
127+
""")
128+
model = mcnp_str_to_model(mcnp_str)
129+
cell = model.geometry.get_all_cells()[1]
130+
131+
for point in points_inside:
132+
assert point in cell.region
133+
134+
for point in points_outside:
135+
assert point not in cell.region

0 commit comments

Comments
 (0)