Introduction to WarpX
Last updated on 2026-09-23 | Edit this page
Estimated time: 10 minutes
Overview
Questions
- 🤌 What is WarpX?
- 🤔 What is a PIC code?
- 🧐 What can I use WarpX for?
- 🏋️ Why does it need HPC?
Objectives
- 💡 Understand the basics of PIC codes
- 🧑💻 Learn about the features of WarpX
- 🎯 Figure out if WarpX can be useful for you!
- 💰 Connect numerics to computational cost.
Overview of PIC
WarpX is a general purpose open-source high-performance multi-physics Particle-In-Cell (PIC) code. The PIC method is a very popular approach to simulate the dynamics of physical systems governed by relativistic electrodynamics. Plasmas ⭐ and beams ☄️, which are often made of charged particles that may travel almost at the speed of light, fall into this category. Additionally, other physical effects can be integrated into the PIC algorithm, such as different quantum 🎲 processes.
Here is a picture that condenses the core idea: there are particles and fields. The particles are approximated as macroparticles (usually each representative of many real particles), while the fields are approximated on a grid in space. The particles and the fields are updated, self-consistently, in a temporal loop.
🔎 What does one macroparticle represent? A macroparticle samples the positions and momenta of many physical particles. Its weight tells us how many particles it represents and therefore how much charge it contributes to the grid. For the same plasma density, we can use more macroparticles with smaller weights. This improves sampling and generally reduces statistical noise; it does not make the physical plasma denser.
Here is a more informative image that explains the core algorithmic steps. As the particles travel in space, they generate current densities, which in turn generate an electromagnetic field. The electromagnetic field then pushes the particles via the Lorentz force. Therefore, the current density \(\textbf{J}\) and the force \(\textbf{F}_L\) are the quantities that connect the particles and the fields, or in PIC lingo, the macroparticles and the grid. Hence, the idea is the following. First, define a well-posed initial condition, and then iterate the following:
- Interpolate the fields from the grid to the particles’ positions and compute the Lorentz force that acts on each macroparticle,
- Advance the position and momenta of the macroparticles using the relativistic equations of motion,
- Deposit the macroparticles’ current contributions onto the grid,
- Solve Maxwell’s equations.
In some cases, one can adopt an electrostatic approximation and solve Poisson’s equation instead of the full Maxwell equations. In that case, the current \(\textbf{J}\) calculation is replaced with the charge density \(\rho\) calculation. Once \(\rho\) is known, the electrostatic potential is computed to then find the electric field.
🔄 Self-consistent means feedback. A small excess of electrons in one region changes the electric field. That field changes electron motion, which changes the charge distribution and the field again. In the two-stream example, this feedback can amplify an initial disturbance into a growing wave. The evolving fields are part of the answer, rather than just a prescribed force on the particles.
If you want to know more about PIC, here are a few references:
- The two bibles on PIC 📚
- An old review written by one of the pioneers: John M. Dawson,
Particle simulation of plasmas, Rev. Mod. Phys. 55, 403
- Browse WarpX docs for many, many more references about advanced algorithms and methods.
What goes in, what comes out?
The input describes the geometry, particle species and their initial distributions, applied fields or lasers, and boundary conditions. It also sets the grid, time stepping, and which results to save. WarpX produces diagnostics: particle snapshots, fields on the grid, and reduced quantities such as total field energy. The log tells you how the run progressed; analysis notebooks turn the saved diagnostics into physical observations. The wakefield example walks through this input-to-plot workflow.
Features and applications of WarpX
WarpX is developed and used by a wide range of researchers working in different fields, from accelerator physics to nuclear fusion and a lot more. To learn about what WarpX can be used for, check out our examples and the scientific publications that acknowledged WarpX.
What physical questions can WarpX help answer?
WarpX can help investigate how charged particles and fields influence one another. For example:
- 🎢 Plasma instabilities: how can electrons moving through a plasma excite waves, and how do those waves change the particle motion? The two-stream example introduces this feedback.
- 🏎️ Plasma-based acceleration: how does a laser pulse or a particle beam drive a plasma wake, and which electrons gain energy from it?
- 🔦 Laser–matter interaction: how does an intense laser transfer energy to a target and accelerate ions? See the laser-driven ion accelerator.
- ☄️ Beam interactions: how do the fields of colliding particle beams change their trajectories? See the beam–beam example.
The WarpX application examples provide starting points for these studies. Each calculation still needs a choice of physical model, initial conditions, and numerical resolution appropriate to the system being studied.
Some cool features of WarpX:
📖 Open-source!
✈️ Runs on GPUs: NVIDIA, AMD, and Intel
🚀 Runs on multiple GPUs or CPUs, on systems ranging from laptops to supercomputers
🤓 Many many advanced algorithms and methods: mesh-refinement, embedded boundaries, electrostatic/electromagnetic/pseudospectral solvers, etc.
💾 Standards: openPMD for input/output data, PICMI for inputs
🤸 Active development and maintenance: check out our GitHub repo
🗺️ International, cross-disciplinary community: plasma physics, fusion devices, laser-plasma interactions, beam physics, plasma-based acceleration, astrophysics, others?
From PIC to HPC
The PIC loop explains where the computing work comes from: update many particles, transfer information between particles and the grid, and update fields on many cells. These operations repeat at every time step.
| Simulation choice | Connection to the physics | Connection to computing |
|---|---|---|
| Grid spacing | Determines which spatial structures can be resolved | Finer grids have more cells and require more memory |
| Time step | Determines which time scales can be resolved and must satisfy the chosen solver’s stability constraints, if any | Shorter steps require more computing time to cover the same physical duration |
| Macroparticles | Controls how densely the particle distribution is sampled and the noise | More particles require more work and memory |
| Saved diagnostics | Determine which changes can be inspected after the run | Writing and reading data take time and storage |
A simulation must resolve the characteristic spatial and time scales of interest. A three-dimensional grid can therefore become large, even though the physical experiment is small. More macroparticles improve sampling, but do not compensate for an inadequately resolved grid.
📏 Resolution is a choice to check. Grid spacing resolves spatial structures, time steps resolve their evolution, and particle count controls sampling noise. A successful run alone does not establish accuracy. Repeat with finer numerical settings and check whether the quantities you care about change appreciably. This is a convergence study: its purpose is to establish adequate resolution for your observable, rather than simply to make the calculation larger.
🏎️ High-performance computing (HPC) distributes this work across computing resources. A CPU has cores that can work concurrently; a GPU can carry out many similar particle or grid operations in parallel. On larger machines, work is also distributed across processes using MPI, a system for exchanging data between processes. Communication, uneven workloads, and writing diagnostics can limit the speedup. Using more hardware does not change which physics the input asks the code to solve. The WarpX parallelization settings describe how the grid is divided among processes and threads.
🧩 How is the work shared? WarpX divides the spatial grid into blocks. Processes can work on different blocks, while CPU threads or GPU threads update particles and fields within them. Neighboring blocks exchange field data, and particles crossing a block boundary must be passed to their new owner (we call it redistribution). If particles concentrate in one region, some processes may have more work than others and the simulation can be unbalanced. This is why both communication and balancing the workload matter when moving from one device to a large machine.