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.
Open in the workbenchDownload .vivOutputs below are from the site build’s run; Run all runs it again in your browser.
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
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
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
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)