# Simple particle-in-cell examples

I am studying about the 1D EM-PIC (Electro Magnetics using particle-in-cell) simulation. I want to have a simultaneous time-integration of the electric/magnetic fields plus the motion of free charges due to electrostatic/Lorentz forces. I studied PIC simulation algorithms and I want to practice by making my own code for 1D-PIC with a simple model. However, there are only complicate models when I search for theses and source codes about PIC.

My goal is to apply it to relativistic high harmonic generation experiments in my lab. But before application, it seems adequate to practice to make my own PIC code with some examples. I have no idea how to study this field.

Any help and comments will be appreciated.

I didn't know the method, but checking on Wikipedia's article it seems that these methods involve two phases, that are repeated one after the other repeatedly:

1. Particle mover: compute the motion of particles based on the fields given in your mesh; and

2. Field solver: based on the (new) position of your particles compute the fields.

For the first phase, you need to integrate an ODE. For the second one, you need to solve a PDE.

I found a site that explains it and presents Matlab's examples (reference 1). It seems to use a finite difference method for the field solution and a Verlet integration to update the position of particles.

Additionally, it seems that ZPIC has been created with the purpose of teaching this. Citing the site (reference 2):

Our collaborators at IST have been developing a new PIC code for educational use: ZPIC, a 1D/2D self-contained fully relativistic electromagnetic code running with spectral and finite different solvers. The efforts with ZPIC are geared towards creating an open source computational toolkit for plasma physics education inside a virtual laboratory that can be run off-line. The ZPIC educational suite has minimal set of installation requirements (C compiler for ZPIC, and python3 and jupyter to run the notebooks). Because of its simplicity, we also encourage you to go through ZPIC source code and make your own changes.

They even have Jupyter Notebooks teaching different lessons.

### References

1. Simple Particle In Cell Code in Matlab. https://www.particleincell.com/2011/particle-in-cell-example/. Accessed: April 7, 2020.

2. “ZPIC”. PICKSC, https://picksc.idre.ucla.edu/software/educational/zpic/. Accessed: April 7, 2020.