mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
adding plot function to DAGMCUnvierse (#3451)
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
This commit is contained in:
parent
23eab2c89b
commit
7a1cafa6c1
2 changed files with 27 additions and 3 deletions
|
|
@ -13,6 +13,7 @@ from .checkvalue import check_type, check_value
|
|||
from .surface import _BOUNDARY_TYPES
|
||||
from .bounding_box import BoundingBox
|
||||
from .utility_funcs import input_path
|
||||
from .plots import add_plot_params
|
||||
|
||||
|
||||
class DAGMCUniverse(openmc.UniverseBase):
|
||||
|
|
@ -566,6 +567,21 @@ class DAGMCUniverse(openmc.UniverseBase):
|
|||
fill = mats_per_id[dag_cell.fill.id] if dag_cell.fill else None
|
||||
self.add_cell(openmc.DAGMCCell(cell_id=dag_cell_id, fill=fill))
|
||||
|
||||
@add_plot_params
|
||||
def plot(self, *args, **kwargs):
|
||||
"""Display a slice plot of the DAGMCUniverse.
|
||||
"""
|
||||
model = openmc.Model()
|
||||
model.geometry = openmc.Geometry(self)
|
||||
|
||||
for mat_name in self.material_names:
|
||||
material = openmc.Material(name=mat_name)
|
||||
# Placeholder nuclide to ensure material is not empty
|
||||
material.add_nuclide('H1', 1.0)
|
||||
model.materials.append(material)
|
||||
|
||||
return model.plot(*args, **kwargs)
|
||||
|
||||
|
||||
class DAGMCCell(openmc.Cell):
|
||||
"""A cell class for DAGMC-based geometries.
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@ pytestmark = pytest.mark.skipif(
|
|||
not openmc.lib._dagmc_enabled(), reason="DAGMC CAD geometry is not enabled."
|
||||
)
|
||||
|
||||
def test_plotting_dagmc_geometry(request):
|
||||
"""Test plotting a DAGMC geometry with OpenMC. This is different to CSG
|
||||
geometry plotting as the path to the DAGMC file needs handling."""
|
||||
def test_plotting_dagmc_model(request):
|
||||
"""Test plotting a DAGMC model with OpenMC. This is different to CSG
|
||||
model plotting as the path to the DAGMC file needs handling."""
|
||||
|
||||
dag_universe = openmc.DAGMCUniverse(request.path.parent / 'dagmc.h5m')
|
||||
csg_with_dag_inside = dag_universe.bounded_universe()
|
||||
|
|
@ -30,3 +30,11 @@ def test_plotting_dagmc_geometry(request):
|
|||
model.settings.particles = 50
|
||||
|
||||
model.plot()
|
||||
|
||||
|
||||
def test_plotting_dagmc_universe(request):
|
||||
"""Test plotting a DAGMCUniverse with OpenMC. This is different to plotting
|
||||
UniverseBase as the materials are not defined withing the DAGMCUniverse."""
|
||||
|
||||
dag_universe = openmc.DAGMCUniverse(request.path.parent / 'dagmc.h5m')
|
||||
dag_universe.plot()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue