7 #ifndef WARPX_PARTICLES_COLLISION_ELASTIC_COLLISION_PEREZ_H_ 8 #define WARPX_PARTICLES_COLLISION_ELASTIC_COLLISION_PEREZ_H_ 15 #include <AMReX_Random.H> 37 template <
typename T_index,
typename T_R,
typename SoaData_type>
38 AMREX_GPU_HOST_DEVICE AMREX_INLINE
40 T_index
const I1s, T_index
const I1e,
41 T_index
const I2s, T_index
const I2e,
42 T_index *I1, T_index *I2,
43 SoaData_type soa_1, SoaData_type soa_2,
44 T_R
const q1, T_R
const q2,
45 T_R
const m1, T_R
const m2,
46 T_R
const T1, T_R
const T2,
47 T_R
const dt, T_R
const L, T_R
const dV,
48 amrex::RandomEngine
const& engine)
53 T_R *
const AMREX_RESTRICT w1 = soa_1.m_rdata[
PIdx::w];
54 T_R *
const AMREX_RESTRICT u1x = soa_1.m_rdata[
PIdx::ux];
55 T_R *
const AMREX_RESTRICT u1y = soa_1.m_rdata[
PIdx::uy];
56 T_R *
const AMREX_RESTRICT u1z = soa_1.m_rdata[
PIdx::uz];
58 T_R *
const AMREX_RESTRICT w2 = soa_2.m_rdata[
PIdx::w];
59 T_R *
const AMREX_RESTRICT u2x = soa_2.m_rdata[
PIdx::ux];
60 T_R *
const AMREX_RESTRICT u2y = soa_2.m_rdata[
PIdx::uy];
61 T_R *
const AMREX_RESTRICT u2z = soa_2.m_rdata[
PIdx::uz];
65 if ( T1 <= T_R(0.0) && L <= T_R(0.0) )
70 if ( T2 <= T_R(0.0) && L <= T_R(0.0) )
80 for (
int i1=I1s; i1<static_cast<int>(I1e); ++i1) { n1 += w1[ I1[i1] ]; }
81 for (
int i2=I2s; i2<static_cast<int>(I2e); ++i2) { n2 += w2[ I2[i2] ]; }
82 n1 = n1 / dV; n2 = n2 / dV;
84 int i1 = I1s;
int i2 = I2s;
85 for (
int k = 0; k < amrex::max(NI1,NI2); ++k)
87 n12 += amrex::min( w1[ I1[i1] ], w2[ I2[i2] ] );
88 ++i1;
if ( i1 == static_cast<int>(I1e) ) { i1 = I1s; }
89 ++i2;
if ( i2 == static_cast<int>(I2e) ) { i2 = I2s; }
96 if ( T1t < T_R(0.0) || T2t < T_R(0.0) ) {
100 lmdD = T_R(1.0)/std::sqrt( n1*q1*q1/(T1t*PhysConst::ep0) +
101 n2*q2*q2/(T2t*PhysConst::ep0) );
103 T_R rmin = std::pow( T_R(4.0) * MathConst::pi / T_R(3.0) *
104 amrex::max(n1,n2), T_R(-1.0/3.0) );
105 lmdD = amrex::max(lmdD, rmin);
109 int i1 = I1s;
int i2 = I2s;
110 for (
int k = 0; k < amrex::max(NI1,NI2); ++k)
113 u1x[ I1[i1] ], u1y[ I1[i1] ], u1z[ I1[i1] ],
114 u2x[ I2[i2] ], u2y[ I2[i2] ], u2z[ I2[i2] ],
116 q1, m1, w1[ I1[i1] ], q2, m2, w2[ I2[i2] ],
119 ++i1;
if ( i1 == static_cast<int>(I1e) ) { i1 = I1s; }
120 ++i2;
if ( i2 == static_cast<int>(I2e) ) { i2 = I2s; }
126 #endif // WARPX_PARTICLES_COLLISION_ELASTIC_COLLISION_PEREZ_H_
Definition: WarpXParticleContainer_fwd.H:28
Definition: WarpXParticleContainer_fwd.H:28
AMREX_GPU_HOST_DEVICE AMREX_INLINE void UpdateMomentumPerezElastic(T_R &u1x, T_R &u1y, T_R &u1z, T_R &u2x, T_R &u2y, T_R &u2z, T_R const n1, T_R const n2, T_R const n12, T_R const q1, T_R const m1, T_R const w1, T_R const q2, T_R const m2, T_R const w2, T_R const dt, T_R const L, T_R const lmdD, amrex::RandomEngine const &engine)
Definition: UpdateMomentumPerezElastic.H:30
Definition: WarpXParticleContainer_fwd.H:28
AMREX_GPU_HOST_DEVICE AMREX_INLINE void ElasticCollisionPerez(T_index const I1s, T_index const I1e, T_index const I2s, T_index const I2e, T_index *I1, T_index *I2, SoaData_type soa_1, SoaData_type soa_2, T_R const q1, T_R const q2, T_R const m1, T_R const m2, T_R const T1, T_R const T2, T_R const dt, T_R const L, T_R const dV, amrex::RandomEngine const &engine)
Prepare information for and call UpdateMomentumPerezElastic().
Definition: ElasticCollisionPerez.H:39
Definition: WarpXParticleContainer_fwd.H:27
AMREX_GPU_HOST_DEVICE T_R ComputeTemperature(T_index const Is, T_index const Ie, T_index const *I, T_R const *ux, T_R const *uy, T_R const *uz, T_R const m)
Definition: ComputeTemperature.H:15