diff --git a/src/dagmc.cpp b/src/dagmc.cpp index 29e89b4bc..1e6f3d02a 100644 --- a/src/dagmc.cpp +++ b/src/dagmc.cpp @@ -290,7 +290,7 @@ void load_dagmc_geometry() if (c->material_[0] == MATERIAL_VOID) { continue; } - auto& mat = model::materials[c->material_[0]]; + auto& mat = model::materials[model::material_map[c->material_[0]]]; if (model::DAG->has_prop(vol_handle, "temp")) { rval = model::DAG->prop_value(vol_handle, "temp", temp_value); MB_CHK_ERR_CONT(rval); diff --git a/src/summary.cpp b/src/summary.cpp index 500a5c15c..d2721f97e 100644 --- a/src/summary.cpp +++ b/src/summary.cpp @@ -92,6 +92,7 @@ void write_geometry(hid_t file) #ifdef DAGMC if (settings::dagmc) { write_attribute(geom_group, "dagmc", 1); + close_group(geom_group); return; } #endif diff --git a/tests/regression_tests/dagmc/legacy/dagmc.h5m b/tests/regression_tests/dagmc/legacy/dagmc.h5m index c90b6d674..fbbe9a34a 100644 Binary files a/tests/regression_tests/dagmc/legacy/dagmc.h5m and b/tests/regression_tests/dagmc/legacy/dagmc.h5m differ diff --git a/tests/regression_tests/dagmc/legacy/inputs_true.dat b/tests/regression_tests/dagmc/legacy/inputs_true.dat index 8ca49c324..056a7eb9d 100644 --- a/tests/regression_tests/dagmc/legacy/inputs_true.dat +++ b/tests/regression_tests/dagmc/legacy/inputs_true.dat @@ -1,6 +1,6 @@ - + @@ -22,6 +22,8 @@ -4 -4 -4 4 4 4 + 7 + 50.0 true diff --git a/tests/regression_tests/dagmc/legacy/test.py b/tests/regression_tests/dagmc/legacy/test.py index b6f2f55e2..38c3c4267 100644 --- a/tests/regression_tests/dagmc/legacy/test.py +++ b/tests/regression_tests/dagmc/legacy/test.py @@ -5,10 +5,19 @@ from openmc.stats import Box import pytest from tests.testing_harness import PyAPITestHarness +import numpy as np + pytestmark = pytest.mark.skipif( not openmc.capi._dagmc_enabled(), reason="DAGMC CAD geometry is not enabled.") + +class DAGMCPyAPITestHarness(PyAPITestHarness): + + def _compare_inputs(self): + super()._compare_inputs() + + def test_dagmc(): model = openmc.model.Model() @@ -16,6 +25,7 @@ def test_dagmc(): model.settings.batches = 5 model.settings.inactive = 0 model.settings.particles = 100 + model.settings.temperature = {'tolerance': 50.0} source = openmc.Source(space=Box([-4, -4, -4], [ 4, 4, 4])) @@ -34,6 +44,7 @@ def test_dagmc(): u235.add_nuclide('U235', 1.0, 'ao') u235.set_density('g/cc', 11) u235.id = 40 + u235.temperature = 320 water = openmc.Material(name="water") water.add_nuclide('H1', 2.0, 'ao') @@ -46,4 +57,21 @@ def test_dagmc(): model.materials = mats harness = PyAPITestHarness('statepoint.5.h5', model=model) + model.settings.verbosity = 1 + harness._build_inputs() + + # check cell temps as well here + openmc.capi.init([]) + + expected_temps = { 1 : 320.0, # assigned by material + 2 : 300.0, # assigned in dagmc file + 3 : 293.6 } # assigned by default + + for cell_id, temp in expected_temps.items(): + capi_cell = openmc.capi.cells[cell_id] + assert np.isclose(capi_cell.get_temperature(), temp) + + openmc.capi.finalize() + + model.settings.verbosity = 7 harness.main()