WarpX
Loading...
Searching...
No Matches
ElasticCollisionPerez.H
Go to the documentation of this file.
1/* Copyright 2019 Yinjian Zhao
2 *
3 * This file is part of WarpX.
4 *
5 * License: BSD-3-Clause-LBNL
6 */
7#ifndef WARPX_PARTICLES_COLLISION_ELASTIC_COLLISION_PEREZ_H_
8#define WARPX_PARTICLES_COLLISION_ELASTIC_COLLISION_PEREZ_H_
9
12#include "Utils/WarpXConst.H"
13
14#include <AMReX_Random.H>
15
41
42template <typename T_index, typename T_PR, typename T_R, typename SoaData_type>
45 T_index const I1s, T_index const I1e,
46 T_index const I2s, T_index const I2e,
47 T_index const* AMREX_RESTRICT I1,
48 T_index const* AMREX_RESTRICT I2,
49 SoaData_type soa_1, SoaData_type soa_2,
50 T_PR const n1, T_PR const n2,
51 T_PR const T1, T_PR const T2,
52 T_PR const q1, T_PR const q2,
53 T_PR const m1, T_PR const m2,
54 T_R const dt, T_R const global_lamdb,
55 CumulativeScatteringModel const scattering_model,
56 T_PR const L, T_R const dV,
57 amrex::RandomEngine const& engine,
58 bool const isSameSpecies, T_index coll_idx)
59{
60 const T_index NI1 = I1e - I1s;
61 const T_index NI2 = I2e - I2s;
62 const T_index max_N = amrex::max(NI1,NI2);
63 const T_index min_N = amrex::min(NI1,NI2);
64
65 T_PR * const AMREX_RESTRICT w1 = soa_1.m_rdata[PIdx::w];
66 T_PR * const AMREX_RESTRICT u1x = soa_1.m_rdata[PIdx::ux];
67 T_PR * const AMREX_RESTRICT u1y = soa_1.m_rdata[PIdx::uy];
68 T_PR * const AMREX_RESTRICT u1z = soa_1.m_rdata[PIdx::uz];
69
70 T_PR * const AMREX_RESTRICT w2 = soa_2.m_rdata[PIdx::w];
71 T_PR * const AMREX_RESTRICT u2x = soa_2.m_rdata[PIdx::ux];
72 T_PR * const AMREX_RESTRICT u2y = soa_2.m_rdata[PIdx::uy];
73 T_PR * const AMREX_RESTRICT u2z = soa_2.m_rdata[PIdx::uz];
74
75 // compute Debye length lmdD (if not using a fixed L = Coulomb log)
76 T_PR lmdD = T_PR(-1.0);
77 if ( L <= T_PR(0.0) ) {
78 if (global_lamdb <= T_PR(0.0)) {
79 lmdD = T_PR(1.0)/std::sqrt( n1*q1*q1/(T1*PhysConst::epsilon_0) +
80 n2*q2*q2/(T2*PhysConst::epsilon_0) );
81 } else {
82 lmdD = global_lamdb;
83 }
84 }
85
86 // compute atomic spacing
87 const T_PR maxn = amrex::max(n1,n2);
88 const auto rmin = static_cast<T_PR>( 1.0/std::cbrt(4.0*MathConst::pi/3.0*maxn) );
89
90 // bmax (screening length) cannot be smaller than atomic spacing
91 const T_PR bmax = amrex::max(lmdD, rmin);
92
93 // set max cross section based on mfp = atomic spacing
94 const T_PR sigma_max = T_PR(1.0) / (maxn * rmin);
95
96 // call UpdateMomentumPerezElastic()
97 {
98 T_index i1 = I1s + coll_idx;
99 T_index i2 = I2s + coll_idx;
100
101 // we will start from collision number = coll_idx and then add
102 // stride (smaller set size) until we do all collisions (larger set size)
103 for (T_index k = coll_idx; k < max_N; k += min_N)
104 {
105
106 // Compute the effective density n12 used to compute the normalized
107 // transport mean free path (s12) in UpdateMomentumPerezElastic().
108 // s12 is defined such that the expected value of the change in particle
109 // velocity is equal to that from the full NxN pairing method for each particle, as described in
110 // Justin Ray Angus, Yichen Fu, Vasily Geyko, Dave Grote, David Larson, JCP 531, 113927 (2025).
111 // This method is a direct extension of the original binary-pairing method for equally weighted
112 // particles by Takizuka and Abe JCP 25 (1977).
113 T_PR n12;
114 const T_PR wpmax = amrex::max(w1[ I1[i1] ],w2[ I2[i2] ]);
115 if (isSameSpecies) { n12 = wpmax*static_cast<T_PR>(min_N+max_N-1)/dV; }
116 else { n12 = wpmax*static_cast<T_PR>(min_N)/dV; }
117
119 u1x[ I1[i1] ], u1y[ I1[i1] ], u1z[ I1[i1] ],
120 u2x[ I2[i2] ], u2y[ I2[i2] ], u2z[ I2[i2] ],
121 q1, m1, w1[ I1[i1] ], q2, m2, w2[ I2[i2] ],
122 n12, sigma_max, L, bmax, scattering_model, dt, engine );
123
124 if (max_N == NI1) {
125 i1 += min_N;
126 }
127 if (max_N == NI2) {
128 i2 += min_N;
129 }
130 }
131 }
132
133}
134
135#endif // WARPX_PARTICLES_COLLISION_ELASTIC_COLLISION_PEREZ_H_
#define AMREX_RESTRICT
#define AMREX_INLINE
#define AMREX_GPU_HOST_DEVICE
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 const *AMREX_RESTRICT I1, T_index const *AMREX_RESTRICT I2, SoaData_type soa_1, SoaData_type soa_2, T_PR const n1, T_PR const n2, T_PR const T1, T_PR const T2, T_PR const q1, T_PR const q2, T_PR const m1, T_PR const m2, T_R const dt, T_R const global_lamdb, CumulativeScatteringModel const scattering_model, T_PR const L, T_R const dV, amrex::RandomEngine const &engine, bool const isSameSpecies, T_index coll_idx)
Definition ElasticCollisionPerez.H:44
CumulativeScatteringModel
Definition UpdateMomentumPerezElastic.H:19
AMREX_GPU_HOST_DEVICE AMREX_INLINE void UpdateMomentumPerezElastic(T_PR &u1x, T_PR &u1y, T_PR &u1z, T_PR &u2x, T_PR &u2y, T_PR &u2z, T_PR const q1, T_PR const m1, T_PR const w1, T_PR const q2, T_PR const m2, T_PR const w2, T_PR const n12, T_PR const sigma_max, T_PR const L, T_PR const bmax, CumulativeScatteringModel const scattering_model, T_R const dt, amrex::RandomEngine const &engine)
Definition UpdateMomentumPerezElastic.H:93
constexpr auto epsilon_0
vacuum permittivity: dielectric permittivity of vacuum [F/m]
Definition constant.H:163
constexpr auto pi
ratio of a circle's circumference to its diameter
Definition constant.H:29
__host__ __device__ constexpr const T & min(const T &a, const T &b) noexcept
__host__ __device__ constexpr const T & max(const T &a, const T &b) noexcept
@ uz
Definition WarpXParticleContainer.H:70
@ w
Definition WarpXParticleContainer.H:70
@ uy
Definition WarpXParticleContainer.H:70
@ ux
Definition WarpXParticleContainer.H:70