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
23 changes: 18 additions & 5 deletions src/openmc_mcnp_adapter/openmc_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,14 +563,22 @@ def get_openmc_universes(cells, surfaces, materials, data):
# Drop parentheses
trcl = trcl[1:-1].split()

vector = tuple(float(c) for c in trcl[:3])
c['_region'] = c['_region'].translate(vector, translate_memo)
# Get displacement vector
vector = np.array([float(c) for c in trcl[:3]])

if len(trcl) > 3:
rotation_matrix = np.array([float(x) for x in trcl[3:]]).reshape((3, 3))
# If displacement vector origin is -1, reverse displacement vector
if len(trcl) == 13:
if int(trcl[12]) == -1:
vector *= -1
c['_region'] = c['_region'].translate(vector, translate_memo)

rotation_matrix = np.array([float(x) for x in trcl[3:12]]).reshape((3, 3))
if use_degrees:
rotation_matrix = np.cos(rotation_matrix * pi/180.0)
c['_region'] = c['_region'].rotate(rotation_matrix.T, pivot=vector)
else:
c['_region'] = c['_region'].translate(vector, translate_memo)

# Update surfaces dictionary with new surfaces
for surf_id, surf in c['_region'].get_surfaces().items():
Expand Down Expand Up @@ -846,8 +854,13 @@ def get_universe(uid):
if ftrans is not None:
ftrans = ftrans.split()
if len(ftrans) > 3:
cell.translation = tuple(float(x) for x in ftrans[:3])
rotation_matrix = np.array([float(x) for x in ftrans[3:]]).reshape((3, 3))
vector = np.array([float(x) for x in ftrans[:3]])
if len(ftrans) == 13:
if int(ftrans[12]) == -1:
vector *= -1

cell.translation = tuple(vector)
rotation_matrix = np.array([float(x) for x in ftrans[3:12]]).reshape((3, 3))
if use_degrees:
rotation_matrix = np.cos(rotation_matrix * pi/180.0)
cell.rotation = rotation_matrix
Expand Down
3 changes: 3 additions & 0 deletions src/openmc_mcnp_adapter/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ def parse_data(section):
if len(values) >= 3:
displacement = np.array([float(x) for x in values[:3]])
if len(values) >= 12:
if len(values) == 13:
if int(values[12]) == -1:
displacement *= -1
rotation = np.array([float(x) for x in values[3:12]]).reshape((3,3)).T
if use_degrees:
rotation = np.cos(rotation * pi/180.0)
Expand Down
12 changes: 10 additions & 2 deletions tests/test_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,14 @@ def test_trcl_macrobody():
"FILL=10(2.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0)",
"FILL=10 *TRCL=(2.0 0.0 0.0 0.0 90.0 90.0 90.0 0.0 90.0 90.0 90.0 0.0)",
"*FILL=10(2.0 0.0 0.0 0.0 90.0 90.0 90.0 0.0 90.0 90.0 90.0 0.0)",
"FILL=10 TRCL=(2.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 1)",
"FILL=10 TRCL=(-2.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 -1)",
"FILL=10(2.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 1)",
"FILL=10(-2.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 -1)",
"FILL=10 *TRCL=(2.0 0.0 0.0 0.0 90.0 90.0 90.0 0.0 90.0 90.0 90.0 0.0 1)",
"FILL=10 *TRCL=(-2.0 0.0 0.0 0.0 90.0 90.0 90.0 0.0 90.0 90.0 90.0 0.0 -1)",
"*FILL=10(2.0 0.0 0.0 0.0 90.0 90.0 90.0 0.0 90.0 90.0 90.0 0.0 1)",
"*FILL=10(-2.0 0.0 0.0 0.0 90.0 90.0 90.0 0.0 90.0 90.0 90.0 0.0 -1)",
"FILL=10(1)",
"FILL=10(2)",
"FILL=10(3)",
Expand All @@ -175,8 +183,8 @@ def test_fill_transformation(keywords):
2 so 1.0

m1 1001.80c 1.0
tr1 2.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0
*tr2 2.0 0.0 0.0 0.0 90.0 90.0 90.0 0.0 90.0 90.0 90.0 0.0
tr1 2.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 1
*tr2 -2.0 0.0 0.0 0.0 90.0 90.0 90.0 0.0 90.0 90.0 90.0 0.0 -1
tr3 2.0 0.0 0.0
""")
model = mcnp_str_to_model(mcnp_str)
Expand Down