88
88
period = diagnostic_interval ,
89
89
data_list = ['Er' , 'Ez' , 'phi' , 'rho' ,'rho_electrons' ],
90
90
warpx_format = 'openpmd' ,
91
- write_dir = '.' ,
92
- warpx_file_prefix = 'particle_boundary_interaction_plt'
91
+ # write_dir = '.',
92
+ # warpx_file_prefix = 'particle_boundary_interaction_plt'
93
93
)
94
94
95
95
part_diag = picmi .ParticleDiagnostic (name = 'diag1' ,
96
96
period = diagnostic_interval ,
97
97
species = [electrons ],
98
98
warpx_format = 'openpmd' ,
99
- write_dir = '.' ,
100
- warpx_file_prefix = 'particle_boundary_interaction_plt'
99
+ # write_dir = '.',
100
+ # warpx_file_prefix = 'particle_boundary_interaction_plt'
101
101
)
102
102
103
103
##########################
129
129
##########################
130
130
131
131
def mirror_reflection ():
132
- buffer = particle_containers .ParticleBoundaryBufferWrapper ()
133
- if (len (buffer .get_particle_boundary_buffer ("electrons" , 'eb' , 'deltaTimeScraped' , 0 ))> 0 ): #otherwise np.concatenate doesnt work
132
+ buffer = particle_containers .ParticleBoundaryBufferWrapper () #boundary buffer
133
+ scraping = (len (buffer .get_particle_boundary_buffer ("electrons" , 'eb' , 'deltaTimeScraped' , 0 ))> 0 ) #bouleen saying if particles where scraped
134
+
135
+ if scraping : #otherwise np.concatenate doesnt work
134
136
delta_t = np .concatenate (buffer .get_particle_boundary_buffer ("electrons" , 'eb' , 'deltaTimeScraped' , 0 ))
135
137
136
- #step 1: extract the different parameters of the scraping buffer (normal, time, position)
138
+
139
+ #STEP 1: extract the different parameters of the boundary buffer (normal, time, position)
137
140
r = np .concatenate (buffer .get_particle_boundary_buffer ("electrons" , 'eb' , 'x' , 0 ))
138
141
theta = np .concatenate (buffer .get_particle_boundary_buffer ("electrons" , 'eb' , 'theta' , 0 ))
139
142
z = np .concatenate (buffer .get_particle_boundary_buffer ("electrons" , 'eb' , 'z' , 0 ))
@@ -147,23 +150,30 @@ def mirror_reflection():
147
150
ny = np .concatenate (buffer .get_particle_boundary_buffer ("electrons" , 'eb' , 'ny' , 0 ))
148
151
nz = np .concatenate (buffer .get_particle_boundary_buffer ("electrons" , 'eb' , 'nz' , 0 ))
149
152
150
- #step 2: use these parameters to inject from the same position electrons in the plasma
151
- elect_pc = particle_containers .ParticleContainerWrapper ('electrons' )
153
+
154
+ #STEP 2: use these parameters to inject particle from the same position in the plasma
155
+ elect_pc = particle_containers .ParticleContainerWrapper ('electrons' ) #general particle container
156
+
157
+ ####this part is specific to the case of simple reflection.
152
158
un = ux * nx + uy * ny + uz * nz
153
159
ux_reflect = - 2 * un * nx + ux #for a "mirror reflection" u(sym)=-2(u.n)n+u
154
160
uy_reflect = - 2 * un * ny + uy
155
161
uz_reflect = - 2 * un * nz + uz
156
- elect_pc .add_particles (
157
- x = x + (dt - delta_t )* ux_reflect , y = y + (dt - delta_t )* uy_reflect , z = z + (dt - delta_t )* uz_reflect , ux = ux_reflect , uy = uy_reflect , uz = uz_reflect ,
162
+ elect_pc .add_particles (
163
+ x = x + (dt - delta_t )* ux_reflect , y = y + (dt - delta_t )* uy_reflect , z = z + (dt - delta_t )* uz_reflect ,
164
+ ux = ux_reflect , uy = uy_reflect , uz = uz_reflect ,
158
165
w = w ,
159
166
unique_particles = args .unique
160
- )
161
- buffer .clear_buffer ()
167
+ ) #adds the particle in the general particle container at the next step
168
+ #### Can be modified depending to the model of interaction.
169
+
170
+ buffer .clear_buffer () #reinitialise the boundary buffer
162
171
163
- callbacks .installafterstep (mirror_reflection )
172
+ callbacks .installafterstep (mirror_reflection ) #mirror_reflection is called at the next step
173
+ # using the new particle container modified at the last step
164
174
165
175
##########################
166
176
# simulation run
167
177
##########################
168
178
169
- sim .step (max_steps )
179
+ sim .step (max_steps ) #the whole process is done "max_steps" times
0 commit comments