Skip to content

Commit 172a1a9

Browse files
committed
Add test for x/y/z surfaces that produce cones
1 parent fdcbe00 commit 172a1a9

2 files changed

Lines changed: 34 additions & 1 deletion

File tree

src/openmc_mcnp_adapter/openmc_conversion.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,8 @@ def flip_sense(surf):
334334
# decide if we want the up or down part of the
335335
# cone since one sheet is used
336336
up = grad >= 0
337-
surf = cls_cone(z0=offset, r2=angle, up=up)
337+
kwargs = {f"{s['mnemonic']}0": offset, "r2": angle, "up": up}
338+
surf = cls_cone(**kwargs)
338339
else:
339340
raise NotImplementedError(f"{s['mnemonic']} surface with {len(coeffs)} parameters")
340341
elif s['mnemonic'] == 'rcc':

tests/test_surfaces.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,38 @@ def test_axisymmetric_surfaces(mnemonic, params, expected_type, attr, value):
289289
assert getattr(surf, attr) == approx(value)
290290

291291

292+
@mark.parametrize("mnemonic", ["x", "y", "z"])
293+
def test_axisymmetric_surfaces_cone(mnemonic):
294+
# cone with a r=1 bottom at plane=0 and a r=2 top at plane=3
295+
coeffs = (0.0, 1.0, 3.0, 2.0)
296+
surf = convert_surface(mnemonic, coeffs)
297+
298+
# Helper to build a point (x,y,z) given radial distance r and axial coord a
299+
def pt(r: float, a: float):
300+
if mnemonic == "x":
301+
return (a, r, 0.0) # axial along x; radius in y
302+
elif mnemonic == "y":
303+
return (r, a, 0.0) # axial along y; radius in x
304+
else: # "z"
305+
return (r, 0.0, a) # axial along z; radius in x
306+
307+
# Points near the r=1 slice (at axial ~ 0)
308+
assert pt(0.0, 0.01) in -surf
309+
assert pt(0.0, -0.01) in -surf
310+
assert pt(0.99, 0.01) in -surf
311+
assert pt(1.05, 0.01) in +surf
312+
313+
# Points near the r=2 slice (at axial ~ 3)
314+
assert pt(1.99, 2.99) in -surf
315+
assert pt(2.0, 2.99) in +surf
316+
assert pt(0.0, 2.99) in -surf
317+
assert pt(0.0, 3.01) in -surf
318+
319+
# Points between the r=1 and r=2 slices (at axial = 1.5)
320+
assert pt(1.49, 1.5) in -surf
321+
assert pt(1.51, 1.5) in +surf
322+
323+
292324
@mark.parametrize(
293325
"mnemonic, params, expected_type, up_expected",
294326
[

0 commit comments

Comments
 (0)