Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset timers at correct place in deplete #2821

Merged
merged 2 commits into from
Jan 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions 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 @@ -429,6 +432,16 @@ def __call__(self, vec, source_rate):
# Reset results in OpenMC
openmc.lib.reset()

# 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)

# If the source rate is zero, return zero reaction rates without running
Expand All @@ -449,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 Expand Up @@ -508,8 +523,6 @@ def write_bos_data(step):
"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:
Expand Down