Skip to content
VLASIFY™
TutorialPlasma & PIC simulation

PIConGPU simulation tutorial: from example to first GPU run

Updated · Scientifically reviewed by Dinkar Mishra, PhD on

Short answer

PIConGPU is a C++ PIC code designed for GPUs, where physics settings are compiled into the binary. The workflow is: load a picongpu.profile environment, copy an example with pic-create, edit .param files (physics, compile time) and .cfg files (run size, GPUs, plugins), compile with pic-build, and submit with tbg using a template for your cluster's scheduler. Output is written in openPMD format for analysis in Python.

Who this is for

Researchers with access to GPU clusters who want to run large laser–plasma or plasma simulations with PIConGPU.

Software

PIConGPU current releaseCUDA or ROCm per PIConGPU docs

Prerequisites

  • Access to a GPU system with the dependencies PIConGPU needs (compiler, CUDA or ROCm, MPI, Boost, openPMD-api, and others). Many HPC centres provide ready-made environments; the PIConGPU documentation lists profiles for numerous systems.
  • Familiarity with Slurm job submission; see how to submit a Slurm job.

Step 1: set up the environment

Following the installation guide, obtain PIConGPU and create a picongpu.profile for your system (example profiles ship with the code). Then:

source "$HOME/picongpu.profile"
echo "$PICSRC"            # path to the PIConGPU source, set by the profile

Step 2: create a project from an example

pic-create "$PICSRC/share/picongpu/examples/LaserWakefield" "$HOME/picInputs/myLWFA"
cd "$HOME/picInputs/myLWFA"
ls include/picongpu/param/ etc/picongpu/
  • include/picongpu/param/*.param: compile-time physics, such as species, laser, density profile and grid cell size.
  • etc/picongpu/*.cfg: run-time settings, such as number of GPUs, grid size in cells, number of steps and output plugins.

Step 3: edit and compile

Change, for example, the laser a0a_0 in laser.param or the density in density.param, then compile:

pic-build

Compilation can take several minutes. Re-run pic-build after every .param change.

Step 4: submit with tbg

tbg -s sbatch -c etc/picongpu/1.cfg -t etc/picongpu/your-cluster/gpu.tpl "$HOME/runs/lwfa_001"

Replace the template path with the one for your system (templates live under etc/picongpu/). tbg copies the input set into the run directory, which records exactly what was run.

Step 5: analyse openPMD output

import openpmd_api as io

series = io.Series("simOutput/openPMD/simData_%T.bp", io.Access.read_only)
it = series.iterations[max(series.iterations)]
E_y = it.meshes["E"]["y"].load_chunk()
series.flush()
print(E_y.shape)

The file pattern and backend (.bp for ADIOS2 or .h5 for HDF5) depend on your output configuration.

Verify

  • The run writes regular progress output, and the job log shows the expected number of GPUs.
  • Field snapshots show the laser entering the plasma, and a wake period close to the plasma wavelength (see the plasma wavelength calculator).
  • Repeat with a finer cell size (a .param change and recompile) to check that key results are converged.

Troubleshooting

  • pic-build fails: the environment profile is incomplete or modules are missing. Start from a documented profile for a similar system.
  • The job fails at start: the number of GPUs in .cfg (the device grid) does not match the resources requested in the template, or the grid cannot be divided evenly between GPUs.
  • No output files: the output plugin was not enabled in the .cfg file, or the output backend is not installed.

Assumptions and limitations

  • Paths, example names and template names follow the documentation at the time of writing and differ between releases and systems.
  • The Python snippet uses openPMD-api. openPMD-viewer is an alternative for quick plots.
  • PIConGPU is best suited to GPU clusters. On a single small GPU, simpler codes may be quicker to set up.

Frequently asked questions

Why does PIConGPU compile the physics into the binary?+

Compile-time configuration through C++ templates lets the compiler generate specialised, highly optimised GPU kernels for your exact setup. The cost is that changing .param files requires recompiling; changing .cfg run parameters does not.

Which GPUs does PIConGPU support?+

Through the alpaka abstraction library, PIConGPU targets NVIDIA (CUDA) and AMD (HIP) GPUs, as well as CPUs. Check the documentation for supported versions on your system.

What is tbg?+

tbg ("template batch generator") combines your .cfg run configuration with a scheduler template (Slurm, PBS, bash) to create and submit a job script, and copies the setup into the run directory for reproducibility.

Is PIConGPU suitable for beginners?+

It has a steeper learning curve than Python-driven codes, but its examples are good starting points. It shines for very large GPU runs, synthetic radiation diagnostics and research that needs its specific physics modules.

References

  1. PIConGPU documentation · PIConGPU developers (HZDR)
  2. PIConGPU source code · GitHub
  3. Bussmann et al., Radiative signatures of the relativistic Kelvin-Helmholtz instability (SC13) · Conference paper
  4. openPMD standard · openPMD project

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.

Related guides

How Vlasify can help

Get a Quote