This site is version 0.0.1. Most of the code on this site is drafted by an agent and needs review. I apologize for the AI-speak, we are working on rewriting it!
viv-lang.org

← Posts

demoAIPlasma physics

A gyro-orbit and the E×B drift by the Boris push

The Boris push moves a charged particle through electric and magnetic fields in almost every particle-in-cell code. In a magnetic field alone it keeps the speed to rounding and puts every position on one circle; the gyroperiod comes out 6.28449 instead of , longer by . With an electric field added, a particle started at moves at exactly that velocity forever, and any other start averages to it.

Look inside this program

  • Atlas

    The program’s map: every function and which calls which.

  • There’s no recorded run of this program yet.

A charged particle in a uniform magnetic field circles the field lines at the cyclotron frequency . This circling is gyration, and its circle is the gyro-orbit. Add a uniform electric field at right angles to and the center of the circle, the guiding center, moves at the drift velocity , whatever the particle's charge or mass.

A particle-in-cell (PIC) code moves millions of particles through these fields for millions of steps, so the step it uses must not add or remove energy on its own. The Boris push (J. P. Boris, 1970) is the standard choice. It splits the step into half an electric kick, a rotation about , and the other half kick. This notebook runs it with , so and the exact gyroperiod is , and checks each property against a closed form. posts/refs/boris_push.py computes the same numbers with a separate numpy implementation.

Gyration keeps the speed and the circle

With no electric field the two kicks vanish and the step is a pure rotation of , so cannot change except by rounding. The cell runs 20000 steps from and records the largest and smallest speed.

The positions are updated with the new velocity, . Each step turns by the same angle , so each position step is the previous one turned by : the positions are the corners of a regular polygon and all lie on one circle. The cell takes the circle through the first three positions and measures every other position's distance from its center. Its radius is , which is , not the exact .

Printed

1.07692e-14
center: [1, -0.025]
r_min: 1.00031
r_max: 1.00031

Tests 2 of 2 pass

  • the speed stays 1 to rounding over 20000 steps (passes)
  • every position lies on one circle of radius sqrt(1 + dt^2/4) = 1.000312 (passes)

The period is too long by

The rotation in the step turns by , a little less than the exact . The cell above summed the angle between successive velocities; dividing by the number of steps gives , and the gyroperiod is . Expanding the arctangent,

At that is against . The speed is exact and the radius is off by ; the phase falls behind by of a turn per turn. The figure repeats the measurement for five time steps. At the term shows: the error is , below .

Printed

theta: 0.0499896
T_boris: 6.28449
per_err: [0.013194, 0.00332449, 0.000832779, 0.000208299, 5.20812e-05]
Boris gyro-orbit, dt = 0.05: the first 1.25 turns-1-0.500.5100.511.52xy
Boris positionsexact orbit, radius v/ωc=1
Gyroperiod error of the Boris push
measured(ωcΔt)2/12
10⁻⁴10⁻³10⁻²0.050.10.2time step ωcΔtT/(2π/ωc)−1

Tests 3 of 3 pass

  • the measured gyroperiod is 2 pi dt / (2 atan(dt/2)) = 6.284494 (passes)
  • it exceeds 2 pi by the fraction dt^2/12, to within 1% of that fraction (passes)
  • at dt = 0.4 the period error is 1.3194e-2, the exact arctan value, not 0.4^2/12 = 1.3333e-2 (passes)

The drift in crossed fields

Now add . The drift velocity is . Write one Boris step as , with and the rotation. The vector is turned by into , because its half-angle from is . So is a fixed point of the step: a particle started there never gyrates.

For any other start, is only rotated, so the particle gyrates about a guiding center moving at . Averaged over steps the velocity differs from by the unfinished part of a turn, , which is here and falls as .

Printed

fixed: [6.59195e-17, -0.1]
mean_vx: 0.000325744
mean_vy: -0.0992457
drift_err: 0.000821673
E x B drift: E = 0.1 x-hat, B = z-hat, 5 gyroperiods-4-20-10123xy
Boris trajectoryguiding center at E×B/B2

Tests 2 of 2 pass

  • started at E x B / B^2 = (0, -0.1), the velocity stays there to rounding (passes)
  • the mean velocity misses E x B / B^2 by |u0| |sin(N theta/2)| / (N sin(theta/2)) = 8.2167e-4 (passes)

Checked when the site was built: 7 of 7 tests passed, in 0.36 s. Download 2026-09-25-the-boris-push-gyrates-and-drifts.viv