|
1 | 1 | from collections.abc import Sequence |
2 | 2 | from textwrap import dedent |
3 | 3 |
|
| 4 | +import numpy as np |
4 | 5 | import openmc |
5 | 6 | from openmc.model.surface_composite import OrthogonalBox, \ |
6 | 7 | RectangularParallelepiped, RightCircularCylinder, ConicalFrustum, \ |
@@ -119,6 +120,23 @@ def test_plane_sense_rule4(): |
119 | 120 | assert (1e10, 0., 0.) in +surf |
120 | 121 |
|
121 | 122 |
|
| 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 | + |
122 | 140 | @mark.parametrize( |
123 | 141 | "mnemonic, params", |
124 | 142 | [ |
@@ -416,6 +434,27 @@ def test_rcc_macrobody(coeffs, expected_bottom, expected_top, r, coeff): |
416 | 434 | assert surf.top.d / getattr(surf.top, coeff) == approx(expected_top) |
417 | 435 |
|
418 | 436 |
|
| 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 | + |
419 | 458 | def test_trc_macrobody(): |
420 | 459 | coeffs = (0.0, 0.0, 0.0, 0.0, 0.0, 10.0, 1.0, 2.0) |
421 | 460 | surf = convert_surface("trc", coeffs) |
|
0 commit comments