diff options
Diffstat (limited to 'Examples/Modules')
3 files changed, 149 insertions, 2 deletions
diff --git a/Examples/Modules/RigidInjection/analysis_rigid_injection_BoostedFrame.py b/Examples/Modules/RigidInjection/analysis_rigid_injection_BoostedFrame.py index 3dcf40ac8..f28272897 100755 --- a/Examples/Modules/RigidInjection/analysis_rigid_injection_BoostedFrame.py +++ b/Examples/Modules/RigidInjection/analysis_rigid_injection_BoostedFrame.py @@ -19,8 +19,8 @@ import read_raw_data yt.funcs.mylog.setLevel(0) # Read data from back-transformed diagnostics -snapshot = './lab_frame_data/snapshot00001' -header = './lab_frame_data/Header' +snapshot = './lab_frame_data/snapshots/snapshot00001' +header = './lab_frame_data/snapshots/Header' allrd, info = read_raw_data.read_lab_snapshot(snapshot, header) z = np.mean( read_raw_data.get_particle_field(snapshot, 'beam', 'z') ) w = np.std ( read_raw_data.get_particle_field(snapshot, 'beam', 'x') ) diff --git a/Examples/Modules/boosted_diags/analysis_3Dbacktransformed_diag.py b/Examples/Modules/boosted_diags/analysis_3Dbacktransformed_diag.py new file mode 100755 index 000000000..3b8e7aa76 --- /dev/null +++ b/Examples/Modules/boosted_diags/analysis_3Dbacktransformed_diag.py @@ -0,0 +1,36 @@ +#! /usr/bin/env python + +''' +Analysis script of a WarpX simulation in a boosted frame. + +The simulation runs in a boosted frame, and the analysis is done in the lab +frame, i.e., on the back-transformed diagnostics for the full 3D simulation and +an x-z slice at y=y_center. The field-data, Ez, along z, at (x_center,y_center,:) is compared +between the full back-transformed diagnostic and the reduced diagnostic (i.e., x-z slice) . +''' + +import numpy as np +import read_raw_data + +# Read data from back-transformed diagnostics of entire domain +snapshot = './lab_frame_data/snapshots/snapshot00002' +header = './lab_frame_data/snapshots/Header' +allrd, info = read_raw_data.read_lab_snapshot(snapshot, header) +F = allrd['Ez'] +print("F.shape ", F.shape) +F_1D = np.squeeze(F[F.shape[0]//2,F.shape[1]//2,:]) + + +# Read data from reduced back-transformed diagnostics (i.e. slice) +snapshot_slice = './lab_frame_data/slices/slice00002' +header_slice = './lab_frame_data/slices/Header' +allrd, info = read_raw_data.read_lab_snapshot(snapshot_slice, header_slice) +Fs = allrd['Ez'] +print("Fs.shape", Fs.shape) +Fs_1D = np.squeeze(Fs[Fs.shape[0]//2,1,:]) + +error = np.max(np.abs(Fs_1D - F_1D)) / np.max(np.abs(F_1D)) + +# Print error and assert small error +print("relative error: " + str(error)) +assert( error < 1E-15 ) diff --git a/Examples/Modules/boosted_diags/inputs.3d.slice b/Examples/Modules/boosted_diags/inputs.3d.slice new file mode 100644 index 000000000..fdd150949 --- /dev/null +++ b/Examples/Modules/boosted_diags/inputs.3d.slice @@ -0,0 +1,111 @@ +warpx.zmax_plasma_to_compute_max_step = 0.0031 + +amr.n_cell = 32 32 64 +amr.max_grid_size = 64 +amr.blocking_factor = 32 +amr.max_level = 0 +amr.plot_int = 10000 + +geometry.coord_sys = 0 # 0: Cartesian +geometry.is_periodic = 1 1 0 # Is periodic? +geometry.prob_lo = -128.e-6 -128.e-6 -40.e-6 +geometry.prob_hi = 128.e-6 128.e-6 0.96e-6 + +algo.current_deposition = esirkepov +algo.charge_deposition = standard +algo.field_gathering = standard +algo.particle_pusher = vay +algo.maxwell_fdtd_solver = ckc +interpolation.nox = 3 +interpolation.noy = 3 +interpolation.noz = 3 +warpx.use_filter = 1 +warpx.cfl = 1. +warpx.do_pml = 0 + +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 + +warpx.gamma_boost = 10. +warpx.boost_direction = z +warpx.do_boosted_frame_diagnostic = 1 +warpx.num_snapshots_lab = 4 +warpx.dz_snapshots_lab = 0.001 +warpx.boosted_frame_diag_fields= Ex Ey Ez By rho + +particles.nspecies = 3 +particles.species_names = electrons ions beam +particles.use_fdtd_nci_corr = 1 + +electrons.charge = -q_e +electrons.mass = m_e +electrons.injection_style = NUniformPerCell +electrons.num_particles_per_cell_each_dim = 1 1 1 +electrons.momentum_distribution_type = "gaussian" +electrons.xmin = -120.e-6 +electrons.xmax = 120.e-6 +electrons.ymin = -120.e-6 +electrons.ymax = 120.e-6 +electrons.zmin = 0. +electrons.zmax = .003 +electrons.profile = constant +electrons.density = 3.5e24 +electrons.do_continuous_injection = 1 +electrons.do_boosted_frame_diags = 1 + +ions.charge = q_e +ions.mass = m_p +ions.injection_style = NUniformPerCell +ions.num_particles_per_cell_each_dim = 1 1 1 +ions.momentum_distribution_type = "gaussian" +ions.xmin = -120.e-6 +ions.xmax = 120.e-6 +ions.ymin = -120.e-6 +ions.ymax = 120.e-6 +ions.zmin = 0. +ions.zmax = .003 +ions.profile = constant +ions.density = 3.5e24 +ions.do_continuous_injection = 1 +ions.do_boosted_frame_diags = 1 + +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 = .2e-6 +beam.x_m = 0. +beam.y_m = 0. +beam.z_m = -20.e-6 +beam.npart = 1000 +beam.q_tot = -1.e-14 +beam.momentum_distribution_type = "gaussian" +beam.ux_m = 0.0 +beam.uy_m = 0.0 +beam.uz_m = 200000. +beam.ux_th = .2 +beam.uy_th = .2 +beam.uz_th = 20. + +lasers.nlasers = 1 +lasers.names = laser1 +laser1.profile = Gaussian +laser1.position = 0. 0. -0.1e-6 # This point is on the laser plane +laser1.direction = 0. 0. 1. # The plane normal direction +laser1.polarization = 0. 1. 0. # The main polarization vector +laser1.e_max = 2.e12 # Maximum amplitude of the laser field (in V/m) +laser1.profile_waist = 45.e-6 # The waist of the laser (in meters) +laser1.profile_duration = 20.e-15 # The duration of the laser (in seconds) +laser1.profile_t_peak = 40.e-15 # The time at which the laser reaches its peak (in seconds) +laser1.profile_focal_distance = 0.5e-3 # Focal distance from the antenna (in meters) +laser1.wavelength = 0.81e-6 # The wavelength of the laser (in meters) + +slice.dom_lo = -128.e-6 0.0 -40.e-6 +slice.dom_hi = 128.e-6 0.0 0.96e-6 +slice.coarsening_ratio = 1 1 1 +slice.plot_int = -1 +slice.num_slice_snapshots_lab = 4 +slice.dt_slice_snapshots_lab = 3.3356409519815207e-12 |