The Numerics of VMEC++

arXiv:2502.04374 · physics.plasm-ph, astro-ph.IM · Submitted 2025-02-05 · Read on arXiv

Listen

Radio episode about this paper

Transcript

Introduction to the show: ident: Physics. The day in general physics: instruments, methods and results across the field.

Kai: We're looking at the paper: "The Numerics of VMEC++".

Title and authors: Kai: So we've seen that "The Numerics of VMEC++" is focused on turning a complex equilibrium problem into a solvable numerical framework, specifically focusing on the mechanics of VMEC++.

Mira: The authors are Jonathan Schilling and the team at Proxima Fusion in Munich, and their work centers on making this kind of detailed calculation more efficient.

Lev: It's interesting because they are taking an existing tool and pushing its numerical capabilities to handle more complex, free-boundary problems reliably.

Kai: They aren't just running the code; they are rigorously defining all the mathematical steps, from how they calculate normal derivatives to how the Fourier basis works.

Mira: It’s about providing a detailed roadmap for anyone trying to implement or understand these kinds of plasma equilibrium solvers, which is crucial for validating simulations.

Lev: For someone building real hardware, knowing exactly where the overhead lands in these complex numerical steps matters a lot for performance metrics.

The paper's summary: Kai: In this paper, they summarize how VMEC++ approaches plasma equilibrium by using those Fourier methods to solve the force balance problem iteratively.

Mira: Essentially, they explain the process of computing residual MHD forces in real space, moving them into Fourier space, and then using an accelerated descent method to adjust the flux surface geometry toward force balance.

Lev: They are showing how this whole pipeline is structured so that you can see exactly where the physics meets the numerical discretization.

Kai: They also detail the two modes again: fixed boundary mode for simpler checks versus free boundary mode which allows for plasma shape evolution until force balance is achieved.

Mira: The key implication here is that they are providing a concrete, rigorous way to handle those difficult iterative adjustments in a system where the geometry itself is changing.

Lev: It’s about proving the numerical stability of their approach when you let the boundary move around.

The paper's improvements: Kai: The paper highlights several improvements they've made to the VMEC framework, starting with better constraint handling through spectral condensation.

Mira: That allows for a more economical use of available Fourier coefficients because they fit real space points well while simultaneously condensing them into a spectrally condensed Fourier representation.

Lev: That’s good because it means you don't need an excessive number of high-frequency modes to capture the physics, right?

Kai: Exactly. Then they introduce direct equal-arclength parameterization for flux surfaces, which helps get a unique poloidal angle-like coordinate in asymmetric cases.

Mira: That method reduces the set of Fourier coefficients by one element by assuming x equals y plus that specific condition, so it’s a neat trick for efficiency.

Lev: Reducing the required coefficients by one is tangible overhead savings when you have to compute those large matrices later.

Kai: They also detail computing analytical first and second order derivatives for both the objective function and the constraint, which feed into non-linear optimization algorithms to find better Fourier coefficients.

Mira: And they suggest feeding that optimization routine the value of M minus one, because M can't go lower than one, which guides its path in parameter space more effectively.

Lev: So it’s about making the optimizer smarter by giving it a better understanding of the bounds on its parameters.

Conclusion: Kai: To wrap up, "The Numerics of VMEC++" is about solidifying the implications of using spectral condensation and parameterization tricks to make this equilibrium code more practical.

Mira: They’ve shown a way to handle free boundaries robustly while keeping the computational cost manageable by optimizing how they use Fourier coefficients.

Lev: For me, it means when we move this to real hardware, we need those efficiency gains because the overhead of complex matrix assembly needs to be minimized for actual runs.

Kai: It’s about taking a highly theoretical method and showing exactly how it translates into a usable numerical pipeline for actual plasma geometry determination.

Mira: This paper gives us a solid foundation for understanding how to push these methods further, especially concerning the handling of those tricky geometric details in three dimensions.

