Skip to content

Commit b1d55c9

Browse files
committed
Added particles with different quantities
1 parent b43fcd9 commit b1d55c9

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

scripts/warp_2d_script.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
# Current smoothing parameters
8282
# ----------------------------
8383
# Turn current smoothing on or off (0:off; 1:on)
84-
use_smooth = 1
84+
use_smooth = 1
8585
# Number of passes of smoother and compensator in each direction (x, y, z)
8686
npass_smooth = array([[ 0 , 0 ], [ 0 , 0 ], [ 1 , 1 ]])
8787
# Smoothing coefficients in each direction (x, y, z)
@@ -159,7 +159,7 @@
159159
def plasma_dens_func( x, y, z ):
160160
"""
161161
User-defined function: density profile of the plasma
162-
162+
163163
It should return the relative density with respect to n_plasma,
164164
at the position x, y, z (i.e. return a number between 0 and 1)
165165
@@ -189,7 +189,7 @@ def plasma_dens_func( x, y, z ):
189189
# -----------------
190190
# Initialize beam electrons (0:off, 1:on)
191191
# (Please be aware that initializing a beam in 2D geometry makes very little
192-
# physical sense, because of the long range of its space-charge fields)
192+
# physical sense, because of the long range of its space-charge fields)
193193
use_beam = 0
194194
# Longitudinal momentum of the beam
195195
beam_uz = 100.
@@ -212,7 +212,7 @@ def plasma_dens_func( x, y, z ):
212212
def beam_dens_func(x, y, z):
213213
"""
214214
User-defined function: density profile of the beam
215-
215+
216216
It should return the relative density with respect to n_beam,
217217
at the position x, y, z (i.e. return a number between 0 and 1)
218218
@@ -317,7 +317,7 @@ def beam_dens_func(x, y, z):
317317
# Continuously inject the plasma, if the moving window is on
318318
if use_moving_window :
319319
installuserinjection( plasma_injector.continuous_injection )
320-
320+
321321
# Setup the diagnostics
322322
# ---------------------
323323
if write_fields == 1:
@@ -327,12 +327,19 @@ def beam_dens_func(x, y, z):
327327
installafterstep( diag1.write )
328328
if write_particles == 1:
329329
species_dict = { species.name : species for species in listofallspecies \
330-
if not( species.name in ["Hydrogen0+", "electron from Hydrogen"] )}
330+
if species.name == "electrons" }
331331
diag2 = ParticleDiagnostic( period=diag_period, top=top, w3d=w3d,
332332
species=species_dict, write_dir='./example-2d',
333333
particle_data={"position","momentum","weighting","id"},
334334
comm_world=comm_world, lparallel_output=parallel_output )
335335
installafterstep( diag2.write )
336+
species_dict = { species.name : species for species in listofallspecies \
337+
if species.name == "Hydrogen1+" }
338+
diag3 = ParticleDiagnostic( period=diag_period, top=top, w3d=w3d,
339+
species=species_dict, write_dir='./example-2d',
340+
particle_data={"position"},
341+
comm_world=comm_world, lparallel_output=parallel_output )
342+
installafterstep( diag3.write )
336343

337344
print('\nInitialization complete\n')
338345

@@ -346,7 +353,7 @@ def beam_dens_func(x, y, z):
346353
while n_stepped < N_steps:
347354
step(10)
348355
n_stepped = n_stepped + 10
349-
356+
350357
# Interactive mode
351358
elif interactive==1:
352359
print '<<< To execute n steps, type "step(n)" at the prompt >>>'

0 commit comments

Comments
 (0)