Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Rigid injection: Center field scaling around the v push #5389

Draft
wants to merge 4 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
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();
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