diff options
Diffstat (limited to 'Examples')
-rw-r--r-- | Examples/Tests/plasma_lens/PICMI_inputs_3d.py | 89 | ||||
-rwxr-xr-x | Examples/Tests/plasma_lens/analysis.py | 6 | ||||
-rw-r--r-- | Examples/Tests/plasma_lens/inputs_3d | 1 | ||||
-rw-r--r-- | Examples/Tests/plasma_lens/inputs_boosted_3d | 1 |
4 files changed, 96 insertions, 1 deletions
diff --git a/Examples/Tests/plasma_lens/PICMI_inputs_3d.py b/Examples/Tests/plasma_lens/PICMI_inputs_3d.py new file mode 100644 index 000000000..ed64ae3e5 --- /dev/null +++ b/Examples/Tests/plasma_lens/PICMI_inputs_3d.py @@ -0,0 +1,89 @@ +#!/usr/bin/env python3 + +from pywarpx import picmi + +# Physical constants +c = picmi.constants.c +q_e = picmi.constants.q_e + +# Number of time steps +max_steps = 84 + +# Number of cells +nx = 16 +ny = 16 +nz = 16 + +# Physical domain +xmin = -1. +xmax = 1. +ymin = -1. +ymax = 1. +zmin = 0. +zmax = 2. + +# Create grid +grid = picmi.Cartesian3DGrid(number_of_cells = [nx, ny, nz], + lower_bound = [xmin, ymin, zmin], + upper_bound = [xmax, ymax, zmax], + lower_boundary_conditions = ['dirichlet', 'dirichlet', 'dirichlet'], + upper_boundary_conditions = ['dirichlet', 'dirichlet', 'dirichlet'], + lower_boundary_conditions_particles = ['absorbing', 'absorbing', 'absorbing'], + upper_boundary_conditions_particles = ['absorbing', 'absorbing', 'absorbing']) + +# Particles +vel_z = 0.5*c +multiparticles_distribution = picmi.ParticleListDistribution(x = [0.05, 0.], + y = [0., 0.04], + z = [0.05, 0.05], + ux = [0., 0.], + uy = [0., 0.], + uz = [vel_z, vel_z], + weight = [1., 1.]) + +electrons = picmi.Species(particle_type = 'electron', + name = 'electrons', + initial_distribution = multiparticles_distribution) + +# Plasma lenses +plasma_lenses = picmi.PlasmaLens(period = 0.5, + starts = [0.1, 0.11, 0.12, 0.13], + lengths = [0.1, 0.11, 0.12, 0.13], + strengths_E = [600000., 800000., 600000., 200000.], + strengths_B = [0.0, 0.0, 0.0, 0.0]) + +# Electromagnetic solver +solver = picmi.ElectromagneticSolver(grid = grid, + method = 'Yee', + cfl = 0.7) + +# Diagnostics +part_diag1 = picmi.ParticleDiagnostic(name = 'diag1', + period = max_steps, + species = [electrons], + data_list = ['ux', 'uy', 'uz'], + write_dir = '.', + warpx_file_prefix = 'Python_plasma_lens_plt') + +# Set up simulation +sim = picmi.Simulation(solver = solver, + max_steps = max_steps, + verbose = 1, + particle_shape = 'linear', + warpx_serialize_initial_conditions = 1, + warpx_do_dynamic_scheduling = 0) + +# Add plasma electrons +sim.add_species(electrons, layout = None) + +# Add the plasma lenses +sim.add_applied_field(plasma_lenses) + +# Add diagnostics +sim.add_diagnostic(part_diag1) + +# Write input file that can be used to run with the compiled version +#sim.write_input_file(file_name = 'inputs_3d_picmi') + +# Advance simulation until last time step +sim.step(max_steps) diff --git a/Examples/Tests/plasma_lens/analysis.py b/Examples/Tests/plasma_lens/analysis.py index f13ecb00f..6a0af60ad 100755 --- a/Examples/Tests/plasma_lens/analysis.py +++ b/Examples/Tests/plasma_lens/analysis.py @@ -60,7 +60,11 @@ def applylens(x0, vx0, vz0, gamma, lens_length, lens_strength): return x1, vx1 clight = c -vel_z = eval(ds.parameters.get('my_constants.vel_z')) +try: + vel_z = eval(ds.parameters.get('my_constants.vel_z')) +except TypeError: + # vel_z is not saved in my_constants with the PICMI version + vel_z = 0.5*c 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()] diff --git a/Examples/Tests/plasma_lens/inputs_3d b/Examples/Tests/plasma_lens/inputs_3d index 5f557e4eb..48f2263f0 100644 --- a/Examples/Tests/plasma_lens/inputs_3d +++ b/Examples/Tests/plasma_lens/inputs_3d @@ -18,6 +18,7 @@ boundary.particle_hi = absorbing absorbing absorbing # Algorithms algo.particle_shape = 1 +warpx.cfl = 0.7 my_constants.vel_z = 0.5*clight diff --git a/Examples/Tests/plasma_lens/inputs_boosted_3d b/Examples/Tests/plasma_lens/inputs_boosted_3d index 32d6fa47e..c997136d4 100644 --- a/Examples/Tests/plasma_lens/inputs_boosted_3d +++ b/Examples/Tests/plasma_lens/inputs_boosted_3d @@ -20,6 +20,7 @@ boundary.particle_hi = absorbing absorbing absorbing algo.particle_shape = 1 warpx.gamma_boost = 2. warpx.boost_direction = z +warpx.cfl = 0.7 my_constants.vel_z = 0.5*clight |