Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ electrons.uz = gamma_bunch
electrons.zmax = -25e-6
electrons.zmin = -125e-6
electrons.zinject_plane=0.0
electrons.rigid_advance=0

positrons.charge = q_e
positrons.injection_style = nuniformpercell
Expand All @@ -77,7 +76,6 @@ positrons.uz = gamma_bunch
positrons.zmax = -25e-6
positrons.zmin = -125e-6
positrons.zinject_plane=0.0
positrons.rigid_advance=0

warpx.do_moving_window = 1
warpx.moving_window_dir = z
Expand All @@ -86,7 +84,7 @@ warpx.moving_window_v = sqrt(1-(1+K*K/2)/(gamma_bunch*gamma_bunch))
# Undulator field
particles.B_ext_particle_init_style = parse_B_ext_particle_function
particles.Bx_external_particle_function(x,y,z,t) = 0
particles.By_external_particle_function(x,y,z,t) = if( z>0, Bu*cos(k_u*z), 0 )
particles.By_external_particle_function(x,y,z,t) = Bu*cos(k_u*z)
particles.Bz_external_particle_function(x,y,z,t) =0.0

warpx.cfl = 0.99
7 changes: 5 additions & 2 deletions Source/Particles/Gather/ScaleFields.H
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ struct ScaleFields
// This only approximates what should be happening. The particles
// should by advanced a fraction of a time step instead.
// Scaling the fields is much easier and may be good enough.
const amrex::Real dtscale = 1._rt - (m_z_plane_previous - zp)/(m_vz_ave_boosted + m_v_boost)/m_dt;
if (0._rt < dtscale && dtscale < 1._rt)
amrex::Real dtscale = 0.5_rt - (m_z_plane_previous - zp)/(m_vz_ave_boosted + m_v_boost)/m_dt;
if (dtscale < 0._rt) {
dtscale = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps add a comment that since the scale factor is zero, the push of the velocity doesn't change the velocity.

}
if (dtscale < 1._rt)
{
Exp *= dtscale;
Eyp *= dtscale;
Expand Down
6 changes: 0 additions & 6 deletions Source/Particles/RigidInjectedParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,6 @@ RigidInjectedParticleContainer::PushPX (WarpXParIter& pti,
amrex::ParticleReal* AMREX_RESTRICT x_save = xp_save.dataPtr();
amrex::ParticleReal* AMREX_RESTRICT y_save = yp_save.dataPtr();
amrex::ParticleReal* AMREX_RESTRICT z_save = zp_save.dataPtr();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Saving and re-setting u to its original value is not needed anymore since the scaling factor for E and B is 0 for particles to the left of the plane.

amrex::ParticleReal* AMREX_RESTRICT ux_save = uxp_save.dataPtr();
amrex::ParticleReal* AMREX_RESTRICT uy_save = uyp_save.dataPtr();
amrex::ParticleReal* AMREX_RESTRICT uz_save = uzp_save.dataPtr();

// Undo the push for particles not injected yet.
// The zp are advanced a fixed amount.
Expand All @@ -267,9 +264,6 @@ RigidInjectedParticleContainer::PushPX (WarpXParIter& pti,
amrex::ParticleReal xp, yp, zp;
GetPosition(i, xp, yp, zp);
if (zp <= z_plane_lev) {
ux[i] = ux_save[i];
uy[i] = uy_save[i];
uz[i] = uz_save[i];
xp = x_save[i];
yp = y_save[i];
if (rigid) {
Expand Down