Linear MHD on polar splines: q model vs. variational p model¶
2026-11-17 · 1f5424ddd · Struphy 3.6.2 · media folder · study folder
Description¶
Question. Struphy has two discretizations of linear ideal MHD around a static equilibrium with a velocity in
H(div) that can be used on polar splines (no hole at the magnetic axis):
- the q model, LinearMHDWithQ (magnetic field in H(div)): a non-variational splitting into the shear Alfven
step, the background current, the background q = sqrt(p) and the sound step;
- the variational p model, VariationalLinearMHD (velocity in H(div), pressure p): the discrete Euler-Poincare
equations of the linearized MHD Lagrangian, with second-order fields (b-hat, p-hat) that carry the energy of the
equilibrium current and pressure, split into a shear Alfven/fast and a sound step.
How do they compare in accuracy, robustness against large time steps, energy behaviour and cost? On polar splines the
variational model needs the L2 projections in its transport operators (transport_projection="L2",
struphy#950): with the commuting projector it has a spurious mode at the axis (finding 1). Its sound step uses the
Kronecker preconditioner of the Schur complement (schur_precond="StiffnessPreconditioner", struphy#951). The
study was run with the branch of struphy#951 (stacked on #950) before their merge; with the merge commit recorded
here, short reruns (10 time steps, the eigenvalues of the stable case at dt = 0.5) give bit-identical results.
Setup (cases.py). Screw pinch (ScrewPinch, a = 1, B0 = 1, uniform density, length 2 pi R0, pressure from
the force balance plus p0 = 0.1) on IGAPolarCylinder with C1 polar splines, degree 3, 16 x 12 x 12 elements (32
radially for the convergence checks), 4 MPI ranks. Three cases:
- kink: q = 0.7 -> 1.3, R0 = 3: m = 1 internal kink, q = 1 at r = 0.71; block (m, n) = (1, -1);
- stable: q = 1.1 -> 1.9, R0 = 3: no resonance of (1, -1), stable; shear Alfven continuum
omega_A(r) = |1/q(r) - 1| B0 / R0 and slow continuum;
- suydam: q = 1.5 -> 2.5, R0 = 2: pressure-driven interchange (Suydam criterion violated for r < 0.82) at the
q = 2 surface (r = 0.71); block (2, -1).
The pressure gradient of this screw pinch (B_z constant) violates the Suydam criterion near the axis in all three
cases; it matters only for blocks with a resonance there. In addition, a polar torus (IGAPolarTorus, a = 1,
R0 = 3, 16 x 12 x 8) with AdhocTorus (q = 0.8 -> 2.0, beta = 0.1), toroidal block n = -1. AdhocTorus is
not an equilibrium: inside q = 1 the pressure gradient balances only 3-8 % of j x B. The torus results are
therefore only used for the time-step behaviour and the comparison of the two models, not for converged growth
rates. They were computed with the predecessor of eig_block.py (same operators and options); run_eig_all.sh with
TORUS=1 reproduces them. The torus modes of finding 8 were computed from the saved matrices of these runs
(eig_block.py --load-A, which recomputes two columns as a check: relative difference 3e-9 for q, 3e-13 for the
variational model).
Analysis.
- Exact eigenvalues of the one-step map (eig_block.py, all runs: bash run_eig_all.sh, figures and tables:
python compare_eig.py). One time step of the whole splitting is applied column by column to the basis of an
invariant Fourier block: (m, n) on the cylinder, including the in-plane polar degrees of freedom at the axis for
|m| = 1 (their m = +1 coordinate is read off the polar extraction operator); n on the torus (all poloidal harmonics,
1432 columns). gamma = log|lambda| / dt, omega = arg(lambda) / dt. Time runs (fits of exp(2 gamma t)) underestimate
the growth rate by up to 10 % at t = 60 because the modes have not separated; the eigenvalues have no such error.
The block is exact if the step commutes with the symmetry. The "leak", the part of the output outside the block,
is 1e-4 to 4e-3 on the cylinder (the projectors of the polar splines interpolate at three points per ring) and
1e-11 to 1e-9 on the torus.
- Mode structure (eig_block.py --modes 3, figures: python compare_modes.py): the velocity of the fastest
eigenvectors, evaluated in a poloidal plane (z = 0, or phi = 0 on the torus) from both phases of the complex
eigenvector. The phase is chosen such that the dominant poloidal harmonic of u_r is real at its peak; the
radial profiles are the amplitudes of the poloidal Fourier harmonics (in the logical angle) of u_r, u_theta, u_z.
- Energy (params_linear.py, run_energy.sh, figure: python compare_energy.py): time runs on the stable case,
T = 100, smooth helical velocity perturbation, the scalar en_tot of each model in every step.
- Cost (profile_cost.py, python compare_cost.py): wall time per step and per propagator, 8 steps after a
warm-up, kink case, 4 MPI ranks.
- Shortest axial wave (bash run_nyquist.sh, figures: python compare_nyquist.py, python compare_timerun.py):
kink time runs at dt = 0.5 up to T = 400 (velocity saved), the blocks (1, N3 // 2) for 8 to 24 axial elements
N3, and check_nyquist_kernel.py: the norm of b = -curl P(B0 x u) for smooth m = 1 waves in each velocity
component, with P = Pi^1 (q model) and P = L2 projection (variational model), on the polar cylinder and,
without polar splines, on a hollow cylinder and a periodic slab (--geom hollow|slab).
Main findings¶
| quantity | q model | variational (L2) |
|---|---|---|
| kink gamma, dt -> 0 (16 / 32 radial elements at dt = 0.25) | 0.0472 (0.04506 / 0.04505) | 0.0472 (0.04666 / 0.04666) |
| kink: error of gamma at dt = 0.5 / 0.25 / 0.125 | 18 % / 4.6 % / 1.2 % | 4.9 % / 1.2 % / 0.30 % |
| Suydam gamma at dt = 0.125 (16 / 32 radial elements) | 0.01155 / 0.00924 | 0.01171 / 0.00916 |
| stable case, block (1, -1): growing eigenvalues at dt = 0.5 / 0.25 / 0.125 | 7.4e-3 / 2.0e-4 / 1.1e-4, all at omega dt = 2.6-2.9 | none ( |
| static mode of the shortest axial wave, block (1, N3 / 2), kink case: N3 = 12 / 16 / 24 (odd N3 = 11, 13) | 0.182 / 0.251 / 0.315 (none) | 0.184 / 0.253 / 0.318 (none) |
| the same, stable case, N3 = 12 | 0.120 | 0.120 |
| stable case: max change of en_tot over T = 100 (dt = 0.5 / 0.125) | 7.5e-2 / 7.0e-2 (en_tot is not an invariant of the q model) | 2.8e-13 / 5.4e-14 |
| cost per unit time at kink error 0.3 % (dt) | 4.0 s (0.0625) | 7.5 s (0.125) |
| cost per unit time at kink error 1.2 % (dt) | about 2.1 s (0.125; estimated from 0.26 s per step) | 4.2 s (0.25) |
- The variational model needs the L2 transport on polar splines. With the commuting projector
Pi^1in the transport, the block of the kink has a mode at the axis (radial peak r = 0.03) with gamma = 0.155 at dt = 0.25, three times faster than the kink, and it does not decrease under radial refinement (time runs: 0.154 at 16, 0.145 at 32 radial elements). The degrees of freedom ofPi^1are line integrals along edges, and at the axis all radial edges start at one point, where the product of two discrete 2-forms (b x u) has no limit. The L2 projection uses volume integrals only. With it the mode is gone. (This block has a leak of 8e-2: the commuting projectors interpolate at three points per ring at the axis, so the value 0.155 is approximate.) The eigenvector shows it: the axis mode is a small vortex pair confined to r < 0.15, about two elements, and with the commuting projector even the kink of the same block (gamma = 0.0450) carries a spike of its m = 1 velocity at the axis, while the L2 kink is smooth there.

- Both models give the same instabilities. The kink converges to gamma = 0.0472 in both, and is converged in the radial resolution (16 vs. 32 elements: 2e-4 for q, below 1e-5 for the variational model). The pressure-driven Suydam mode agrees within 1 % at 32 radial elements (0.00924 vs. 0.00916 at dt = 0.125). It is not converged radially (-20 % from 16 to 32 elements in both models), as expected for a mode localized at the resonant surface. The eigenvectors agree as well: the kink is a rigid shift of the core inside q = 1 with the return flow at the q = 1 surface, and its u_r, u_theta and u_z profiles of the two models lie on top of each other. The Suydam mode is concentrated at the q = 2 surface (u_r peaks at r = 0.67, u_theta at 0.71); with 16 radial elements its u_theta oscillates from element to element there, and the 32-element profiles, again the same in both models, are narrower.

- The variational model converges about four times faster in the time step. Both are second order. At a given dt, the error of the variational kink growth rate equals that of the q model at dt / 2 (kink), and it is about 3.5 times smaller for the Suydam mode. At dt = 0.5 the q model turns the Suydam mode into a slowly rotating pair with a growth rate about seven times below the dt -> 0 limit (1.8e-3 vs. 0.0127).
- The q model has time-step-induced growing modes, the variational model none. On the stable screw pinch, where no eigenvalue may grow, all eigenvalues of the variational step in the block (1, -1) lie on the unit circle to round-off (the discrete energy is conserved exactly and positive in this block; finding 9 shows a block where it is not, in both models, from the spatial discretization). The q model has growing pairs at every dt, always at omega dt = 2.6-2.9 (fast waves), with gamma = 7.4e-3 at dt = 0.5, falling to 1e-4 at dt = 0.125: they move to higher frequencies as dt decreases and fade only slowly. In the kink case at dt = 0.5 the same family grows faster (5.2e-2) than the kink itself. Both models also show a few slowly growing pairs with gamma up to 2e-3 next to the kink at small dt, at the level of the block leak.
- Energy. The variational en_tot (including the second-order fields) is conserved to 3e-13 over 100 time units at both dt. The q model has no discrete invariant: its en_tot, the quadratic energy of the perturbation, exchanges energy with the equilibrium through the current and pressure terms and changes by up to 7.5 %. This is not an error of the q model, but it is why its stability against the time step is not guaranteed (finding 4). These runs are too short to see the grid-scale mode of finding 9: from round-off it needs about 300 time units.
- Cost. At equal accuracy of the kink growth rate, the variational model costs about twice as much per unit time (1.85 at 0.3 %, about 2 at 1.2 %): 0.93 s per step at dt = 0.125, of which 0.73 s in the shear Alfven step (BiCGStab with two operator applications per iteration, plus one mass-matrix solve per application of the L2 transport), against 0.25 s per step at dt = 0.0625 for the q model. Without the sound preconditioner of struphy#951 the variational sound step needed 55 instead of 4 BiCGStab iterations.
- Polar torus (AdhocTorus, not an equilibrium). The time-step behaviour is the same as on the cylinder: the q model has a family of overstable modes at omega dt = 2.3-2.4 (7 pairs, gamma up to 6.2e-3 at dt = 0.5, a third of the kink growth rate at dt = 0.25), the variational model at most two weak pairs (2.9e-4 at dt = 0.25), none at dt = 0.5 and 0.125, and its kink growth rate is converged already at dt = 0.5. The converged growth rates of the two models differ by 2 % (kink) and 8 % (second mode), and the q model shows real growing m = 1 modes at the edge at dt = 0.125. With an equilibrium that is not in force balance, the two models linearize different continuous problems, so these differences cannot be attributed to the discretizations.
- Mode structure on the torus. The kink of the two models (dt = 0.125) has the same shape: a shift of the core inside q = 1 (r = 0.41) towards the low-field side in the plane phi = 0. The toroidal coupling is weak at this aspect ratio: the m = 0 and m = 2 harmonics of u_r reach 4 % and 3 % of the m = 1 harmonic, m = 3 0.2 %, in both models. The profiles differ only close to the axis (r < 0.15), where the q model has a small dip.
- Both models have a static grid-scale instability at the shortest axial wave (even number of axial elements). Kink time runs at dt = 0.5 grow with the kink eigenvalue up to t = 240 (the time-step-induced pair of the q model, 0.052 in this block, is hardly excited by the smooth seed), then both are taken over by a mode with gamma = 0.182 (q) and 0.184 (variational), m = +-1 and n = 6, the shortest axial wave of 12 axial elements, grown from round-off. Its block has a real eigenvalue with these growth rates, independent of dt and of the radial resolution; it exists in the stable case too (0.120), grows with the axial resolution (0.25 at 16, 0.31 at 24 axial elements) and is absent for an odd number of axial elements (11, 13). The cause is a spurious kernel of the discrete Lie derivative curl P(B0 x u), the same in both models and for both projectors: the velocity in H(div) does not bend the field lines at the alternating axial wave. It is analysed in the study Spurious modes of the discrete Lie derivative in linear MHD.








Comparison figures¶










Videos¶
q_stable_dt0.5: q model (LinearMHDWithQ, B in H(div)), stable case, dt = 0.5, T = 100, 16 x 12 x 12
var_stable_dt0.5: variational p model (VariationalLinearMHD, L2 transport), stable case, dt = 0.5, T = 100, 16 x 12 x 12
q_stable_dt0.125: q model, stable case, dt = 0.125, T = 100, 16 x 12 x 12
var_stable_dt0.125: variational p model (L2 transport), stable case, dt = 0.125, T = 100, 16 x 12 x 12
q_kink_dt0.5: q model, kink case, dt = 0.5, T = 400, 16 x 12 x 12, velocity saved (finding 9)
var_kink_dt0.5: variational p model (L2 transport), kink case, dt = 0.5, T = 400, 16 x 12 x 12, velocity saved (finding 9)
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@1f5424ddd54e262afb6e997cccae3805eb6a4992"
struphy compile
The parameter and post-processing files are in studies/2026-11-linear-q-vs-variational-polar/params/. Run each command in that folder:
| run | description | params |
|---|---|---|
| q_stable_dt0.5 | q model (LinearMHDWithQ, B in H(div)), stable case, dt = 0.5, T = 100, 16 x 12 x 12 | params_linear.py |
| var_stable_dt0.5 | variational p model (VariationalLinearMHD, L2 transport), stable case, dt = 0.5, T = 100, 16 x 12 x 12 | params_linear.py |
| q_stable_dt0.125 | q model, stable case, dt = 0.125, T = 100, 16 x 12 x 12 | params_linear.py |
| var_stable_dt0.125 | variational p model (L2 transport), stable case, dt = 0.125, T = 100, 16 x 12 x 12 | params_linear.py |
| q_kink_dt0.5 | q model, kink case, dt = 0.5, T = 400, 16 x 12 x 12, velocity saved (finding 9) | params_linear.py |
| var_kink_dt0.5 | variational p model (L2 transport), kink case, dt = 0.5, T = 400, 16 x 12 x 12, velocity saved (finding 9) | params_linear.py |
q_stable_dt0.5
mpirun -n 4 python params_linear.py --model q --case stable --dt 0.5 --tend 100 --sim-folder q_stable_dt0.5
python compare_energy.py
var_stable_dt0.5
mpirun -n 4 python params_linear.py --model var --case stable --dt 0.5 --tend 100 --sim-folder var_stable_dt0.5
python compare_energy.py
q_stable_dt0.125
mpirun -n 4 python params_linear.py --model q --case stable --dt 0.125 --tend 100 --sim-folder q_stable_dt0.125
python compare_energy.py
var_stable_dt0.125
mpirun -n 4 python params_linear.py --model var --case stable --dt 0.125 --tend 100 --sim-folder var_stable_dt0.125
python compare_energy.py
q_kink_dt0.5
mpirun -n 4 python params_linear.py --model q --case kink --dt 0.5 --tend 400 --save-velocity --sim-folder q_kink_dt0.5
python compare_timerun.py
var_kink_dt0.5
mpirun -n 4 python params_linear.py --model var --case kink --dt 0.5 --tend 400 --save-velocity --sim-folder var_kink_dt0.5
python compare_timerun.py
