Skip to content
Open
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
37 changes: 21 additions & 16 deletions src/openmc_mcnp_adapter/openmc_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def flip_sense(surf):
warnings.simplefilter("ignore", openmc.IDWarning)
surf = surf.translate(displacement, inplace=True)
if rotation is not None:
surf = surf.rotate(rotation, pivot=displacement, inplace=True)
surf = surf.rotate(rotation, pivot=displacement, inplace=True)

openmc_surfaces[s['id']] = surf

Expand Down Expand Up @@ -347,21 +347,26 @@ def get_openmc_universes(cells, surfaces, materials, data):
else:
c['parameters']['fill'] = f'{fill} {trcl}'

if not trcl.startswith('('):
raise NotImplementedError(
'TRn card not supported (cell {}).'.format(c['id']))

# Drop parentheses
trcl = trcl[1:-1].split()

vector = tuple(float(c) for c in trcl[:3])
c['_region'] = c['_region'].translate(vector, translate_memo)
# Apply transformation to region
vector = None
rotation_matrix = None

if len(trcl) > 3:
rotation_matrix = np.array([float(x) for x in trcl[3:]]).reshape((3, 3))
if use_degrees:
rotation_matrix = np.cos(rotation_matrix * pi/180.0)
print(rotation_matrix)
# check for a TRn card
if not trcl.startswith('('):
vector, rotation = data['tr'][int(trcl)]
else:
# Drop parentheses
trcl = trcl[1:-1].split()
vector = tuple(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 use_degrees:
rotation_matrix = np.cos(rotation_matrix * pi/180.0)

if vector is not None:
c['_region'] = c['_region'].translate(vector, translate_memo)

if rotation_matrix is not None:
c['_region'] = c['_region'].rotate(rotation_matrix.T, pivot=vector)

# Update surfaces dictionary with new surfaces
Expand Down Expand Up @@ -646,7 +651,7 @@ def get_universe(uid):

elif c['material'] > 0:
cell.fill = mat

if 'vol' in c["parameters"]:
cell.volume = float(c["parameters"]["vol"])

Expand Down