### Moving special case of keff calculation (n<=3) to cpp side

parent b3b021f0
 ... ... @@ -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 // 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; k_combined = 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 = simulation::keff; k_combined = simulation::keff_std; if (simulation::n_realizations <=1){ k_combined = std::numeric_limits::infinity(); } return 0; } // Initialize variables ... ...
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!