diff options
Diffstat (limited to 'Examples/Modules/RigidInjection')
-rwxr-xr-x | Examples/Modules/RigidInjection/analysis_rigid_injection_BF.py | 39 | ||||
-rw-r--r-- | Examples/Modules/RigidInjection/inputs.bf | 49 |
2 files changed, 88 insertions, 0 deletions
diff --git a/Examples/Modules/RigidInjection/analysis_rigid_injection_BF.py b/Examples/Modules/RigidInjection/analysis_rigid_injection_BF.py new file mode 100755 index 000000000..7522d1ab1 --- /dev/null +++ b/Examples/Modules/RigidInjection/analysis_rigid_injection_BF.py @@ -0,0 +1,39 @@ +#! /usr/bin/env python + +import sys, os, yt, glob +import numpy as np +import scipy.constants as scc +import read_raw_data +yt.funcs.mylog.setLevel(0) + +# filename = sys.argv[1] + +def get_particle_field(snapshot, species, field): + fn = snapshot + '/' + species + files = glob.glob(os.path.join(fn, field + '_*')) + files.sort() + all_data = np.array([]) + for f in files: + data = np.fromfile(f) + all_data = np.concatenate((all_data, data)) + return all_data + +# Read data from back-transformed diagnostics +snapshot = './lab_frame_data/snapshot00001' +header = './lab_frame_data/Header' +allrd, info = read_raw_data.read_lab_snapshot(snapshot, header) +z = np.mean( get_particle_field(snapshot, 'beam', 'z') ) +w = np.std ( get_particle_field(snapshot, 'beam', 'x') ) + +# initial parameters +z0 = 20.e-6 +w0 = 1.e-6 +theta0 = np.arcsin(0.1) + +# Theoretical beam width after propagation if rigid ON +wth = np.sqrt( w0**2 + (z-z0)**2*theta0**2 ) +error = np.abs((w-wth)/wth) + +# Print error and assert small error +print("error: " + str(error)) +assert( error < 0.03 ) diff --git a/Examples/Modules/RigidInjection/inputs.bf b/Examples/Modules/RigidInjection/inputs.bf new file mode 100644 index 000000000..c7a60f14f --- /dev/null +++ b/Examples/Modules/RigidInjection/inputs.bf @@ -0,0 +1,49 @@ +# stop_time = 1.5e-13 + +warpx.zmax_plasma_to_compute_max_step = 50.e-6 +warpx.gamma_boost = 5. +warpx.boost_direction = z +warpx.do_boosted_frame_diagnostic = 1 +warpx.num_snapshots_lab = 2 +warpx.dt_snapshots_lab = 1.8679589331096515e-13 + +amr.n_cell = 256 512 # 32 64 +amr.max_grid_size = 512 +amr.blocking_factor = 16 +amr.max_level = 0 +amr.plot_int = 100000 +geometry.coord_sys = 0 # 0: Cartesian +geometry.is_periodic = 1 0 # Is periodic? +geometry.prob_lo = -50.e-6 -10.e-6 +geometry.prob_hi = 50.e-6 0.e-6 +warpx.cfl = .999 +warpx.do_pml = 1 +warpx.do_moving_window = 1 +warpx.moving_window_dir = z +warpx.moving_window_v = 1.0 # in units of the speed of light +warpx.serialize_ics = 1 +particles.nspecies = 1 +particles.species_names = beam +particles.rigid_injected_species = beam +beam.charge = -q_e +beam.mass = m_e +beam.injection_style = "gaussian_beam" +beam.x_rms = 1.e-6 +beam.y_rms = 1.e-6 +beam.z_rms = .5e-6 +beam.x_m = 0. +beam.y_m = 0. +beam.z_m = -5.e-6 +beam.npart = 10000 +beam.q_tot = -1.e-20 +beam.momentum_distribution_type = "gaussian" +beam.ux_m = 0.0 +beam.uy_m = 0.0 +beam.uz_m = 1000. +beam.ux_th = 100. +beam.uy_th = 100. +beam.uz_th = 0. +beam.zinject_plane = 20.e-6 +beam.rigid_advance = true +beam.projected = true +beam.focused = false |