Add wrapped timed_deplete method for providing process time

Simple wrapper function that passes all arguments to
openmc.deplete.integrator.deplete and returns a two-item
tuple. The first item is the process time spent depleting
all materials (can be on one of many MPI processes).
The second item is what is returned directly from the
deplete function.
This commit is contained in:
Andrew Johnson 2019-06-21 09:43:17 -05:00
parent a31e6ced65
commit 2ecca7bff6
No known key found for this signature in database
GPG key ID: 253418E91B7F6FEB

View file

@ -53,6 +53,25 @@ def deplete(chain, x, rates, dt, print_out=True, matrix_func=None):
return x_result
def timed_deplete(*args, **kwargs):
"""Wrapper over :func:`deplete` that also returns process time
All arguments and keyword arguments are passed onto
:func:`deplete` directly.
Returns
-------
proc_time: float
Process time required to return from deplete
results: list of numpy arrays
Output from :func:`deplete` call
"""
start = time.time()
results = deplete(*args, **kwargs)
return time.time() - start, results
def _cram_wrapper(chain, n0, rates, dt, matrix_func=None):
"""Wraps depletion matrix creation / CRAM solve for multiprocess execution