Create Your Own Plasma PIC Simulation (With Python)

Philip Mocz
The Startup
Published in
6 min readSep 17, 2020

--

For today’s recreational coding exercise, we will investigate plasma physics with particle-in-cell (PIC) simulations. We will create a simulation of two electron beams passing through each other in opposite directions. An interesting phenomenon occurs, called the Two-Stream Instability.

You may find the accompanying Python code on github.

Before we begin, below is a gif of what running our simulation looks like:

Plasma PIC simulation of the Two-Stream Instability

Particle-In-Cell (PIC) Method

We will consider a one-dimensional system of electrons in an unmagnetized uniform medium of ions. The electrons will be described by N particles, indexed by i, each having a

  • position rᵢ
  • velocity vᵢ

The electrons feel an acceleration aᵢ which is due to the electric field E at the location of the particle. The equations of motion for the electrons are given by:

What remains to be done is to calculate the electric field E, which depends on the number density n of the electrons. The electric field E is defined as the negative gradient of the electric potential…

--

--

Philip Mocz
The Startup

Computational Physicist. Sharing intro tutorials on creating your own computer simulations! Harvard ’12 (A.B), ’17 (PhD). Connect with me @PMocz