From 1f0233fa15890309c601a15e45859fd68bdf6e69 Mon Sep 17 00:00:00 2001 From: RevathiJambunathan Date: Thu, 19 Oct 2023 21:00:45 -0700 Subject: [PATCH] scale re for radiation using gamma_rad --- .../Particles/PhysicalParticleContainer.cpp | 12 +++++------- Source/Particles/PulsarParameters.H | 6 ++++++ Source/Particles/PulsarParameters.cpp | 19 +++++++++++++++++++ Source/Particles/Pusher/PushSelector.H | 6 +++--- ...UpdateMomentumBorisWithRadiationReaction.H | 15 +++++++-------- .../RigidInjectedParticleContainer.cpp | 5 ++--- 6 files changed, 42 insertions(+), 21 deletions(-) diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index f5ac1772d48..273566f084c 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -2854,8 +2854,7 @@ PhysicalParticleContainer::PushP (int lev, Real dt, amrex::Real BC_width = Pulsar::m_BC_width; amrex::Real gather_buffer_boxmin = Pulsar::m_gatherbuffer_min; amrex::Real gather_buffer_boxmax = Pulsar::m_gatherbuffer_max; - amrex::Real gammarad_real = Pulsar::m_gammarad_real; - amrex::Real gammarad_scaled = Pulsar::m_gammarad_scaled; + amrex::Real re_scaledratio = Pulsar::m_re_scaledratio; #endif #ifdef AMREX_USE_OMP @@ -3020,7 +3019,7 @@ PhysicalParticleContainer::PushP (int lev, Real dt, Exp, Eyp, Ezp, Bxp, Byp, Bzp, qp, m, #ifdef PULSAR - gammarad_real, gammarad_scaled, + re_scaledratio, #endif dt); } else if (pusher_algo == ParticlePusherAlgo::Boris) { @@ -3164,8 +3163,7 @@ PhysicalParticleContainer::PushPX (WarpXParIter& pti, amrex::Real BC_width = Pulsar::m_BC_width; amrex::Real gather_buffer_boxmin = Pulsar::m_gatherbuffer_min; amrex::Real gather_buffer_boxmax = Pulsar::m_gatherbuffer_max; - amrex::Real gammarad_real = Pulsar::m_gammarad_real; - amrex::Real gammarad_scaled = Pulsar::m_gammarad_scaled; + amrex::Real re_scaledratio = Pulsar::m_re_scaledratio; #endif @@ -3417,7 +3415,7 @@ PhysicalParticleContainer::PushPX (WarpXParIter& pti, t_chi_max, #endif #ifdef PULSAR - gammarad_real, gammarad_scaled, + re_scaledratio, #endif dt); // PulsarPartDiagData); @@ -3457,7 +3455,7 @@ PhysicalParticleContainer::PushPX (WarpXParIter& pti, m, q, pusher_algo, do_crr, do_copy, t_chi_max, #ifdef PULSAR - gammarad_real, gammarad_scaled, + re_scaledratio, #endif dt); } diff --git a/Source/Particles/PulsarParameters.H b/Source/Particles/PulsarParameters.H index 6ec6cada0af..cda38107a66 100644 --- a/Source/Particles/PulsarParameters.H +++ b/Source/Particles/PulsarParameters.H @@ -707,6 +707,12 @@ public: static amrex::Real m_gammarad_scaled; static amrex::Real m_damping_strength; static amrex::Real m_totalcells_injectionring; + static int m_do_scale_re_RR; + static amrex::Real m_re_scaled; + static amrex::Real m_gammarad_RR; + static amrex::Real m_BLC; + static amrex::Real m_beta_rec_RR; + static amrex::Real m_re_scaledratio; private: }; diff --git a/Source/Particles/PulsarParameters.cpp b/Source/Particles/PulsarParameters.cpp index e918c3d47f7..d8d943f678e 100644 --- a/Source/Particles/PulsarParameters.cpp +++ b/Source/Particles/PulsarParameters.cpp @@ -147,6 +147,12 @@ amrex::Real Pulsar::m_gammarad_real = 1.; amrex::Real Pulsar::m_gammarad_scaled = 1.; amrex::Real Pulsar::m_damping_strength = 4.; amrex::Real Pulsar::m_totalcells_injectionring = 0; +int Pulsar::m_do_scale_re_RR = 0; +amrex::Real Pulsar::m_re_scaled; +amrex::Real Pulsar::m_gammarad_RR; +amrex::Real Pulsar::m_BLC; +amrex::Real Pulsar::m_beta_rec_RR; +amrex::Real Pulsar::m_re_scaledratio = 1.; Pulsar::Pulsar () { @@ -383,6 +389,19 @@ Pulsar::ReadParameters () { pp.get("damping_strength", m_damping_strength); amrex::Print() << " damping strength in PML " << m_damping_strength << "\n"; amrex::Print() << " cubic pml flag : " << m_pml_cubic_sigma << "\n"; + // for radiation reaction with scaled electron radius + pp.get("scale_re_for_RR", m_do_scale_re_RR); + if (m_do_scale_re_RR == 1) { + pp.get("gammarad_RR",m_gammarad_RR); // gammathreshold at which re is scaled + pp.get("beta_rec_RR",m_beta_rec_RR); // reconnection rate + amrex::Real S = m_RLC/m_R_star; // Scale separation ratio + m_BLC = m_B_star/(S*S*S); // Bfield at LC + m_re_scaled = m_beta_rec_RR * (3./2.) * PhysConst::m_e * PhysConst::c + / (m_gammarad_RR * m_gammarad_RR * PhysConst::q_e * m_BLC); + amrex::Print() << " re_scaled at gammarad : " << m_gammarad_RR << " is : " << m_re_scaled << "\n"; + m_re_scaledratio = m_re_scaled / PhysConst::r_e; + amrex::Print() << " ratio : re_scaled/re : " << m_re_scaledratio << "\n"; + } } diff --git a/Source/Particles/Pusher/PushSelector.H b/Source/Particles/Pusher/PushSelector.H index 8580b964a22..cd42f55d953 100644 --- a/Source/Particles/Pusher/PushSelector.H +++ b/Source/Particles/Pusher/PushSelector.H @@ -66,7 +66,7 @@ void doParticlePush(const GetParticlePosition& GetPosition, const amrex::Real t_chi_max, #endif #ifdef PULSAR - const amrex::Real gammarad_real, const amrex::Real gammarad_scaled, + const amrex::Real re_scaledratio, #endif const amrex::Real dt, amrex::Real * PulsarDiag = nullptr) { @@ -86,7 +86,7 @@ void doParticlePush(const GetParticlePosition& GetPosition, Ex, Ey, Ez, Bx, By, Bz, qp, m, #ifdef PULSAR - gammarad_real, gammarad_scaled, + re_scaledratio, #endif dt); } @@ -107,7 +107,7 @@ void doParticlePush(const GetParticlePosition& GetPosition, Ex, Ey, Ez, Bx, By, Bz, qp, m, #ifdef PULSAR - gammarad_real, gammarad_scaled, + re_scaledratio, #endif dt); amrex::ParticleReal x, y, z; diff --git a/Source/Particles/Pusher/UpdateMomentumBorisWithRadiationReaction.H b/Source/Particles/Pusher/UpdateMomentumBorisWithRadiationReaction.H index f3956d5ce9e..f46705f5133 100644 --- a/Source/Particles/Pusher/UpdateMomentumBorisWithRadiationReaction.H +++ b/Source/Particles/Pusher/UpdateMomentumBorisWithRadiationReaction.H @@ -27,7 +27,7 @@ void UpdateMomentumBorisWithRadiationReaction( const amrex::ParticleReal Bx, const amrex::ParticleReal By, const amrex::ParticleReal Bz, const amrex::ParticleReal q, const amrex::ParticleReal m, #ifdef PULSAR - const amrex::Real gammarad_real, const amrex::Real gammarad_scaled, + const amrex::Real re_scaledratio, #endif const amrex::Real dt ) { @@ -75,18 +75,17 @@ void UpdateMomentumBorisWithRadiationReaction( //Calculation of auxiliary quantities const amrex::ParticleReal bdotE = (bx_n*Ex + by_n*Ey + bz_n*Ez); const amrex::ParticleReal bdotE2 = bdotE*bdotE; -#ifdef PULSAR - // To account for radiation reaction in the scaled pulsar simulation - // we scale the ultra-relativistic term, gamma_n with gamma_real/gamma_scaled - const amrex::ParticleReal gamma_scale_fac = gammarad_scaled/gammarad_real; - const amrex::ParticleReal coeff = gamma_scale_fac*gamma_scale_fac*gamma_n*gamma_n*(fl_q2-bdotE2); -#else const amrex::ParticleReal coeff = gamma_n*gamma_n*(fl_q2-bdotE2); -#endif //Radiation reaction constant const amrex::ParticleReal q_over_mc = q/(m*PhysConst::c); +#ifdef PULSAR + // For a scaled down system, we scale up radiation reaction drag force by upscaling re + // re_scaled is derived by equating the drag force and accelerating force, for a set gammarad < sigma_LC + const amrex::ParticleReal RRcoeff = (2.0_prt/3.0_prt)*PhysConst::r_e*re_scaledratio*q_over_mc*q_over_mc; +#else const amrex::ParticleReal RRcoeff = (2.0_prt/3.0_prt)*PhysConst::r_e*q_over_mc*q_over_mc; +#endif //Compute the components of the RR force const amrex::ParticleReal frx = diff --git a/Source/Particles/RigidInjectedParticleContainer.cpp b/Source/Particles/RigidInjectedParticleContainer.cpp index e63e46ed626..e0421588bd7 100644 --- a/Source/Particles/RigidInjectedParticleContainer.cpp +++ b/Source/Particles/RigidInjectedParticleContainer.cpp @@ -409,8 +409,7 @@ RigidInjectedParticleContainer::PushP (int lev, Real dt, const auto do_crr = do_classical_radiation_reaction; #ifdef PULSAR - amrex::Real gammarad_real = Pulsar::m_gammarad_real; - amrex::Real gammarad_scaled = Pulsar::m_gammarad_scaled; + amrex::Real re_scaledratio = Pulsar::m_re_scaledratio; #endif amrex::ParallelFor( np, [=] AMREX_GPU_DEVICE (long ip) @@ -441,7 +440,7 @@ RigidInjectedParticleContainer::PushP (int lev, Real dt, Exp, Eyp, Ezp, Bxp, Byp, Bzp, qp, m, #ifdef PULSAR - gammarad_real, gammarad_scaled, + re_scaledratio, #endif dt); } else if (pusher_algo == ParticlePusherAlgo::Boris) {