mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
Differentiating between geometry and material ID updates in the Python API.
This commit is contained in:
parent
fdcc1ddb7b
commit
cdcc9181f9
6 changed files with 43 additions and 20 deletions
|
|
@ -653,16 +653,25 @@ class DAGMCUniverse(UniverseBase):
|
|||
Name of the universe
|
||||
filename : str
|
||||
Path to the DAGMC file used to represent this universe.
|
||||
auto_ids : bool
|
||||
auto_geom_ids : bool
|
||||
Set IDs automatically on initialization (True) or report overlaps
|
||||
in ID space between CSG and DAGMC (False)
|
||||
auto_mat_ids : bool
|
||||
Set IDs automatically on initialization (True) or report overlaps
|
||||
in ID space between OpenMC and UWUW materials (False)
|
||||
"""
|
||||
|
||||
def __init__(self, filename, universe_id=None, name='', auto_ids=False):
|
||||
def __init__(self,
|
||||
filename,
|
||||
universe_id=None,
|
||||
name='',
|
||||
auto_geom_ids=False,
|
||||
auto_mat_ids=False):
|
||||
super().__init__(universe_id, name)
|
||||
# Initialize class attributes
|
||||
self.filename = filename
|
||||
self.auto_ids = auto_ids
|
||||
self.auto_geom_ids = auto_geom_ids
|
||||
self.auto_mat_ids = auto_mat_ids
|
||||
|
||||
def __repr__(self):
|
||||
fmt_str = '{: <16}=\t{}\n'
|
||||
|
|
@ -681,13 +690,22 @@ class DAGMCUniverse(UniverseBase):
|
|||
self._filename = val
|
||||
|
||||
@property
|
||||
def auto_ids(self):
|
||||
return self._auto_ids
|
||||
def auto_geom_ids(self):
|
||||
return self._auto_geom_ids
|
||||
|
||||
@auto_ids.setter
|
||||
def auto_ids(self, val):
|
||||
cv.check_type('DAGMC auto ids', val, bool)
|
||||
self._auto_ids = val
|
||||
@auto_geom_ids.setter
|
||||
def auto_geom_ids(self, val):
|
||||
cv.check_type('DAGMC automatic geometry ids', val, bool)
|
||||
self._auto_geom_ids = val
|
||||
|
||||
@property
|
||||
def auto_mat_ids(self):
|
||||
return self._auto_mat_ids
|
||||
|
||||
@auto_geom_ids.setter
|
||||
def auto_mat_ids(self, val):
|
||||
cv.check_type('DAGMC automatic material ids', val, bool)
|
||||
self._auto_mat_ids = val
|
||||
|
||||
def clone(self, clone_materials=True, clone_regions=True, memo=None):
|
||||
pass
|
||||
|
|
@ -710,7 +728,9 @@ class DAGMCUniverse(UniverseBase):
|
|||
dagmc_element = ET.Element('dagmc')
|
||||
dagmc_element.set('id', str(self.id))
|
||||
dagmc_element.set('name', self.name)
|
||||
if self.auto_ids:
|
||||
dagmc_element.set('auto_ids', 'true')
|
||||
if self.auto_geom_ids:
|
||||
dagmc_element.set('auto_geom_ids', 'true')
|
||||
if self.auto_mat_ids:
|
||||
dagmc_element.set('auto_mat_ids', 'true')
|
||||
dagmc_element.set('filename', self.filename)
|
||||
xml_element.append(dagmc_element)
|
||||
|
|
|
|||
|
|
@ -223,9 +223,15 @@ DAGUniverse::DAGUniverse(pugi::xml_node node) {
|
|||
}
|
||||
|
||||
adjust_geometry_ids_ = false;
|
||||
if (check_for_node(node, "auto_ids")) {
|
||||
adjust_geometry_ids_ = get_node_value_bool(node, "auto_ids");
|
||||
if (check_for_node(node, "auto_geom_ids")) {
|
||||
adjust_geometry_ids_ = get_node_value_bool(node, "auto_geom_ids");
|
||||
}
|
||||
|
||||
adjust_material_ids_ = false;
|
||||
if (check_for_node(node, "auto_mat_ids")) {
|
||||
adjust_geometry_ids_ = get_node_value_bool(node, "auto_mat_ids");
|
||||
}
|
||||
|
||||
initialize();
|
||||
}
|
||||
|
||||
|
|
@ -280,8 +286,6 @@ void DAGUniverse::initialize() {
|
|||
// notify user if UWUW materials are going to be used
|
||||
if (using_uwuw) {
|
||||
write_message("Found UWUW Materials in the DAGMC geometry file.", 6);
|
||||
|
||||
|
||||
}
|
||||
|
||||
// load the DAGMC geometry
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<geometry>
|
||||
<dagmc auto_ids="true" filename="dagmc.h5m" id="9" name="" />
|
||||
<dagmc auto_geom_ids="true" auto_mat_ids="true" filename="dagmc.h5m" id="9" name="" />
|
||||
</geometry>
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<materials>
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@ class UWUWTest(PyAPITestHarness):
|
|||
model.settings.export_to_xml()
|
||||
|
||||
# geometry
|
||||
dag_univ = openmc.DAGMCUniverse("dagmc.h5m")
|
||||
dag_univ.auto_ids = True
|
||||
dag_univ = openmc.DAGMCUniverse("dagmc.h5m", auto_geom_ids=True)
|
||||
model.geometry = openmc.Geometry(root=dag_univ)
|
||||
|
||||
# tally
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<geometry>
|
||||
<cell fill="9" id="13" region="9 -10 11 -12 13 -14" universe="10" />
|
||||
<dagmc auto_ids="true" filename="dagmc.h5m" id="9" name="" />
|
||||
<dagmc auto_geom_ids="true" auto_mat_ids="true" filename="dagmc.h5m" id="9" name="" />
|
||||
<surface boundary="reflective" coeffs="-24.0" id="9" name="left" type="x-plane" />
|
||||
<surface boundary="reflective" coeffs="24.0" id="10" name="right" type="x-plane" />
|
||||
<surface boundary="reflective" coeffs="-24.0" id="11" name="front" type="y-plane" />
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class DAGMCUniverseTest(PyAPITestHarness):
|
|||
|
||||
### GEOMETRY ###
|
||||
# create the DAGMC universe
|
||||
pincell_univ = openmc.DAGMCUniverse(filename='dagmc.h5m', auto_ids=True)
|
||||
pincell_univ = openmc.DAGMCUniverse(filename='dagmc.h5m', auto_geom_ids=True)
|
||||
|
||||
left = openmc.XPlane(x0=-24.0, name='left', boundary_type='reflective')
|
||||
right = openmc.XPlane(x0=24.0, name='right', boundary_type='reflective')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue