Skip to content

Commit cb80e92

Browse files
committed
Add surface transformation and non-axis-aligned RCC tests
1 parent 172a1a9 commit cb80e92

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

tests/test_surfaces.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from collections.abc import Sequence
22
from textwrap import dedent
33

4+
import numpy as np
45
import openmc
56
from openmc.model.surface_composite import OrthogonalBox, \
67
RectangularParallelepiped, RightCircularCylinder, ConicalFrustum, \
@@ -119,6 +120,23 @@ def test_plane_sense_rule4():
119120
assert (1e10, 0., 0.) in +surf
120121

121122

123+
def test_surface_transformation_with_tr_card():
124+
mcnp_str = dedent("""
125+
title
126+
1 0 -1
127+
128+
1 1 pz 0.0
129+
130+
tr1 0.0 1.0 1.0 1.0 0.0 0.0 0.0 0.0 1.0 0.0 -1.0 0.0
131+
""")
132+
model = mcnp_str_to_model(mcnp_str)
133+
surf = model.geometry.get_all_surfaces()[1]
134+
135+
# The transformed plane corresponds to -y + 1 = 0, so y > 1 is negative sense
136+
assert (0.0, 1.1, 1.0) in -surf
137+
assert (0.0, 0.9, 1.0) in +surf
138+
139+
122140
@mark.parametrize(
123141
"mnemonic, params",
124142
[
@@ -416,6 +434,27 @@ def test_rcc_macrobody(coeffs, expected_bottom, expected_top, r, coeff):
416434
assert surf.top.d / getattr(surf.top, coeff) == approx(expected_top)
417435

418436

437+
def test_rcc_macrobody_non_axis_aligned():
438+
coeffs = (0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.5)
439+
surf = convert_surface("rcc", coeffs)
440+
assert isinstance(surf, RightCircularCylinder)
441+
442+
# Points along and around the axis defined by the height vector (1, 1, 0)
443+
midpoint = (0.5, 0.5, 0.0)
444+
axis_unit = np.array(coeffs[3:6])
445+
446+
inside_point = (midpoint[0], midpoint[1], 0.1)
447+
outside_radial = (midpoint[0], midpoint[1], 0.6)
448+
below_bottom = -0.1 * axis_unit
449+
top = np.array((1.0, 1.0, 0.0))
450+
above_top = top + 0.1 * axis_unit
451+
452+
assert inside_point in -surf
453+
assert outside_radial in +surf
454+
assert below_bottom in +surf
455+
assert above_top in +surf
456+
457+
419458
def test_trc_macrobody():
420459
coeffs = (0.0, 0.0, 0.0, 0.0, 0.0, 10.0, 1.0, 2.0)
421460
surf = convert_surface("trc", coeffs)

0 commit comments

Comments
 (0)