From c238eab6e20f732facdef32909f368b9436fb964 Mon Sep 17 00:00:00 2001 From: MaxThevenet Date: Thu, 16 May 2019 17:46:58 -0700 Subject: Photons are derived class from PhysicalParticleContainer --- Source/Particles/PhotonParticleContainer.cpp | 87 ++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 Source/Particles/PhotonParticleContainer.cpp (limited to 'Source/Particles/PhotonParticleContainer.cpp') diff --git a/Source/Particles/PhotonParticleContainer.cpp b/Source/Particles/PhotonParticleContainer.cpp new file mode 100644 index 000000000..14af6c0d9 --- /dev/null +++ b/Source/Particles/PhotonParticleContainer.cpp @@ -0,0 +1,87 @@ +#include +#include +#include + +#ifdef _OPENMP +#include +#endif + +#include +#include +#include +#include + +using namespace amrex; + +PhotonParticleContainer::PhotonParticleContainer (AmrCore* amr_core, int ispecies, + const std::string& name) + : PhysicalParticleContainer(amr_core, ispecies, name) +{ + + // This will read .[...] from the inputs file + // where is the name of your species + ParmParse pp(species_name); + + // read .size_in_inches in the input file, and + // store it into member data. + pp.query("size_in_inches", size_in_inches); + +} + +void PhotonParticleContainer::InitData() +{ + AddParticles(0); // Note - add on level 0 + if (maxLevel() > 0) { + Redistribute(); // We then redistribute + } +} + +void +PhotonParticleContainer::PushPX(WarpXParIter& pti, + Cuda::ManagedDeviceVector& xp, + Cuda::ManagedDeviceVector& yp, + Cuda::ManagedDeviceVector& zp, + Cuda::ManagedDeviceVector& giv, + Real dt) +{ + // This wraps the call to warpx_particle_pusher so that inheritors can modify the call. + auto& attribs = pti.GetAttribs(); + auto& uxp = attribs[PIdx::ux]; + auto& uyp = attribs[PIdx::uy]; + auto& uzp = attribs[PIdx::uz]; + auto& Exp = attribs[PIdx::Ex]; + auto& Eyp = attribs[PIdx::Ey]; + auto& Ezp = attribs[PIdx::Ez]; + auto& Bxp = attribs[PIdx::Bx]; + auto& Byp = attribs[PIdx::By]; + auto& Bzp = attribs[PIdx::Bz]; + const long np = pti.numParticles(); + + // Probably want to push photons in some way here. + // WarpXParticleContainer::PushX(int lev, Real dt) is probably + // a good start. + // In particular grep ParallelFor thing if you want + // to write GPU-compatible code. +} + +void +PhotonParticleContainer::Evolve (int lev, + const MultiFab& Ex, const MultiFab& Ey, const MultiFab& Ez, + const MultiFab& Bx, const MultiFab& By, const MultiFab& Bz, + MultiFab& jx, MultiFab& jy, MultiFab& jz, + MultiFab* cjx, MultiFab* cjy, MultiFab* cjz, + MultiFab* rho, MultiFab* crho, + const MultiFab* cEx, const MultiFab* cEy, const MultiFab* cEz, + const MultiFab* cBx, const MultiFab* cBy, const MultiFab* cBz, + Real t, Real dt) +{ + PhysicalParticleContainer::Evolve (lev, + Ex, Ey, Ez, + Bx, By, Bz, + jx, jy, jz, + cjx, cjy, cjz, + rho, crho, + cEx, cEy, cEz, + cBx, cBy, cBz, + t, dt); +} -- cgit v1.2.3 From e357ac13dbe948f1bf550584cf408a4e7cb0f312 Mon Sep 17 00:00:00 2001 From: MaxThevenet Date: Thu, 16 May 2019 18:05:45 -0700 Subject: no particle pusher for photons --- Source/Particles/PhotonParticleContainer.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'Source/Particles/PhotonParticleContainer.cpp') diff --git a/Source/Particles/PhotonParticleContainer.cpp b/Source/Particles/PhotonParticleContainer.cpp index 14af6c0d9..b4070a773 100644 --- a/Source/Particles/PhotonParticleContainer.cpp +++ b/Source/Particles/PhotonParticleContainer.cpp @@ -58,10 +58,11 @@ PhotonParticleContainer::PushPX(WarpXParIter& pti, const long np = pti.numParticles(); // Probably want to push photons in some way here. - // WarpXParticleContainer::PushX(int lev, Real dt) is probably - // a good start. - // In particular grep ParallelFor thing if you want - // to write GPU-compatible code. + // PhysicalParticleContainer::PushPX is probably + // a good start. Let's start by writing CPU code. + for (WarpXParIter pti(*this, 0); pti.isValid(); ++pti) + { + } } void @@ -75,6 +76,10 @@ PhotonParticleContainer::Evolve (int lev, const MultiFab* cBx, const MultiFab* cBy, const MultiFab* cBz, Real t, Real dt) { + // This does gather, push and depose. + // Push and depose have been re-written for photon, + // so they do not do anything. + // Currently, I guess photons do gather fields from the mesh. PhysicalParticleContainer::Evolve (lev, Ex, Ey, Ez, Bx, By, Bz, -- cgit v1.2.3 From 679156e73e537284b97e642ef13f9d784b44f264 Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Mon, 3 Jun 2019 10:45:35 +0200 Subject: Added dedicated pusher to photons --- Source/FortranInterface/WarpX_f.H | 16 ++++++-- Source/FortranInterface/WarpX_picsar.F90 | 58 ++++++++++++++++++++++++++-- Source/Particles/PhotonParticleContainer.cpp | 25 +++++++----- 3 files changed, 84 insertions(+), 15 deletions(-) (limited to 'Source/Particles/PhotonParticleContainer.cpp') diff --git a/Source/FortranInterface/WarpX_f.H b/Source/FortranInterface/WarpX_f.H index 52996a60a..20781a8ee 100644 --- a/Source/FortranInterface/WarpX_f.H +++ b/Source/FortranInterface/WarpX_f.H @@ -87,7 +87,7 @@ extern "C" const amrex_real* uxp, const amrex_real* uyp, const amrex_real* uzp, amrex_real* xpold, amrex_real* ypold, amrex_real* zpold, amrex_real* uxpold, amrex_real* uypold, amrex_real* uzpold); - + // Charge deposition void warpx_charge_deposition(amrex::Real* rho, const long* np, const amrex::Real* xp, const amrex::Real* yp, const amrex::Real* zp, const amrex::Real* w, @@ -167,6 +167,16 @@ extern "C" const amrex::Real* charge, const amrex::Real* mass, const amrex::Real* dt, const long* particle_pusher_algo); + // Particle pusher (positions) + + void warpx_particle_pusher_positions(const long* np, + amrex::Real* xp, amrex::Real* yp, amrex::Real* zp, + amrex::Real* uxp, amrex::Real* uyp, amrex::Real* uzp, amrex::Real* gaminv, + const amrex::Real* exp, const amrex::Real* eyp,const amrex::Real* ezp, + const amrex::Real* bxp, const amrex::Real* byp,const amrex::Real* bzp, + const amrex::Real* charge, const amrex::Real* mass, const amrex::Real* dt, + const long* particle_pusher_algo); + // Laser pusher @@ -185,7 +195,7 @@ extern "C" amrex::Real* u_Xx, amrex::Real* u_Xy, amrex::Real* u_Xz, amrex::Real* u_Yx, amrex::Real* u_Yy, amrex::Real* u_Yz, amrex::Real* positionx, amrex::Real* positiony, amrex::Real* positionz ); - + void update_laser_particle( const long* np, amrex::Real* xp, amrex::Real* yp, amrex::Real* zp, amrex::Real* uxp, amrex::Real* uyp, amrex::Real* uzp, @@ -194,7 +204,7 @@ extern "C" amrex::Real* nvecx, amrex::Real* nvecy, amrex::Real* nvecz, amrex::Real* mobility, amrex::Real* dt, const amrex::Real* c, const amrex::Real* beta_boost, const amrex::Real* gamma_boost ); - + // Maxwell solver void warpx_push_evec( diff --git a/Source/FortranInterface/WarpX_picsar.F90 b/Source/FortranInterface/WarpX_picsar.F90 index c17e8861b..42d7a904e 100644 --- a/Source/FortranInterface/WarpX_picsar.F90 +++ b/Source/FortranInterface/WarpX_picsar.F90 @@ -117,7 +117,7 @@ contains pxr_ll4symtry = ll4symtry .eq. 1 pxr_l_lower_order_in_v = l_lower_order_in_v .eq. 1 pxr_l_nodal = l_nodal .eq. 1 - + exg_nguards = ixyzmin - exg_lo eyg_nguards = ixyzmin - eyg_lo ezg_nguards = ixyzmin - ezg_lo @@ -268,7 +268,7 @@ subroutine warpx_charge_deposition(rho,np,xp,yp,zp,w,q,xmin,ymin,zmin,dx,dy,dz,n #ifdef WARPX_RZ integer(c_long) :: type_rz_depose = 1 #endif - + ! Compute the number of valid cells and guard cells integer(c_long) :: rho_nvalid(AMREX_SPACEDIM), rho_nguards(AMREX_SPACEDIM) rho_nvalid = rho_ntot - 2*rho_ng @@ -387,7 +387,7 @@ subroutine warpx_charge_deposition(rho,np,xp,yp,zp,w,q,xmin,ymin,zmin,dx,dy,dz,n real(amrex_real), intent(IN OUT):: jx(*), jy(*), jz(*) real(amrex_real), intent(IN) :: rmin, dr -#ifdef WARPX_RZ +#ifdef WARPX_RZ integer(c_long) :: type_rz_depose = 1 #endif ! Compute the number of valid cells and guard cells @@ -587,6 +587,58 @@ subroutine warpx_charge_deposition(rho,np,xp,yp,zp,w,q,xmin,ymin,zmin,dx,dy,dz,n end subroutine warpx_push_evec + + ! _________________________________________________________________ + !> + !> @brief + !> Main subroutine for the particle positions + !> + !> @param[in] np number of super-particles + !> @param[in] xp,yp,zp particle position arrays + !> @param[in] uxp,uyp,uzp normalized momentum in each direction + !> @param[in] gaminv particle Lorentz factors + !> @param[in] ex,ey,ez particle electric fields in each direction [UNUSED] + !> @param[in] bx,by,bz particle magnetic fields in each direction [UNUSED] + !> @param[in] q charge + !> @param[in] m masse + !> @param[in] dt time step + !> @param[in] particle_pusher_algo Particle pusher algorithm [UNUSED] + subroutine warpx_particle_pusher_positions(np,xp,yp,zp,uxp,uyp,uzp, & + gaminv,& + ex,ey,ez,bx,by,bz,q,m,dt, & + particle_pusher_algo) & + bind(C, name="warpx_particle_pusher_positions") + + INTEGER(c_long), INTENT(IN) :: np + REAL(amrex_real),INTENT(INOUT) :: gaminv(np) + REAL(amrex_real),INTENT(IN) :: xp(np),yp(np),zp(np) + REAL(amrex_real),INTENT(INOUT) :: uxp(np),uyp(np),uzp(np) + REAL(amrex_real),INTENT(IN) :: ex(np),ey(np),ez(np) + REAL(amrex_real),INTENT(IN) :: bx(np),by(np),bz(np) + REAL(amrex_real),INTENT(IN) :: q,m,dt + INTEGER(c_long), INTENT(IN) :: particle_pusher_algo + + INTEGER(c_long) :: ip + + IF (m > 0.0) THEN + CALL pxr_set_gamma(np,uxp,uyp,uzp,gaminv) + ELSE + DO ip=1, np + gaminv(ip) = 0.0 + END DO + END IF + + !!!! --- push particle species positions a time step +#if (AMREX_SPACEDIM == 3) || (defined WARPX_RZ) + CALL pxr_pushxyz(np,xp,yp,zp,uxp,uyp,uzp,gaminv,dt) +#elif (AMREX_SPACEDIM == 2) + CALL pxr_pushxz(np,xp,zp,uxp,uzp,gaminv,dt) +#endif + + end subroutine warpx_particle_pusher_positions + + + ! _________________________________________________________________ !> !> @brief diff --git a/Source/Particles/PhotonParticleContainer.cpp b/Source/Particles/PhotonParticleContainer.cpp index b4070a773..0e1adc13b 100644 --- a/Source/Particles/PhotonParticleContainer.cpp +++ b/Source/Particles/PhotonParticleContainer.cpp @@ -22,7 +22,7 @@ PhotonParticleContainer::PhotonParticleContainer (AmrCore* amr_core, int ispecie // where is the name of your species ParmParse pp(species_name); - // read .size_in_inches in the input file, and + // read .size_in_inches in the input file, and // store it into member data. pp.query("size_in_inches", size_in_inches); @@ -56,13 +56,20 @@ PhotonParticleContainer::PushPX(WarpXParIter& pti, auto& Byp = attribs[PIdx::By]; auto& Bzp = attribs[PIdx::Bz]; const long np = pti.numParticles(); - - // Probably want to push photons in some way here. - // PhysicalParticleContainer::PushPX is probably - // a good start. Let's start by writing CPU code. - for (WarpXParIter pti(*this, 0); pti.isValid(); ++pti) - { - } + + // Using new pusher for positions + const amrex_real zero_mass = 0.0; + const amrex_real zero_charge = 0.0; + warpx_particle_pusher_positions(&np, + xp.dataPtr(), + yp.dataPtr(), + zp.dataPtr(), + uxp.dataPtr(), uyp.dataPtr(), uzp.dataPtr(), + giv.dataPtr(), + Exp.dataPtr(), Eyp.dataPtr(), Ezp.dataPtr(), + Bxp.dataPtr(), Byp.dataPtr(), Bzp.dataPtr(), + &zero_charge, &zero_mass, &dt, + &WarpX::particle_pusher_algo); } void @@ -77,7 +84,7 @@ PhotonParticleContainer::Evolve (int lev, Real t, Real dt) { // This does gather, push and depose. - // Push and depose have been re-written for photon, + // Push and depose have been re-written for photon, // so they do not do anything. // Currently, I guess photons do gather fields from the mesh. PhysicalParticleContainer::Evolve (lev, -- cgit v1.2.3 From 81b53da1c52294a642f0d7919a25fa704a6172b7 Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Mon, 3 Jun 2019 11:20:26 +0200 Subject: now WARPX_QED is defined via makefile --- GNUmakefile | 2 ++ Source/Make.WarpX | 17 ++++++++++++----- Source/Particles/MultiParticleContainer.H | 2 -- Source/Particles/MultiParticleContainer.cpp | 4 ++-- Source/Particles/PhotonParticleContainer.cpp | 7 ++++++- 5 files changed, 22 insertions(+), 10 deletions(-) (limited to 'Source/Particles/PhotonParticleContainer.cpp') diff --git a/GNUmakefile b/GNUmakefile index 9d7b1c65f..5e4c46628 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -8,6 +8,8 @@ DEBUG = FALSE DIM = 2 #DIM = 3 +QED = TRUE + COMP = gcc #COMP = intel #COMP = pgi diff --git a/Source/Make.WarpX b/Source/Make.WarpX index c1ef54c33..280955665 100644 --- a/Source/Make.WarpX +++ b/Source/Make.WarpX @@ -45,6 +45,13 @@ endif DEFINES += -DWARPX_USE_PY endif +ifeq ($(QED),TRUE) + CXXFLAGS += -DWARPX_QED + CFLAGS += -DWARPX_QED + FFLAGS += -DWARPX_QED + F90FLAGS += -DWARPX_QED +endif + -include Make.package include $(WARPX_HOME)/Source/Make.package include $(WARPX_HOME)/Source/BoundaryConditions/Make.package @@ -98,7 +105,7 @@ ifeq ($(USE_OPENPMD), TRUE) DEFINES += -DWARPX_USE_OPENPMD -DopenPMD_HAVE_MPI=1 LIBRARIES += -lopenPMD -lhdf5 endif - + ifeq ($(USE_PSATD),TRUE) FFTW_HOME ?= NOT_SET @@ -139,7 +146,7 @@ ifeq ($(USE_HDF5),TRUE) endif DEFINES += -DWARPX_USE_HDF5 LIBRARIES += -lhdf5 -lz -endif +endif # job_info support CEXE_sources += AMReX_buildInfo.cpp @@ -186,7 +193,7 @@ else ifdef WarpxBinDir -all: $(executable) +all: $(executable) $(SILENT) $(RM) AMReX_buildInfo.cpp @if [ ! -d $(WarpxBinDir) ]; then mkdir -p $(WarpxBinDir); fi $(SILENT) mv -f $(executable) $(WarpxBinDir)/ @@ -195,7 +202,7 @@ all: $(executable) else -all: $(executable) +all: $(executable) $(SILENT) $(RM) AMReX_buildInfo.cpp @echo SUCCESS @@ -203,7 +210,7 @@ endif endif -AMReX_buildInfo.cpp: +AMReX_buildInfo.cpp: $(AMREX_HOME)/Tools/C_scripts/makebuildinfo_C.py \ --amrex_home "$(AMREX_HOME)" \ --COMP "$(COMP)" --COMP_VERSION "$(COMP_VERSION)" \ diff --git a/Source/Particles/MultiParticleContainer.H b/Source/Particles/MultiParticleContainer.H index 2754607fd..44e325b84 100644 --- a/Source/Particles/MultiParticleContainer.H +++ b/Source/Particles/MultiParticleContainer.H @@ -22,8 +22,6 @@ // concrete class dervied from WarpXParticlContainer. // -//Enable QED effects -#define WARPX_QED #ifdef WARPX_QED //BW ENGINE diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index c53ddceac..c22e87345 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -75,8 +75,8 @@ MultiParticleContainer::MultiParticleContainer (AmrCore* amr_core) #ifdef WARPX_QED //Add a tau field (optical depth) for all photon species - //for (int i = 0; i < nspecies; ++i) - //allcontainers[i]->AddRealComp("tau"); + for (int i = 0; i < nspecies; ++i) + allcontainers[i]->AddRealComp("tau"); #endif } diff --git a/Source/Particles/PhotonParticleContainer.cpp b/Source/Particles/PhotonParticleContainer.cpp index 0e1adc13b..8c8008627 100644 --- a/Source/Particles/PhotonParticleContainer.cpp +++ b/Source/Particles/PhotonParticleContainer.cpp @@ -26,6 +26,11 @@ PhotonParticleContainer::PhotonParticleContainer (AmrCore* amr_core, int ispecie // store it into member data. pp.query("size_in_inches", size_in_inches); +#define WARPX_QED +#ifdef WARPX_QED + plot_flags.resize(PIdx::nattribs + 6, 1); +#endif + } void PhotonParticleContainer::InitData() @@ -57,7 +62,7 @@ PhotonParticleContainer::PushPX(WarpXParIter& pti, auto& Bzp = attribs[PIdx::Bz]; const long np = pti.numParticles(); - // Using new pusher for positions + // Using new pusher for positions const amrex_real zero_mass = 0.0; const amrex_real zero_charge = 0.0; warpx_particle_pusher_positions(&np, -- cgit v1.2.3 From cf3b3e52e484eca8c5640f65863186ba47137cad Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Mon, 3 Jun 2019 11:39:26 +0200 Subject: Moved addition of tau component into PhotonParticleContainer --- Source/Particles/MultiParticleContainer.cpp | 7 ------- Source/Particles/PhotonParticleContainer.cpp | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) (limited to 'Source/Particles/PhotonParticleContainer.cpp') diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index c22e87345..d8ccb36c6 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -72,13 +72,6 @@ MultiParticleContainer::MultiParticleContainer (AmrCore* amr_core) pc_tmp->AddRealComp("uyold"); pc_tmp->AddRealComp("uzold"); } - -#ifdef WARPX_QED - //Add a tau field (optical depth) for all photon species - for (int i = 0; i < nspecies; ++i) - allcontainers[i]->AddRealComp("tau"); -#endif - } void diff --git a/Source/Particles/PhotonParticleContainer.cpp b/Source/Particles/PhotonParticleContainer.cpp index 8c8008627..b0bbf406a 100644 --- a/Source/Particles/PhotonParticleContainer.cpp +++ b/Source/Particles/PhotonParticleContainer.cpp @@ -26,8 +26,8 @@ PhotonParticleContainer::PhotonParticleContainer (AmrCore* amr_core, int ispecie // store it into member data. pp.query("size_in_inches", size_in_inches); -#define WARPX_QED #ifdef WARPX_QED + AddRealComp("tau"); plot_flags.resize(PIdx::nattribs + 6, 1); #endif -- cgit v1.2.3 From eb61eabea96c7fe4dfdbc890053f52f0548d3ed4 Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Mon, 3 Jun 2019 12:01:13 +0200 Subject: initial work for a function to initialize optical depth --- Source/Particles/PhotonParticleContainer.H | 5 +++++ Source/Particles/PhotonParticleContainer.cpp | 8 ++++++++ 2 files changed, 13 insertions(+) (limited to 'Source/Particles/PhotonParticleContainer.cpp') diff --git a/Source/Particles/PhotonParticleContainer.H b/Source/Particles/PhotonParticleContainer.H index fbc68f0b0..4c72fe47e 100644 --- a/Source/Particles/PhotonParticleContainer.H +++ b/Source/Particles/PhotonParticleContainer.H @@ -63,6 +63,11 @@ public: int lev, amrex::Real dt ) override {}; + +#ifdef WARPX_QED + virtual void InitOpticalDepth(); +#endif + private: amrex::Real size_in_inches = 1.; diff --git a/Source/Particles/PhotonParticleContainer.cpp b/Source/Particles/PhotonParticleContainer.cpp index b0bbf406a..b440b7990 100644 --- a/Source/Particles/PhotonParticleContainer.cpp +++ b/Source/Particles/PhotonParticleContainer.cpp @@ -36,6 +36,7 @@ PhotonParticleContainer::PhotonParticleContainer (AmrCore* amr_core, int ispecie void PhotonParticleContainer::InitData() { AddParticles(0); // Note - add on level 0 + if (maxLevel() > 0) { Redistribute(); // We then redistribute } @@ -102,3 +103,10 @@ PhotonParticleContainer::Evolve (int lev, cBx, cBy, cBz, t, dt); } + + +#ifdef WARPX_QED + void InitOpticalDepth(){ + + } +#endif -- cgit v1.2.3 From c0eb69ccbd7a2523ed82220cacb1b4bbcd83bbcf Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Mon, 3 Jun 2019 12:03:02 +0200 Subject: coorected bug --- Source/Particles/PhotonParticleContainer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Source/Particles/PhotonParticleContainer.cpp') diff --git a/Source/Particles/PhotonParticleContainer.cpp b/Source/Particles/PhotonParticleContainer.cpp index b440b7990..b80e597c3 100644 --- a/Source/Particles/PhotonParticleContainer.cpp +++ b/Source/Particles/PhotonParticleContainer.cpp @@ -106,7 +106,7 @@ PhotonParticleContainer::Evolve (int lev, #ifdef WARPX_QED - void InitOpticalDepth(){ - + void PhysicalParticleContainer::InitOpticalDepth(){ + } #endif -- cgit v1.2.3 From 16a345b0e522f6fdf1bffeb5196b356b0957e326 Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Mon, 3 Jun 2019 12:27:50 +0200 Subject: corrected bug --- Source/Particles/PhotonParticleContainer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Particles/PhotonParticleContainer.cpp') diff --git a/Source/Particles/PhotonParticleContainer.cpp b/Source/Particles/PhotonParticleContainer.cpp index b80e597c3..41ad13fc2 100644 --- a/Source/Particles/PhotonParticleContainer.cpp +++ b/Source/Particles/PhotonParticleContainer.cpp @@ -106,7 +106,7 @@ PhotonParticleContainer::Evolve (int lev, #ifdef WARPX_QED - void PhysicalParticleContainer::InitOpticalDepth(){ + void PhotonParticleContainer::InitOpticalDepth(){ } #endif -- cgit v1.2.3 From e1067378f5d43c11850f4e6518cbfe3a96250889 Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Mon, 3 Jun 2019 14:37:08 +0200 Subject: Added a wrapper for BW engine --- Source/Particles/MultiParticleContainer.H | 30 +++------------------------- Source/Particles/MultiParticleContainer.cpp | 12 ++++++----- Source/Particles/PhotonParticleContainer.cpp | 4 ++++ Source/QED/Make.package | 5 +++-- Source/QED/amrex_rng_wrapper.cpp | 18 +++++++++++++++++ Source/QED/amrex_rng_wrapper.h | 20 +++++++++++++++++++ Source/QED/amrex_rng_wrapper.hpp | 27 ------------------------- Source/QED/breit_wheeler_engine_wrapper.h | 7 +++---- 8 files changed, 58 insertions(+), 65 deletions(-) create mode 100644 Source/QED/amrex_rng_wrapper.cpp create mode 100644 Source/QED/amrex_rng_wrapper.h delete mode 100644 Source/QED/amrex_rng_wrapper.hpp (limited to 'Source/Particles/PhotonParticleContainer.cpp') diff --git a/Source/Particles/MultiParticleContainer.H b/Source/Particles/MultiParticleContainer.H index 44e325b84..eb1d2ba75 100644 --- a/Source/Particles/MultiParticleContainer.H +++ b/Source/Particles/MultiParticleContainer.H @@ -22,33 +22,9 @@ // concrete class dervied from WarpXParticlContainer. // - +// #ifdef WARPX_QED -//BW ENGINE -//#define PXRMP_GPU __host__ __device__ -#define PXRMP_WITH_SI_UNITS -#include "breit_wheeler_engine.hpp" -//Alias for the picsar::multi_physics namespace -namespace pxrmp = picsar::multi_physics; - -//RNG wrapper BW engine -class amrex_rng_wrapper -{ -public: - //Get rnd number uniformly distributed in [a,b) - amrex::Real unf(amrex::Real a, amrex::Real b) - { - return (b-a)*amrex::Random() + a; - } - - //Get rnd number with exponential distribution - amrex::Real exp(amrex::Real l) - { - amrex::Real zero_plus_to_one = 1.0 - unf(0.0, 1.0); - return -log(zero_plus_to_one)/l; - } -}; -//___________________________________________ + #include "breit_wheeler_engine_wrapper.h" #endif class MultiParticleContainer @@ -228,7 +204,7 @@ public: //bw_engine is a public member of the MultiParticleContainer object #ifdef WARPX_QED - pxrmp::breit_wheeler_engine bw_engine; + warpx_breit_wheeler_engine bw_engine; #endif protected: diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index d8ccb36c6..92f66c705 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -10,13 +10,15 @@ using namespace amrex; constexpr int MultiParticleContainer::nstencilz_fdtd_nci_corr; -#ifdef WARPX_QED + MultiParticleContainer::MultiParticleContainer (AmrCore* amr_core): - bw_engine{std::move(amrex_rng_wrapper{})}//, default_lambda};//, bw_ctrl}; -#else -MultiParticleContainer::MultiParticleContainer (AmrCore* amr_core) -#endif + bw_engine{std::move(init_warpx_breit_wheeler_engine())} { + +#ifdef WARPX_QED + +#endif + ReadParameters(); allcontainers.resize(nspecies + nlasers); diff --git a/Source/Particles/PhotonParticleContainer.cpp b/Source/Particles/PhotonParticleContainer.cpp index 41ad13fc2..9ea448ec8 100644 --- a/Source/Particles/PhotonParticleContainer.cpp +++ b/Source/Particles/PhotonParticleContainer.cpp @@ -37,6 +37,10 @@ void PhotonParticleContainer::InitData() { AddParticles(0); // Note - add on level 0 +#ifdef WARPX_QED + InitOpticalDepth(); +#endif + if (maxLevel() > 0) { Redistribute(); // We then redistribute } diff --git a/Source/QED/Make.package b/Source/QED/Make.package index 12b007e73..6e38efb9e 100644 --- a/Source/QED/Make.package +++ b/Source/QED/Make.package @@ -1,5 +1,6 @@ -CEXE_headers += WarpXConst.H -CEXE_headers += WarpXUtil.H +CEXE_headers += amrex_rng_wrapper.h +CEXE_headers += breit_wheeler_engine_wrapper.h +CEXE_sources += amrex_rng_wrapper.cpp INCLUDE_LOCATIONS += $(WARPX_HOME)/Source/QED VPATH_LOCATIONS += $(WARPX_HOME)/Source/QED diff --git a/Source/QED/amrex_rng_wrapper.cpp b/Source/QED/amrex_rng_wrapper.cpp new file mode 100644 index 000000000..955144c4c --- /dev/null +++ b/Source/QED/amrex_rng_wrapper.cpp @@ -0,0 +1,18 @@ +//This file provides a wrapper aroud the RNG +//provided by the amrex library + +#include "amrex_rng_wrapper.h" + +//RNG wrapper BW engine +//Get rnd number uniformly distributed in [a,b) +amrex::Real amrex_rng_wrapper::unf(amrex::Real a, amrex::Real b) +{ + return (b-a)*amrex::Random() + a; +} + +//Get rnd number with exponential distribution +amrex::Real amrex_rng_wrapper::exp(amrex::Real l) +{ + amrex::Real zero_plus_to_one = 1.0 - unf(0.0, 1.0); + return -log(zero_plus_to_one)/l; +} diff --git a/Source/QED/amrex_rng_wrapper.h b/Source/QED/amrex_rng_wrapper.h new file mode 100644 index 000000000..f9818c589 --- /dev/null +++ b/Source/QED/amrex_rng_wrapper.h @@ -0,0 +1,20 @@ +#ifndef WARPX_amrex_rng_wrapper_h_ +#define WARPX_rng_wrapper_h_ + +//This file provides a wrapper aroud the RNG +//provided by the amrex library + +#include + +//RNG wrapper BW engine +class amrex_rng_wrapper +{ +public: + //Get rnd number uniformly distributed in [a,b) + amrex::Real unf(amrex::Real a, amrex::Real b); + + //Get rnd number with exponential distribution + amrex::Real exp(amrex::Real l); +}; + +#endif //amrex_rng_wrapper_hpp_ diff --git a/Source/QED/amrex_rng_wrapper.hpp b/Source/QED/amrex_rng_wrapper.hpp deleted file mode 100644 index 25d667df7..000000000 --- a/Source/QED/amrex_rng_wrapper.hpp +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef WARPX_amrex_rng_wrapper_hpp_ -#define WARPX_rng_wrapper_hpp_ - -//This file provides a wrapper aroud the RNG -//provided by the amrex library - -#include - -//RNG wrapper BW engine -inline class amrex_rng_wrapper -{ -public: - //Get rnd number uniformly distributed in [a,b) - amrex::Real unf(amrex::Real a, amrex::Real b) - { - return (b-a)*amrex::Random() + a; - } - - //Get rnd number with exponential distribution - amrex::Real exp(amrex::Real l) - { - amrex::Real zero_plus_to_one = 1.0 - unf(0.0, 1.0); - return -log(zero_plus_to_one)/l; - } -}; - -#endif //amrex_rng_wrapper_hpp_ diff --git a/Source/QED/breit_wheeler_engine_wrapper.h b/Source/QED/breit_wheeler_engine_wrapper.h index 17bf4ef69..3bb3ea740 100644 --- a/Source/QED/breit_wheeler_engine_wrapper.h +++ b/Source/QED/breit_wheeler_engine_wrapper.h @@ -9,17 +9,16 @@ #define PXRMP_WITH_SI_UNITS #include "breit_wheeler_engine.hpp" -#include "amrex_rng_wrapper.hpp" +#include "amrex_rng_wrapper.h" using warpx_breit_wheeler_engine = picsar::multi_physics::breit_wheeler_engine; //Helper function to initialize the engine -inline warpx_breit_wheeler_engine&& init_warpx_breit_wheeler_engine(){ - return std::move(warpx_breit_wheeler_engine{std::move{amrex_rng_wrapper{}}}); +inline warpx_breit_wheeler_engine init_warpx_breit_wheeler_engine(){ + return warpx_breit_wheeler_engine{std::move(amrex_rng_wrapper{})}; } //___________________________________________ -#endif #endif //WARPX_breit_wheeler_engine_wrapper_H_ -- cgit v1.2.3 From ffb2c6a10bcfcf8c2b7a617f0d1ddb9fd8666aec Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Mon, 3 Jun 2019 15:24:54 +0200 Subject: Added function to initialize the optical depth (still crashing) --- Source/Particles/MultiParticleContainer.cpp | 9 +++++---- Source/Particles/PhotonParticleContainer.H | 8 ++++++-- Source/Particles/PhotonParticleContainer.cpp | 17 ++++++++++------- 3 files changed, 21 insertions(+), 13 deletions(-) (limited to 'Source/Particles/PhotonParticleContainer.cpp') diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index 92f66c705..a56651f50 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -10,14 +10,15 @@ using namespace amrex; constexpr int MultiParticleContainer::nstencilz_fdtd_nci_corr; - +#ifdef WARPX_QED MultiParticleContainer::MultiParticleContainer (AmrCore* amr_core): bw_engine{std::move(init_warpx_breit_wheeler_engine())} +#else +MultiParticleContainer::MultiParticleContainer (AmrCore* amr_core) +#endif { -#ifdef WARPX_QED - -#endif + ReadParameters(); diff --git a/Source/Particles/PhotonParticleContainer.H b/Source/Particles/PhotonParticleContainer.H index 4c72fe47e..616231ef6 100644 --- a/Source/Particles/PhotonParticleContainer.H +++ b/Source/Particles/PhotonParticleContainer.H @@ -4,6 +4,8 @@ #include #include +#include "breit_wheeler_engine_wrapper.h" + class PhotonParticleContainer : public PhysicalParticleContainer { @@ -63,9 +65,11 @@ public: int lev, amrex::Real dt ) override {}; - +//This function initialises the optical depth of the photons #ifdef WARPX_QED - virtual void InitOpticalDepth(); + 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 9ea448ec8..6e6300bd1 100644 --- a/Source/Particles/PhotonParticleContainer.cpp +++ b/Source/Particles/PhotonParticleContainer.cpp @@ -11,6 +11,8 @@ #include #include +#include "breit_wheeler_engine_wrapper.h" + using namespace amrex; PhotonParticleContainer::PhotonParticleContainer (AmrCore* amr_core, int ispecies, @@ -37,10 +39,6 @@ void PhotonParticleContainer::InitData() { AddParticles(0); // Note - add on level 0 -#ifdef WARPX_QED - InitOpticalDepth(); -#endif - if (maxLevel() > 0) { Redistribute(); // We then redistribute } @@ -110,7 +108,12 @@ PhotonParticleContainer::Evolve (int lev, #ifdef WARPX_QED - void PhotonParticleContainer::InitOpticalDepth(){ - - } +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 -- cgit v1.2.3 From 17f2c26f30c2e2dbffcf5f3becb7dd6ae454b41a Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Mon, 3 Jun 2019 15:55:48 +0200 Subject: Corrected bug --- Source/Particles/PhotonParticleContainer.H | 4 +++- Source/Particles/PhotonParticleContainer.cpp | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'Source/Particles/PhotonParticleContainer.cpp') diff --git a/Source/Particles/PhotonParticleContainer.H b/Source/Particles/PhotonParticleContainer.H index 616231ef6..966fc1e2d 100644 --- a/Source/Particles/PhotonParticleContainer.H +++ b/Source/Particles/PhotonParticleContainer.H @@ -4,7 +4,9 @@ #include #include -#include "breit_wheeler_engine_wrapper.h" +#ifdef WARPX_QED + #include "breit_wheeler_engine_wrapper.h" +#endif class PhotonParticleContainer : public PhysicalParticleContainer diff --git a/Source/Particles/PhotonParticleContainer.cpp b/Source/Particles/PhotonParticleContainer.cpp index 6e6300bd1..daf196014 100644 --- a/Source/Particles/PhotonParticleContainer.cpp +++ b/Source/Particles/PhotonParticleContainer.cpp @@ -11,8 +11,6 @@ #include #include -#include "breit_wheeler_engine_wrapper.h" - using namespace amrex; PhotonParticleContainer::PhotonParticleContainer (AmrCore* amr_core, int ispecies, -- cgit v1.2.3 From 1259a63a21ea6b072481ed285c888bcd6b417e51 Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Mon, 3 Jun 2019 16:17:17 +0200 Subject: modified the pusher of the photon particle container --- Source/FortranInterface/WarpX_f.H | 4 +--- Source/FortranInterface/WarpX_picsar.F90 | 6 ++---- Source/Particles/PhotonParticleContainer.cpp | 6 ++---- 3 files changed, 5 insertions(+), 11 deletions(-) (limited to 'Source/Particles/PhotonParticleContainer.cpp') diff --git a/Source/FortranInterface/WarpX_f.H b/Source/FortranInterface/WarpX_f.H index 20781a8ee..0fca39d2f 100644 --- a/Source/FortranInterface/WarpX_f.H +++ b/Source/FortranInterface/WarpX_f.H @@ -172,9 +172,7 @@ extern "C" void warpx_particle_pusher_positions(const long* np, amrex::Real* xp, amrex::Real* yp, amrex::Real* zp, amrex::Real* uxp, amrex::Real* uyp, amrex::Real* uzp, amrex::Real* gaminv, - const amrex::Real* exp, const amrex::Real* eyp,const amrex::Real* ezp, - const amrex::Real* bxp, const amrex::Real* byp,const amrex::Real* bzp, - const amrex::Real* charge, const amrex::Real* mass, const amrex::Real* dt, + const amrex::Real* mass, const amrex::Real* dt, const long* particle_pusher_algo); diff --git a/Source/FortranInterface/WarpX_picsar.F90 b/Source/FortranInterface/WarpX_picsar.F90 index 42d7a904e..c70d20564 100644 --- a/Source/FortranInterface/WarpX_picsar.F90 +++ b/Source/FortranInterface/WarpX_picsar.F90 @@ -605,7 +605,7 @@ subroutine warpx_charge_deposition(rho,np,xp,yp,zp,w,q,xmin,ymin,zmin,dx,dy,dz,n !> @param[in] particle_pusher_algo Particle pusher algorithm [UNUSED] subroutine warpx_particle_pusher_positions(np,xp,yp,zp,uxp,uyp,uzp, & gaminv,& - ex,ey,ez,bx,by,bz,q,m,dt, & + m,dt, & particle_pusher_algo) & bind(C, name="warpx_particle_pusher_positions") @@ -613,9 +613,7 @@ subroutine warpx_charge_deposition(rho,np,xp,yp,zp,w,q,xmin,ymin,zmin,dx,dy,dz,n REAL(amrex_real),INTENT(INOUT) :: gaminv(np) REAL(amrex_real),INTENT(IN) :: xp(np),yp(np),zp(np) REAL(amrex_real),INTENT(INOUT) :: uxp(np),uyp(np),uzp(np) - REAL(amrex_real),INTENT(IN) :: ex(np),ey(np),ez(np) - REAL(amrex_real),INTENT(IN) :: bx(np),by(np),bz(np) - REAL(amrex_real),INTENT(IN) :: q,m,dt + REAL(amrex_real),INTENT(IN) :: m,dt INTEGER(c_long), INTENT(IN) :: particle_pusher_algo INTEGER(c_long) :: ip diff --git a/Source/Particles/PhotonParticleContainer.cpp b/Source/Particles/PhotonParticleContainer.cpp index daf196014..9900bd1ad 100644 --- a/Source/Particles/PhotonParticleContainer.cpp +++ b/Source/Particles/PhotonParticleContainer.cpp @@ -65,16 +65,13 @@ PhotonParticleContainer::PushPX(WarpXParIter& pti, // Using new pusher for positions const amrex_real zero_mass = 0.0; - const amrex_real zero_charge = 0.0; warpx_particle_pusher_positions(&np, xp.dataPtr(), yp.dataPtr(), zp.dataPtr(), uxp.dataPtr(), uyp.dataPtr(), uzp.dataPtr(), giv.dataPtr(), - Exp.dataPtr(), Eyp.dataPtr(), Ezp.dataPtr(), - Bxp.dataPtr(), Byp.dataPtr(), Bzp.dataPtr(), - &zero_charge, &zero_mass, &dt, + &zero_mass, &dt, &WarpX::particle_pusher_algo); } @@ -102,6 +99,7 @@ PhotonParticleContainer::Evolve (int lev, cEx, cEy, cEz, cBx, cBy, cBz, t, dt); + } -- cgit v1.2.3 From 9822611b0e0b883bfa81a73c40ac8440f0ee21c2 Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Mon, 3 Jun 2019 16:28:08 +0200 Subject: corrected bug --- Source/Particles/PhotonParticleContainer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Particles/PhotonParticleContainer.cpp') diff --git a/Source/Particles/PhotonParticleContainer.cpp b/Source/Particles/PhotonParticleContainer.cpp index 9900bd1ad..2bcf87d6a 100644 --- a/Source/Particles/PhotonParticleContainer.cpp +++ b/Source/Particles/PhotonParticleContainer.cpp @@ -28,7 +28,7 @@ PhotonParticleContainer::PhotonParticleContainer (AmrCore* amr_core, int ispecie #ifdef WARPX_QED AddRealComp("tau"); - plot_flags.resize(PIdx::nattribs + 6, 1); + plot_flags.resize(PIdx::nattribs + 1, 1); #endif } -- cgit v1.2.3 From 727ebf6b085d58223033f235faebc1b7cd9a0b59 Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Mon, 26 Aug 2019 17:35:56 +0200 Subject: Fixed issues due to merge with dev --- Source/Particles/PhotonParticleContainer.H | 50 +++++++++++++++++++--------- Source/Particles/PhotonParticleContainer.cpp | 6 ++-- 2 files changed, 37 insertions(+), 19 deletions(-) (limited to 'Source/Particles/PhotonParticleContainer.cpp') diff --git a/Source/Particles/PhotonParticleContainer.H b/Source/Particles/PhotonParticleContainer.H index fbc68f0b0..3f948271b 100644 --- a/Source/Particles/PhotonParticleContainer.H +++ b/Source/Particles/PhotonParticleContainer.H @@ -46,22 +46,40 @@ public: amrex::Cuda::ManagedDeviceVector& giv, amrex::Real dt) override; - virtual void DepositCurrent(WarpXParIter& pti, - RealVector& wp, - RealVector& uxp, - RealVector& uyp, - RealVector& uzp, - amrex::MultiFab& jx, - amrex::MultiFab& jy, - amrex::MultiFab& jz, - amrex::MultiFab* cjx, - amrex::MultiFab* cjy, - amrex::MultiFab* cjz, - const long np_current, - const long np, - int thread_num, - int lev, - amrex::Real dt ) override {}; + + + + virtual void DepositCurrent(WarpXParIter& pti, + RealVector& wp, + RealVector& uxp, + RealVector& uyp, + RealVector& uzp, + const int * const ion_lev, + 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) override {}; + + 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) override {}; + private: diff --git a/Source/Particles/PhotonParticleContainer.cpp b/Source/Particles/PhotonParticleContainer.cpp index b4070a773..670f091d0 100644 --- a/Source/Particles/PhotonParticleContainer.cpp +++ b/Source/Particles/PhotonParticleContainer.cpp @@ -22,7 +22,7 @@ PhotonParticleContainer::PhotonParticleContainer (AmrCore* amr_core, int ispecie // where is the name of your species ParmParse pp(species_name); - // read .size_in_inches in the input file, and + // read .size_in_inches in the input file, and // store it into member data. pp.query("size_in_inches", size_in_inches); @@ -56,7 +56,7 @@ PhotonParticleContainer::PushPX(WarpXParIter& pti, auto& Byp = attribs[PIdx::By]; auto& Bzp = attribs[PIdx::Bz]; const long np = pti.numParticles(); - + // Probably want to push photons in some way here. // PhysicalParticleContainer::PushPX is probably // a good start. Let's start by writing CPU code. @@ -77,7 +77,7 @@ PhotonParticleContainer::Evolve (int lev, Real t, Real dt) { // This does gather, push and depose. - // Push and depose have been re-written for photon, + // Push and depose have been re-written for photon, // so they do not do anything. // Currently, I guess photons do gather fields from the mesh. PhysicalParticleContainer::Evolve (lev, -- cgit v1.2.3 From 4c2c9f149dffcd7943db92444490ade82ae47b67 Mon Sep 17 00:00:00 2001 From: Luca Date: Thu, 29 Aug 2019 03:23:02 +0200 Subject: Updated PushPX routine --- Source/Particles/PhotonParticleContainer.cpp | 46 +++++++++++++++++++--------- 1 file changed, 31 insertions(+), 15 deletions(-) (limited to 'Source/Particles/PhotonParticleContainer.cpp') diff --git a/Source/Particles/PhotonParticleContainer.cpp b/Source/Particles/PhotonParticleContainer.cpp index 670f091d0..5c84f8199 100644 --- a/Source/Particles/PhotonParticleContainer.cpp +++ b/Source/Particles/PhotonParticleContainer.cpp @@ -11,6 +11,9 @@ #include #include +// Import low-level single-particle kernels +#include + using namespace amrex; PhotonParticleContainer::PhotonParticleContainer (AmrCore* amr_core, int ispecies, @@ -44,25 +47,38 @@ PhotonParticleContainer::PushPX(WarpXParIter& pti, Cuda::ManagedDeviceVector& giv, Real dt) { - // This wraps the call to warpx_particle_pusher so that inheritors can modify the call. + // This wraps the momentum and position advance so that inheritors can modify the call. auto& attribs = pti.GetAttribs(); - auto& uxp = attribs[PIdx::ux]; - auto& uyp = attribs[PIdx::uy]; - auto& uzp = attribs[PIdx::uz]; - auto& Exp = attribs[PIdx::Ex]; - auto& Eyp = attribs[PIdx::Ey]; - auto& Ezp = attribs[PIdx::Ez]; - auto& Bxp = attribs[PIdx::Bx]; - auto& Byp = attribs[PIdx::By]; - auto& Bzp = attribs[PIdx::Bz]; - const long np = pti.numParticles(); + // 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(); - // Probably want to push photons in some way here. - // PhysicalParticleContainer::PushPX is probably - // a good start. Let's start by writing CPU code. - for (WarpXParIter pti(*this, 0); pti.isValid(); ++pti) + if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) { + copy_attribs(pti, x, y, z); } + + //No need to update momentum for photons (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 -- cgit v1.2.3 From 3992ec8b1de4c38b100e1b01360ae41836e5a413 Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Thu, 29 Aug 2019 17:51:28 +0200 Subject: Added some comments --- Source/Particles/PhotonParticleContainer.H | 3 ++- Source/Particles/PhotonParticleContainer.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'Source/Particles/PhotonParticleContainer.cpp') diff --git a/Source/Particles/PhotonParticleContainer.H b/Source/Particles/PhotonParticleContainer.H index 3f948271b..1c2c61dac 100644 --- a/Source/Particles/PhotonParticleContainer.H +++ b/Source/Particles/PhotonParticleContainer.H @@ -48,7 +48,7 @@ public: - + // DepositCurrent should do nothing for photons virtual void DepositCurrent(WarpXParIter& pti, RealVector& wp, RealVector& uxp, @@ -65,6 +65,7 @@ public: int depos_lev, amrex::Real dt) override {}; + // DepositCurrentFortran should do nothing for photons virtual void DepositCurrentFortran(WarpXParIter& pti, RealVector& wp, RealVector& uxp, diff --git a/Source/Particles/PhotonParticleContainer.cpp b/Source/Particles/PhotonParticleContainer.cpp index 5c84f8199..64b2e0095 100644 --- a/Source/Particles/PhotonParticleContainer.cpp +++ b/Source/Particles/PhotonParticleContainer.cpp @@ -69,7 +69,7 @@ PhotonParticleContainer::PushPX(WarpXParIter& pti, copy_attribs(pti, x, y, z); } - //No need to update momentum for photons (now) + //No need to update momentum for photons (for now) amrex::ParallelFor( pti.numParticles(), -- cgit v1.2.3 From d55fd6f190470cb56cfcbf3435d8b14a3ef597b8 Mon Sep 17 00:00:00 2001 From: MaxThevenet Date: Mon, 2 Sep 2019 07:10:11 -0700 Subject: fix compilation errors --- Source/Particles/PhotonParticleContainer.H | 32 ++++++++++++++-------------- Source/Particles/PhotonParticleContainer.cpp | 23 -------------------- 2 files changed, 16 insertions(+), 39 deletions(-) (limited to 'Source/Particles/PhotonParticleContainer.cpp') diff --git a/Source/Particles/PhotonParticleContainer.H b/Source/Particles/PhotonParticleContainer.H index 966fc1e2d..a4b8ca84c 100644 --- a/Source/Particles/PhotonParticleContainer.H +++ b/Source/Particles/PhotonParticleContainer.H @@ -50,22 +50,22 @@ public: amrex::Cuda::ManagedDeviceVector& giv, amrex::Real dt) override; - virtual void DepositCurrent(WarpXParIter& pti, - RealVector& wp, - RealVector& uxp, - RealVector& uyp, - RealVector& uzp, - amrex::MultiFab& jx, - amrex::MultiFab& jy, - amrex::MultiFab& jz, - amrex::MultiFab* cjx, - amrex::MultiFab* cjy, - amrex::MultiFab* cjz, - const long np_current, - const long np, - int thread_num, - int lev, - amrex::Real dt ) override {}; + + virtual void DepositCurrent(WarpXParIter& pti, + RealVector& wp, + RealVector& uxp, + RealVector& uyp, + RealVector& uzp, + const int * const ion_lev, + 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) override {}; //This function initialises the optical depth of the photons #ifdef WARPX_QED diff --git a/Source/Particles/PhotonParticleContainer.cpp b/Source/Particles/PhotonParticleContainer.cpp index 2bcf87d6a..31a62b739 100644 --- a/Source/Particles/PhotonParticleContainer.cpp +++ b/Source/Particles/PhotonParticleContainer.cpp @@ -50,29 +50,6 @@ PhotonParticleContainer::PushPX(WarpXParIter& pti, Cuda::ManagedDeviceVector& giv, Real dt) { - // This wraps the call to warpx_particle_pusher so that inheritors can modify the call. - auto& attribs = pti.GetAttribs(); - auto& uxp = attribs[PIdx::ux]; - auto& uyp = attribs[PIdx::uy]; - auto& uzp = attribs[PIdx::uz]; - auto& Exp = attribs[PIdx::Ex]; - auto& Eyp = attribs[PIdx::Ey]; - auto& Ezp = attribs[PIdx::Ez]; - auto& Bxp = attribs[PIdx::Bx]; - auto& Byp = attribs[PIdx::By]; - auto& Bzp = attribs[PIdx::Bz]; - const long np = pti.numParticles(); - - // Using new pusher for positions - const amrex_real zero_mass = 0.0; - warpx_particle_pusher_positions(&np, - xp.dataPtr(), - yp.dataPtr(), - zp.dataPtr(), - uxp.dataPtr(), uyp.dataPtr(), uzp.dataPtr(), - giv.dataPtr(), - &zero_mass, &dt, - &WarpX::particle_pusher_algo); } void -- cgit v1.2.3 From 0b2df2923cb1c4bafa95e3ddd5f22bc5681ddb32 Mon Sep 17 00:00:00 2001 From: MaxThevenet Date: Thu, 5 Sep 2019 09:39:13 -0700 Subject: add newline at end of file --- Source/Particles/PhotonParticleContainer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Particles/PhotonParticleContainer.cpp') diff --git a/Source/Particles/PhotonParticleContainer.cpp b/Source/Particles/PhotonParticleContainer.cpp index 326f756b1..61e602ffb 100644 --- a/Source/Particles/PhotonParticleContainer.cpp +++ b/Source/Particles/PhotonParticleContainer.cpp @@ -111,4 +111,4 @@ PhotonParticleContainer::Evolve (int lev, cBx, cBy, cBz, t, dt); -} \ No newline at end of file +} -- cgit v1.2.3 From 35ce418dd0d9ac0ef810450978ee0985d22b2990 Mon Sep 17 00:00:00 2001 From: MaxThevenet Date: Thu, 12 Sep 2019 08:32:31 -0700 Subject: further cleaning for photon PR --- Source/Particles/PhotonParticleContainer.H | 4 ---- Source/Particles/PhotonParticleContainer.cpp | 13 +------------ Source/QED/Make.package | 6 ------ Source/QED/amrex_rng_wrapper.cpp | 18 ------------------ Source/QED/amrex_rng_wrapper.h | 20 -------------------- Source/QED/breit_wheeler_engine_wrapper.h | 24 ------------------------ 6 files changed, 1 insertion(+), 84 deletions(-) delete mode 100644 Source/QED/Make.package delete mode 100644 Source/QED/amrex_rng_wrapper.cpp delete mode 100644 Source/QED/amrex_rng_wrapper.h delete mode 100644 Source/QED/breit_wheeler_engine_wrapper.h (limited to 'Source/Particles/PhotonParticleContainer.cpp') diff --git a/Source/Particles/PhotonParticleContainer.H b/Source/Particles/PhotonParticleContainer.H index c3ddb785c..4f9fbc047 100644 --- a/Source/Particles/PhotonParticleContainer.H +++ b/Source/Particles/PhotonParticleContainer.H @@ -65,10 +65,6 @@ public: int depos_lev, amrex::Real dt) {}; -private: - - amrex::Real size_in_inches = 1.; - }; #endif // #ifndef WARPX_PhotonParticleContainer_H_ diff --git a/Source/Particles/PhotonParticleContainer.cpp b/Source/Particles/PhotonParticleContainer.cpp index 61e602ffb..c0a159f1b 100644 --- a/Source/Particles/PhotonParticleContainer.cpp +++ b/Source/Particles/PhotonParticleContainer.cpp @@ -21,17 +21,7 @@ using namespace amrex; PhotonParticleContainer::PhotonParticleContainer (AmrCore* amr_core, int ispecies, const std::string& name) : PhysicalParticleContainer(amr_core, ispecies, name) -{ - - // This will read .[...] from the inputs file - // where is the name of your species - ParmParse pp(species_name); - - // read .size_in_inches in the input file, and - // store it into member data. - pp.query("size_in_inches", size_in_inches); - -} +{} void PhotonParticleContainer::InitData() { @@ -100,7 +90,6 @@ PhotonParticleContainer::Evolve (int lev, // This does gather, push and depose. // Push and depose have been re-written for photon, // so they do not do anything. - // Currently, I guess photons do gather fields from the mesh. PhysicalParticleContainer::Evolve (lev, Ex, Ey, Ez, Bx, By, Bz, diff --git a/Source/QED/Make.package b/Source/QED/Make.package deleted file mode 100644 index 6e38efb9e..000000000 --- a/Source/QED/Make.package +++ /dev/null @@ -1,6 +0,0 @@ -CEXE_headers += amrex_rng_wrapper.h -CEXE_headers += breit_wheeler_engine_wrapper.h -CEXE_sources += amrex_rng_wrapper.cpp - -INCLUDE_LOCATIONS += $(WARPX_HOME)/Source/QED -VPATH_LOCATIONS += $(WARPX_HOME)/Source/QED diff --git a/Source/QED/amrex_rng_wrapper.cpp b/Source/QED/amrex_rng_wrapper.cpp deleted file mode 100644 index 955144c4c..000000000 --- a/Source/QED/amrex_rng_wrapper.cpp +++ /dev/null @@ -1,18 +0,0 @@ -//This file provides a wrapper aroud the RNG -//provided by the amrex library - -#include "amrex_rng_wrapper.h" - -//RNG wrapper BW engine -//Get rnd number uniformly distributed in [a,b) -amrex::Real amrex_rng_wrapper::unf(amrex::Real a, amrex::Real b) -{ - return (b-a)*amrex::Random() + a; -} - -//Get rnd number with exponential distribution -amrex::Real amrex_rng_wrapper::exp(amrex::Real l) -{ - amrex::Real zero_plus_to_one = 1.0 - unf(0.0, 1.0); - return -log(zero_plus_to_one)/l; -} diff --git a/Source/QED/amrex_rng_wrapper.h b/Source/QED/amrex_rng_wrapper.h deleted file mode 100644 index f9818c589..000000000 --- a/Source/QED/amrex_rng_wrapper.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef WARPX_amrex_rng_wrapper_h_ -#define WARPX_rng_wrapper_h_ - -//This file provides a wrapper aroud the RNG -//provided by the amrex library - -#include - -//RNG wrapper BW engine -class amrex_rng_wrapper -{ -public: - //Get rnd number uniformly distributed in [a,b) - amrex::Real unf(amrex::Real a, amrex::Real b); - - //Get rnd number with exponential distribution - amrex::Real exp(amrex::Real l); -}; - -#endif //amrex_rng_wrapper_hpp_ diff --git a/Source/QED/breit_wheeler_engine_wrapper.h b/Source/QED/breit_wheeler_engine_wrapper.h deleted file mode 100644 index 3bb3ea740..000000000 --- a/Source/QED/breit_wheeler_engine_wrapper.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef WARPX_breit_wheeler_engine_wrapper_h_ -#define WARPX_breit_wheeler_engine_wrapper_h_ - -//This file provides a wrapper aroud the breit_wheeler engine -//provided by the standard template library - -//BW ENGINE -//#define PXRMP_GPU __host__ __device__ -#define PXRMP_WITH_SI_UNITS -#include "breit_wheeler_engine.hpp" - -#include "amrex_rng_wrapper.h" - -using warpx_breit_wheeler_engine = - picsar::multi_physics::breit_wheeler_engine; - -//Helper function to initialize the engine -inline warpx_breit_wheeler_engine init_warpx_breit_wheeler_engine(){ - return warpx_breit_wheeler_engine{std::move(amrex_rng_wrapper{})}; -} - -//___________________________________________ - -#endif //WARPX_breit_wheeler_engine_wrapper_H_ -- cgit v1.2.3