WarpX
UpdateMomentumHigueraCary.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_PUSHER_UPDATEMOMENTUM_HIGUERACARY_H_
8 #define WARPX_PARTICLES_PUSHER_UPDATEMOMENTUM_HIGUERACARY_H_
9 
10 #include "Utils/WarpXConst.H"
11 
12 #include <AMReX_FArrayBox.H>
13 #include <AMReX_REAL.H>
14 
15 
20 template <typename T>
23  T& ux, T& uy, T& uz,
24  const T Ex, const T Ey, const T Ez,
25  const T Bx, const T By, const T Bz,
26  const T q, const T m, const amrex::Real dt )
27 {
28  using namespace amrex::literals;
29 
30  // Constants
31  const T qmt = 0.5_prt*q*dt/m;
32  constexpr T invclight = 1._prt/PhysConst::c;
33  constexpr T invclightsq = 1._prt/(PhysConst::c*PhysConst::c);
34  // Compute u_minus
35  const T umx = ux + qmt*Ex;
36  const T umy = uy + qmt*Ey;
37  const T umz = uz + qmt*Ez;
38  // Compute gamma squared of u_minus
39  T gamma = 1._prt + (umx*umx + umy*umy + umz*umz)*invclightsq;
40  // Compute beta and betam squared
41  const T betax = qmt*Bx;
42  const T betay = qmt*By;
43  const T betaz = qmt*Bz;
44  const T betam = betax*betax + betay*betay + betaz*betaz;
45  // Compute sigma
46  const T sigma = gamma - betam;
47  // Get u*
48  const T ust = (umx*betax + umy*betay + umz*betaz)*invclight;
49  // Get new gamma inverse
50  gamma = 1._prt/std::sqrt(0.5_prt*(sigma + std::sqrt(sigma*sigma + 4._prt*(betam + ust*ust)) ));
51  // Compute t
52  const T tx = gamma*betax;
53  const T ty = gamma*betay;
54  const T tz = gamma*betaz;
55  // Compute s
56  const T s = 1._prt/(1._prt+(tx*tx + ty*ty + tz*tz));
57  // Compute um dot t
58  const T umt = umx*tx + umy*ty + umz*tz;
59  // Compute u_plus
60  const T upx = s*( umx + umt*tx + umy*tz - umz*ty );
61  const T upy = s*( umy + umt*ty + umz*tx - umx*tz );
62  const T upz = s*( umz + umt*tz + umx*ty - umy*tx );
63  // Get new u
64  ux = upx + qmt*Ex + upy*tz - upz*ty;
65  uy = upy + qmt*Ey + upz*tx - upx*tz;
66  uz = upz + qmt*Ez + upx*ty - upy*tx;
67 }
68 
69 #endif // WARPX_PARTICLES_PUSHER_UPDATEMOMENTUM_HIGUERACARY_H_
#define AMREX_INLINE
#define AMREX_GPU_HOST_DEVICE
AMREX_GPU_HOST_DEVICE AMREX_INLINE void UpdateMomentumHigueraCary(T &ux, T &uy, T &uz, const T Ex, const T Ey, const T Ez, const T Bx, const T By, const T Bz, const T q, const T m, const amrex::Real dt)
Push the particle's positions over one timestep, given the value of its momenta ux,...
Definition: UpdateMomentumHigueraCary.H:22
static constexpr auto c
vacuum speed of light [m/s]
Definition: constant.H:44
float dt
Definition: stencil.py:442
int gamma
boosted frame
Definition: stencil.py:431