mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-26 21:25:36 -04:00
Moving special case of keff calculation (n<=3) to cpp side
This commit is contained in:
parent
b3b021f034
commit
5fbae7cab4
2 changed files with 12 additions and 15 deletions
|
|
@ -230,18 +230,9 @@ def keff():
|
|||
Mean k-eigenvalue and standard deviation of the mean
|
||||
|
||||
"""
|
||||
n = openmc.capi.num_realizations()
|
||||
if n > 3:
|
||||
# Use the combined estimator if there are enough realizations
|
||||
k = (c_double*2)()
|
||||
_dll.openmc_get_keff(k)
|
||||
return tuple(k)
|
||||
else:
|
||||
# Otherwise, return the tracklength estimator
|
||||
mean = c_double.in_dll(_dll, 'keff').value
|
||||
std_dev = c_double.in_dll(_dll, 'keff_std').value \
|
||||
if n > 1 else np.inf
|
||||
return (mean, std_dev)
|
||||
k = (c_double*2)()
|
||||
_dll.openmc_get_keff(k)
|
||||
return tuple(k)
|
||||
|
||||
|
||||
def master():
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
#include <cmath> // for sqrt, abs, pow
|
||||
#include <iterator> // for back_inserter
|
||||
#include <string>
|
||||
#include <limits> //for infinity
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -388,10 +389,15 @@ int openmc_get_keff(double* k_combined)
|
|||
k_combined[0] = 0.0;
|
||||
k_combined[1] = 0.0;
|
||||
|
||||
// Make sure we have at least four realizations. Notice that at the end,
|
||||
// there is a N-3 term in a denominator.
|
||||
//Special case for n <=3. Notice that at the end,
|
||||
//there is a N-3 term in a denominator.
|
||||
if (simulation::n_realizations <= 3) {
|
||||
return -1;
|
||||
k_combined[0] = simulation::keff;
|
||||
k_combined[1] = simulation::keff_std;
|
||||
if (simulation::n_realizations <=1){
|
||||
k_combined[1] = std::numeric_limits<double>::infinity();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Initialize variables
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue