diff options
-rw-r--r-- | Source/Particles/PhotonParticleContainer.H | 31 | ||||
-rw-r--r-- | Source/Particles/PhotonParticleContainer.cpp | 56 | ||||
-rw-r--r-- | Source/Particles/Pusher/Make.package | 1 | ||||
-rw-r--r-- | Source/Particles/Pusher/UpdatePositionPhoton.H | 28 |
4 files changed, 88 insertions, 28 deletions
diff --git a/Source/Particles/PhotonParticleContainer.H b/Source/Particles/PhotonParticleContainer.H index a4b8ca84c..3818ba14d 100644 --- a/Source/Particles/PhotonParticleContainer.H +++ b/Source/Particles/PhotonParticleContainer.H @@ -4,10 +4,6 @@ #include <PhysicalParticleContainer.H> #include <AMReX_Vector.H> -#ifdef WARPX_QED - #include "breit_wheeler_engine_wrapper.h" -#endif - class PhotonParticleContainer : public PhysicalParticleContainer { @@ -51,6 +47,8 @@ public: amrex::Real dt) override; + + // DepositCurrent should do nothing for photons virtual void DepositCurrent(WarpXParIter& pti, RealVector& wp, RealVector& uxp, @@ -65,14 +63,25 @@ public: int thread_num, int lev, int depos_lev, - amrex::Real dt) override {}; + amrex::Real dt) {}; + + + // DepositCurrentFortran should do nothing for photons + virtual void DepositCurrentFortran(WarpXParIter& pti, + RealVector& wp, + RealVector& uxp, + RealVector& uyp, + RealVector& uzp, + amrex::MultiFab* jx, + amrex::MultiFab* jy, + amrex::MultiFab* jz, + const long offset, + const long np_to_depose, + int thread_num, + int lev, + int depos_lev, + amrex::Real dt) {}; -//This function initialises the optical depth of the photons -#ifdef WARPX_QED - virtual void InitOpticalDepth( - WarpXParIter& pti, - warpx_breit_wheeler_engine& engine); -#endif private: diff --git a/Source/Particles/PhotonParticleContainer.cpp b/Source/Particles/PhotonParticleContainer.cpp index 31a62b739..61e602ffb 100644 --- a/Source/Particles/PhotonParticleContainer.cpp +++ b/Source/Particles/PhotonParticleContainer.cpp @@ -11,6 +11,11 @@ #include <WarpX.H> #include <WarpXConst.H> + +// Import low-level single-particle kernels +#include <UpdatePositionPhoton.H> + + using namespace amrex; PhotonParticleContainer::PhotonParticleContainer (AmrCore* amr_core, int ispecies, @@ -26,11 +31,6 @@ PhotonParticleContainer::PhotonParticleContainer (AmrCore* amr_core, int ispecie // store it into member data. pp.query("size_in_inches", size_in_inches); -#ifdef WARPX_QED - AddRealComp("tau"); - plot_flags.resize(PIdx::nattribs + 1, 1); -#endif - } void PhotonParticleContainer::InitData() @@ -50,6 +50,40 @@ PhotonParticleContainer::PushPX(WarpXParIter& pti, Cuda::ManagedDeviceVector<Real>& giv, Real dt) { + + // This wraps the momentum and position advance so that inheritors can modify the call. + auto& attribs = pti.GetAttribs(); + // Extract pointers to the different particle quantities + Real* const AMREX_RESTRICT x = xp.dataPtr(); + Real* const AMREX_RESTRICT y = yp.dataPtr(); + Real* const AMREX_RESTRICT z = zp.dataPtr(); + Real* const AMREX_RESTRICT gi = giv.dataPtr(); + Real* const AMREX_RESTRICT ux = attribs[PIdx::ux].dataPtr(); + Real* const AMREX_RESTRICT uy = attribs[PIdx::uy].dataPtr(); + Real* const AMREX_RESTRICT uz = attribs[PIdx::uz].dataPtr(); + const Real* const AMREX_RESTRICT Ex = attribs[PIdx::Ex].dataPtr(); + const Real* const AMREX_RESTRICT Ey = attribs[PIdx::Ey].dataPtr(); + const Real* const AMREX_RESTRICT Ez = attribs[PIdx::Ez].dataPtr(); + const Real* const AMREX_RESTRICT Bx = attribs[PIdx::Bx].dataPtr(); + const Real* const AMREX_RESTRICT By = attribs[PIdx::By].dataPtr(); + const Real* const AMREX_RESTRICT Bz = attribs[PIdx::Bz].dataPtr(); + + if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) + { + copy_attribs(pti, x, y, z); + } + + //No need to update momentum for photons (for now) + + amrex::ParallelFor( + pti.numParticles(), + [=] AMREX_GPU_DEVICE (long i) { + + UpdatePositionPhoton( x[i], y[i], z[i], + ux[i], uy[i], uz[i], dt ); + } + ); + } void @@ -78,15 +112,3 @@ PhotonParticleContainer::Evolve (int lev, t, dt); } - - -#ifdef WARPX_QED -void PhotonParticleContainer::InitOpticalDepth( - WarpXParIter& pti, - warpx_breit_wheeler_engine& engine) -{ - auto& taus = pti.GetAttribs(particle_comps["tau"]); - for(auto& tau: taus) - tau = engine.get_optical_depth(); -} -#endif diff --git a/Source/Particles/Pusher/Make.package b/Source/Particles/Pusher/Make.package index 95a38fa2d..45886702e 100644 --- a/Source/Particles/Pusher/Make.package +++ b/Source/Particles/Pusher/Make.package @@ -2,5 +2,6 @@ CEXE_headers += GetAndSetPosition.H CEXE_headers += UpdatePosition.H CEXE_headers += UpdateMomentumBoris.H CEXE_headers += UpdateMomentumVay.H +CEXE_headers += UpdatePositionPhoton.H INCLUDE_LOCATIONS += $(WARPX_HOME)/Source/Particles/Pusher VPATH_LOCATIONS += $(WARPX_HOME)/Source/Particles/Pusher diff --git a/Source/Particles/Pusher/UpdatePositionPhoton.H b/Source/Particles/Pusher/UpdatePositionPhoton.H new file mode 100644 index 000000000..1944535cc --- /dev/null +++ b/Source/Particles/Pusher/UpdatePositionPhoton.H @@ -0,0 +1,28 @@ +#ifndef WARPX_PARTICLES_PUSHER_UPDATEPOSITIONPHOTON_H_ +#define WARPX_PARTICLES_PUSHER_UPDATEPOSITIONPHOTON_H_ + +#include <AMReX_FArrayBox.H> +#include <WarpXConst.H> +#include <AMReX_REAL.H> + +/* \brief Push the position of a photon particle over one timestep, + * given the value of its momenta `ux`, `uy`, `uz` */ +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void UpdatePositionPhoton( + amrex::Real& x, amrex::Real& y, amrex::Real& z, + const amrex::Real ux, const amrex::Real uy, const amrex::Real uz, + const amrex::Real dt ) +{ + // Compute speed of light over inverse of momentum modulus + const amrex::Real c_over_umod = PhysConst::c/std::sqrt(ux*ux + uy*uy + uz*uz); + + // Update positions over one time step + x += ux * c_over_umod * dt; +#if (defined WARPX_DIM_3D) || (defined WARPX_DIM_RZ) // RZ pushes particles in 3D + y += uy * c_over_umod * dt; +#endif + z += uz * c_over_umod * dt; + +} + +#endif // WARPX_PARTICLES_PUSHER_UPDATEPOSITION_H_ |