aboutsummaryrefslogtreecommitdiff
path: root/Examples
diff options
context:
space:
mode:
Diffstat (limited to 'Examples')
-rwxr-xr-xExamples/Tests/plasma_lens/analysis.py18
-rw-r--r--Examples/Tests/plasma_lens/inputs_3d14
2 files changed, 20 insertions, 12 deletions
diff --git a/Examples/Tests/plasma_lens/analysis.py b/Examples/Tests/plasma_lens/analysis.py
index b348a3053..53b80f8d2 100755
--- a/Examples/Tests/plasma_lens/analysis.py
+++ b/Examples/Tests/plasma_lens/analysis.py
@@ -53,10 +53,13 @@ def applylens(x0, vx0, vz0, lens_length, lens_strength):
vx1 = -w*A*np.sin(w*t + phi)
return x1, vx1
+vel_z = eval(ds.parameters.get('my_constants.vel_z'))
+
plasma_lens_period = float(ds.parameters.get('particles.repeated_plasma_lens_period'))
plasma_lens_starts = [float(x) for x in ds.parameters.get('particles.repeated_plasma_lens_starts').split()]
plasma_lens_lengths = [float(x) for x in ds.parameters.get('particles.repeated_plasma_lens_lengths').split()]
-plasma_lens_strengths = [eval(x) for x in ds.parameters.get('particles.repeated_plasma_lens_strengths').split()]
+plasma_lens_strengths_E = [eval(x) for x in ds.parameters.get('particles.repeated_plasma_lens_strengths_E').split()]
+plasma_lens_strengths_B = [eval(x) for x in ds.parameters.get('particles.repeated_plasma_lens_strengths_B').split()]
clight = c
@@ -81,8 +84,9 @@ for i in range(len(plasma_lens_starts)):
tt = tt + dt
xx = xx + dt*ux
yy = yy + dt*uy
- xx, ux = applylens(xx, ux, uz, plasma_lens_lengths[i], plasma_lens_strengths[i])
- yy, uy = applylens(yy, uy, uz, plasma_lens_lengths[i], plasma_lens_strengths[i])
+ lens_strength = plasma_lens_strengths_E[i] + plasma_lens_strengths_B[i]*vel_z
+ xx, ux = applylens(xx, ux, uz, plasma_lens_lengths[i], lens_strength)
+ yy, uy = applylens(yy, uy, uz, plasma_lens_lengths[i], lens_strength)
dt = plasma_lens_lengths[i]/uz
tt = tt + dt
zz = z_lens + plasma_lens_lengths[i]
@@ -92,10 +96,10 @@ dt1 = (zz_sim1 - zz)/uz
xx = xx + dt0*ux
yy = yy + dt1*uy
-assert abs(xx - xx_sim) < 0.011, Exception('error in x particle position')
-assert abs(yy - yy_sim) < 0.011, Exception('error in y particle position')
-assert abs(ux - ux_sim) < 70., Exception('error in x particle velocity')
-assert abs(uy - uy_sim) < 70., Exception('error in y particle velocity')
+assert abs(np.abs((xx - xx_sim)/xx)) < 0.003, Exception('error in x particle position')
+assert abs(np.abs((yy - yy_sim)/yy)) < 0.003, Exception('error in y particle position')
+assert abs(np.abs((ux - ux_sim)/ux)) < 5.e-5, Exception('error in x particle velocity')
+assert abs(np.abs((uy - uy_sim)/uy)) < 5.e-5, Exception('error in y particle velocity')
test_name = os.path.split(os.getcwd())[1]
checksumAPI.evaluate_checksum(test_name, filename)
diff --git a/Examples/Tests/plasma_lens/inputs_3d b/Examples/Tests/plasma_lens/inputs_3d
index fa19685a2..c2a96a7a1 100644
--- a/Examples/Tests/plasma_lens/inputs_3d
+++ b/Examples/Tests/plasma_lens/inputs_3d
@@ -17,31 +17,35 @@ boundary.particle_lo = absorbing absorbing absorbing
boundary.particle_hi = absorbing absorbing absorbing
warpx.do_pml = 0
-warpx.const_dt = 1.e-6
+warpx.const_dt = 1.e-7
warpx.do_electrostatic = labframe
# Algorithms
algo.particle_shape = 1
+my_constants.vel_z = 0.2e6
+
# particles
particles.species_names = electrons
electrons.charge = -q_e
electrons.mass = m_e
electrons.injection_style = "MultipleParticles"
-electrons.multiple_particles_pos_x = 0.5 0.
-electrons.multiple_particles_pos_y = 0. 0.4
+electrons.multiple_particles_pos_x = 0.05 0.
+electrons.multiple_particles_pos_y = 0. 0.04
electrons.multiple_particles_pos_z = 0.05 0.05
electrons.multiple_particles_vel_x = 0. 0.
electrons.multiple_particles_vel_y = 0. 0.
-electrons.multiple_particles_vel_z = 0.02e6/clight 0.02e6/clight
+electrons.multiple_particles_vel_z = vel_z/clight vel_z/clight
electrons.multiple_particles_weight = 1. 1.
particles.E_ext_particle_init_style = repeated_plasma_lens
+particles.B_ext_particle_init_style = repeated_plasma_lens
particles.repeated_plasma_lens_period = 0.5
particles.repeated_plasma_lens_starts = 0.1 0.11 0.12 0.13
particles.repeated_plasma_lens_lengths = 0.1 0.11 0.12 0.13
-particles.repeated_plasma_lens_strengths = 0.07 0.06 0.06 0.03
+particles.repeated_plasma_lens_strengths_E = 0.06 0.08 0.06 0.02
+particles.repeated_plasma_lens_strengths_B = 0.08/vel_z 0.04/vel_z 0.06/vel_z 0.04/vel_z
# Diagnostics
diagnostics.diags_names = diag1