11#include " openmc/tallies/next_event_scoring.h"
22
3+ #include < algorithm> // for clamp
4+
35#include " openmc/secondary_uncorrelated.h"
46#include " openmc/source.h"
57
@@ -14,11 +16,13 @@ void score_point_tally_elastic(
1416
1517 // Neutron velocity in LAB
1618 Direction v_n = std::sqrt (p.E ()) * p.u ();
19+ auto u_n = v_n / v_n.norm ();
1720
1821 // Velocity of center-of-mass
1922 Direction v_cm = (v_n + awr * v_t ) / (awr + 1.0 );
2023 auto u_cm = v_cm / v_cm.norm ();
2124
25+ double E_in = p.E ();
2226 double E_com = v_cm.dot (v_cm);
2327 double E_out = (v_n - v_cm).dot (v_n - v_cm);
2428
@@ -27,11 +31,15 @@ void score_point_tally_elastic(
2731
2832 auto pdf = [&](Direction u, double & E) {
2933 double mu = u.dot (u_cm);
34+ double mu_l = u.dot (u_n);
3035 E = E_out;
3136 double jac =
3237 get_jac_and_transform_impl (E_com, mu, E, p.current_seed (), awr);
38+ double mu_cm =
39+ 1.0 + mu_l * std::sqrt (E_in * E) / E_out - (E_in + E) / (2.0 * E_out);
40+ mu_cm = std::clamp (mu_cm, -1.0 , 1.0 );
3341 if (!d_->angle ().empty ()) {
34- return jac * d_->angle ().evaluate (p.E (), mu ) / (2.0 * PI);
42+ return jac * d_->angle ().evaluate (p.E (), mu_cm ) / (2.0 * PI);
3543 } else {
3644 return jac * 0.5 / (2.0 * PI);
3745 }
0 commit comments