Lev: It sets a clear benchmark for what real hardware needs to be able to handle computationally without the solution blows up due to numerical instability.

Jonathan Schilling

Proxima Fusion

physics.plasm-ph, astro-ph.IM

Submitted: 2025-02-05

Updated: 2026-11-18

Code: https://github.com/hbldh/pyefd

License: http://creativecommons.org/licenses/by-nc-nd/4.0/

The gist: The Variational Moments Equilibrium Code (VMEC) is a computational tool employed in stellarator physics to determine plasma equilibrium…

Key concepts

Spectral Condensation
This technique converts a real-space flux surface representation into Fourier coefficients suitable for VMEC. It efficiently uses available finite Fourier coefficients by fitting real-space points well while condensing them into a spectrally condensed Fourier representation, making the process more economical.
Equal-Arclength Parameterization
This method parameterizes flux surfaces using direct equal-arclength parameterization. This is useful for obtaining a unique poloidal angle-like coordinate, especially in asymmetric cases, and it reduces the set of Fourier coefficients needed by assuming $x_{s1}$ equals $y_{c1}$.
Jacobian Matrix Computation
The system computes the Jacobian matrix of the curve fitting problem. This matrix is approximately diagonal, which allows for an efficient calculation of its maximum eigenvalue. This helps understand how small changes in free parameters affect the force balance and stability.
Even-m and Odd-m Decomposition
Metric elements ($g_{\alpha\beta}$) are decomposed into even-$m$ and odd-$m$ contributions when evaluated at half-grid points. This decomposition is more robust than direct evaluation, especially for handling products of odd modes, ensuring a stable calculation of geometric quantities.

Terminology

Summary

The Variational Moments Equilibrium Code (VMEC) is a computational tool employed in stellarator physics to determine plasma equilibrium, specifically calculating three-dimensional geometry and magnetic field configurations under ideal magnetohydrodynamics (MHD) assumptions, often assuming nested flux surfaces. p. 6

Where the paper says it

Chapter 1 Introduction The Variational Moments Equilibrium Code (VMEC) [1] is the main computational workhorse used in the stellarator community to compute the three-dimensional geometry of and magnetic field in the plasma. VMEC computes the plasma equilibrium in a stellarator under the assumption of ideal magneto-hydrodynamics (MHD).

VMEC achieves this by computing residual MHD force components in real space on a grid, transforming these into Fourier space, and then employing an accelerated descent method to adjust the flux surface geometry toward force balance. p. 6
Where the paper says it

, on a grid in radial, poloidal and toroidal magnetic flux coordinates, and transformed back into Fourier space. The Fourier coefficients of the forces are then used to move the flux surface geometry (represented by cylindrical coordinates R and Z) and stream function λ towards force balance using an accelerated descent method.

The code operates in two modes: fixed-boundary mode, which solves for a predefined plasma boundary geometry and fixed pressure or rotational transform/current profiles on the flux surfaces; and free-boundary mode, which permits the plasma boundary to evolve until it achieves force balance with an external magnetic field generated by coils. p. 6

Where the paper says it

The fixed-boundary mode solves the ideal MHD force balance for a given, fixed, plasma boundary geometry and fixed radial profiles of pressure and either rotational transform or enclosed toroidal current on a number of flux surfaces inside the plasma boundary. The free-boundary mode extends the fixed-boundary operation by allowing the plasma boundary to move into force balance with an external magnetic field produced by coils.

Free-boundary computations are noted to be significantly more computationally intensive. p. 6
Where the paper says it

The free-boundary mode extends the fixed-boundary operation by allowing the plasma boundary to move into force balance with an external magnetic field produced by coils. This adds computational complexity and hence, free-boundary computations are usually a factor of 2 to 10 slower than the corresponding fixed-boundary computations.

