WarpX
KineticEnergy.H
Go to the documentation of this file.
1 /* Copyright 2021 Luca Fedeli
2  *
3  * This file is part of WarpX.
4  *
5  * License: BSD-3-Clause-LBNL
6  */
7 
8 #ifndef WARPX_PARTICLES_KINETIC_ENERGY_H_
9 #define WARPX_PARTICLES_KINETIC_ENERGY_H_
10 
11 #include "Utils/WarpXConst.H"
12 
13 #include "AMReX_Extension.H"
14 #include "AMReX_GpuQualifiers.H"
15 #include "AMReX_REAL.H"
16 
17 #include <cmath>
18 
19 namespace Algorithms{
20 
33  amrex::ParticleReal KineticEnergy(
34  const amrex::ParticleReal ux, const amrex::ParticleReal uy, const amrex::ParticleReal uz,
35  const amrex::ParticleReal mass)
36  {
37  using namespace amrex;
38 
39  constexpr auto inv_c2 = 1.0_prt/(PhysConst::c * PhysConst::c);
40 
41  // The expression used is derived by reducing the expression
42  // (gamma - 1)*(gamma + 1)/(gamma + 1)
43 
44  const auto u2 = ux*ux + uy*uy + uz*uz;
45  const auto gamma = std::sqrt(1.0_prt + u2*inv_c2);
46  return 1.0_prt/(1.0_prt + gamma)*mass*u2;
47  }
48 
59  amrex::ParticleReal KineticEnergyPhotons(
60  const amrex::ParticleReal ux, const amrex::ParticleReal uy, const amrex::ParticleReal uz)
61  {
62  // Photons have zero mass, but ux, uy and uz are calculated assuming a mass equal to the
63  // electron mass. Hence, photons need a special treatment to calculate the total energy.
64  constexpr auto me_c = PhysConst::m_e * PhysConst::c;
65 
66  return me_c * std::sqrt(ux*ux + uy*uy + uz*uz);
67  }
68 
69 }
70 
71 #endif // WARPX_PARTICLES_KINETIC_ENERGY_H_
#define AMREX_INLINE
#define AMREX_GPU_HOST_DEVICE
Definition: KineticEnergy.H:19
AMREX_GPU_HOST_DEVICE AMREX_INLINE amrex::ParticleReal KineticEnergyPhotons(const amrex::ParticleReal ux, const amrex::ParticleReal uy, const amrex::ParticleReal uz)
Computes the kinetic energy of a photon.
Definition: KineticEnergy.H:59
AMREX_GPU_HOST_DEVICE AMREX_INLINE amrex::ParticleReal 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:33
static constexpr auto c
vacuum speed of light [m/s]
Definition: constant.H:44
static constexpr auto m_e
electron mass [kg]
Definition: constant.H:52
int gamma
boosted frame
Definition: stencil.py:431