Electrostatic particle-in-cell

A Python solver for collisionless, electrostatic 1D1V dynamics, with configurable populations, initial distributions, sources, and boundaries. Simulation and plotting are separate, with HDF5 output and CSV diagnostics.

Two-stream evolution

The animation shows the summed number distribution in position–velocity space, using all particles in each saved snapshot. Colors use a fixed logarithmic scale (bright: higher density; dark: lower density), with no smoothing. The preview samples 51 saved states from normalized time 0 to 40.

Two-stream number distribution in position and velocity; final state at normalized time 40
Two-stream phase space · normalized time 0–40. Open GIF

The run uses 32,768 particles, 128 mesh cells, a time step of 0.025, and periodic boundaries. Two equal electron populations have drifts of ±1 and thermal speeds of 0.05, with a neutralizing background. All quantities are normalized; the code documentation defines the units.

Results

Particle count stays constant in this run. The maximum relative change in total energy is 0.0034% over the saved diagnostics. These are illustrative numerical results; energy conservation alone does not establish convergence.

Two-stream electric-field evolution and diagnostic histories

Electric-field evolution and diagnostics for the full run.

Number distribution snapshots and marginals for the two-stream run

Distribution snapshots and marginals, computed from all simulation particles.

Particle phase-space snapshots from the two-stream run

Saved particle phase-space snapshots.

Download and reproduce

From the extracted pic folder, use Python 3.10 or newer:

python -m pip install -r requirements.txt
python -m unittest test_pic_solver.py
python pic_solver.py inputs/two_stream.json --output results/two_stream
python pic_plots.py results/two_stream/run.h5 --animate --distribution-animation
python make_preview.py results/two_stream/run.h5 --output preview

Large raw HDF5 files are regenerated by the simulation command. The README documents the input format, numerical method, output schema, and model limits.