The numerical methodology relies on a comprehensive set of mathematical tools, including normal derivative calculations, solving elliptic partial differential equations (Laplace's and Poisson's equations), Green’s Second Identity, trigonometric identities, series expansions (Binomial and geometric), generating functions, orthogonality of the Fourier basis, forward and inverse Fourier transforms, and methods for handling parity in Fourier transforms.

The toroidal coordinate system is established using a left-handed system where the poloidal coordinate is denoted by theta and the toroidal coordinate by zeta. p. 2

Where the paper says it

Trapezoidal . 17 3 Toroidal Coordinate System 19 3.

Flux surface geometry, represented by R(theta, zeta) and Z(theta, zeta), is modeled using two-dimensional discrete Fourier series in theta and zeta. p. 6
Where the paper says it

, on a grid in radial, poloidal and toroidal magnetic flux coordinates, and transformed back into Fourier space. The Fourier coefficients of the forces are then used to move the flux surface geometry (represented by cylindrical coordinates R and Z) and stream function λ towards force balance using an accelerated descent method.

These representations can be simplified using real-valued basis functions derived from complex Fourier coefficients, which are then truncated at maximum mode numbers M and N. p. 2
Where the paper says it

6 Generating Functions . 7 Orthogonality of the Fourier Basis .

Symmetry properties, such as toroidal periodicity (n fp) and stellarator symmetry (R(theta, zeta) = R(-theta, -zeta)), are exploited to reduce the required number of Fourier coefficients. p. 2
Where the paper says it

2 Symmetry Properties . 3 Vectorized Formulation of Fourier Series .

Tangential derivatives of R and Z with respect to theta and phi can be computed analytically using the Fourier representation. p. 2
Where the paper says it

4 Normalized Coordinates . 5 Tangential Derivatives .

Coordinate system transformations between cylindrical and Cartesian coordinates are defined via specific transformations for unit vectors and surface normals. p. 2
Where the paper says it

6 Toroidal Rotation of the Coordinate System . 7 Cartesian Components, Unit Vectors and Surface Normal .

A technique called spectral condensation is utilized to convert a real-space flux surface representation into Fourier coefficients suitable for VMEC, leveraging the poloidal freedom to efficiently utilize finite Fourier coefficients. p. 6

Where the paper says it

, on a grid in radial, poloidal and toroidal magnetic flux coordinates, and transformed back into Fourier space. The Fourier coefficients of the forces are then used to move the flux surface geometry (represented by cylindrical coordinates R and Z) and stream function λ towards force balance using an accelerated descent method.

This process involves defining spectral width metrics, such as M(p, q), and performing curve fitting using the sum of squared deviations (curve energy W c), optimizing this minimization subject to the constraint that the curve energy vanishes. p. 2
Where the paper says it

1 Spectral Width . 2 Curve Fitting .

Geometry is parameterized using direct equal-arclength parameterization, which computes Fourier coefficients for a given closed curve by defining a tangential parameter t based on arclength and fitting a Fourier series, often employing trapezoidal quadrature or analytical integration over piecewise-linear segments for Fourier integrals. p. 2
Where the paper says it

5 Direct Equal-Arclength Parameterization . 1 Trapezoidal Quadrature .

The metric elements g alpha beta are defined based on the geometry; their evaluation on the half-grid is performed by combining even- m and odd- m contributions, with specific interpolation rules applied to manage product terms involving odd modes. The constraint imposed by the toroidal current profile is formulated using covariant magnetic field components. p. 3

Where the paper says it

9 Constraint of Toroidal Current Profile . 10 Covariant Magnetic Field Components .

The total plasma volume is computed by integrating the differential volume profile over the radial coordinate, which requires specialized numerical integration schemes on the half-grid. p. 7
Where the paper says it

The VMEC input file then only needs to contain the respective circuit currents and the total magnetic field produced by all main coils is then computed by linear superposition of the response tables stored in the mgrid file, weighted by the user-provided circuit currents. Related Publications In the following, a complete (to the author’s knowledge) list of publications and, where applicable, corresponding internal reports of ORNL (with sometimes additional details in comparison with the published journal articles) related to the numerical details implemented in VMEC is provided: 1.

