WarpX
Loading...
Searching...
No Matches
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
20template <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 // Compute u_minus
33 const T umx = ux + qmt*Ex;
34 const T umy = uy + qmt*Ey;
35 const T umz = uz + qmt*Ez;
36 // Compute gamma squared of u_minus
37 T gamma = 1._prt + (umx*umx + umy*umy + umz*umz)*PhysConst::inv_c2_v<T>;
38 // Compute beta and betam squared
39 const T betax = qmt*Bx;
40 const T betay = qmt*By;
41 const T betaz = qmt*Bz;
42 const T betam = betax*betax + betay*betay + betaz*betaz;
43 // Compute sigma
44 const T sigma = gamma - betam;
45 // Get u*
46 const T ust = (umx*betax + umy*betay + umz*betaz)*PhysConst::inv_c_v<T>;
47 // Get new gamma inverse
48 gamma = 1._prt/std::sqrt(0.5_prt*(sigma + std::sqrt(sigma*sigma + 4._prt*(betam + ust*ust)) ));
49 // Compute t
50 const T tx = gamma*betax;
51 const T ty = gamma*betay;
52 const T tz = gamma*betaz;
53 // Compute s
54 const T s = 1._prt/(1._prt+(tx*tx + ty*ty + tz*tz));
55 // Compute um dot t
56 const T umt = umx*tx + umy*ty + umz*tz;
57 // Compute u_plus
58 const T upx = s*( umx + umt*tx + umy*tz - umz*ty );
59 const T upy = s*( umy + umt*ty + umz*tx - umx*tz );
60 const T upz = s*( umz + umt*tz + umx*ty - umy*tx );
61 // Get new u
62 ux = upx + qmt*Ex + upy*tz - upz*ty;
63 uy = upy + qmt*Ey + upz*tx - upx*tz;
64 uz = upz + qmt*Ez + upx*ty - upy*tx;
65}
66
67#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
constexpr auto inv_c_v
inverse of the vacuum speed of light [s/m] (variable template)
Definition constant.H:142
constexpr auto inv_c2_v
inverse of the square of the vacuum speed of light [s^2/m^2] (variable template)
Definition constant.H:146