Skip to content
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
8 changes: 4 additions & 4 deletions src/openmc_mcnp_adapter/openmc_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,14 @@ def flip_sense(surf):
surf = surface_composite.XConeOneSided(x0=x0, y0=y0, z0=z0, r2=R2, up=up)
elif s['mnemonic'] == 'k/y':
surf = surface_composite.YConeOneSided(x0=x0, y0=y0, z0=z0, r2=R2, up=up)
elif s['mnemonic'] == 'k/z':
else:
surf = surface_composite.ZConeOneSided(x0=x0, y0=y0, z0=z0, r2=R2, up=up)
else:
if s['mnemonic'] == 'k/x':
surf = openmc.XCone(surface_id=s['id'], x0=x0, y0=y0, z0=z0, r2=R2)
elif s['mnemonic'] == 'k/y':
surf = openmc.YCone(surface_id=s['id'], x0=x0, y0=y0, z0=z0, r2=R2)
elif s['mnemonic'] == 'k/z':
else:
surf = openmc.ZCone(surface_id=s['id'], x0=x0, y0=y0, z0=z0, r2=R2)
elif s['mnemonic'] in ('kx', 'ky', 'kz'):
x, R2 = coeffs[:2]
Expand All @@ -279,14 +279,14 @@ def flip_sense(surf):
surf = surface_composite.XConeOneSided(x0=x, r2=R2, up=up)
elif s['mnemonic'] == 'ky':
surf = surface_composite.YConeOneSided(y0=x, r2=R2, up=up)
elif s['mnemonic'] == 'kz':
else:
surf = surface_composite.ZConeOneSided(z0=x, r2=R2, up=up)
else:
if s['mnemonic'] == 'kx':
surf = openmc.XCone(surface_id=s['id'], x0=x, r2=R2)
elif s['mnemonic'] == 'ky':
surf = openmc.YCone(surface_id=s['id'], y0=x, r2=R2)
elif s['mnemonic'] == 'kz':
else:
surf = openmc.ZCone(surface_id=s['id'], z0=x, r2=R2)
elif s['mnemonic'] == 'sq':
a, b, c, D, E, F, G, x, y, z = coeffs
Expand Down
29 changes: 29 additions & 0 deletions tests/test_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,21 @@ def test_trcl(cell_card, surface_cards, points_inside, points_outside):
assert point not in cell.region


def test_trcl_macrobody():
mcnp_str = dedent("""
title
1 0 -1 trcl=(2.0 0.0 0.0)

1 rpp -1.0 1.0 -1.0 1.0 -1.0 1.0

m1 1001.80c 1.0
""")
model = mcnp_str_to_model(mcnp_str)
cell = model.geometry.get_all_cells()[1]
assert (1.5, 0., 0.) in cell.region
assert (0., 0., 0.) not in cell.region


@mark.parametrize(
"keywords",
[
Expand Down Expand Up @@ -170,3 +185,17 @@ def test_fill_transformation(keywords):
assert geometry.find((2.0, 0.0, 0.0))[-1] is cells[2]
assert geometry.find((4.0, 0.0, 0.0))[-1] is cells[3]
assert geometry.find((0.0, 0.0, 0.0))[-1] is cells[3]


def test_cell_volume():
mcnp_str = dedent("""
title
1 0 -1 VOL=5.0

1 so 1.0

m1 1001.80c 1.0
""")
model = mcnp_str_to_model(mcnp_str)
cell = model.geometry.get_all_cells()[1]
assert cell.volume == 5.0
27 changes: 26 additions & 1 deletion tests/test_surfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
RectangularParallelepiped, RightCircularCylinder, ConicalFrustum, \
XConeOneSided, YConeOneSided, ZConeOneSided
from openmc_mcnp_adapter import mcnp_str_to_model, get_openmc_surfaces
from pytest import approx, mark
from pytest import approx, mark, raises


def convert_surface(mnemonic: str, params: Sequence[float]) -> openmc.Surface:
Expand Down Expand Up @@ -120,6 +120,16 @@ def test_plane_sense_rule4():
assert (1e10, 0., 0.) in +surf


def test_plane_invalid():
coeffs = (
0., 0., 0.,
0., 0., 1.,
0., 0., 2.,
)
with raises(ValueError):
convert_surface("p", coeffs)


def test_surface_transformation_with_tr_card():
mcnp_str = dedent("""
title
Expand Down Expand Up @@ -400,6 +410,21 @@ def test_box_macrobody():
assert surf.ax3_max.d / surf.ax3_max.c == approx(3.0)


def test_box_macrobody_inf():
coeffs = (0.0, 0.0, 0.0,
1.0, 0.0, 0.0,
0.0, 2.0, 0.0)
surf = convert_surface("box", coeffs)
assert isinstance(surf, OrthogonalBox)

# Check a few points; since it is infinite in z, any value in z should work
assert (0.5, 0.5, 0.0) in -surf
assert (0.5, 0.5, -100.0) in -surf
assert (0.5, 0.5, 100.0) in -surf
assert (0.5, -0.01, 0.0) in +surf
assert (1.01, 0.5, 0.0) in +surf


def test_rpp_macrobody():
coeffs = (-1.0, 2.0, -3.0, 4.0, 0.5, 5.5)
surf = convert_surface("rpp", coeffs)
Expand Down