From 3e6eba4439f14d57c29f58b8a2711128e83e718a Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 16 Feb 2022 09:34:34 -0600 Subject: [PATCH] Respond to @gridley comments on #1974 --- include/openmc/physics_common.h | 2 +- src/physics.cpp | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/include/openmc/physics_common.h b/include/openmc/physics_common.h index 2c5e79dad..e38a3c7f8 100644 --- a/include/openmc/physics_common.h +++ b/include/openmc/physics_common.h @@ -10,7 +10,7 @@ namespace openmc { //! \brief Performs the russian roulette operation for a particle //! \param[in,out] p Particle object -//! \param[in] weight_cutoff Weight below which particles are rouletted +//! \param[in] weight_survive Weight assigned to particles that survive void russian_roulette(Particle& p, double weight_survive); } // namespace openmc diff --git a/src/physics.cpp b/src/physics.cpp index 01af1259f..63d764b67 100644 --- a/src/physics.cpp +++ b/src/physics.cpp @@ -624,8 +624,8 @@ void absorption(Particle& p, int i_nuclide) { if (settings::survival_biasing) { // Determine weight absorbed in survival biasing - double wgt_absorb = p.wgt() * p.neutron_xs(i_nuclide).absorption / - p.neutron_xs(i_nuclide).total; + const double wgt_absorb = p.wgt() * p.neutron_xs(i_nuclide).absorption / + p.neutron_xs(i_nuclide).total; // Adjust weight of particle by probability of absorption p.wgt() -= wgt_absorb; @@ -949,9 +949,8 @@ Direction sample_target_velocity(const Nuclide& nuc, double E, Direction u, // cdf value at upper bound attainable energy double m = (nuc.xs_cdf_[i_E_up + 1] - nuc.xs_cdf_[i_E_up]) / - (nuc.energy_0K_[i_E_up + 1] - nuc.energy_0K_[i_E_up]); - double cdf_up = - nuc.xs_cdf_[i_E_up] + m * (E_up - nuc.energy_0K_[i_E_up]); + (nuc.energy_0K_[i_E_up + 1] - nuc.energy_0K_[i_E_up]); + double cdf_up = nuc.xs_cdf_[i_E_up] + m * (E_up - nuc.energy_0K_[i_E_up]); while (true) { // directly sample Maxwellian @@ -959,9 +958,8 @@ Direction sample_target_velocity(const Nuclide& nuc, double E, Direction u, // sample a relative energy using the xs cdf double cdf_rel = cdf_low + prn(seed) * (cdf_up - cdf_low); - int i_E_rel = lower_bound_index(nuc.xs_cdf_.begin() + i_E_low, - nuc.xs_cdf_.begin() + i_E_up+2, - cdf_rel); + int i_E_rel = lower_bound_index(nuc.xs_cdf_.begin() + i_E_low, + nuc.xs_cdf_.begin() + i_E_up + 2, cdf_rel); double E_rel = nuc.energy_0K_[i_E_low + i_E_rel]; double m = (nuc.xs_cdf_[i_E_low + i_E_rel + 1] - nuc.xs_cdf_[i_E_low + i_E_rel]) /