WarpX
Loading...
Searching...
No Matches
ImpactIonization.H
Go to the documentation of this file.
1/* Copyright 2021 Modern Electron
2 *
3 * This file is part of WarpX.
4 *
5 * License: BSD-3-Clause-LBNL
6 */
7#ifndef WARPX_PARTICLES_COLLISION_IMPACT_IONIZATION_H_
8#define WARPX_PARTICLES_COLLISION_IMPACT_IONIZATION_H_
9
11
13#include "Utils/ParticleUtils.H"
14#include "Utils/WarpXConst.H"
15
16#include <AMReX_Random.H>
17#include <AMReX_REAL.H>
18
23
28{
29public:
30
52 ScatteringProcess const& mcc_process,
53 double const mass,
54 amrex::ParticleReal const total_collision_prob,
55 amrex::ParticleReal const nu_max,
56 amrex::ParserExecutor<4> const& n_a_func,
57 amrex::Real t
58 ) : m_mcc_process(mcc_process.executor()), m_mass(mass),
59 m_total_collision_prob(total_collision_prob),
60 m_nu_max(nu_max), m_n_a_func(n_a_func), m_t(t) { }
61
71 template <typename PData>
74 const PData& ptd, int const i, amrex::RandomEngine const& engine
75 ) const noexcept
76 {
77 using namespace amrex;
78 using std::sqrt;
79
80 // determine if this particle should collide
81 if (Random(engine) > m_total_collision_prob) { return false; }
82
83 // get references to the particle to get its position
84 const auto& p = ptd.getSuperParticle(i);
85 ParticleReal x, y, z;
86 double E_coll;
87 get_particle_position(p, x, y, z);
88
89 // calculate neutral density at particle location
90 const ParticleReal n_a = m_n_a_func(x, y, z, m_t);
91
92 // get the particle velocity
93 const ParticleReal ux = ptd.m_rdata[PIdx::ux][i];
94 const ParticleReal uy = ptd.m_rdata[PIdx::uy][i];
95 const ParticleReal uz = ptd.m_rdata[PIdx::uz][i];
96
97 // calculate kinetic energy
98 constexpr auto eV = PhysConst::q_e;
99 E_coll = Algorithms::KineticEnergy<double>(ux, uy, uz, m_mass)/eV;
100
101 // get collision cross-section
102 const ParticleReal sigma_E = m_mcc_process.getCrossSection(static_cast<amrex::ParticleReal>(E_coll));
103
104 // calculate normalized collision frequency
105 const ParticleReal u_coll2 = ux*ux + uy*uy + uz*uz;
106 const ParticleReal nu_i = n_a * sigma_E * sqrt(u_coll2) / m_nu_max;
107
108 // check if this collision should be performed
109 return (Random(engine) <= nu_i);
110 }
111
112private:
114 double m_mass;
115 amrex::ParticleReal m_total_collision_prob = 0;
116 amrex::ParticleReal m_nu_max;
118 amrex::Real m_t;
119};
120
121
126{
127public:
128
151 amrex::ParticleReal energy_cost, double mass1, amrex::ParticleReal sqrt_kb_m,
152 amrex::ParserExecutor<4> const& T_a_func, amrex::Real t
153 ) : m_energy_cost(energy_cost), m_mass1(mass1),
154 m_sqrt_kb_m(sqrt_kb_m), m_T_a_func(T_a_func), m_t(t) { }
155
170 template <typename DstData, typename SrcData>
172 void operator() (DstData& dst1, DstData& dst2, SrcData& src,
173 int const i_src, int const i_dst1, int const i_dst2,
174 amrex::RandomEngine const& engine) const noexcept
175 {
176 using namespace amrex;
177 using std::sqrt;
178
179 // get references to the particle to get its position
180 const auto& p = src.getSuperParticle(i_src);
181 ParticleReal x, y, z;
182 double E_coll;
183 get_particle_position(p, x, y, z);
184
185 // calculate standard deviation in neutral velocity distribution using
186 // the local temperature
187 const ParticleReal ion_vel_std = m_sqrt_kb_m * std::sqrt(m_T_a_func(x, y, z, m_t));
188
189 // get references to the original particle's velocity
190 auto& ux = src.m_rdata[PIdx::ux][i_src];
191 auto& uy = src.m_rdata[PIdx::uy][i_src];
192 auto& uz = src.m_rdata[PIdx::uz][i_src];
193
194 // get references to the new particles' velocities
195 auto& e_ux = dst1.m_rdata[PIdx::ux][i_dst1];
196 auto& e_uy = dst1.m_rdata[PIdx::uy][i_dst1];
197 auto& e_uz = dst1.m_rdata[PIdx::uz][i_dst1];
198 auto& i_ux = dst2.m_rdata[PIdx::ux][i_dst2];
199 auto& i_uy = dst2.m_rdata[PIdx::uy][i_dst2];
200 auto& i_uz = dst2.m_rdata[PIdx::uz][i_dst2];
201
202 // calculate kinetic energy
203 constexpr auto eV = PhysConst::q_e;
204 E_coll = Algorithms::KineticEnergy<double>(ux, uy, uz, m_mass1)/eV;
205
206 // each electron gets half the energy (could change this later)
207 const auto E_out = static_cast<amrex::ParticleReal>((E_coll - m_energy_cost) / 2.0_prt * eV);
208
209 // precalculate often used value
210 constexpr auto c2 = PhysConst::c * PhysConst::c;
211 const auto mc2 = m_mass1*c2;
212
213 const amrex::ParticleReal up = sqrt(E_out * (E_out + 2.0_prt*mc2) / c2) / m_mass1;
214
215 // isotropically scatter electrons
216 ParticleUtils::RandomizeVelocity(ux, uy, uz, up, engine);
217 ParticleUtils::RandomizeVelocity(e_ux, e_uy, e_uz, up, engine);
218
219 // get velocities for the ion from a Maxwellian distribution
220 i_ux = ion_vel_std * RandomNormal(0_prt, 1.0_prt, engine);
221 i_uy = ion_vel_std * RandomNormal(0_prt, 1.0_prt, engine);
222 i_uz = ion_vel_std * RandomNormal(0_prt, 1.0_prt, engine);
223 }
224
225private:
226 amrex::ParticleReal m_energy_cost;
227 double m_mass1;
228 amrex::ParticleReal m_sqrt_kb_m;
230 amrex::Real m_t;
231};
232#endif // WARPX_PARTICLES_COLLISION_IMPACT_IONIZATION_H_
#define AMREX_FORCE_INLINE
#define AMREX_GPU_HOST_DEVICE
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void get_particle_position(const WarpXParticleContainer::SuperParticleType &p, amrex::ParticleReal &x, amrex::ParticleReal &y, amrex::ParticleReal &z) noexcept
Extract the cartesian position coordinates of the particle p and store them in the variables x,...
Definition GetAndSetPosition.H:27
ImpactIonizationFilterFunc(ScatteringProcess const &mcc_process, double const mass, amrex::ParticleReal const total_collision_prob, amrex::ParticleReal const nu_max, amrex::ParserExecutor< 4 > const &n_a_func, amrex::Real t)
Constructor of the ImpactIonizationFilterFunc functor.
Definition ImpactIonization.H:51
double m_mass
Definition ImpactIonization.H:114
amrex::ParticleReal m_nu_max
Definition ImpactIonization.H:116
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool operator()(const PData &ptd, int const i, amrex::RandomEngine const &engine) const noexcept
Functor call. This method determines if a given (electron) particle should undergo an ionization coll...
Definition ImpactIonization.H:73
amrex::ParticleReal m_total_collision_prob
Definition ImpactIonization.H:115
amrex::ParserExecutor< 4 > m_n_a_func
Definition ImpactIonization.H:117
amrex::Real m_t
Definition ImpactIonization.H:118
ScatteringProcess::Executor m_mcc_process
Definition ImpactIonization.H:113
ImpactIonizationTransformFunc(amrex::ParticleReal energy_cost, double mass1, amrex::ParticleReal sqrt_kb_m, amrex::ParserExecutor< 4 > const &T_a_func, amrex::Real t)
Constructor of the ImpactIonizationTransformFunc functor.
Definition ImpactIonization.H:150
amrex::ParticleReal m_energy_cost
Definition ImpactIonization.H:226
amrex::Real m_t
Definition ImpactIonization.H:230
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void operator()(DstData &dst1, DstData &dst2, SrcData &src, int const i_src, int const i_dst1, int const i_dst2, amrex::RandomEngine const &engine) const noexcept
Functor call. It determines the properties of the generated pair and decreases the kinetic energy of ...
Definition ImpactIonization.H:172
amrex::ParticleReal m_sqrt_kb_m
Definition ImpactIonization.H:228
double m_mass1
Definition ImpactIonization.H:227
amrex::ParserExecutor< 4 > m_T_a_func
Definition ImpactIonization.H:229
Definition ScatteringProcess.H:31
AMREX_GPU_HOST_DEVICE AMREX_INLINE T KineticEnergy(const amrex::ParticleReal ux, const amrex::ParticleReal uy, const amrex::ParticleReal uz, const amrex::ParticleReal mass)
Computes the kinetic energy of a particle. This method should not be used with photons.
Definition KineticEnergy.H:36
AMREX_GPU_HOST_DEVICE AMREX_INLINE void RandomizeVelocity(amrex::ParticleReal &ux, amrex::ParticleReal &uy, amrex::ParticleReal &uz, const amrex::ParticleReal vp, amrex::RandomEngine const &engine)
Function to perform scattering of a particle that results in a random velocity vector with given magn...
Definition ParticleUtils.H:221
static constexpr auto c
vacuum speed of light [m/s]
Definition constant.H:44
static constexpr auto q_e
elementary charge [C]
Definition constant.H:52
Real Random()
Real RandomNormal(Real mean, Real stddev)
__host__ __device__ GpuComplex< T > sqrt(const GpuComplex< T > &a_z) noexcept
@ uz
Definition WarpXParticleContainer.H:70
@ uy
Definition WarpXParticleContainer.H:70
@ ux
Definition WarpXParticleContainer.H:70
Definition ScatteringProcess.H:75