From 402b09ee3d81054bc97d2fff0d45d9ebc27fe358 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Fri, 17 Nov 2017 11:22:48 -0600 Subject: [PATCH] Add Python bindings for global num_realizations. Fix active rate. --- docs/source/pythonapi/capi.rst | 1 + openmc/capi/tally.py | 9 +++++++-- src/output.F90 | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/source/pythonapi/capi.rst b/docs/source/pythonapi/capi.rst index 44a755bbd..3c6300bb6 100644 --- a/docs/source/pythonapi/capi.rst +++ b/docs/source/pythonapi/capi.rst @@ -22,6 +22,7 @@ Functions openmc.capi.keff openmc.capi.load_nuclide openmc.capi.next_batch + openmc.capi.num_realizations openmc.capi.plot_geometry openmc.capi.reset openmc.capi.run diff --git a/openmc/capi/tally.py b/openmc/capi/tally.py index 6725ee5c9..4a76de41d 100644 --- a/openmc/capi/tally.py +++ b/openmc/capi/tally.py @@ -13,7 +13,7 @@ from .error import _error_handler, AllocationError, InvalidIDError from .filter import _get_filter -__all__ = ['Tally', 'tallies', 'global_tallies'] +__all__ = ['Tally', 'tallies', 'global_tallies', 'num_realizations'] # Tally functions _dll.openmc_extend_tallies.argtypes = [c_int32, POINTER(c_int32), POINTER(c_int32)] @@ -89,7 +89,7 @@ def global_tallies(): # Get sum, sum-of-squares, and number of realizations sum_ = array[:, 1] sum_sq = array[:, 2] - n = c_int32.in_dll(_dll, 'n_realizations').value + n = num_realizations() # Determine mean mean = sum_ / n @@ -102,6 +102,11 @@ def global_tallies(): return list(zip(mean, stdev)) +def num_realizations(): + """Number of realizations of global tallies.""" + return c_int32.in_dll(_dll, 'n_realizations').value + + class Tally(_FortranObjectWithID): """Tally stored internally. diff --git a/src/output.F90 b/src/output.F90 index 3d02489f7..c20077584 100644 --- a/src/output.F90 +++ b/src/output.F90 @@ -570,7 +570,7 @@ contains write(ou,100) "Total time elapsed", time_total % elapsed ! Calculate particle rate in active/inactive batches - n_active = n_batches - n_inactive + n_active = current_batch - n_inactive if (restart_run) then if (restart_batch < n_inactive) then speed_inactive = real(n_particles * (n_inactive - restart_batch) * &