-
Notifications
You must be signed in to change notification settings - Fork 0
/
picmi_inputfile_ionization-v2.py
209 lines (178 loc) · 7.79 KB
/
picmi_inputfile_ionization-v2.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
"""
This file is part of PIConGPU.
Copyright 2024 PIConGPU contributors
Authors: Masoud Afshari, Brian Edward Marre
License: GPLv3+
"""
from picongpu import picmi
from picongpu import pypicongpu
import numpy as np
"""
@file PICMI user script reproducing the PIConGPU LWFA example
This Python script is example PICMI user script reproducing the LaserWakefield example setup, based on 8.cfg.
"""
# generation modifiers
ENABLE_IONS = True
ENABLE_IONIZATION = True
ADD_CUSTOM_INPUT = True
OUTPUT_DIRECTORY_PATH = "lwfa_ionization_v2"
numberCells = np.array([192, 2048, 192])
cellSize = np.array([0.1772e-6, 0.4430e-7, 0.1772e-6]) # unit: meter
# Define the simulation grid based on grid.param
grid = picmi.Cartesian3DGrid(
picongpu_n_gpus=[2, 4, 1],
number_of_cells=numberCells.tolist(),
lower_bound=[0, 0, 0],
upper_bound=(numberCells * cellSize).tolist(),
lower_boundary_conditions=["open", "open", "open"],
upper_boundary_conditions=["open", "open", "open"]
)
gaussianProfile = picmi.distribution.GaussianDistribution(
density=1.0e25,
center_front=8.0e-5,
sigma_front=8.0e-5,
center_rear=10.0e-5,
sigma_rear=8.0e-5,
factor=-1.0,
power=4.0,
vacuum_cells_front=50
)
solver = picmi.ElectromagneticSolver(
grid=grid,
method="Yee"
)
laser = picmi.GaussianLaser(
wavelength=0.8e-6,
waist=5.0e-6 / 1.17741,
duration=5.0e-15,
propagation_direction=[0.0, 1.0, 0.0],
polarization_direction=[1.0, 0.0, 0.0],
focal_position=[float(numberCells[0] * cellSize[0] / 2.0), 4.62e-5, float(numberCells[2] * cellSize[2] / 2.0)],
centroid_position=[float(numberCells[0] * cellSize[0] / 2.0), 0.0, float(numberCells[2] * cellSize[2] / 2.0)],
picongpu_polarization_type=pypicongpu.laser.GaussianLaser.PolarizationType.CIRCULAR,
a0=8.0,
picongpu_phase=0.0
)
random_layout = picmi.PseudoRandomLayout(n_macroparticles_per_cell=2)
# Initialize particles based on speciesInitialization.param
# simulation schema : https://github.com/BrianMarre/picongpu/blob/2ddcdab4c1aca70e1fc0ba02dbda8bd5e29d98eb/share/picongpu/pypicongpu/schema/simulation.Simulation.json
# for particle type see https://github.com/openPMD/openPMD-standard/blob/upcoming-2.0.0/EXT_SpeciesType.md
species_list = []
if not ENABLE_IONIZATION:
interaction = None
primary_electrons = picmi.Species(particle_type="electron", name="electron", initial_distribution=gaussianProfile)
species_list.append((primary_electrons , random_layout))
if ENABLE_IONS:
hydrogen_fully_ionized = picmi.Species(
particle_type="H", name="hydrogen", picongpu_fixed_charge=True, initial_distribution=gaussianProfile
)
species_list.append((hydrogen_fully_ionized, random_layout))
else:
if not ENABLE_IONS:
raise ValueError("Ions species required for ionization")
hydrogen_with_ionization = picmi.Species(
particle_type="H", name="hydrogen", charge_state=0, initial_distribution=gaussianProfile
)
species_list.append((hydrogen_with_ionization, random_layout))
secondary_electrons_from_ionization = picmi.Species(particle_type="electron", name="electron", initial_distribution=None)
species_list.append((secondary_electrons_from_ionization, None))
adk_ionization_model = picmi.ADK(
ADK_variant=picmi.ADKVariant.CircularPolarization,
ion_species=hydrogen_with_ionization,
ionization_electron_species=secondary_electrons_from_ionization,
ionization_current=None
)
bsi_effectiveZ_ionization_model = picmi.BSI(
BSI_extensions=[picmi.BSIExtension.EffectiveZ],
ion_species=hydrogen_with_ionization,
ionization_electron_species=secondary_electrons_from_ionization,
ionization_current=None
)
interaction = picmi.Interaction(
ground_state_ionization_model_list=[adk_ionization_model, bsi_effectiveZ_ionization_model]
)
sim = picmi.Simulation(
solver=solver,
max_steps=4000,
time_step_size=1.39e-16,
picongpu_moving_window_move_point=0.9,
picongpu_interaction=interaction,
picongpu_template_dir="./customTemplates"
)
for species, layout in species_list:
sim.add_species(species, layout=layout)
sim.add_laser(laser, None)
# additional non standardized custom user input
# only active if custom templates are used
# for generating setup with custom input see standard implementation,
# see https://picongpu.readthedocs.io/en/latest/usage/picmi/custom_template.html
if ADD_CUSTOM_INPUT:
min_weight_input = pypicongpu.customuserinput.CustomUserInput() # particle.param.mustache
min_weight_input.addToCustomInput({"minimum_weight": 10.0}, "minimum_weight")
sim.picongpu_add_custom_user_input(min_weight_input)
output_configuration = pypicongpu.customuserinput.CustomUserInput()
output_configuration.addToCustomInput(
{
"png_plugin_SCALE_IMAGE": 1.0,
"png_plugin_SCALE_TO_CELLSIZE": "true",
"png_plugin_WHITE_BOX_PER_GPU": "false",
"png_plugin_EM_FIELD_SCALE_CHANNEL1": 7,
"png_plugin_EM_FIELD_SCALE_CHANNEL2": -1,
"png_plugin_EM_FIELD_SCALE_CHANNEL3": -1,
"png_plugin_CUSTOM_NORMALIZATION_SI": "{5.0e12 / SI::SPEED_OF_LIGHT_SI, 5.0e12, 15.0}",
"png_plugin_PRE_PARTICLE_DENS_OPACITY": 0.25,
"png_plugin_PRE_CHANNEL1_OPACITY": 1.0,
"png_plugin_PRE_CHANNEL2_OPACITY": 1.0,
"png_plugin_PRE_CHANNEL3_OPACITY": 1.0,
"png_plugin_preParticleDensCol": "colorScales::grayInv",
"png_plugin_preChannel1_colorScale": "colorScales::green",
"png_plugin_preChannel2_colorScale": "colorScales::none",
"png_plugin_preChannel3_colorScale": "colorScales::none",
"png_plugin_preChannel1": "field_E.x() * field_E.x();",
"png_plugin_preChannel2": "field_E.y()",
"png_plugin_preChannel3": "-1.0_X * field_E.y()",
"png_plugin_period": 100,
"png_plugin_axis": "yx",
"png_plugin_slicePoint": 0.5,
"png_plugin_species_name": "electron",
"png_plugin_folder_name": "pngElectronsYX",
},
"png plugin configuration"
)
output_configuration.addToCustomInput(
{
"energy_histogram_species_name": "electron",
"energy_histogram_period": 100,
"energy_histogram_bin_count": 1024,
"energy_histogram_min_energy": 0.0,
"energy_histogram_max_energy": 1000.0,
"energy_histogram_filter": "all",
},
"energy histogram plugin configuration"
)
output_configuration.addToCustomInput(
{
"phase_space_species_name": "electron",
"phase_space_period": 100,
"phase_space_space": "y",
"phase_space_momentum": "py",
"phase_space_min": -1.0,
"phase_space_max": 1.0,
"phase_space_filter": "all",
},
"phase space plugin configuration"
)
output_configuration.addToCustomInput(
{"openPMD_period": 100, "openPMD_file": "simData", "openPMD_extension": "bp"}, "openPMD plugin configuration"
)
output_configuration.addToCustomInput(
{"checkpoint_period": 100, "checkpoint_backend": "openPMD", "checkpoint_restart_backend": "openPMD"},
"checkpoint configuration"
)
output_configuration.addToCustomInput(
{"macro_particle_count_period": 100, "macro_particle_count_species_name": "electron"},
"macro particle count plugin configuration"
)
sim.picongpu_add_custom_user_input(output_configuration)
if __name__ == "__main__":
sim.write_input_file(OUTPUT_DIRECTORY_PATH)