diff --git a/openmc/deplete/coupled_operator.py b/openmc/deplete/coupled_operator.py index a8c1fa156..669e98dda 100644 --- a/openmc/deplete/coupled_operator.py +++ b/openmc/deplete/coupled_operator.py @@ -460,7 +460,6 @@ class CoupledOperator(OpenMCOperator): # Run OpenMC openmc.lib.run() - openmc.lib.reset_timers() # Extract results rates = self._calculate_reaction_rates(source_rate) @@ -529,6 +528,8 @@ class CoupledOperator(OpenMCOperator): "openmc_simulation_n{}.h5".format(step), write_source=False) + openmc.lib.reset_timers() + def finalize(self): """Finalize a depletion simulation and release resources.""" if self.cleanup_when_done: diff --git a/tests/regression_tests/deplete_with_transport/test.py b/tests/regression_tests/deplete_with_transport/test.py index 9b37e4351..477959d1c 100644 --- a/tests/regression_tests/deplete_with_transport/test.py +++ b/tests/regression_tests/deplete_with_transport/test.py @@ -3,6 +3,7 @@ from math import floor import shutil from pathlib import Path +from collections import defaultdict from difflib import unified_diff import numpy as np @@ -122,8 +123,11 @@ def test_full(run_in_tmpdir, problem, multiproc): n_tallies = np.empty(N + 1, dtype=int) # Get statepoint files for all BOS points and EOL + runtimes = defaultdict(list) for n in range(N + 1): statepoint = openmc.StatePoint(f"openmc_simulation_n{n}.h5") + for measure, time in statepoint.runtime.items(): + runtimes[measure].append(time) k_n = statepoint.keff k_state[n] = [k_n.nominal_value, k_n.std_dev] n_tallies[n] = len(statepoint.tallies) @@ -134,6 +138,21 @@ def test_full(run_in_tmpdir, problem, multiproc): # Check that no additional tallies are loaded from the files assert np.all(n_tallies == 0) + # Convert values in runtimes to arrays + runtimes = {k: np.array(v) for k, v in runtimes.items()} + + # Check that runtimes are qualitatively correct + assert runtimes['reading cross sections'][0] != 0 + assert runtimes['total initialization'][0] != 0 + assert np.all(runtimes['reading cross sections'][1:] == 0) + assert np.all(runtimes['total initialization'][1:] == 0) + assert np.all(runtimes['inactive batches'] == 0) + del runtimes['reading cross sections'] + del runtimes['total initialization'] + del runtimes['inactive batches'] + for measure, times in runtimes.items(): + assert np.all(times != 0) + def test_depletion_results_to_material(run_in_tmpdir, problem): """Checks openmc.Materials objects can be created from depletion results"""