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)
8686npass_smooth = array ([[ 0 , 0 ], [ 0 , 0 ], [ 1 , 1 ]])
8787# Smoothing coefficients in each direction (x, y, z)
159159def 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)
193193use_beam = 0
194194# Longitudinal momentum of the beam
195195beam_uz = 100.
@@ -212,7 +212,7 @@ def plasma_dens_func( x, y, z ):
212212def 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
318318if use_moving_window :
319319 installuserinjection ( plasma_injector .continuous_injection )
320-
320+
321321# Setup the diagnostics
322322# ---------------------
323323if write_fields == 1 :
@@ -327,12 +327,19 @@ def beam_dens_func(x, y, z):
327327 installafterstep ( diag1 .write )
328328if 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
337344print ('\n Initialization 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
351358elif interactive == 1 :
352359 print '<<< To execute n steps, type "step(n)" at the prompt >>>'
0 commit comments