Skip to content

Couple PIC particles to a field solver ​

Particles in a particle-in-cell solver advance one of two ways: in the field's Runge–Kutta stage loop, as a companion of the field stepper, or with a two-level pusher staggered with the fields. Tutorial 13 builds a 1-D plasma both ways; this page is the choice. The properties of each: Particles.

In the field's stage loop ​

The particles are a second stepper, sp%initialize_companion(st, ...), driven through the same calls in the same stage window; their residual is the Lorentz force gathered at the stage positions. Two questions decide whether a scheme can carry them: does it give charge-conserving stage currents, and up to which ωΔt is a gyration (or any oscillation of the coupled system) stable?

fortran
type(stepper) :: st
integer(I4P)  :: s

print '(A)', 'scheme          stage currents   largest omega dt'
do s=1, size(RK_SCHEMES)
   call st%initialize(trim(RK_SCHEMES(s)), FORM_BUTCHER, lb=[1, 1], ub=[8, 1], components=.true.)
   print '(A16,L10,F18.4)', RK_SCHEMES(s), st%stage_current_admissible(), st%imag_axis_bound()
   call st%destroy
enddo
text
$ cookbook_particles route
scheme          stage currents   largest omega dt
euler                    T            0.0000
ssp-22                   T            0.0000
ssp-33                   T            1.7321
ssp-54                   T            3.2784
ssp-104                  T            4.9215
rk4                      T            2.8284
lsrk-33                  T            1.7321
lsrk-54                  T            3.3407
lsrk-64                  T            4.8948
lsrk-74                  T            5.6770
lsrk-124                 T           10.9538
lsrk-134                 T            6.5491
lsrk-144                 T            6.0793
heun-euler-21            T            0.0000
cash-karp-54             T            0.0000
dopri-54                 F            0.9972
calvo-65                 F            2.6093
feagin-108               T            1.1540
runge-2                  T            0.0000
heun-2                   T            0.0000
kutta-3                  T            1.7321
ralston-4                T            2.8284
shanks-4                 T            2.8284
butcher-6                T            0.0000
ssp-53                   T            2.6952
jiang-shu-4              T            2.8284
ssp-43                   T            2.1562
shanks-7                 T            1.9484
shanks-7b                T            2.8616
shanks-8                 T            0.0000
cooper-verner-8          T            3.0018
tmy-7s                   T            2.4708
stepanov-10              T            0.0000
zhang-10                 T            0.0000
bs-32                    F            1.7321
fehlberg-45              F            0.0000
tsitouras-54             F            0.4780
stepanov-54              F            0.5256
pp-54a                   F            0.3720
pp-54b                   T            0.0000
dopri-65                 F            1.7644
tsit-pap-64              T            1.7644
verner-65a               F            1.3068
verner-65r               F            0.0000
tsit-pap-75              T            0.0000
verner-76e               F            0.0000
verner-76r               F            0.0000
sharp-smart-76           F            3.9069
fehlberg-78              F            1.8824
verner-78a               F            4.0838
tsit-pap-86              T            2.9149
dopri-87                 F            0.0000
verner-87e               F            0.0000
verner-87r               F            2.5913
enright-ver-87           F            3.0015
fehlberg-89              F            0.0000
verner-89                F            0.1944
tsitouras-98             F            2.6896
verner-98e               F            2.7570
verner-98r               F            2.7022
sharp-98                 F            0.0000
dopri-853                T            5.9604
bs-54                    F            1.6643
  • stage_current_admissible() is true for every scheme of the catalogue: each has ak+1,k≠0 and bs≠0, so lookahead and stage_current keep Gauss's law at every stage (Tutorial 13 shows the calls).
  • euler and ssp-22 have no imaginary-axis interval: their gyration grows at any step. Take dt below imag_axis_bound() / omega_max of the fastest mode, the cyclotron and the plasma frequencies included.
  • The coupled step is the field's scheme: its order, and a gyration energy that decays by |R(iωΔt)|2 per step (Particles).

With a two-level pusher ​

