diff --git a/src/openmc_mcnp_adapter/openmc_conversion.py b/src/openmc_mcnp_adapter/openmc_conversion.py index 6b0caea..af48f50 100644 --- a/src/openmc_mcnp_adapter/openmc_conversion.py +++ b/src/openmc_mcnp_adapter/openmc_conversion.py @@ -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 @@ -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 @@ -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"])