Skip to content

Commit

Permalink
Remove unnecessary make_unit_vector and add an assert for the validit…
Browse files Browse the repository at this point in the history
…y of cos_theta
  • Loading branch information
whokion committed Mar 6, 2024
1 parent 628e91d commit e3093fb
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ CELER_FUNCTION Interaction ChipsNeutronElasticInteractor::operator()(Engine& rng
// squared (\f$ -t = Q^{2} \f$) in the c.m. frame
real_type cos_theta
= 1 - real_type(0.5) * sample_momentum_square_(rng) / ipow<2>(cm_p);
clamp(cos_theta, real_type{-1}, real_type{1});
CELER_ASSERT(std::fabs(cos_theta) <= 1);

// Boost to the center of mass (c.m.) frame
Real3 cm_mom = cm_p * from_spherical(cos_theta, sample_phi_(rng));
Expand All @@ -132,8 +132,7 @@ CELER_FUNCTION Interaction ChipsNeutronElasticInteractor::operator()(Engine& rng
neutron_energy_ + target_mass});
boost(boost_vector(lv), &nlv1);

result.direction
= make_unit_vector(rotate(make_unit_vector(nlv1.mom), inc_direction_));
result.direction = rotate(make_unit_vector(nlv1.mom), inc_direction_);

// Kinetic energy of the scattered neutron and the recoiled nucleus
lv.energy -= nlv1.energy;
Expand Down

0 comments on commit e3093fb

Please sign in to comment.