diff --git a/openmc/capi/core.py b/openmc/capi/core.py index ad4f77dff..baba0b833 100644 --- a/openmc/capi/core.py +++ b/openmc/capi/core.py @@ -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(): diff --git a/src/eigenvalue.cpp b/src/eigenvalue.cpp index 08a4d3f91..0d6aa19b3 100644 --- a/src/eigenvalue.cpp +++ b/src/eigenvalue.cpp @@ -29,6 +29,7 @@ #include // for sqrt, abs, pow #include // for back_inserter #include +#include //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::infinity(); + } + return 0; } // Initialize variables