File indexing completed on 2025-02-22 10:31:16
0001
0002
0003
0004
0005
0006
0007
0008 #pragma once
0009
0010 #include "celeritas/Quantities.hh"
0011 #include "celeritas/phys/InteractionUtils.hh"
0012 #include "celeritas/phys/Secondary.hh"
0013
0014 namespace celeritas
0015 {
0016 namespace detail
0017 {
0018
0019
0020
0021
0022 class IoniFinalStateHelper
0023 {
0024 public:
0025
0026
0027 using Energy = units::MevEnergy;
0028 using Mass = units::MevMass;
0029 using Momentum = units::MevMomentum;
0030
0031
0032 public:
0033
0034 inline CELER_FUNCTION IoniFinalStateHelper(Energy inc_energy,
0035 Real3 const& inc_direction,
0036 Momentum inc_momentum,
0037 Mass inc_mass,
0038 Energy electron_energy,
0039 Mass electron_mass,
0040 ParticleId electron_id,
0041 Secondary* secondary);
0042
0043
0044 template<class Engine>
0045 inline CELER_FUNCTION Interaction operator()(Engine& rng);
0046
0047 private:
0048
0049 real_type inc_energy_;
0050
0051 Real3 const& inc_direction_;
0052
0053 real_type inc_momentum_;
0054
0055 real_type inc_mass_;
0056
0057 real_type electron_energy_;
0058
0059 real_type electron_mass_;
0060
0061 ParticleId electron_id_;
0062
0063 Secondary* secondary_;
0064 };
0065
0066
0067
0068
0069
0070
0071
0072 CELER_FUNCTION
0073 IoniFinalStateHelper::IoniFinalStateHelper(Energy inc_energy,
0074 Real3 const& inc_direction,
0075 Momentum inc_momentum,
0076 Mass inc_mass,
0077 Energy electron_energy,
0078 Mass electron_mass,
0079 ParticleId electron_id,
0080 Secondary* secondary)
0081 : inc_energy_(value_as<Energy>(inc_energy))
0082 , inc_direction_(inc_direction)
0083 , inc_momentum_(value_as<Momentum>(inc_momentum))
0084 , inc_mass_(value_as<Mass>(inc_mass))
0085 , electron_energy_(value_as<Energy>(electron_energy))
0086 , electron_mass_(value_as<Mass>(electron_mass))
0087 , electron_id_(electron_id)
0088 , secondary_{secondary}
0089 {
0090 CELER_EXPECT(secondary_);
0091 }
0092
0093
0094
0095
0096
0097 template<class Engine>
0098 CELER_FUNCTION Interaction IoniFinalStateHelper::operator()(Engine& rng)
0099 {
0100
0101 real_type momentum = std::sqrt(electron_energy_
0102 * (electron_energy_ + 2 * electron_mass_));
0103 real_type costheta = electron_energy_
0104 * (inc_energy_ + inc_mass_ + electron_mass_)
0105 / (momentum * inc_momentum_);
0106 CELER_ASSERT(costheta <= 1);
0107
0108
0109 secondary_->energy = Energy{electron_energy_};
0110 secondary_->direction
0111 = ExitingDirectionSampler{costheta, inc_direction_}(rng);
0112 secondary_->particle_id = electron_id_;
0113
0114
0115 Interaction result;
0116 result.energy = Energy{inc_energy_ - electron_energy_};
0117 result.direction = calc_exiting_direction(
0118 {inc_momentum_, inc_direction_}, {momentum, secondary_->direction});
0119 result.secondaries = {secondary_, 1};
0120
0121 return result;
0122 }
0123
0124
0125 }
0126 }