7 #ifndef WARPX_PARTICLE_UTILS_H_
8 #define WARPX_PARTICLE_UTILS_H_
45 void getEnergy ( amrex::ParticleReal
const u2,
double const mass,
49 using namespace amrex::literals;
68 double const M,
double&
gamma,
double& energy )
71 using namespace amrex::literals;
77 2.0_rt * m * M * u2 / (
gamma + 1.0_rt)
78 / (M + m +
sqrt(m*m + M*M + 2.0_rt * m * M *
gamma))
93 amrex::ParticleReal& uz,
94 amrex::ParticleReal
const Vx, amrex::ParticleReal
const Vy,
95 amrex::ParticleReal
const Vz )
97 using namespace amrex::literals;
101 const auto V2 = (Vx*Vx + Vy*Vy + Vz*Vz);
102 const auto gamma_V = 1.0_prt / std::sqrt(1.0_prt - V2 / c2);
103 const auto gamma_u = std::sqrt(1.0_prt + (ux*ux + uy*uy + uz*uz) / c2);
110 ux = vx * (1.0_prt + (gamma_V - 1.0_prt) * Vx*Vx/V2)
111 + vy * (gamma_V - 1.0_prt) * Vx*Vy/V2
112 + vz * (gamma_V - 1.0_prt) * Vx*Vz/V2
113 - gamma_V * Vx * gamma_u;
115 uy = vy * (1.0_prt + (gamma_V - 1.0_prt) * Vy*Vy/V2)
116 + vx * (gamma_V - 1.0_prt) * Vx*Vy/V2
117 + vz * (gamma_V - 1.0_prt) * Vy*Vz/V2
118 - gamma_V * Vy * gamma_u;
120 uz = vz * (1.0_prt + (gamma_V - 1.0_prt) * Vz*Vz/V2)
121 + vx * (gamma_V - 1.0_prt) * Vx*Vz/V2
122 + vy * (gamma_V - 1.0_prt) * Vy*Vz/V2
123 - gamma_V * Vz * gamma_u;
142 using namespace amrex::literals;
144 auto const theta =
amrex::Random(engine) * 2.0_prt * MathConst::pi;
146 auto const xy =
sqrt(1_prt - z*z);
162 amrex::ParticleReal& uz,
163 const amrex::ParticleReal vp,
166 amrex::ParticleReal x, y, z;
184 const auto xlo = tilebox.
lo();
185 const auto xhi = tilebox.
hi();
187 && (xlo[1] <= point.
y) && (point.
y <= xhi[1]),
188 && (xlo[2] <= point.
z) && (point.
z <= xhi[2]));
#define AMREX_GPU_HOST_DEVICE
#define AMREX_D_TERM(a, b, c)
AMREX_GPU_HOST_DEVICE const Real * hi() const &noexcept
AMREX_GPU_HOST_DEVICE const Real * lo() const &noexcept
Definition: ParticleUtils.cpp:25
AMREX_GPU_HOST_DEVICE AMREX_INLINE void getCollisionEnergy(amrex::ParticleReal const u2, double const m, double const M, double &gamma, double &energy)
Return (relativistic) collision energy assuming the target (with mass M) is stationary and the projec...
Definition: ParticleUtils.H:67
AMREX_GPU_HOST_DEVICE AMREX_INLINE void doLorentzTransform(amrex::ParticleReal &ux, amrex::ParticleReal &uy, amrex::ParticleReal &uz, amrex::ParticleReal const Vx, amrex::ParticleReal const Vy, amrex::ParticleReal const Vz)
Perform a Lorentz transformation of the given velocity to a frame moving with velocity (Vx,...
Definition: ParticleUtils.H:92
AMREX_GPU_HOST_DEVICE AMREX_INLINE void getEnergy(amrex::ParticleReal const u2, double const mass, double &energy)
Return (relativistic) particle energy given velocity and mass. Note the use of double since this calc...
Definition: ParticleUtils.H:45
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:161
ParticleBins findParticlesInEachCell(int const lev, MFIter const &mfi, ParticleTileType const &ptile)
Find the particles and count the particles that are in each cell. More specifically this function ret...
Definition: ParticleUtils.cpp:37
AMREX_GPU_HOST_DEVICE AMREX_INLINE void getRandomVector(amrex::ParticleReal &x, amrex::ParticleReal &y, amrex::ParticleReal &z, amrex::RandomEngine const &engine)
Generate random unit vector in 3 dimensions https://mathworld.wolfram.com/SpherePointPicking....
Definition: ParticleUtils.H:136
AMREX_GPU_HOST_DEVICE AMREX_INLINE bool containsInclusive(amrex::RealBox const &tilebox, amrex::XDim3 const point)
Definition: ParticleUtils.H:183
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:50
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex< T > sqrt(const GpuComplex< T > &a_z) noexcept
int gamma
boosted frame
Definition: stencil.py:431