Canonical Maxwellian equilibrium of guiding centers in a tokamak¶
2026-11-14 · e0351a835 · Struphy 3.6.2 · media folder · study folder
Description¶
Question. Does a canonical Maxwellian, a function of the constants of motion of guiding-center orbits, stay
stationary over long times in a tokamak with the guiding-center pushers of Struphy (model GuidingCenter, discrete
gradients) and C1 polar splines at the magnetic axis, and can the diagnostics tell it from distributions that are
not stationary? Eight runs: the base run (exact equilibrium), the other shifts of psi_c (none: exact; B0: not
exact), a gyro-Maxwellian control with the same profiles in the position (not an equilibrium), epsilon = 0.02 and
0.1, and the pushers discrete gradient 2nd order and explicit RK4, each changing one thing against the base run.
Setup. Example GuidingCenter/tokamak_equilibrium (params_tokamak_equilibrium.py). Guiding centers
f(X, v_par, mu, t) in a static field, with parallel streaming, the mirror force and the grad-B and curvature drifts
of order epsilon = 0.05 (normalized cyclotron period). Full torus without hole (IGAPolarTorus, a = 1, R0 = 3, C1
polar splines), ad hoc tokamak equilibrium (AdhocTorus, circular flux surfaces, B0 = 1 on axis, q = 1.71 + 0.16
r²). The canonical Maxwellian (CanonicalMaxwellian2D)
f0 = n(psi_c) / (2 pi)^(3/2) / vth(psi_c)³ exp(-(v_par²/2 + mu |B0|) / vth(psi_c)²) has the profiles
n = (1 - s)² and vth = 0.15 + 0.10 (1 - s) in the normalized canonical toroidal momentum s(psi_c), with
psi_c = P_phi minus a shift of the order of the orbit width, here with the field max |B0| on the surface psi =
P_phi (shift="Bmax"), which keeps psi_c a constant of motion, so f0 is an exact equilibrium (Jeans' theorem).
Grid 16 x 48 x 48, cubic splines, 25 markers per cell (921,600 markers, drawn uniformly on the disc, weights
f0 / s0), dt = 0.2, T = 100 (500 steps), both pushers discrete gradient 1st order, markers leaving the plasma at
r = a are removed. All runs use the same markers (seed 1234): the runs with epsilon = 0.05 and the same pusher
differ only in the weights. 4 MPI ranks, 30 - 51 min per run. The runs were made with 82f76f386 of
struphy-hub/struphy#949 (the --shift flag and the pictures of this page), merged as e0351a835 with the same code
of the example, the particles and the post-processing; run_case.sh runs and post-processes
one run, compare.py makes the comparison.
Analysis (pproc_tokamak_equilibrium.py). The markers are binned every 5 steps in r = eta1 a, in the
poloidal plane (eta1, eta2), in v_par, mu, (r, v_par) and (v_par, mu) (density, divided by the Jacobian). The
change f(t) - f(0) uses the same markers with fixed weights, so it contains only the noise of the marker motion,
not that of the initial loading. Trapped-passing boundaries at the outboard midplane: v_par² = 2 mu (B_max -
B_min) on the flux surface (in (r, v_par) for mu B_min = vth²). Color scales are clipped at the 99.5th
percentile, because the division by the Jacobian makes single bins at the axis very noisy. The runs are compared
by the relative L2 deviation from t = 0 of the distributions binned in r and in v_par (the 2D slices have too
few markers per bin), as medians over t = 5 - 25 and t = 75 - 100, since single markers next to the axis cause
spikes.
Main findings¶
| run | dev. r, t = 5-25 / 75-100 | dev. v_par, t = 5-25 / 75-100 | max energy drift | lost markers | time |
|---|---|---|---|---|---|
| base (shift Bmax, exact) | 0.017 / 0.017 (-1%) | 0.015 / 0.023 (+57%) | 6.4e-4 | 71,544 | 38 min |
| shift_none (exact) | 0.018 / 0.018 (-1%) | 0.014 / 0.022 (+63%) | 1.5e-3 | 71,544 | 37 min |
| shift_b0 (not exact) | 0.017 / 0.019 (+13%) | 0.018 / 0.035 (+90%) | 1.1e-3 | 71,544 | 37 min |
| gyro (control) | 0.018 / 0.030 (+64%) | 0.015 / 0.038 (+148%) | 1.6e-3 | 71,544 | 37 min |
| eps0.02 | 0.010 / 0.014 (+45%) | 0.015 / 0.014 (-6%) | 3.4e-5 | 28,952 | 30 min |
| eps0.1 | 0.020 / 0.023 (+17%) | 0.018 / 0.024 (+32%) | 7.1e-3 | 140,268 | 51 min |
| dg2 | 0.016 / 0.017 (+1%) | 0.015 / 0.021 (+46%) | 5.4e-4 | 71,528 | 46 min |
| rk4 | 0.016 / 0.016 (+1%) | 0.015 / 0.021 (+47%) | 5.4e-4 | 71,543 | 34 min |
- The exact equilibria stay stationary. For shift Bmax and shift None, f(100) - f(0) is noise without structure in all views, and the deviation in r has no drift (1.7% - 1.8% at early and late times). The same holds for all three pushers.
- The diagnostics see the distributions that are not stationary. The gyro-Maxwellian control develops a change that is odd in v_par at r/a = 0.4 - 0.9, close to the trapped-passing boundary: more particles with v_par > 0, fewer with v_par < 0 (figure below). This is the radial shift of the passing orbits by the drifts, in opposite directions for co- and counter-passing particles, which moves the density gradient by plus or minus an orbit width. Its deviation grows by 64% in r and by 148% in v_par (to 3.8%). The canonical Maxwellian with the on-axis shift B0 shows the same pattern, weaker (+90% in v_par, to 3.5%), as expected since psi_c jumps only for the barely trapped particles.
- A slower growth in v_par remains for the exact equilibria (+46% to +63%, to 2.1% - 2.3%), about the same for discrete gradient 1st and 2nd order and RK4, so it is not an error of the time integration. It does not appear for epsilon = 0.02 (-6%); it is most likely the decorrelation of the Monte-Carlo noise of the fixed markers by the drifts, not a relaxation of f (no structure in f(100) - f(0)).
- epsilon. Smaller drifts give smaller deviations and losses (epsilon = 0.02: 1.0% - 1.4% in r, 29k lost markers, energy drift 3.4e-5); larger drifts larger ones (epsilon = 0.1: 140k lost markers, energy drift 7.1e-3, and more spikes from markers crossing the axis region, where the orbits are widest).
- Pushers. Discrete gradient 2nd order and explicit RK4 give the same deviations (1.6%, 2.1%) and energy drift (5.4e-4), slightly below discrete gradient 1st order (1.7%, 2.3%, 6.4e-4); RK4 is the fastest (34 min, dg1 38 min, dg2 46 min).
- Losses and energy. The runs with epsilon = 0.05 lose the same 71,500 markers (7.8%; same markers, same orbits), which carry only 1.7e-4 of the mass in the base run (the density vanishes at the edge). The energy drift comes mostly from these losses; it differs between the initial conditions because the weights of the lost edge markers differ.
- Spikes of the deviation (up to 100% in the 2D slices) come from single markers close to the magnetic axis, whose weight is divided by the small Jacobian of their bin: an artifact of the binning.




Comparison figures¶



Videos¶
base: canonical Maxwellian, shift Bmax, epsilon = 0.05, discrete gradient 1st order, grid 16 x 48 x 48, 25 markers per cell, T = 100
shift_none: canonical Maxwellian without shift of psi_c (exact equilibrium)
shift_b0: canonical Maxwellian, shift with the on-axis field B0 (not exactly stationary: psi_c jumps at the bounce points of barely trapped particles)
gyro: gyro-Maxwellian with the same profiles in the flux label of the position (control, not an equilibrium)
eps0.02: as base, epsilon = 0.02 (smaller drifts and orbit widths)
eps0.1: as base, epsilon = 0.1 (larger drifts and orbit widths)
dg2: as base, both pushers discrete gradient 2nd order
rk4: as base, both pushers explicit RK4
Reproduce¶
Install the Struphy version of the study (in a fresh virtual environment) and compile the kernels:
pip install "struphy @ git+https://github.com/struphy-hub/struphy@e0351a835"
struphy compile
The parameter and post-processing files are in studies/2026-11-gc-canonical-maxwellian/params/. Run each command in that folder:
| run | description | params |
|---|---|---|
| base | canonical Maxwellian, shift Bmax, epsilon = 0.05, discrete gradient 1st order, grid 16 x 48 x 48, 25 markers per cell, T = 100 | params_tokamak_equilibrium.py |
| shift_none | canonical Maxwellian without shift of psi_c (exact equilibrium) | params_tokamak_equilibrium.py |
| shift_b0 | canonical Maxwellian, shift with the on-axis field B0 (not exactly stationary: psi_c jumps at the bounce points of barely trapped particles) | params_tokamak_equilibrium.py |
| gyro | gyro-Maxwellian with the same profiles in the flux label of the position (control, not an equilibrium) | params_tokamak_equilibrium.py |
| eps0.02 | as base, epsilon = 0.02 (smaller drifts and orbit widths) | params_tokamak_equilibrium.py |
| eps0.1 | as base, epsilon = 0.1 (larger drifts and orbit widths) | params_tokamak_equilibrium.py |
| dg2 | as base, both pushers discrete gradient 2nd order | params_tokamak_equilibrium.py |
| rk4 | as base, both pushers explicit RK4 | params_tokamak_equilibrium.py |
base
mpirun -n 4 python params_tokamak_equilibrium.py --sim-folder base --save-step 5
python pproc_tokamak_equilibrium.py base --save-step 5 --video
shift_none
mpirun -n 4 python params_tokamak_equilibrium.py --sim-folder shift_none --save-step 5 --shift none
python pproc_tokamak_equilibrium.py shift_none --save-step 5 --shift none --video
shift_b0
mpirun -n 4 python params_tokamak_equilibrium.py --sim-folder shift_b0 --save-step 5 --shift B0
python pproc_tokamak_equilibrium.py shift_b0 --save-step 5 --shift B0 --video
gyro
mpirun -n 4 python params_tokamak_equilibrium.py --sim-folder gyro --save-step 5 --init gyro
python pproc_tokamak_equilibrium.py gyro --save-step 5 --init gyro --video
eps0.02
mpirun -n 4 python params_tokamak_equilibrium.py --sim-folder eps0.02 --save-step 5 --epsilon 0.02
python pproc_tokamak_equilibrium.py eps0.02 --save-step 5 --epsilon 0.02 --video
eps0.1
mpirun -n 4 python params_tokamak_equilibrium.py --sim-folder eps0.1 --save-step 5 --epsilon 0.1
python pproc_tokamak_equilibrium.py eps0.1 --save-step 5 --epsilon 0.1 --video
dg2
mpirun -n 4 python params_tokamak_equilibrium.py --sim-folder dg2 --save-step 5 --algo discrete_gradient_2nd_order
python pproc_tokamak_equilibrium.py dg2 --save-step 5 --algo discrete_gradient_2nd_order --video
rk4
mpirun -n 4 python params_tokamak_equilibrium.py --sim-folder rk4 --save-step 5 --algo explicit --butcher rk4
python pproc_tokamak_equilibrium.py rk4 --save-step 5 --algo explicit --butcher rk4 --video







































































