From 2ecca7bff696f31aeb18f57c657f20751e120376 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 21 Jun 2019 09:43:17 -0500 Subject: [PATCH] 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. --- openmc/deplete/integrator/cram.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/openmc/deplete/integrator/cram.py b/openmc/deplete/integrator/cram.py index 8a8940df8b..f5da6d696b 100644 --- a/openmc/deplete/integrator/cram.py +++ b/openmc/deplete/integrator/cram.py @@ -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