demoAIPlasma physics
The two-stream instability in a particle-in-cell code
Two cold electron beams passing through each other are unstable. A particle-in-cell code with 2000 particles measures the growth rate of the fastest mode as 0.35366 ; cold-beam linear theory gives . The phase-space film shows the beams rolling up into vortices of trapped electrons, which is where the growth stops.
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.
Two beams of electrons move through each other at velocities and , over a fixed background of ions that keeps the plasma neutral on average. A small ripple in density bunches both beams, the bunches make an electric field, and the field bunches them further. The ripple grows exponentially at a rate that linear theory predicts, until electrons are trapped in the wave's potential wells and the growth stops.
A particle-in-cell (PIC) code follows this with no model beyond Newton's law and Gauss's law. Each step it spreads the particles' charge onto a grid, solves for the electric field on the grid, reads the field back at each particle, and moves the particles. Units: the plasma frequency , the beam speed .
For two cold beams at , each of density , write . The dispersion relation
is the quartic , and its unstable root has
which is positive only for . The cell below computes from it.
Printed
Tests 2 of 2 pass
- the cold-beam growth rate at k v0 = sqrt(3/8) is 1 / (2 sqrt 2) = 0.353553 (passes)
- the root of the quartic at a = 0.48 grows at 0.335693, and at a = 1.2 it is stable (numpy.roots) (passes)
The particle code
The box is one wavelength of the fastest mode, , with 32 grid cells and 2000 particles, 1000 per beam. The particles start evenly spaced, a quiet start, with their positions shifted by so that only the one mode is seeded. With random positions the instability would grow out of noise in every mode at once, and the fit below would need far more particles.
- Deposit. Each particle's charge is shared between the two nearest grid points in proportion to how close it is (cloud-in-cell). The ions add a uniform .
- Field. Gauss's law , integrated along the grid by the trapezoid rule; the mean of is removed, since a periodic box has no net field.
- Push. Leapfrog: velocities live at half steps, positions at whole steps, and an electron's acceleration is .
Printed
Tests 1 of 1 pass
- the box is neutral: the mean charge density is zero (passes)
Running it
The cell runs 250 steps to . Every 12 steps it adds a frame to the film: a histogram of the particles in the plane. It also records the amplitude of the seeded mode at every step.
In the film the two beams are the bright lines at . They ripple, then fold over each other into vortices: electrons caught in the wave's potential wells, going round at the bounce frequency. At that point the field stops growing.
The growth rate
While the mode is small it grows as , so is a straight line of slope . The cell fits that line by least squares between and . Before the seed still carries the other three roots of the quartic, a decaying one and an oscillating pair, and their share falls only as . After the amplitude is above 0.1 and trapping has begun to slow the growth.
The fit gives , above theory. The test allows 1%, and here
is why. Moving the window to or moves the fitted rate by up to
0.4%, so the choice of window alone is worth that much. Halving the time step,
doubling the grid or quadrupling the particles moves it by at most 0.4% as
well (posts/refs/two_stream_pic.py runs each case). A numpy implementation of
the same algorithm gives the same rate to .
Printed
Tests 3 of 3 pass
- the fitted growth rate is the cold-beam rate 0.353553 to within 1% (passes)
- the same algorithm in numpy (posts/refs/two_stream_pic.py) fits 0.353661097 (passes)
- fits over [4, 12] and [6, 16] stay within 0.4% of theory (passes)
Saturation
The amplitude of the mode peaks at 0.568 at and then falls back: the trapped electrons now give energy back to the field as fast as they take it. From to the peak, the energy in the field grows by a factor of about . The dashed line in the figure is with the theoretical rate, drawn through the fitted amplitude at .
Printed
Tests 3 of 3 pass
- the field energy grows by a factor of 2.9857e9 from t = 0 to its peak (numpy run) (passes)
- the mode peaks at amplitude 0.56818 at t = 23.8, as in the numpy run (passes)
- after the peak the amplitude falls: at t = 24.9 it is 0.4754 (passes)