The positions live at tn, the velocities (or the momenta u=γv) at tn−1/2. Per step: gather E and B at xn, one selah_push call, deposit the current of the move xn→xn+1, advance the field (Tutorial 13, the Boris step). The pusher is one argument; compare them on one gyration in a uniform B (32 steps of one exact period) and on the E×B drift (vE=0.5c, qBΔt/m=1, 100 steps, started at vE, a force-free equilibrium):

fortran
real(R_P), parameter :: PI=acos(-1._R_P), VE=0.5_R_P
real(R_P)            :: p(8,1), e(3,1), b(3,1), dt, g, u0, ue
integer(I4P)         :: k, n

b(:,1) = [0._R_P, 0._R_P, 1._R_P]
print '(A)', 'pusher         gyration: angle error   |u| error   drift: |u - u_E| / u_E   x / t - v_E'
do k=1, size(PUSHERS)
   ! one gyration: u = (1, 0, 0) at t^{-1/2}, at the origin; the exact period is 2 pi gamma (2 pi for Boris's v)
   g = merge(1._R_P, sqrt(2._R_P), PUSHERS(k) == PUSHER_BORIS)
   dt = 2 * PI * g / 32
   p(:,1) = [0._R_P, 0._R_P, 0._R_P, 1._R_P, 0._R_P, 0._R_P, 1._R_P, 1._R_P] ! x 1:3, u 4:6, q 7, m 8
   e = 0._R_P
   do n=1, 32
      call selah_push(PUSHERS(k), LAYOUT_V_FIRST, 1_I4P, dt, 1_I4P, 4_I4P, 7_I4P, 8_I4P, p, e, b, c=1._R_P)
   enddo
   u0 = norm2(p(4:6,1))
   write(*, '(A14,ES22.3,A12)', advance='no') NAMES(k), atan2(p(5,1), p(4,1)), small(u0 - 1._R_P)
   ! the drift: E + v x B = 0 at v = v_E
   ue = VE ; if (PUSHERS(k) /= PUSHER_BORIS) ue = VE / sqrt(1._R_P - VE**2)      ! u_E = gamma_E v_E
   p(:,1) = [0._R_P, 0._R_P, 0._R_P, ue, 0._R_P, 0._R_P, 1._R_P, 1._R_P]
   e(:,1) = [0._R_P, VE, 0._R_P]
   do n=1, 100
      call selah_push(PUSHERS(k), LAYOUT_V_FIRST, 1_I4P, 1._R_P, 1_I4P, 4_I4P, 7_I4P, 8_I4P, p, e, b, c=1._R_P)
   enddo
   print '(A21,A16)', small(norm2(p(4:6,1) - [ue, 0._R_P, 0._R_P]) / ue), small(p(1,1) / 100 - VE)
enddo
text
$ cookbook_particles pushers
pusher         gyration: angle error   |u| error   drift: |u - u_E| / u_E   x / t - v_E
boris                      2.007E-02   round-off            round-off       round-off
boris-rel                  2.007E-02   round-off             1.88E-02        1.15E-02
vay                        2.007E-02   round-off            round-off       round-off
higuera-cary               5.094E-03   round-off            round-off       round-off
  • Every pusher keeps |u| in a pure magnetic field to round-off.
  • Boris, the relativistic Boris and Vay lag the gyration by the same angle, 32(2π/32−2arctan⁡(π/32))=2.007⋅10−2 rad, the lag of a turn of 2arctan⁡(ωΔt/2) per step instead of ωΔt. Higuera–Cary's lag is smaller on this case.
  • The relativistic Boris does not keep the force-free state: u moves off uE and the particle drifts at the wrong mean speed. Vay and Higuera–Cary keep it to round-off; the non-relativistic Boris keeps its own (E×B exact).
  • So: PUSHER_BORIS below relativistic speeds; PUSHER_HIGUERA_CARY for relativistic particles (volume-preserving, force-free state kept); PUSHER_VAY where volume preservation does not matter; PUSHER_BORIS_RELATIVISTIC to reproduce a code that uses it.

The relativistic pushers take c= (here 1); a Gaussian-units caller passes B/c. LAYOUT_V_LAST takes the particles as p(np, ncomp) and the fields as (np, 3).