diff options
author | 2019-11-20 14:27:00 -0800 | |
---|---|---|
committer | 2019-11-20 14:27:00 -0800 | |
commit | dc091f87b0149d30bea844de925ed65d1a81bbf3 (patch) | |
tree | f93c1979aa62e989be6563f182e80cb52cf07840 /Examples/Modules/gaussian_beam/PICMI_inputs_gaussian_beam.py | |
parent | 93b3c21262035097d7204521e0afd76b0e15db44 (diff) | |
parent | 13f3c87791971c4e72b567410f938a6dade47647 (diff) | |
download | WarpX-dc091f87b0149d30bea844de925ed65d1a81bbf3.tar.gz WarpX-dc091f87b0149d30bea844de925ed65d1a81bbf3.tar.zst WarpX-dc091f87b0149d30bea844de925ed65d1a81bbf3.zip |
Merge branch 'dev' of https://github.com/ECP-WarpX/WarpX into doNotDepositCurrent
Diffstat (limited to 'Examples/Modules/gaussian_beam/PICMI_inputs_gaussian_beam.py')
-rw-r--r-- | Examples/Modules/gaussian_beam/PICMI_inputs_gaussian_beam.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/Examples/Modules/gaussian_beam/PICMI_inputs_gaussian_beam.py b/Examples/Modules/gaussian_beam/PICMI_inputs_gaussian_beam.py new file mode 100644 index 000000000..ecc8f5a65 --- /dev/null +++ b/Examples/Modules/gaussian_beam/PICMI_inputs_gaussian_beam.py @@ -0,0 +1,62 @@ +import numpy as np +from pywarpx import picmi +#from warp import picmi + +constants = picmi.constants + +nx = 32 +ny = 32 +nz = 32 + +xmin = -2. +xmax = +2. +ymin = -2. +ymax = +2. +zmin = -2. +zmax = +2. + +number_sim_particles = 32768 +total_charge = 8.010883097437485e-07 + +beam_rms_size = 0.25 +electron_beam_divergence = -0.04*constants.c + +em_order = 3 + +grid = picmi.Cartesian3DGrid(number_of_cells = [nx, ny, nz], + lower_bound = [xmin, ymin, zmin], + upper_bound = [xmax, ymax, zmax], + lower_boundary_conditions = ['periodic', 'periodic', 'open'], + upper_boundary_conditions = ['periodic', 'periodic', 'open'], + warpx_max_grid_size=16) + +solver = picmi.ElectromagneticSolver(grid = grid, + cfl = 1., + stencil_order=[em_order,em_order,em_order]) + +electron_beam = picmi.GaussianBunchDistribution(n_physical_particles = total_charge/constants.q_e, + rms_bunch_size = [beam_rms_size, beam_rms_size, beam_rms_size], + velocity_divergence = [electron_beam_divergence, electron_beam_divergence, electron_beam_divergence]) + +proton_beam = picmi.GaussianBunchDistribution(n_physical_particles = total_charge/constants.q_e, + rms_bunch_size = [beam_rms_size, beam_rms_size, beam_rms_size]) + +electrons = picmi.Species(particle_type='electron', name='electrons', initial_distribution=electron_beam) +protons = picmi.Species(particle_type='proton', name='protons', initial_distribution=proton_beam) + +sim = picmi.Simulation(solver = solver, + max_steps = 10, + verbose = 1, + warpx_plot_int = 10, + warpx_current_deposition_algo = 'direct') + +sim.add_species(electrons, layout=picmi.PseudoRandomLayout(n_macroparticles=number_sim_particles)) +sim.add_species(protons, layout=picmi.PseudoRandomLayout(n_macroparticles=number_sim_particles)) + +# write_inputs will create an inputs file that can be used to run +# with the compiled version. +sim.write_input_file(file_name = 'inputs_from_PICMI') + +# Alternatively, sim.step will run WarpX, controlling it from Python +#sim.step() + |