mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
Updates to the Python API to support model generation with DAGMC universes.
This commit is contained in:
parent
d94710996f
commit
afaf3b04bf
5 changed files with 26 additions and 17 deletions
|
|
@ -27,7 +27,7 @@ class Cell(IDManagerMixin):
|
|||
automatically be assigned.
|
||||
name : str, optional
|
||||
Name of the cell. If not specified, the name is the empty string.
|
||||
fill : openmc.Material or openmc.Universe or openmc.Lattice or None or iterable of openmc.Material, optional
|
||||
fill : openmc.Material or openmc.UniverseBase or openmc.Lattice or None or iterable of openmc.Material, optional
|
||||
Indicates what the region of space is filled with
|
||||
region : openmc.Region, optional
|
||||
Region of space that is assigned to the cell.
|
||||
|
|
@ -38,7 +38,7 @@ class Cell(IDManagerMixin):
|
|||
Unique identifier for the cell
|
||||
name : str
|
||||
Name of the cell
|
||||
fill : openmc.Material or openmc.Universe or openmc.Lattice or None or iterable of openmc.Material
|
||||
fill : openmc.Material or openmc.UniverseBase or openmc.Lattice or None or iterable of openmc.Material
|
||||
Indicates what the region of space is filled with. If None, the cell is
|
||||
treated as a void. An iterable of materials is used to fill repeated
|
||||
instances of a cell with different materials.
|
||||
|
|
@ -156,7 +156,7 @@ class Cell(IDManagerMixin):
|
|||
def fill_type(self):
|
||||
if isinstance(self.fill, openmc.Material):
|
||||
return 'material'
|
||||
elif isinstance(self.fill, openmc.Universe):
|
||||
elif isinstance(self.fill, openmc.UniverseBase):
|
||||
return 'universe'
|
||||
elif isinstance(self.fill, openmc.Lattice):
|
||||
return 'lattice'
|
||||
|
|
@ -278,11 +278,10 @@ class Cell(IDManagerMixin):
|
|||
cv.check_type('cell.fill[i]', f, openmc.Material)
|
||||
|
||||
elif not isinstance(fill, (openmc.Material, openmc.Lattice,
|
||||
openmc.Universe)):
|
||||
openmc.UniverseBase)):
|
||||
msg = ('Unable to set Cell ID="{0}" to use a non-Material or '
|
||||
'Universe fill "{1}"'.format(self._id, fill))
|
||||
raise ValueError(msg)
|
||||
|
||||
self._fill = fill
|
||||
|
||||
# Info about atom content can now be invalid
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ from .cell import Cell
|
|||
from .material import Material
|
||||
from .mixin import IDManagerMixin
|
||||
from .surface import Surface
|
||||
from .universe import Universe
|
||||
from .universe import UniverseBase
|
||||
|
||||
|
||||
_FILTER_TYPES = (
|
||||
|
|
@ -408,8 +408,8 @@ class UniverseFilter(WithIDFilter):
|
|||
|
||||
Parameters
|
||||
----------
|
||||
bins : openmc.Universe, int, or iterable thereof
|
||||
The Universes to tally. Either openmc.Universe objects or their
|
||||
bins : openmc.UniverseBase, int, or iterable thereof
|
||||
The Universes to tally. Either openmc.UniverseBase objects or their
|
||||
Integral ID numbers can be used.
|
||||
filter_id : int
|
||||
Unique identifier for the filter
|
||||
|
|
@ -417,14 +417,14 @@ class UniverseFilter(WithIDFilter):
|
|||
Attributes
|
||||
----------
|
||||
bins : Iterable of Integral
|
||||
openmc.Universe IDs.
|
||||
openmc.UniverseBase IDs.
|
||||
id : int
|
||||
Unique identifier for the filter
|
||||
num_bins : Integral
|
||||
The number of filter bins
|
||||
|
||||
"""
|
||||
expected_type = Universe
|
||||
expected_type = UniverseBase
|
||||
|
||||
|
||||
class MaterialFilter(WithIDFilter):
|
||||
|
|
|
|||
|
|
@ -14,13 +14,13 @@ class Geometry:
|
|||
|
||||
Parameters
|
||||
----------
|
||||
root : openmc.Universe or Iterable of openmc.Cell, optional
|
||||
root : openmc.UniverseBase or Iterable of openmc.Cell, optional
|
||||
Root universe which contains all others, or an iterable of cells that
|
||||
should be used to create a root universe.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
root_universe : openmc.Universe
|
||||
root_universe : openmc.UniverseBase
|
||||
Root universe which contains all others
|
||||
bounding_box : 2-tuple of numpy.array
|
||||
Lower-left and upper-right coordinates of an axis-aligned bounding box
|
||||
|
|
@ -32,7 +32,7 @@ class Geometry:
|
|||
self._root_universe = None
|
||||
self._offsets = {}
|
||||
if root is not None:
|
||||
if isinstance(root, openmc.Universe):
|
||||
if isinstance(root, openmc.UniverseBase):
|
||||
self.root_universe = root
|
||||
else:
|
||||
univ = openmc.Universe()
|
||||
|
|
@ -50,8 +50,7 @@ class Geometry:
|
|||
|
||||
@root_universe.setter
|
||||
def root_universe(self, root_universe):
|
||||
check_type('root universe', root_universe,
|
||||
(openmc.Universe, openmc.DAGMCUniverse))
|
||||
check_type('root universe', root_universe, openmc.UniverseBase)
|
||||
self._root_universe = root_universe
|
||||
|
||||
def add_volume_information(self, volume_calc):
|
||||
|
|
|
|||
|
|
@ -488,7 +488,7 @@ class RectLattice(Lattice):
|
|||
|
||||
@Lattice.universes.setter
|
||||
def universes(self, universes):
|
||||
cv.check_iterable_type('lattice universes', universes, openmc.Universe,
|
||||
cv.check_iterable_type('lattice universes', universes, openmc.UniverseBase,
|
||||
min_depth=2, max_depth=3)
|
||||
self._universes = np.asarray(universes)
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from collections.abc import Iterable
|
|||
from copy import copy, deepcopy
|
||||
from numbers import Real
|
||||
import random
|
||||
from xml.etree import ElementTree as ET
|
||||
|
||||
import numpy as np
|
||||
|
||||
|
|
@ -677,10 +678,20 @@ class DAGMCUniverse(UniverseBase):
|
|||
def clone(self, clone_materials=True, clone_regions=True, memo=None):
|
||||
pass
|
||||
|
||||
def get_all_cells(self, memo=None):
|
||||
return OrderedDict()
|
||||
|
||||
def create_xml_subelement(self, xml_element, memo=None):
|
||||
|
||||
if memo and self in memo:
|
||||
return
|
||||
|
||||
if memo is not None:
|
||||
memo.add(self)
|
||||
|
||||
# Set xml element values
|
||||
dagmc_element = ET.Element('dagmc')
|
||||
dagmc_element.set('id', self.id)
|
||||
dagmc_element.set('id', str(self.id))
|
||||
dagmc_element.set('name', self.name)
|
||||
dagmc_element.set('filename', self.filename)
|
||||
xml_element.append(dagmc_element)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue