From 55e5528cfebd958ba341a059f01bdde4ea288e61 Mon Sep 17 00:00:00 2001 From: Remi Lehe Date: Tue, 2 Nov 2021 17:34:08 -0700 Subject: Change the way in which the laser particle weight is calculated. (#2417) * Minor fixes to the laser particles * Update calculation of the weights for laser antenna particles * Correct name of the constant epsilon_0 * Correct unused variables * Update 2D benchmarks * Update 3D benchmarks * Update RZ tests * Update benchmark for pml_x_psatd * Update energy value --- Source/Particles/LaserParticleContainer.cpp | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'Source/Particles/LaserParticleContainer.cpp') diff --git a/Source/Particles/LaserParticleContainer.cpp b/Source/Particles/LaserParticleContainer.cpp index 1790f3019..559489f34 100644 --- a/Source/Particles/LaserParticleContainer.cpp +++ b/Source/Particles/LaserParticleContainer.cpp @@ -650,27 +650,26 @@ LaserParticleContainer::ComputeSpacing (int lev, Real& Sx, Real& Sy) const void LaserParticleContainer::ComputeWeightMobility (Real Sx, Real Sy) { - constexpr Real eps = 0.01_rt; - constexpr Real fac = 1.0_rt / (2.0_rt * MathConst::pi * PhysConst::mu0 * PhysConst::c * PhysConst::c * eps); - m_weight = fac * m_wavelength * Sx * Sy / std::min(Sx,Sy) * m_e_max; - // The mobility is the constant of proportionality between the field to // be emitted, and the corresponding velocity that the particles need to have. - m_mobility = (Sx * Sy)/(m_weight * PhysConst::mu0 * PhysConst::c * PhysConst::c); + // We set the mobility so that the particles do not exceed a fraction + // `eps` of the speed of light, at the peak of the laser field. + constexpr Real eps = 0.05_rt; + m_mobility = eps/m_e_max; + m_weight = PhysConst::ep0 / m_mobility; + // Multiply by particle spacing +#if (AMREX_SPACEDIM == 3) + m_weight *= Sx * Sy; +#elif (AMREX_SPACEDIM == 2) + m_weight *= Sx; + amrex::ignore_unused(Sy); +#else + amrex::ignore_unused(Sx,Sy); +#endif // When running in the boosted-frame, the input parameters (and in particular // the amplitude of the field) are given in the lab-frame. // Therefore, the mobility needs to be modified by a factor WarpX::gamma_boost. m_mobility = m_mobility/WarpX::gamma_boost; - - // If mobility is too high (caused by a small wavelength compared to the grid size), - // calculated antenna particle velocities may exceed c, which can cause a segfault. - constexpr Real warning_tol = 0.1_rt; - if (m_wavelength < std::min(Sx,Sy)*warning_tol){ - WarpX::GetInstance().RecordWarning("Laser", - "Laser wavelength seems to be much smaller than the grid size." - " This may cause a segmentation fault", - WarnPriority::high); - } } void -- cgit v1.2.3