diff options
author | 2021-08-05 17:22:45 -0700 | |
---|---|---|
committer | 2021-08-05 17:22:45 -0700 | |
commit | 48fa50a7d92a01061e6563fe2c52f55a0de76bb7 (patch) | |
tree | 2843da7183a4c1f0c14cd8e44d485897ab8b7ae6 /Examples/Tests/plasma_lens/analysis.py | |
parent | dc4a2026aae0cc282e09906bfbd621b5bcbfdf7e (diff) | |
download | WarpX-48fa50a7d92a01061e6563fe2c52f55a0de76bb7.tar.gz WarpX-48fa50a7d92a01061e6563fe2c52f55a0de76bb7.tar.zst WarpX-48fa50a7d92a01061e6563fe2c52f55a0de76bb7.zip |
Added B field to plasma lens (#2163)
* Added B field to plasma lens
* Fix B field and updated CI test to include the B field
* Updated benchmark
Diffstat (limited to 'Examples/Tests/plasma_lens/analysis.py')
-rwxr-xr-x | Examples/Tests/plasma_lens/analysis.py | 18 |
1 files changed, 11 insertions, 7 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) |