11from textwrap import dedent
22
3- from pytest import mark
3+ from pytest import mark , approx
44from 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