Skip to content

Commit

Permalink
Refactor updateKEff to use squared fission sources for improved accur…
Browse files Browse the repository at this point in the history
…acy in k_eff calculation
  • Loading branch information
milliCoulomb committed Dec 30, 2024
1 parent 6f9ff8a commit 27019ab
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/BoltzmannSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,16 +384,17 @@ void BoltzmannSolver::updateKEff(const std::vector<double>& fission_source_new,

#pragma omp parallel for reduction(+:sum_new, sum_old)
for(int i = 0; i < num_cells_; ++i) {
sum_new += fission_source_new[i];
sum_old += fission_source_old[i];
sum_new += fission_source_new[i] * fission_source_new[i];
sum_old += fission_source_old[i] * fission_source_old[i];
}

if (sum_old < EPSILON) {
Logger::error("Old fission source sum is zero, cannot update k_eff.");
return;
}

double new_k_eff = sum_new / sum_old * k_eff_old_;
// double new_k_eff = sum_new / sum_old * k_eff_old_;
double new_k_eff = std::sqrt(sum_new / sum_old) * k_eff_old_;
// Atomically update k_eff_
#pragma omp atomic write
k_eff_old_ = k_eff_;
Expand Down

0 comments on commit 27019ab

Please sign in to comment.