Add openmc_reset subroutine

This commit is contained in:
Paul Romano 2017-06-10 16:41:57 -05:00
parent 996375608b
commit 5cd9bc6065
2 changed files with 33 additions and 2 deletions

View file

@ -16,6 +16,7 @@ class _OpenMCLibrary(object):
self._dll.openmc_plot_geometry.restype = None
self._dll.openmc_calculate_volumes.restype = None
self._dll.openmc_finalize.restype = None
self._dll.openmc_reset.restype = None
def init(self, intracomm=None):
"""Initialize OpenMC
@ -53,6 +54,10 @@ class _OpenMCLibrary(object):
"""Finalize simulation and free memory"""
return self._dll.openmc_finalize()
def reset(self):
"""Reset tallies"""
return self._dll.openmc_reset()
def __getattr__(self, key):
# Fall-back for other functions that may be available from library
try:

View file

@ -6,7 +6,8 @@ module simulation
use constants, only: ZERO
use eigenvalue, only: count_source_for_ufs, calculate_average_keff, &
calculate_combined_keff, calculate_generation_keff, &
shannon_entropy, synchronize_bank, keff_generation
shannon_entropy, synchronize_bank, keff_generation, &
k_sum
#ifdef _OPENMP
use eigenvalue, only: join_bank_from_threads
#endif
@ -26,7 +27,7 @@ module simulation
implicit none
private
public :: openmc_run
public :: openmc_run, openmc_reset
contains
@ -422,4 +423,29 @@ contains
end subroutine reduce_overlap_count
!===============================================================================
! OPENMC_RESET resets all tallies
!===============================================================================
subroutine openmc_reset() bind(C)
integer :: i
do i = 1, size(tallies)
tallies(i) % n_realizations = 0
if (allocated(tallies(i) % results)) then
tallies(i) % results(:, :, :) = ZERO
end if
end do
n_realizations = 0
if (allocated(global_tallies)) then
global_tallies(:, :) = ZERO
end if
k_col_abs = ZERO
k_col_tra = ZERO
k_abs_tra = ZERO
k_sum(:) = ZERO
end subroutine openmc_reset
end module simulation