State variables R, Z, and lambda are represented by two-dimensional Fourier series in theta and zeta. p. 6

Where the paper says it

The computation is converged when the force residuals for R, Z and λ have decayed below a userprovided threshold. VMEC is designed to allow computation of the ideal MHD equilibrium for both symmetric and asymmetric two- and three-dimensional configurations, which is configured by selection of which subset of Fourier harmonics to include in the computation.

Their tangential derivatives are computed analytically using separable product basis functions for symmetric configurations, while the toroidal derivative with respect to phi is computed using a factor related to n fp. Symmetry properties of the tangential derivatives are analyzed, involving separate routines for even and odd parity contributions in asymmetric cases. The Jacobian matrix is computed on the radial half-grid by decomposing metric elements and using product interpolation rules to assemble the final Jacobian. p. 3
Where the paper says it

7 Jacobian . 8 Metric Elements .

Magnetic field components are defined using contravariant and covariant components based on metric elements. p. 3

Where the paper says it

9 Constraint of Toroidal Current Profile . 10 Covariant Magnetic Field Components .

The net toroidal current enclosed by a flux surface is related to the divergence of B theta, expressed in terms of covariant magnetic field components. p. 3
Where the paper says it

9 Constraint of Toroidal Current Profile . 10 Covariant Magnetic Field Components .

The computation of the differential volume profile involves evaluating the square root of the metric element determinant on the half-grid using product interpolation rules.

The radial discretization involves representing physical quantities at full-grid radial knots or half-way in toroidal flux space, with parity separation for even and odd poloidal harmonics to reduce computational load. p. 6

Where the paper says it

Starting out from an initial guess for the flux surface geometry, the residual MHD force components are computed in real space, i. , on a grid in radial, poloidal and toroidal magnetic flux coordinates, and transformed back into Fourier space.

The distribution of flux surfaces along the radial coordinate is parameterized by a user input polynomial, and toroidal flux profiles are initialized on the half-grid using trapezoidal quadrature. p. 6
Where the paper says it

, on a grid in radial, poloidal and toroidal magnetic flux coordinates, and transformed back into Fourier space. The Fourier coefficients of the forces are then used to move the flux surface geometry (represented by cylindrical coordinates R and Z) and stream function λ towards force balance using an accelerated descent method.

Metric elements are computed by decomposing them into even- m and odd- m contributions, with specific interpolation rules applied to handle products of odd modes.

The constraint of the toroidal current profile is related to the divergence of B theta, expressed in terms of covariant magnetic field components, leading to an expression involving the metric elements. p. 3

Where the paper says it

9 Constraint of Toroidal Current Profile . 10 Covariant Magnetic Field Components .

The total plasma volume is computed by integrating the differential volume profile over the radial coordinate. p. 7
Where the paper says it

, there are seven circuits: all 10 copies of each of the five non-planar coil type wired in series, respectively, and similar circuits of each 10 copies of the two planar coil types. The VMEC input file then only needs to contain the respective circuit currents and the total magnetic field produced by all main coils is then computed by linear superposition of the response tables stored in the mgrid file, weighted by the user-provided circuit currents.

The Jacobian on the half-grid is assembled using interpolated quantities derived from geometry and tangential derivatives. p. 6
Where the paper says it

, on a grid in radial, poloidal and toroidal magnetic flux coordinates, and transformed back into Fourier space. The Fourier coefficients of the forces are then used to move the flux surface geometry (represented by cylindrical coordinates R and Z) and stream function λ towards force balance using an accelerated descent method.

The final Jacobian on the half-grid is assembled using these interpolated quantities. p. 6

Where the paper says it

, on a grid in radial, poloidal and toroidal magnetic flux coordinates, and transformed back into Fourier space. The Fourier coefficients of the forces are then used to move the flux surface geometry (represented by cylindrical coordinates R and Z) and stream function λ towards force balance using an accelerated descent method.

