Some updates to DAGMC testing.

This commit is contained in:
Patrick Shriwise 2022-08-12 07:53:36 -05:00
parent bde64ed8f1
commit d47f41637f
4 changed files with 10 additions and 31 deletions

View file

@ -678,8 +678,8 @@ class DAGMCUniverse(UniverseBase):
@filename.setter
def filename(self, val):
cv.check_type('DAGMC filename', val, str)
self._filename = val
cv.check_type('DAGMC filename', val, (Path, str))
self._filename = str(val)
@property
def auto_geom_ids(self):

View file

@ -1,6 +1,7 @@
import openmc
import openmc.lib
from pathlib import Path
import pytest
from tests.testing_harness import PyAPITestHarness
@ -27,7 +28,7 @@ def model():
model.settings.dagmc = True
# geometry
dag_univ = openmc.DAGMCUniverse("dagmc.h5m")
dag_univ = openmc.DAGMCUniverse(Path("dagmc.h5m"))
model.geometry = openmc.Geometry(dag_univ)
# tally

View file

@ -53,28 +53,6 @@ class DAGMCUniverseTest(PyAPITestHarness):
# assigns the bound_dag_geometry to the model to test the type checks in model.Geometry setter
model.Geometry = bound_pincell_geometry
# checks that the bounding box is calculated correctly
bounding_box = pincell_univ.bounding_box
assert bounding_box[0].tolist() == [-25., -25., -25.]
assert bounding_box[1].tolist() == [25., 25., 25.]
# checks that the bounding region is six surfaces each with a vacuum boundary type
b_region = pincell_univ.bounding_region(bounded_type='box', boundary_type='vacuum')
assert isinstance(b_region, openmc.Region)
assert len(b_region.get_surfaces()) == 6
starting_id = 10000
for i, surface in enumerate(b_region.get_surfaces().values()):
assert surface.boundary_type == 'vacuum'
assert surface.id == 10000 + i
# checks that the bounding region is a single surface with a reflective boundary type
b_region = pincell_univ.bounding_region(bounded_type='sphere', boundary_type='reflective')
assert isinstance(b_region, openmc.Region)
assert len(b_region.get_surfaces()) == 1
for surface in list(b_region.get_surfaces().values()):
assert surface.boundary_type == 'reflective'
assert surface.id == 10000
# create a 2 x 2 lattice using the DAGMC pincell
pitch = np.asarray((24.0, 24.0))
lattice = openmc.RectLattice()

View file

@ -3,21 +3,21 @@ import pytest
from pathlib import Path
def test_bounding_box():
def test_bounding_box(request):
"""Checks that the DAGMCUniverse.bounding_box returns the correct values"""
u = openmc.DAGMCUniverse(str(Path(__file__).parent.resolve() / "dagmc/dagmc.h5m"))
u = openmc.DAGMCUniverse(Path(request.fspath).parent / "dagmc.h5m")
ll, ur = u.bounding_box
assert ll == pytest.approx((-25.0, -25.0, -25))
assert ur == pytest.approx((25.0, 25.0, 25))
def test_bounding_region():
def test_bounding_region(request):
"""Checks that the DAGMCUniverse.bounding_region() returns a region with
correct surfaces and boundary types"""
u = openmc.DAGMCUniverse(str(Path(__file__).parent.resolve() / "dagmc/dagmc.h5m"))
u = openmc.DAGMCUniverse(Path(request.fspath).parent / "dagmc.h5m")
region = u.bounding_region() # should default to bounded_type='box'
assert isinstance(region, openmc.Region)
@ -42,11 +42,11 @@ def test_bounding_region():
assert region.surface.boundary_type == "reflective"
def test_bounded_universe():
def test_bounded_universe(request):
"""Checks that the DAGMCUniverse.bounded_universe() returns a
openmc.Universe with correct surface ids and cell ids"""
u = openmc.DAGMCUniverse(str(Path(__file__).parent.resolve() / "dagmc/dagmc.h5m"))
u = openmc.DAGMCUniverse(Path(request.fspath).parent / "dagmc.h5m")
# bounded with defaults
bu = u.bounded_universe()