Skip to content

Commit 26805f2

Browse files
authored
Update PICMI_inputs_rz.py
1 parent 89b7db8 commit 26805f2

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

Examples/Tests/particle_boundary_interaction/PICMI_inputs_rz.py

+25-15
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,16 @@
8888
period = diagnostic_interval,
8989
data_list = ['Er', 'Ez', 'phi', 'rho','rho_electrons'],
9090
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'
9393
)
9494

9595
part_diag = picmi.ParticleDiagnostic(name = 'diag1',
9696
period = diagnostic_interval,
9797
species = [electrons],
9898
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'
101101
)
102102

103103
##########################
@@ -129,11 +129,14 @@
129129
##########################
130130

131131
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
134136
delta_t = np.concatenate(buffer.get_particle_boundary_buffer("electrons", 'eb', 'deltaTimeScraped', 0))
135137

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)
137140
r = np.concatenate(buffer.get_particle_boundary_buffer("electrons", 'eb', 'x', 0))
138141
theta = np.concatenate(buffer.get_particle_boundary_buffer("electrons", 'eb', 'theta', 0))
139142
z = np.concatenate(buffer.get_particle_boundary_buffer("electrons", 'eb', 'z', 0))
@@ -147,23 +150,30 @@ def mirror_reflection():
147150
ny = np.concatenate(buffer.get_particle_boundary_buffer("electrons", 'eb', 'ny', 0))
148151
nz = np.concatenate(buffer.get_particle_boundary_buffer("electrons", 'eb', 'nz', 0))
149152

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.
152158
un=ux*nx+uy*ny+uz*nz
153159
ux_reflect=-2*un*nx+ux #for a "mirror reflection" u(sym)=-2(u.n)n+u
154160
uy_reflect=-2*un*ny+uy
155161
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,
158165
w=w,
159166
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
162171

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
164174

165175
##########################
166176
# simulation run
167177
##########################
168178

169-
sim.step(max_steps)
179+
sim.step(max_steps) #the whole process is done "max_steps" times

0 commit comments

Comments
 (0)