General Information

XGC is a global gyrokinetic particle-in-cell code, which specializes in the simulation of the edge region of magnetically confined thermonuclear fusion plasma.

Target Domain

The simulation domain can include the magnetic separatrix, magnetic axis and the biased material wall.

Basic Modes of Operation

In its full-featured operation, XGC can model electromagnetic turbulence with toroidal resolution \(N_\varphi \leq 512\). It utilizes a phase space grid in addition to particles in order to handle the non-Maxwellian particle distribution function in the tokamak edge. There are also simplified, less computationally demanding modes of operation.

XGC currently features three basic modes of operation, corresponding to different targets that can be built from the main code base.

  1. Electromagnetic mode

  • Full-featured mode of operation for simulating whole volume electromagnetic turbulence with gyrokinetic ions and drift kinetic electrons.

  • Employs the mixed-variable/pullback method to mitigate the Ampère cancellation problem.

  • Corresponding targets: xgc-eem-cpp (CPU version) and xgc-eem-cpp-gpu (GPU version).

  1. Electrostatic mode

  • Simulates electrostatic turbulence with gyrokinetic ions and drift kinetic electrons.

  • Less challenging algorithmically compared to the electromagnetic mode, resulting in lower computational resource demands. E.g. allows for a larger timestep size and less stringent mode filtering requirements.

  • Corresponding targets: xgc-es-cpp (CPU version) and xgc-es-cpp-gpu (GPU version).

  1. Axisymmetric mode

  • Solves the same equations as the electrostatic mode with the exception that the Poisson solver retains only the axisymmetric part of the electrostatic potential.

  • Allows economical studies of neoclassical transport compared to full turbulent electrostatic simulations.

  • Corresponding targets: xgca-cpp (CPU version) and xgca-cpp-gpu (GPU version).

Reduced delta-f

The electromagnetic and electrostatic modes can be configured to run in either reduced delta-f (no phase space grid) or total-f mode. While reduced delta-f mode is more economical, requiring fewer marker particles, it comes at the expense of neglecting certain neoclassical effects and may not be suitable for situations involving large departures from a Maxwellian particle distribution.

Stellarator Geometry (XGC-S)

Additionally, stellarator geometry features are available in XGC-S. While presently using a separate code base, integration into the main XGC code base is actively underway. XGC-S can simulate turbulence in non-axisymmetric stellarators. Currently XGC-S supports electrostatic simulations with delta-f gyrokinetic ions and adiabatic electrons.

Selected Physics Features

  • Impurities modeling with an arbitrary number of ion species

  • Each ion species can be run in a drift-kinetic or gyrokinetic mode. Electrons can be adiabatic, drift-kinetic, or gyrokinetic.

  • Neutral particles with atomic cross-sections

  • Heat sources

  • Nonlinear Fokker-Planck-Landau collisions

  • Anomalous diffusion model

Selected Numerical Features

  • Particle resampling

  • Core-edge coupling with GENE, GEM, and XGC itself.

  • In-situ analysis via code coupling

Features Under Development

As a flexible state-of-the-art code, XGC is under constant development to add features. Users should work closely with the core development team if they wish to add features. Most existing features are mutually compatible. Some are not, due to fundamental incompatibilities, while others could be made compatible if there is user interest.


XGC is written in C++, with several Fortran 90 components. It achieves high performance across all leading GPU and many-core architectures and HPC systems by utilizing: * MPI * OpenMP * CUDA, HIP, and SYCL, mostly via Kokkos * Cabana Weak scaling is roughly linear to the maximal number of compute nodes of leading HPC systems in the US.

The following pages describe the XGC repository structure and workflow, coding policies, and how to compile and run XGC.


[1] S. Ku et al., Nuclear Fusion 49, 115021 (2009),

[2] S. Ku, R. Hager, C.S. Chang et al., J. Comp. Physics, 315, 467 (2016),

[3] R. Hager, E.S. Yoon, S. Ku et al., J. Comp. Physics, 315, 644 (2016),

[4] R. Hager, J. Lang et al., Phys. Plasmas 24, 054508 (2017),