diff options
author | 2019-05-07 09:32:47 -0700 | |
---|---|---|
committer | 2019-05-07 09:32:47 -0700 | |
commit | 6bdafd570c25fde71d2ce93ecea6fbd803f8cf2c (patch) | |
tree | fd173453823f9267e32301bcbec5942baf8bfb0a | |
parent | 38b802c0ba0d47fd179a2b384e8867248de078e9 (diff) | |
download | WarpX-6bdafd570c25fde71d2ce93ecea6fbd803f8cf2c.tar.gz WarpX-6bdafd570c25fde71d2ce93ecea6fbd803f8cf2c.tar.zst WarpX-6bdafd570c25fde71d2ce93ecea6fbd803f8cf2c.zip |
laser and plasma cont injection combined and working with MW and boost in z
-rw-r--r-- | Source/Laser/LaserParticleContainer.H | 1 | ||||
-rw-r--r-- | Source/Laser/LaserParticleContainer.cpp | 46 | ||||
-rw-r--r-- | Source/Particles/MultiParticleContainer.H | 4 | ||||
-rw-r--r-- | Source/Particles/MultiParticleContainer.cpp | 24 | ||||
-rw-r--r-- | Source/Particles/WarpXParticleContainer.H | 1 | ||||
-rw-r--r-- | Source/Utils/WarpXMovingWindow.cpp | 4 |
6 files changed, 74 insertions, 6 deletions
diff --git a/Source/Laser/LaserParticleContainer.H b/Source/Laser/LaserParticleContainer.H index 4c7de4c81..bb36f4795 100644 --- a/Source/Laser/LaserParticleContainer.H +++ b/Source/Laser/LaserParticleContainer.H @@ -96,6 +96,7 @@ private: // Inject the laser antenna during the simulation, if it started // outside of the simulation domain and enters it. void ContinuousInjection(amrex::Real dt, const amrex::RealBox& prob_domain) override; + void UpdateContinuousInjectionPosition(amrex::Real dt) override; }; #endif diff --git a/Source/Laser/LaserParticleContainer.cpp b/Source/Laser/LaserParticleContainer.cpp index 569d99c97..8499455de 100644 --- a/Source/Laser/LaserParticleContainer.cpp +++ b/Source/Laser/LaserParticleContainer.cpp @@ -207,10 +207,6 @@ LaserParticleContainer::ContinuousInjection (Real dt, const RealBox& prob_domain { Print()<<" --- In LaserParticleContainer::ContinuousInjection"<<std::endl; Print()<<"z_antenna_th "<<z_antenna_th<<std::endl; - // update position of the antenna (outside of the box) - if (WarpX::gamma_boost>1){ - z_antenna_th -= PhysConst::c * WarpX::beta_boost * dt; - } // If laser antenna particles have not been injected yet, // check if they should be injected at this iteration. If // so, inject them and set done_injecting to 0 (false). @@ -240,6 +236,48 @@ LaserParticleContainer::ContinuousInjection (Real dt, const RealBox& prob_domain } void +LaserParticleContainer::UpdateContinuousInjectionPosition(Real dt) +{ + int dir = WarpX::moving_window_dir; + // update position of the antenna (outside of the box) + // Continuously inject plasma in new cells (by default only on level 0) + if (do_continuous_injection and (WarpX::gamma_boost > 1)){ + // In boosted-frame simulations, the plasma has moved since the last + // call to this function, and injection position needs to be updated + z_antenna_th -= WarpX::beta_boost * +#if ( AMREX_SPACEDIM == 3 ) + WarpX::boost_direction[dir] * PhysConst::c * dt; +#elif ( AMREX_SPACEDIM == 2 ) + // In 2D, dir=0 corresponds to x and dir=1 corresponds to z + // This needs to be converted in order to index `boost_direction` + // which has 3 components, for both 2D and 3D simulations. + WarpX::boost_direction[2*dir] * PhysConst::c * dt; +#endif + } + + /* + if (WarpX::do_plasma_injection and (WarpX::gamma_boost > 1){ + z_antenna_th -= PhysConst::c * WarpX::beta_boost * dt; + } + */ +} + + + + + + + + + + + + + + + + +void LaserParticleContainer::InitData () { InitData(maxLevel()); diff --git a/Source/Particles/MultiParticleContainer.H b/Source/Particles/MultiParticleContainer.H index c6bc6d768..f48daf9bb 100644 --- a/Source/Particles/MultiParticleContainer.H +++ b/Source/Particles/MultiParticleContainer.H @@ -172,7 +172,9 @@ public: void ContinuousInjection(amrex::Real dt, const amrex::RealBox& prob_domain) const; - + + void UpdateContinuousInjectionPosition(amrex::Real dt) const; + // // Parameters for the Cherenkov corrector in the FDTD solver. // Both stencils are calculated ar runtime. diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index 1ce0c5390..9810a168f 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -434,3 +434,27 @@ MultiParticleContainer::ContinuousInjection(Real dt, const RealBox& prob_domain) } } } + +void +MultiParticleContainer::UpdateContinuousInjectionPosition(Real dt) const +{ + for (int i=0; i<nspecies+nlasers; i++){ + auto& pc = allcontainers[i]; + Print()<<"i "<<i<<" pc->do_continuous_injection "<<pc->do_continuous_injection<<std::endl; + if (pc->do_continuous_injection) + { + Print()<<"i "<<i<<" pc->do_continuous_injection "<<pc->do_continuous_injection<<std::endl; + pc->UpdateContinuousInjectionPosition(dt); + } + } + /* + for (int i=nspecies; i<nspecies+nlasers; i++){ + // WarpXParticleContainer& pc = allcontainers[i]; + WarpXParticleContainer& pc = GetParticleContainer(i); + auto& lpc = dynamic_cast<LaserParticleContainer&>(pc); + // auto& pc = allcontainers[i]; + // auto& lpc = dynamic_cast<LaserParticleContainer&>(pc); + lpc.UpdateContinuousInjectionPosition(dt); + } + */ +} diff --git a/Source/Particles/WarpXParticleContainer.H b/Source/Particles/WarpXParticleContainer.H index 62f3570ad..51238907d 100644 --- a/Source/Particles/WarpXParticleContainer.H +++ b/Source/Particles/WarpXParticleContainer.H @@ -193,6 +193,7 @@ public: // RigidInjectedParticleContainer: not implemented. virtual void ContinuousInjection(amrex::Real dt, const amrex::RealBox& prob_domain) {} + virtual void UpdateContinuousInjectionPosition(amrex::Real dt) {} /// /// This returns the total charge for all the particles in this ParticleContainer. diff --git a/Source/Utils/WarpXMovingWindow.cpp b/Source/Utils/WarpXMovingWindow.cpp index 5b84a1eb0..2ba1d2f59 100644 --- a/Source/Utils/WarpXMovingWindow.cpp +++ b/Source/Utils/WarpXMovingWindow.cpp @@ -33,8 +33,10 @@ WarpX::MoveWindow (bool move_j) // and of the plasma injection moving_window_x += moving_window_v * dt[0]; int dir = moving_window_dir; - UpdatePlasmaInjectionPosition( dt[0] ); + UpdatePlasmaInjectionPosition( dt[0] ); + mypc->UpdateContinuousInjectionPosition( dt[0] ); + // compute the number of cells to shift on the base level Real new_lo[AMREX_SPACEDIM]; Real new_hi[AMREX_SPACEDIM]; |