- ParticleSource

# ParticleSource

**ParticleSource**:

ParticleSource blocks must be declared within a particle species block in order to load or emit particles of that species. VSim has many allowable ParticleSource kinds:

## Using macroDensFunc or relMacroDenFunc

When `macroDensFunc`

or `relMacroDenFunc`

is used, please note that density
indirectly specifies the total number of attempts to load a particle. If macroDensFunc
determines that half of the particle load attempts will be successful (as with y/LY
over the domain {0,LY}), density should be double the number density one actually wishes
to appear in the simulation. If one uses a more complex function, for example Gaussian,
this normalization factor may take a more complex form.

## Working in Cylindrical Coordinates

Care must be taken with 2D ZR cylindrical coordinate systems. The loading algorithm will attempt to load particles almost uniformly in both of the dimensions. It does not take into account the larger volume/area represented at large radius compared with lower radius, so if we allow the particles to uniformly fill this space and allow them to be equally weighted, we end up with a high density of macro- and physical particles near the axis.

To compensate for this, we need to create a density profile via the use of a STFunc, e.g. expression = (y/MAXR).

Note that this is only required in the text based case. The loading of particles in a cylindrical volume is handled under the hood in the visual setup.

## ParticleSource parameters

- recordParticleSumStats (boolean, optional, default = true)
If

`true`

, then at each time step, simple statistics will be recorded for all sourced particles (summed over the entire simulation): including the number of macroparticles sourced, their total weight, and the weighted sum of position coordinates as well as the weighted sum of internal variables (the latter can be divided by the total weight to get average positions and velocities of sourced particles). The total energy is currently not recorded (because of the computational time it takes—if desired, one can set`recordParticleData`

to record individual particle data, and then History to sum the particle energies); however, the total (hence average) momentum can be obtained. This data can be accessed via ptclSumData Histories; it is also used by Conductor Block to record charge emitted from conductors. The record is cleared after each time step.

- recordParticleData (boolean, optional, default = false)
If

`true`

, then at each time step all sourced particles will be recorded; they can be accessed via histories (e.g., speciesAbsPtclData2 or speciesBinning) or, e.g., for secondary emission (secondaryEmitter). The record is cleared after each time step.