FBPIC laser wakefield simulation: setting up and checking an LWFA run
Updated · Scientifically reviewed by Dinkar Mishra, PhD on
Short answer
An FBPIC wakefield run is a Python script that creates a Simulation (longitudinal and radial grid, number of azimuthal modes Nm, time step), adds the plasma electrons with a density profile, injects a Gaussian laser with add_laser, sets a moving window at the speed of light, attaches field and particle diagnostics, and calls sim.step(N). Start from the official lwfa_script.py, derive the resolution from the laser wavelength and plasma wavelength, and check convergence before trusting energies.
Who this is for
Students and researchers in laser–plasma acceleration who have FBPIC installed and want a correct first wakefield simulation.
Software
FBPIC current releaseopenPMD-viewer current release
Plasma wavelength calculator
Results update as you type. Scientific notation such as 1e18 is accepted.
| Plasma wavelength λp = 2πc/ωpe | — | |
|---|---|---|
| Plasma wavenumber kp = ωpe/c | — | |
| Skin depth c/ωpe | — |
Prerequisites
- FBPIC installed and tested; see the FBPIC installation tutorial. A GPU is strongly recommended.
- Your laser parameters (wavelength, , waist, duration) and plasma density. Compute the plasma wavelength with the calculator below, and the LWFA scalings with the Laser–Plasma Calculator.
Step 1: choose the resolution
Two length scales matter: the laser wavelength and the plasma wavelength . A common starting point for spectral quasi-cylindrical codes:
- longitudinal cell (FBPIC’s spectral solver is dispersion-free in vacuum, but the plasma response and the particle push still need resolution);
- radial cell a few times larger, resolving the laser waist and the bubble radius;
- box length of 2–3 plasma wavelengths behind the laser, and a radius of a few times the laser waist.
Treat these as starting values and confirm with a convergence test.
Step 2: structure of the script
Start from the official lwfa_script.py for your FBPIC version. Its structure is:
from scipy.constants import c, e, m_e
from fbpic.main import Simulation
from fbpic.lpa_utils.laser import add_laser
from fbpic.openpmd_diag import FieldDiagnostic, ParticleDiagnostic
# Grid: zmin..zmax (moving with the laser), 0..rmax, Nm azimuthal modes
zmin, zmax, Nz = -30.e-6, 0.e-6, 800
rmax, Nr, Nm = 20.e-6, 50, 2
dt = (zmax - zmin) / Nz / c
sim = Simulation(Nz, zmax, Nr, rmax, Nm, dt, zmin=zmin,
boundaries={'z': 'open', 'r': 'reflective'}, use_cuda=True)
# Plasma electrons with a linear up-ramp followed by a plateau
n_e = 3.e24 # m^-3, i.e. 3e18 cm^-3
ramp = 20.e-6
def dens_func(z, r):
n = (z - 0.) / ramp
n[z < 0.] = 0.
n[z > ramp] = 1.
return n
elec = sim.add_new_species(q=-e, m=m_e, n=n_e, dens_func=dens_func,
p_zmin=0.e-6, p_nz=2, p_nr=2, p_nt=4)
# Gaussian laser: a0, waist w0, duration (c*tau), centroid and focal position
add_laser(sim, a0=4., w0=5.e-6, ctau=5.e-6, z0=-5.e-6, zf=25.e-6)
sim.set_moving_window(v=c)
sim.diags = [FieldDiagnostic(500, sim.fld, comm=sim.comm),
ParticleDiagnostic(500, {'electrons': elec}, comm=sim.comm)]
sim.step(10000)
Check every argument name against the documentation of your installed version. The snippet shows the structure, and argument names can change between releases.
Step 3: run it
python lwfa_script.py # single GPU
mpirun -np 4 python lwfa_script.py # four GPUs, domain split along z
Step 4: analyse with openPMD-viewer
from openpmd_viewer import OpenPMDTimeSeries
ts = OpenPMDTimeSeries("./diags/hdf5/")
Ez, info = ts.get_field(field="E", coord="z", iteration=ts.iterations[-1])
uz, w = ts.get_particle(["uz", "w"], species="electrons", iteration=ts.iterations[-1])
print("max longitudinal momentum (m_e c):", uz.max())
Plot the longitudinal field on axis to see the wake, and histogram uz (weighted by w) to obtain the electron spectrum.
Verify
- Physics sanity: the wake period on axis should be close to , and the peak accelerating field roughly of order in the nonlinear regime.
- Numerics: repeat with half the cell size and twice the particles per cell. Injection and peak energy should not change beyond your required precision.
- Modes: compare
Nm = 2withNm = 3if any asymmetry is possible.
Troubleshooting
- No electrons are injected: that may be physical (below the injection threshold for your and density). Check with known parameter scans in the literature before changing numerics.
- Unphysical energy spread or a “hot” beam: numerical Cherenkov effects or insufficient resolution. Refine the grid and compare.
- The run is slow: check that
use_cuda=Truetook effect and the GPU is busy (nvidia-smi).
Assumptions and limitations
- The script is a structural illustration with plausible parameters, not a validated reproduction of a specific experiment.
- The quasi-cylindrical geometry assumes near-cylindrical symmetry. Strongly 3D effects need full 3D codes.
- Expected energies from scaling laws are order-of-magnitude guides. Simulations and experiments routinely differ from them.
Frequently asked questions
How many azimuthal modes (Nm) do I need?+
For a linearly polarised laser on a cylindrically symmetric plasma, Nm = 2 (modes 0 and 1) captures the wakefield and the laser. More modes are needed for asymmetric situations (off-axis lasers, tilted pulses, hosing studies). Check by comparing Nm = 2 and Nm = 3.
Why use a moving window?+
The interesting physics travels with the laser at nearly the speed of light. A window moving at c follows it, so the simulation box only needs to be a few plasma wavelengths long instead of the full acceleration length.
How do I estimate the expected electron energy?+
Use the nonlinear (blowout) LWFA scalings as a first estimate. Our Laser–Plasma Calculator computes the dephasing length, depletion length and energy gain from laser and plasma parameters. The simulation then tells you what actually happens, including injection.
Can FBPIC use a boosted frame?+
Yes, FBPIC supports Lorentz-boosted-frame simulations, which can greatly reduce cost for long acceleration distances. They require care with diagnostics and numerical stability. Learn the lab-frame setup first.
References
- FBPIC documentation: running a simulation (example scripts) · FBPIC developers
- Lehe et al., A spectral, quasi-cylindrical and dispersion-free particle-in-cell algorithm, Comput. Phys. Commun. 203, 66 (2016) · Peer-reviewed article
- Lu et al., Generating multi-GeV electron bunches using single stage laser wakefield acceleration in a 3D nonlinear regime, Phys. Rev. ST Accel. Beams 10, 061301 (2007) · Peer-reviewed article
- openPMD-viewer · openPMD project (GitHub)
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.