The computation of the Jacobian involves assembling terms derived from metric elements, tangential derivatives, and radial derivatives using product interpolation rules to ensure numerical stability. p. 8
Where the paper says it

“Improved Radial Differencing for Three-Dimensional Magnetohydrodynamic Equilibrium Calculations” [22]. This article introduces regularization factors for the odd-m Fourier coefficients in order to increase the numerical accuracy of radial derivatives approximated by finite differences.

The metric elements are decomposed into even- m and odd- m contributions, with specific interpolation rules applied to handle products of odd modes. p. 8
Where the paper says it

“Improved Radial Differencing for Three-Dimensional Magnetohydrodynamic Equilibrium Calculations” [22]. This article introduces regularization factors for the odd-m Fourier coefficients in order to increase the numerical accuracy of radial derivatives approximated by finite differences.

Green — the paper says it, and the page is printed. Red — no passage carries it, so treat that sentence as unverified. The same check runs on your own text: check a summary against its source, $5.

Improvements for AI systems

  1. Improved constraint handling through spectral condensation allows for more economical use of available Fourier coefficients by fitting real-space points well while simultaneously condensing them into a spectrally condensed Fourier representation.

  2. The system can perform direct equal-arclength parameterization of flux surfaces, which is useful for obtaining a unique poloidal angle-like coordinate, especially in asymmetric cases where the method reduces the set of Fourier coefficients by one element by assuming x s 1 equals y c 1.

  3. The AI system can compute analytical first and second-order derivatives for both the objective function and the constraint, which are then used by non-linear optimization algorithms to find optimal Fourier coefficients.

  4. The optimization routine can be fed with the value of M minus one, as M cannot get lower than 1, incorporating this information to guide its path in parameter space more effectively.

  5. The system can utilize a specific method for computing tangential derivatives that involves a complex expression derived from the decomposition of the second-order mixed derivative into terms involving even-m and odd-m Fourier harmonics.

  6. The system can compute the Jacobian matrix of the curve fitting problem, which is approximately diagonal, allowing for efficient calculation of its maximum eigenvalue to understand how changes in free parameters affect the force balance.

  7. The AI system can compute geometric quantities like R and Z on the full poloidal domain by combining even-parity and odd-parity components using symrzl to yield the general R and Z on the full poloidal domain for asymmetric three-dimensional configurations.

  8. The AI system can compute the metric elements g alpha beta at half-grid points by employing a decomposition of metric elements into even-m and odd-m contributions, which is more robust than direct evaluation of the intermediate result.

Abstract

VMEC++ is a Python-friendly, from-scratch reimplementation in C++ of the Variational Moments Equilibrium Code (VMEC), a fixed- and free-boundary ideal-MHD equilibrium solver for stellarators and tokamaks. The first VMEC implementation was written by Steven P. Hirshman and colleagues in the 1980s and 1990s and its latest Fortran incarnation (PARVMEC, https://github.com/ORNL-Fusion/PARVMEC) is widely used in stellarator optimization systems. Our work improves on previous implementations with regard to various critical aspects: special care has been put in providing an idiomatic Python experience, from installation to actual usage; VMEC++ has a zero-crash policy; it supports inputs in the classic INDATA format as well as friendlier JSON files. VMEC++ execution times are typically less than or equal to previous implementations, and time to convergence can be decreased dramatically by leveraging its hot-restart feature: by providing the output of a VMEC++ run as initial state for a subsequent one, VMEC++ is initialized using the previously converged equilibrium. This can dramatically decrease runtimes when running on many similar magnetic configurations as it typically happens in stellarator optimization pipelines. On the flip side, some features of the original Fortran VMEC implementation are not yet available in VMEC++, such as support for non-stellarator-symmetric configurations. This contribution presents the internal numerics of the open-source VMEC++ package publicly for the first time.

Sources

Related papers