Skip to content

Commit 844e411

Browse files
committed
Add test for LIKE n BUT
1 parent 4a1e366 commit 844e411

2 files changed

Lines changed: 32 additions & 4 deletions

File tree

src/openmc_mcnp_adapter/parse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
_KEYWORDS = [
1414
r'\*?trcl', r'\*?fill', 'tmp', 'u', 'lat',
1515
'imp:.', 'vol', 'pwt', 'ext:.', 'fcl', 'wwn', 'dxc', 'nonu', 'pd',
16-
'elpt', 'cosy', 'bflcl', 'unc',
16+
'elpt', 'cosy', 'bflcl', 'unc', 'mat', 'rho',
1717
'pmt' # D1SUNED-specific
1818
]
1919
_ANY_KEYWORD = '|'.join(f'(?:{k})' for k in _KEYWORDS)

tests/test_geometry.py

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

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

66

@@ -9,8 +9,8 @@ def test_cell_complement(whitespace):
99
# Cell 2 corresponds to r < 2 intersected with z > 0
1010
mcnp_str = dedent(f"""
1111
title
12-
100 1.0 +1 : -2
13-
2 1.0 #{whitespace}100
12+
100 1 1.0 +1 : -2
13+
2 1 1.0 #{whitespace}100
1414
1515
1 so 2.0
1616
2 pz 0.0
@@ -27,3 +27,31 @@ def test_cell_complement(whitespace):
2727
assert (0., 0., 2.01) not in cell.region
2828
assert (1., 1., 1.) in cell.region
2929
assert (2., 0., 1.) not in cell.region
30+
31+
32+
def test_likenbut():
33+
mcnp_str = dedent("""
34+
title
35+
1 1 -1.0 -1
36+
2 LIKE 1 BUT MAT=2 RHO=-2.0 TRCL=(2.0 0.0 0.0)
37+
38+
1 so 1.0
39+
40+
m1 1001.80c 1.0
41+
m2 1002.80c 1.0
42+
""")
43+
model = mcnp_str_to_model(mcnp_str)
44+
cell = model.geometry.get_all_cells()[2]
45+
46+
# Material should be changed to m2
47+
mat = cell.fill
48+
assert 'H2' in mat.get_nuclide_densities()
49+
50+
# Density should be 2.0 g/cm3
51+
assert mat.get_mass_density() == approx(2.0)
52+
53+
# Points should correspond to sphere of r=1 centered at (2, 0, 0)
54+
assert (2.0, 0.0, 0.0) in cell.region
55+
assert (0.0, 0.0, 0.0) not in cell.region
56+
assert (2.0, 0.9, 0.0) in cell.region
57+
assert (2.0, 1.1, 0.0) not in cell.region

0 commit comments

Comments
 (0)