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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
#!/usr/bin/env python3
from pywarpx import picmi
##########################
# physics parameters
##########################
V_domain_boundary = 0.0
V_embedded_boundary = 1.0
##########################
# numerics parameters
##########################
dt = 1e-6
# --- Nb time steps
max_steps = 1
# --- grid
nx = 64
ny = 64
nz = 64
xmin = -0.5
xmax = 0.5
ymin = -0.5
ymax = 0.5
zmin = -0.5
zmax = 0.5
##########################
# numerics components
##########################
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'],
warpx_potential_lo_x = V_domain_boundary,
warpx_potential_hi_x = V_domain_boundary,
warpx_potential_lo_y = V_domain_boundary,
warpx_potential_hi_y = V_domain_boundary,
warpx_potential_lo_z = V_domain_boundary,
warpx_potential_hi_z = V_domain_boundary,
warpx_blocking_factor=8,
warpx_max_grid_size = 128
)
solver = picmi.ElectrostaticSolver(
grid=grid, method='Multigrid', required_precision=1e-7
)
embedded_boundary = picmi.EmbeddedBoundary(
implicit_function="-(x**2+y**2+z**2-radius**2)",
potential=V_embedded_boundary,
radius = 0.3
)
##########################
# diagnostics
##########################
field_diag = picmi.FieldDiagnostic(
name = 'diag1',
grid = grid,
period = 1,
data_list = ['Ex', 'Ey', 'Ez', 'phi', 'rho'],
write_dir = '.',
warpx_file_prefix = 'Python_ElectrostaticSphereEB_plt'
)
##########################
# simulation setup
##########################
sim = picmi.Simulation(
solver = solver,
time_step_size = dt,
max_steps = max_steps,
warpx_embedded_boundary=embedded_boundary,
warpx_field_gathering_algo='momentum-conserving'
)
sim.add_diagnostic(field_diag)
##########################
# simulation run
##########################
sim.step(max_steps)
|