From 6f433fc429896ca0df716ea7d598c08e5d3edeb0 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Thu, 11 Aug 2022 17:29:42 +0100 Subject: [PATCH] unit tests DAGMCUniverse bounding_region bounding_box --- tests/unit_tests/test_dagmc_universe.py | 38 +++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 tests/unit_tests/test_dagmc_universe.py diff --git a/tests/unit_tests/test_dagmc_universe.py b/tests/unit_tests/test_dagmc_universe.py new file mode 100644 index 0000000000..3f5403693f --- /dev/null +++ b/tests/unit_tests/test_dagmc_universe.py @@ -0,0 +1,38 @@ +import openmc +import pytest + + +def test_bounding_box(): + + u = openmc.DAGMCUniverse("tests/regression_tests/dagmc/universes/dagmc.h5m") + + ll, ur = u.bounding_box + assert ll == pytest.approx((-25., -25., -25)) + assert ur == pytest.approx((25., 25., 25)) + + +def test_bounding_region(): + + u = openmc.DAGMCUniverse("tests/regression_tests/dagmc/universes/dagmc.h5m") + + region = u.bounding_region() # should default to bounded_type='box' + assert isinstance(region, openmc.Region) + assert len(region) == 6 + assert region[0].surface.type == 'x-plane' + assert region[1].surface.type == 'x-plane' + assert region[2].surface.type == 'y-plane' + assert region[3].surface.type == 'y-plane' + assert region[4].surface.type == 'z-plane' + assert region[5].surface.type == 'z-plane' + assert region[0].surface.boundary_type == 'vacuum' + assert region[1].surface.boundary_type == 'vacuum' + assert region[2].surface.boundary_type == 'vacuum' + assert region[3].surface.boundary_type == 'vacuum' + assert region[4].surface.boundary_type == 'vacuum' + assert region[5].surface.boundary_type == 'vacuum' + + region = u.bounding_region(bounded_type='sphere', boundary_type='reflective') + assert isinstance(region, openmc.Region) + assert isinstance(region, openmc.Halfspace) + assert region.surface.type == 'sphere' + assert region.surface.boundary_type == 'reflective'