Skip to content

Commit

Permalink
ensure correct reporting of XS load time in deplete
Browse files Browse the repository at this point in the history
  • Loading branch information
gridley committed Jan 6, 2024
1 parent 463ba9f commit 3a1d55f
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion openmc/deplete/coupled_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ def __init__(self, model, chain_file=None, prev_results=None,
'fission_yield_opts': fission_yield_opts
}

# Records how many times the operator has been called
self._n_calls = 0

super().__init__(
materials=model.materials,
cross_sections=cross_sections,
Expand Down Expand Up @@ -428,7 +431,16 @@ def __call__(self, vec, source_rate):
"""
# Reset results in OpenMC
openmc.lib.reset()
openmc.lib.reset_timers()

# The timers are reset only if the operator has been called before.
# This is because we call this method after loading cross sections, and
# no transport has taken place yet. As a result, we only reset the
# timers after the first step so as to correctly report the time spent
# reading cross sections in the first depletion step, and from there
# correctly report all particle tracking rates in multistep depletion
# solvers.
if self._n_calls > 0:
openmc.lib.reset_timers()

self._update_materials_and_nuclides(vec)

Expand All @@ -450,6 +462,8 @@ def __call__(self, vec, source_rate):

op_result = OperatorResult(keff, rates)

self._n_calls += 1

return copy.deepcopy(op_result)

def _update_materials(self):
Expand Down

0 comments on commit 3a1d55f

Please sign in to comment.