diff options
author | 2021-06-22 01:13:22 +0200 | |
---|---|---|
committer | 2021-06-21 16:13:22 -0700 | |
commit | a02434ac09285d05b781b88285126d2238d870d7 (patch) | |
tree | cb4e7240546385f15c885464ffc4e61e19b0db81 /Source/Particles/LaserParticleContainer.cpp | |
parent | 37c9ca8e698f62ecbe008bde211fc47c0ea05bd2 (diff) | |
download | WarpX-a02434ac09285d05b781b88285126d2238d870d7.tar.gz WarpX-a02434ac09285d05b781b88285126d2238d870d7.tar.zst WarpX-a02434ac09285d05b781b88285126d2238d870d7.zip |
Laser: warnin antenna of a box; Allow zero amplitude (#1989)
* add check of laser antenna position
* implement axel suggestions
* disable laser if antenna is out the box
* fix bug
* Update Source/Particles/LaserParticleContainer.cpp
* implement neil's solution
* remove unnecessary include
* fix initial status of m_enabled
* adding back a check
* add back check
* add back check
* removed unnecessary comment
Co-authored-by: Neïl Zaim <49716072+NeilZaim@users.noreply.github.com>
Diffstat (limited to 'Source/Particles/LaserParticleContainer.cpp')
-rw-r--r-- | Source/Particles/LaserParticleContainer.cpp | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/Source/Particles/LaserParticleContainer.cpp b/Source/Particles/LaserParticleContainer.cpp index c17dd11b7..4eb2e59f0 100644 --- a/Source/Particles/LaserParticleContainer.cpp +++ b/Source/Particles/LaserParticleContainer.cpp @@ -71,6 +71,7 @@ LaserParticleContainer::LaserParticleContainer (AmrCore* amr_core, int ispecies, if (m_e_max == amrex::Real(0.)){ amrex::Print() << m_laser_name << " with zero amplitude disabled.\n"; + m_enabled = false; return; // Disable laser if amplitude is 0 } @@ -164,8 +165,8 @@ LaserParticleContainer::LaserParticleContainer (AmrCore* amr_core, int ispecies, //Init laser profile - AMREX_ALWAYS_ASSERT_WITH_MESSAGE(m_e_max > 0., - "Laser amplitude (e_max) must be positive."); + AMREX_ALWAYS_ASSERT_WITH_MESSAGE(m_e_max >= 0., + "Laser amplitude (e_max) must be >= 0."); AMREX_ALWAYS_ASSERT_WITH_MESSAGE(m_wavelength > 0., "Laser wavelength must be positive."); @@ -184,13 +185,13 @@ LaserParticleContainer::LaserParticleContainer (AmrCore* amr_core, int ispecies, void LaserParticleContainer::ContinuousInjection (const RealBox& injection_box) { + if (!m_enabled) return; + // Input parameter injection_box contains small box where injection // should occur. // So far, LaserParticleContainer::laser_injection_box contains the // outdated full problem domain at t=0. - if (m_e_max == amrex::Real(0.)) return; // Disable laser if amplitude is 0 - // Convert updated_position to Real* to use RealBox::contains(). #if (AMREX_SPACEDIM == 3) const Real* p_pos = m_updated_position.dataPtr(); @@ -214,7 +215,7 @@ LaserParticleContainer::ContinuousInjection (const RealBox& injection_box) void LaserParticleContainer::UpdateContinuousInjectionPosition (Real dt) { - if (m_e_max == amrex::Real(0.)) return; // Disable laser if amplitude is 0 + if (!m_enabled) return; int dir = WarpX::moving_window_dir; if (do_continuous_injection and (WarpX::gamma_boost > 1)){ @@ -236,15 +237,22 @@ LaserParticleContainer::UpdateContinuousInjectionPosition (Real dt) void LaserParticleContainer::InitData () { + if (!m_enabled) return; + // Call InitData on max level to inject one laser particle per // finest cell. InitData(maxLevel()); + + if(!do_continuous_injection && (TotalNumberOfParticles() == 0)){ + amrex::Print() << "WARNING: laser antenna is completely out of the simulation box !!!\n"; + m_enabled = false; // Disable laser if antenna is completely out of the simulation box + } } void LaserParticleContainer::InitData (int lev) { - if (m_e_max == amrex::Real(0.)) return; // Disable laser if amplitude is 0 + if (!m_enabled) return; // spacing of laser particles in the laser plane. // has to be done after geometry is set up. @@ -423,7 +431,7 @@ LaserParticleContainer::Evolve (int lev, WARPX_PROFILE("LaserParticleContainer::Evolve()"); WARPX_PROFILE_VAR_NS("LaserParticleContainer::Evolve::ParticlePush", blp_pp); - if (m_e_max == amrex::Real(0.)) return; // Disable laser if amplitude is 0 + if (!m_enabled) return; Real t_lab = t; if (WarpX::gamma_boost > 1) { @@ -550,7 +558,8 @@ LaserParticleContainer::Evolve (int lev, void LaserParticleContainer::PostRestart () { - if (m_e_max == amrex::Real(0.)) return; // Disable laser if amplitude is 0 + if (!m_enabled) return; + Real Sx, Sy; const int lev = finestLevel(); ComputeSpacing(lev, Sx, Sy); |