mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
OpenMOC compatiblity module now supports complex regions; fixed major slow down in MGXS Library statepoint loading
This commit is contained in:
parent
0cc4b08c11
commit
b74c6f065f
2 changed files with 61 additions and 37 deletions
|
|
@ -919,23 +919,6 @@ class MGXS(object):
|
|||
'linked with a summary file'
|
||||
raise ValueError(msg)
|
||||
|
||||
# Override the domain object that loaded from an OpenMC summary file
|
||||
# NOTE: This is necessary for micro cross-sections which require
|
||||
# the isotopic number densities as computed by OpenMC
|
||||
geom = statepoint.summary.geometry
|
||||
if self.domain_type in ('cell', 'distribcell'):
|
||||
self.domain = geom.get_all_cells()[self.domain.id]
|
||||
elif self.domain_type == 'universe':
|
||||
self.domain = geom.get_all_universes()[self.domain.id]
|
||||
elif self.domain_type == 'material':
|
||||
self.domain = geom.get_all_materials()[self.domain.id]
|
||||
elif self.domain_type == 'mesh':
|
||||
self.domain = statepoint.meshes[self.domain.id]
|
||||
else:
|
||||
msg = 'Unable to load data from a statepoint for domain type {0} ' \
|
||||
'which is not yet supported'.format(self.domain_type)
|
||||
raise ValueError(msg)
|
||||
|
||||
# Use tally "slicing" to ensure that tallies correspond to our domain
|
||||
# NOTE: This is important if tally merging was used
|
||||
if self.domain_type == 'mesh':
|
||||
|
|
|
|||
|
|
@ -312,6 +312,7 @@ def get_openmoc_cell(openmc_cell):
|
|||
|
||||
if openmc_cell.fill_type == 'material':
|
||||
openmoc_cell.setFill(get_openmoc_material(fill))
|
||||
print('set fill to material {} {}'.format(fill.id, fill.name))
|
||||
elif openmc_cell.fill_type == 'universe':
|
||||
openmoc_cell.setFill(get_openmoc_universe(fill))
|
||||
else:
|
||||
|
|
@ -324,26 +325,9 @@ def get_openmoc_cell(openmc_cell):
|
|||
translation = np.asarray(openmc_cell.translation, dtype=np.float64)
|
||||
openmoc_cell.setTranslation(translation)
|
||||
|
||||
# Add surfaces to OpenMOC cell from OpenMC cell region. Right now this only
|
||||
# works if the region is a single half-space or an intersection of
|
||||
# half-spaces, i.e., no complex cells.
|
||||
region = openmc_cell.region
|
||||
if region is not None:
|
||||
if isinstance(region, openmc.Halfspace):
|
||||
surface = region.surface
|
||||
halfspace = -1 if region.side == '-' else 1
|
||||
openmoc_cell.addSurface(halfspace, get_openmoc_surface(surface))
|
||||
elif isinstance(region, openmc.Intersection):
|
||||
for node in region.nodes:
|
||||
if not isinstance(node, openmc.Halfspace):
|
||||
raise NotImplementedError("Complex cells not yet "
|
||||
"supported in OpenMOC.")
|
||||
surface = node.surface
|
||||
halfspace = -1 if node.side == '-' else 1
|
||||
openmoc_cell.addSurface(halfspace, get_openmoc_surface(surface))
|
||||
else:
|
||||
raise NotImplementedError("Complex cells not yet supported "
|
||||
"in OpenMOC.")
|
||||
# Convert OpenMC's cell region to an equivalent OpenMOC region
|
||||
if openmc_cell.region is not None:
|
||||
openmoc_cell.setRegion(get_openmoc_region(openmc_cell.region))
|
||||
|
||||
# Add the OpenMC Cell to the global collection of all OpenMC Cells
|
||||
OPENMC_CELLS[cell_id] = openmc_cell
|
||||
|
|
@ -354,6 +338,63 @@ def get_openmoc_cell(openmc_cell):
|
|||
return openmoc_cell
|
||||
|
||||
|
||||
def get_openmoc_region(openmc_region):
|
||||
"""Return an OpenMOC region corresponding to an OpenMC region.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
openmc_region : openmc.Region
|
||||
OpenMC region
|
||||
|
||||
Returns
|
||||
-------
|
||||
openmoc_region : openmoc.Region
|
||||
Equivalent OpenMOC region
|
||||
|
||||
"""
|
||||
|
||||
cv.check_type('openmc_region', openmc_region, openmc.Region)
|
||||
|
||||
# Add surfaces to OpenMOC cell from OpenMC cell region
|
||||
if isinstance(openmc_region, openmc.Halfspace):
|
||||
surface = openmc_region.surface
|
||||
halfspace = -1 if openmc_region.side == '-' else 1
|
||||
openmoc_region = \
|
||||
openmoc.Halfspace(halfspace, get_openmoc_surface(surface))
|
||||
elif isinstance(openmc_region, openmc.Intersection):
|
||||
openmoc_region = openmoc.Intersection()
|
||||
for openmc_node in openmc_region.nodes:
|
||||
openmoc_region.addNode(get_openmoc_region(openmc_node))
|
||||
elif isinstance(openmc_region, openmc.Union):
|
||||
openmoc_region = openmoc.Union()
|
||||
for openmc_node in openmc_region.nodes:
|
||||
openmoc_region.addNode(get_openmoc_region(openmc_node))
|
||||
elif isinstance(openmc_region, openmc.Complement):
|
||||
openmoc_region = openmoc.Complement()
|
||||
openmoc_region.addNode(get_openmoc_region(openmc_region.node))
|
||||
|
||||
return openmoc_region
|
||||
|
||||
|
||||
# FIXME:
|
||||
def get_openmc_region(openmoc_region):
|
||||
"""Return an OpenMC region corresponding to an OpenMOC region.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
openmoc_region : openmoc.Region
|
||||
OpenMOC region
|
||||
|
||||
Returns
|
||||
-------
|
||||
openmc_region : openmc.Region
|
||||
Equivalent OpenMC region
|
||||
|
||||
"""
|
||||
|
||||
cv.check_type('openmoc_region', openmoc_region, openmoc.Region)
|
||||
|
||||
|
||||
def get_openmc_cell(openmoc_cell):
|
||||
"""Return an OpenMC cell corresponding to an OpenMOC cell.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue