Source file particles.F90
The source file particles.F90 contains all subroutines the deal with individual
particles in the full-particle and in the hybrid versions of the code.
Subroutines:
-
Subroutine stepx:
The particle positions are stepped according to the particle velocities
x
= x + v * dt. The velocities are unaffected at this
point. Boundary conditions in x and z are always periodic,
whereas in the y direction boundary conditions can be either periodic
or non-periodic; in the non-periodic case the particle's position is reflected
at the boundary and the velocity components are inverted according
to the routine bound_particle (source file
boundary.F90).
Finally the subroutine redistribute
(see below) is called to identify
and transfer particles that have moved into the spatial domain treated
by another processor.
-
Subroutine redistribute:
The subroutine redistribute rearranges the particles such that
each particle is stored in the particle buffer of that processor that treats
the spatial subdomain in which the particle is presently located. It needs
to be called whenever the position of the particles may have changed and
when the particle buffers are loaded at start-up.
-
Subroutine stepv:
The subroutine stepv steps the particle velocities from t
to t + dt and leaves the particle positions unaffected.
-
smooth the electric field E (call to subroutine smooth_e,
source
file boundary.F90), interpolate the electric
and the magnetic field at the exact location of the particle between grid
points (volume weighting rule).
-
in relativistic case: convert velocity into momentum, v
= gamma * v
-
apply first half of electric momentum change: v = v +
dt/2 * E.
-
apply magnetic momentum change (rotation), reduce rotation angle (magnetic
field) by factor gamma in relativistic case

-
apply second half of electric momentum change
-
in relativistic case convert momentum back into velocity by dividing by
gamma.
-
Subroutine calc_rho:
The subroutine calc_rho calculates the mean charge from the
particle position by distributing the charge to the neighboring grid points:
-
on request the array rho is deleted first, otherwise only the ghost
cells are cleared
-
the particles' charge is distributed to the eight grid points that are
clostest to the particle's position (volume weighting rule).
-
if non-periodic boundary conditions in y a virtual charge is added
if the particle is sufficiently close to the wall. The sign of the virtual
charge is determined by the subroutine virtual_charge (source file
boundary.F90).
-
Finally the charge that was collected in the ghost cell layer is transfered
to the neighboring processing element (see subroutine bound_rho_j below).
-
Subroutine calc_j:
The subroutine calc_j calculates the current density from the
particle positions and velocities in full analogy to calc_rho. The
virtual currents associated to non-periodic (conducting) walls in y
are determined by the subroutine virtual_current (source file boundary.F90)
-
Subroutine bound_rho_j:
The subroutine bound_rho_j is only called by the calc_rho
and calc_j. It transfers the charge and current that was accumulated
in the ghost cell layer to the remote processor that is responsible for
the adjacent subdomain. For non-periodic boundary conditions in y
the ghost cells
at the boundary of the whole computational domain are not transfered.
-
Subroutine partsort:
The algorithms used throughout the code do not require any specific
order of the particles within the particle buffer of one processor. As
a consequence the memory accesses may be randomly scattered over the full
subdomain treated by the processor, for example when the forces on the
particle due to the electric and the magnetic fields are calculated. This
leads to a large number of cache misses in the hardware memory cache and
therefore may result in poor performance. To speed up execution the subroutine
partsort rearranges the particles in the buffer such, that memory
accesses become grouped together and allow to make use of the cache.
Switches:
-
relativistic:
If the switch relativistic is set (#define relativistic)
the relativistic version of the equation of motion for the particles is
used. Otherwise the nonrelativistic form is applied.