-
Notifications
You must be signed in to change notification settings - Fork 200
/
Copy pathPICMI_inputs_plasma_acceleration.py
executable file
·80 lines (60 loc) · 3.27 KB
/
PICMI_inputs_plasma_acceleration.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env python3
from pywarpx import picmi
#from warp import picmi
constants = picmi.constants
nx = 64
ny = 64
nz = 64
xmin = -200.e-6
xmax = +200.e-6
ymin = -200.e-6
ymax = +200.e-6
zmin = -200.e-6
zmax = +200.e-6
moving_window_velocity = [0., 0., constants.c]
number_per_cell_each_dim = [2, 2, 1]
max_steps = 10
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'],
lower_boundary_conditions_particles = ['periodic', 'periodic', 'absorbing'],
upper_boundary_conditions_particles = ['periodic', 'periodic', 'absorbing'],
moving_window_velocity = moving_window_velocity,
warpx_max_grid_size=32)
solver = picmi.ElectromagneticSolver(grid=grid, cfl=1)
beam_distribution = picmi.UniformDistribution(density = 1.e23,
lower_bound = [-20.e-6, -20.e-6, -150.e-6],
upper_bound = [+20.e-6, +20.e-6, -100.e-6],
directed_velocity = [0., 0., 1.e9])
plasma_distribution = picmi.UniformDistribution(density = 1.e22,
lower_bound = [-200.e-6, -200.e-6, 0.],
upper_bound = [+200.e-6, +200.e-6, None],
fill_in = True)
beam = picmi.Species(particle_type='electron', name='beam', initial_distribution=beam_distribution)
plasma = picmi.Species(particle_type='electron', name='plasma', initial_distribution=plasma_distribution)
sim = picmi.Simulation(solver = solver,
max_steps = max_steps,
verbose = 1,
warpx_current_deposition_algo = 'esirkepov',
warpx_use_filter = 0)
sim.add_species(beam, layout=picmi.GriddedLayout(grid=grid, n_macroparticle_per_cell=number_per_cell_each_dim))
sim.add_species(plasma, layout=picmi.GriddedLayout(grid=grid, n_macroparticle_per_cell=number_per_cell_each_dim))
field_diag = picmi.FieldDiagnostic(name = 'diag1',
grid = grid,
period = max_steps,
data_list = ['Ex', 'Ey', 'Ez', 'Jx', 'Jy', 'Jz', 'part_per_cell'],
write_dir = '.',
warpx_file_prefix = 'Python_PlasmaAcceleration_plt')
part_diag = picmi.ParticleDiagnostic(name = 'diag1',
period = max_steps,
species = [beam, plasma],
data_list = ['ux', 'uy', 'uz', 'weighting'])
sim.add_diagnostic(field_diag)
sim.add_diagnostic(part_diag)
# 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()