EPOCH PIC simulation tutorial: build, input deck and first laser–plasma run
Updated · Scientifically reviewed by Dinkar Mishra, PhD on
Short answer
EPOCH is an open-source, MPI-parallel Fortran PIC code (1D, 2D, 3D) widely used for laser–plasma interaction. Clone the repository, build the dimension you need with make COMPILER=gfortran in epoch1d, epoch2d or epoch3d, write an input.deck describing the grid, boundaries, species, laser and output, then run mpirun -np N ./bin/epoch2d and give it the output directory. Results are written as SDF files, readable in Python with the sdf helper tools.
Who this is for
Students and researchers in laser–plasma and high-energy-density physics starting with the EPOCH code.
Software
EPOCH 4.19 or latergfortran + MPI any recent
Prerequisites
- Linux (or WSL2),
gfortran,make, an MPI implementation (sudo apt install gfortran openmpi-bin libopenmpi-dev), and Python for analysis. - Laser and plasma parameters. Check the regime with the Laser–Plasma Calculator, and the resolution and cost with the PIC Simulation Planner.
Step 1: get and build EPOCH
git clone --recursive https://github.com/Warwick-Plasma/epoch.git
cd epoch/epoch2d
make COMPILER=gfortran -j 4
ls bin/ # epoch2d executable
Compile-time options (for example particle IDs, QED physics or photon emission) are set in the Makefile. Read the comments before enabling them.
Step 2: write an input deck
Create a directory Data containing input.deck. This example sends a 0.8 µm laser into a plasma slab that starts at x = 0:
begin:constant
lambda0 = 0.8e-6
den = 1.0e25
end:constant
begin:control
nx = 1600
ny = 600
t_end = 300e-15
x_min = -10e-6
x_max = 50e-6
y_min = -15e-6
y_max = 15e-6
stdout_frequency = 200
end:control
begin:boundaries
bc_x_min = simple_laser
bc_x_max = simple_outflow
bc_y_min = periodic
bc_y_max = periodic
end:boundaries
begin:species
name = electron
charge = -1.0
mass = 1.0
npart_per_cell = 4
number_density = if(x gt 0, den, 0)
end:species
begin:species
name = proton
charge = 1.0
mass = 1836.2
npart_per_cell = 4
number_density = number_density(electron)
immobile = T
end:species
begin:laser
boundary = x_min
intensity_w_cm2 = 1.0e19
lambda = lambda0
t_profile = gauss(time, 40e-15, 15e-15)
profile = gauss(y, 0, 5e-6)
end:laser
begin:output
dt_snapshot = 30e-15
grid = always
ey = always
number_density = always + species
end:output
Check the resolution: nm, about , and the electron density of m⁻³ ( cm⁻³) is underdense for 0.8 µm light; see the critical density calculator.
Step 3: run
echo Data | mpirun -np 4 ./bin/epoch2d
EPOCH prints the time step and progress, and writes 0000.sdf, 0001.sdf, … into Data/.
Step 4: read the output in Python
EPOCH ships an SDF reader. Build and install it as described in the documentation (make sdfutils in the code directory), then:
import sdf_helper as sh
data = sh.getdata(5, wkd="Data") # loads Data/0005.sdf
ey = data.Electric_Field_Ey.data
ne = data.Derived_Number_Density_electron.data
print(ey.shape, ey.max(), ne.max())
Verify
- Laser in vacuum: before the plasma, the peak field should match the requested intensity. Convert with , with in W/m².
- Plasma response: the wake or density modulation should have a period close to the plasma wavelength (see the plasma wavelength calculator).
- Convergence: rerun with
nxandnydoubled andnpart_per_celldoubled, and compare your key quantities.
Troubleshooting
- Deck parsing errors: EPOCH reports the line and block. Check spelling of keys for your EPOCH version and that every
begin:has a matchingend:. - The run stops immediately with no output: the output directory name passed on standard input does not exist, or contains no
input.deck. - Unexpected heating or noise: the resolution is too coarse for the density. Revisit the cell size; see PIC grid size.
Assumptions and limitations
- The deck is a learning example with plausible parameters. Keys and defaults can change between EPOCH versions, so the documentation for your version is authoritative.
- Immobile ions are a simplification suitable for short underdense interactions. Use mobile ions for ion acceleration or longer time scales.
- The SDF reader interface may differ slightly between releases.
Frequently asked questions
Does EPOCH run on GPUs?+
The main EPOCH code is CPU-based (MPI, Fortran). It is efficient on CPU clusters. For GPU-centric workflows, codes such as WarpX, PIConGPU or FBPIC are designed for GPUs.
Why does EPOCH ask for a directory when it starts?+
By default EPOCH reads the name of the output directory (which contains input.deck) from standard input. That is why runs are often launched as echo Data | mpirun -np 4 ./bin/epoch2d.
Can I use variables and functions in the input deck?+
Yes. EPOCH's deck parser supports constants blocks, arithmetic expressions, conditionals (if) and functions such as gauss and supergauss, which lets you define density profiles and laser envelopes compactly.
Where do I find example decks?+
The EPOCH documentation and the repository include example input decks for laser interaction, two-stream instabilities and more. Start from an example close to your problem and change one thing at a time.
References
- EPOCH documentation · EPOCH developers (University of Warwick)
- EPOCH source code · GitHub
- Arber et al., Contemporary particle-in-cell approach to laser-plasma modelling, PPCF 57, 113001 (2015) · Peer-reviewed article
Want this set up and verified for you?
We install, configure and validate scientific software on your workstation, cluster or cloud, and train your team to run it.
Services listed on this page are available today. Products marked “early access” or “in development” on our platform page are not yet generally available.
Spotted an error or an outdated command? Tell us. We correct verified issues promptly.