diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/Make.WarpX | 19 | ||||
-rw-r--r-- | Source/Particles/Make.package | 6 | ||||
-rw-r--r-- | Source/Particles/MultiParticleContainer.H | 3 | ||||
-rw-r--r-- | Source/Particles/MultiParticleContainer.cpp | 22 | ||||
-rw-r--r-- | Source/Particles/PhotonParticleContainer.H | 70 | ||||
-rw-r--r-- | Source/Particles/PhotonParticleContainer.cpp | 103 | ||||
-rw-r--r-- | Source/Particles/Pusher/Make.package | 1 | ||||
-rw-r--r-- | Source/Particles/Pusher/UpdatePositionPhoton.H | 29 | ||||
-rw-r--r-- | Source/Particles/WarpXParticleContainer.cpp | 14 |
9 files changed, 262 insertions, 5 deletions
diff --git a/Source/Make.WarpX b/Source/Make.WarpX index 958892c82..73133152e 100644 --- a/Source/Make.WarpX +++ b/Source/Make.WarpX @@ -81,6 +81,21 @@ ifeq ($(USE_SENSEI_INSITU),TRUE) include $(AMREX_HOME)/Src/Extern/SENSEI/Make.package endif +ifeq ($(QED),TRUE) + BOOST_ROOT ?= NOT_SET + ifneq ($(BOOST_ROOT),NOT_SET) + VPATH_LOCATIONS += $(BOOST_ROOT) + INCLUDE_LOCATIONS += $(BOOST_ROOT) + endif + INCLUDE_LOCATIONS += $(PICSAR_HOME)/src/multi_physics/QED/src + CXXFLAGS += -DWARPX_QED + CFLAGS += -DWARPX_QED + FFLAGS += -DWARPX_QED + F90FLAGS += -DWARPX_QED + include $(WARPX_HOME)/Source/QED/Make.package +endif + + include $(PICSAR_HOME)/src/Make.package WARPX_GIT_VERSION := $(shell cd $(WARPX_HOME); git describe --abbrev=12 --dirty --always --tags) @@ -160,7 +175,11 @@ ifeq ($(USE_HDF5),TRUE) LIBRARY_LOCATIONS += $(HDF5_HOME)/lib endif DEFINES += -DWARPX_USE_HDF5 +<<<<<<< HEAD + LIBRARIES += -lhdf5 -lz +======= libraries += -lhdf5 -lz +>>>>>>> dev endif # job_info support diff --git a/Source/Particles/Make.package b/Source/Particles/Make.package index db90de1dc..95f36cf65 100644 --- a/Source/Particles/Make.package +++ b/Source/Particles/Make.package @@ -1,14 +1,18 @@ F90EXE_sources += deposit_cic.F90 F90EXE_sources += interpolate_cic.F90 F90EXE_sources += push_particles_ES.F90 -CEXE_sources += PhysicalParticleContainer.cpp + CEXE_sources += MultiParticleContainer.cpp CEXE_sources += WarpXParticleContainer.cpp CEXE_sources += RigidInjectedParticleContainer.cpp +CEXE_sources += PhysicalParticleContainer.cpp +CEXE_sources += PhotonParticleContainer.cpp + CEXE_headers += MultiParticleContainer.H CEXE_headers += WarpXParticleContainer.H CEXE_headers += RigidInjectedParticleContainer.H CEXE_headers += PhysicalParticleContainer.H +CEXE_headers += PhotonParticleContainer.H CEXE_headers += ShapeFactors.H include $(WARPX_HOME)/Source/Particles/Pusher/Make.package diff --git a/Source/Particles/MultiParticleContainer.H b/Source/Particles/MultiParticleContainer.H index 2b18e174d..1aad4b2cb 100644 --- a/Source/Particles/MultiParticleContainer.H +++ b/Source/Particles/MultiParticleContainer.H @@ -6,6 +6,7 @@ #include <WarpXParticleContainer.H> #include <PhysicalParticleContainer.H> #include <RigidInjectedParticleContainer.H> +#include <PhotonParticleContainer.H> #include <LaserParticleContainer.H> #include <memory> @@ -193,7 +194,7 @@ public: protected: // Particle container types - enum struct PCTypes {Physical, RigidInjected}; + enum struct PCTypes {Physical, RigidInjected, Photon}; std::vector<std::string> species_names; diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index d5ad7a366..9c9bdcec4 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -10,6 +10,7 @@ using namespace amrex; MultiParticleContainer::MultiParticleContainer (AmrCore* amr_core) { + ReadParameters(); allcontainers.resize(nspecies + nlasers); @@ -20,6 +21,9 @@ MultiParticleContainer::MultiParticleContainer (AmrCore* amr_core) else if (species_types[i] == PCTypes::RigidInjected) { allcontainers[i].reset(new RigidInjectedParticleContainer(amr_core, i, species_names[i])); } + else if (species_types[i] == PCTypes::Photon) { + allcontainers[i].reset(new PhotonParticleContainer(amr_core, i, species_names[i])); + } allcontainers[i]->m_deposit_on_main_grid = m_deposit_on_main_grid[i]; allcontainers[i]->m_gather_from_main_grid = m_gather_from_main_grid[i]; } @@ -57,9 +61,11 @@ MultiParticleContainer::ReadParameters () BL_ASSERT(nspecies >= 0); if (nspecies > 0) { + // Get species names pp.getarr("species_names", species_names); BL_ASSERT(species_names.size() == nspecies); + // Get species to deposit on main grid m_deposit_on_main_grid.resize(nspecies, false); std::vector<std::string> tmp; pp.queryarr("deposit_on_main_grid", tmp); @@ -82,9 +88,9 @@ MultiParticleContainer::ReadParameters () species_types.resize(nspecies, PCTypes::Physical); + // Get rigid-injected species std::vector<std::string> rigid_injected_species; pp.queryarr("rigid_injected_species", rigid_injected_species); - if (!rigid_injected_species.empty()) { for (auto const& name : rigid_injected_species) { auto it = std::find(species_names.begin(), species_names.end(), name); @@ -93,6 +99,20 @@ MultiParticleContainer::ReadParameters () species_types[i] = PCTypes::RigidInjected; } } + // Get photon species + std::vector<std::string> photon_species; + pp.queryarr("photon_species", photon_species); + if (!photon_species.empty()) { + for (auto const& name : photon_species) { + auto it = std::find(species_names.begin(), species_names.end(), name); + AMREX_ALWAYS_ASSERT_WITH_MESSAGE( + it != species_names.end(), + "ERROR: species in particles.rigid_injected_species must be part of particles.species_names"); + int i = std::distance(species_names.begin(), it); + species_types[i] = PCTypes::Photon; + } + } + } pp.query("use_fdtd_nci_corr", WarpX::use_fdtd_nci_corr); diff --git a/Source/Particles/PhotonParticleContainer.H b/Source/Particles/PhotonParticleContainer.H new file mode 100644 index 000000000..4f9fbc047 --- /dev/null +++ b/Source/Particles/PhotonParticleContainer.H @@ -0,0 +1,70 @@ +#ifndef WARPX_PhotonParticleContainer_H_ +#define WARPX_PhotonParticleContainer_H_ + +#include <PhysicalParticleContainer.H> +#include <AMReX_Vector.H> + +class PhotonParticleContainer + : public PhysicalParticleContainer +{ +public: + PhotonParticleContainer (amrex::AmrCore* amr_core, + int ispecies, + const std::string& name); + virtual ~PhotonParticleContainer () {} + + virtual void InitData() override; + + virtual void Evolve (int lev, + const amrex::MultiFab& Ex, + const amrex::MultiFab& Ey, + const amrex::MultiFab& Ez, + const amrex::MultiFab& Bx, + const amrex::MultiFab& By, + const amrex::MultiFab& Bz, + amrex::MultiFab& jx, + amrex::MultiFab& jy, + amrex::MultiFab& jz, + amrex::MultiFab* cjx, + amrex::MultiFab* cjy, + amrex::MultiFab* cjz, + amrex::MultiFab* rho, + amrex::MultiFab* crho, + const amrex::MultiFab* cEx, + const amrex::MultiFab* cEy, + const amrex::MultiFab* cEz, + const amrex::MultiFab* cBx, + const amrex::MultiFab* cBy, + const amrex::MultiFab* cBz, + amrex::Real t, + amrex::Real dt) override; + + virtual void PushPX(WarpXParIter& pti, + amrex::Cuda::ManagedDeviceVector<amrex::Real>& xp, + amrex::Cuda::ManagedDeviceVector<amrex::Real>& yp, + amrex::Cuda::ManagedDeviceVector<amrex::Real>& zp, + amrex::Cuda::ManagedDeviceVector<amrex::Real>& giv, + amrex::Real dt) override; + + + + // DepositCurrent should do nothing for photons + 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) {}; + +}; + +#endif // #ifndef WARPX_PhotonParticleContainer_H_ diff --git a/Source/Particles/PhotonParticleContainer.cpp b/Source/Particles/PhotonParticleContainer.cpp new file mode 100644 index 000000000..c0a159f1b --- /dev/null +++ b/Source/Particles/PhotonParticleContainer.cpp @@ -0,0 +1,103 @@ +#include <limits> +#include <sstream> +#include <algorithm> + +#ifdef _OPENMP +#include <omp.h> +#endif + +#include <PhotonParticleContainer.H> +#include <WarpX_f.H> +#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, + const std::string& name) + : PhysicalParticleContainer(amr_core, ispecies, name) +{} + +void PhotonParticleContainer::InitData() +{ + AddParticles(0); // Note - add on level 0 + + if (maxLevel() > 0) { + Redistribute(); // We then redistribute + } +} + +void +PhotonParticleContainer::PushPX(WarpXParIter& pti, + Cuda::ManagedDeviceVector<Real>& xp, + Cuda::ManagedDeviceVector<Real>& yp, + Cuda::ManagedDeviceVector<Real>& zp, + 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 +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) +{ + // This does gather, push and depose. + // Push and depose have been re-written for photon, + // so they do not do anything. + 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); + +} 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..bd6e6cd21 --- /dev/null +++ b/Source/Particles/Pusher/UpdatePositionPhoton.H @@ -0,0 +1,29 @@ +#ifndef WARPX_PARTICLES_PUSHER_UPDATEPOSITIONPHOTON_H_ +#define WARPX_PARTICLES_PUSHER_UPDATEPOSITIONPHOTON_H_ + +#include <WarpXConst.H> + +#include <AMReX_FArrayBox.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_ diff --git a/Source/Particles/WarpXParticleContainer.cpp b/Source/Particles/WarpXParticleContainer.cpp index 6de7a6011..ee606aadb 100644 --- a/Source/Particles/WarpXParticleContainer.cpp +++ b/Source/Particles/WarpXParticleContainer.cpp @@ -136,7 +136,7 @@ WarpXParticleContainer::AddOneParticle (int lev, int grid, int tile, Real x, Real y, Real z, std::array<Real,PIdx::nattribs>& attribs) { - auto& particle_tile = GetParticles(lev)[std::make_pair(grid,tile)]; + auto& particle_tile = DefineAndReturnParticleTile(lev, grid, tile); AddOneParticle(particle_tile, x, y, z, attribs); } @@ -163,6 +163,11 @@ WarpXParticleContainer::AddOneParticle (ParticleTileType& particle_tile, particle_tile.push_back(p); particle_tile.push_back_real(attribs); + + for (int i = PIdx::nattribs; i < NumRealComps(); ++i) + { + particle_tile.push_back_real(i, 0.0); + } } void @@ -195,7 +200,7 @@ WarpXParticleContainer::AddNParticles (int lev, // Add to grid 0 and tile 0 // Redistribute() will move them to proper places. std::pair<int,int> key {0,0}; - auto& particle_tile = GetParticles(lev)[key]; + auto& particle_tile = DefineAndReturnParticleTile(0, 0, 0); std::size_t np = iend-ibegin; @@ -258,6 +263,11 @@ WarpXParticleContainer::AddNParticles (int lev, particle_tile.push_back_real(comp, np, 0.0); #endif } + + for (int i = PIdx::nattribs; i < NumRealComps(); ++i) + { + particle_tile.push_back_real(i, 0.0); + } } Redistribute(); |