GVEC is already providing stellarator-type equilibrium solutions to the gyro-kinetic code GENE-3D [NMP+20],[MND+20],[WNM+21], the linear MHD stability code CASTOR-3D [PDS+23] and the nonlinear time-dependent MHD code JOREK-3D [NRH+22]. The new G-Frame feature and its application are presented in [HPM25] and [PDR+25].
GVEC builds upon the ideas of the well-established VMEC [HW83].
where \((x,y,z)=:\vec{x} \in\R^3\) are Cartesian coordinates and \((\rho,\thet,\zeta)\in[0,1]\times[0,2\pi)\times[0,2\pi)\) are the logical coordinates in radial and angular directions.
The derivatives of \(f\) give the usual tangent basis vectors
with \(\alpha,\beta\in\{\rho,\thet,\zeta\}\).
It also follows that
(7)#\[\begin{equation}\label{eq:from grad to e}
\erho=\left(\grad\thet\times\grad\zeta\right)\Jac\,,\quad
\ethet=\left(\grad\zeta\times\grad\rho\right)\Jac\,,\quad
\ezeta=\left(\grad\rho\times\grad\thet\right)\Jac\,.
\end{equation}\]
This allows us to write the MHD energy functional as
with the covariant components \(B^\alpha=\vec{B}\cdot\grad\alpha\), and
using Einstein summation convention, summing over repeated indices.
In the following, we first define the coordinates and the magnetic field \(\vec{B}\), to be able to write the MHD energy functional in terms of the solution variables.
Before we introduce the magnetic field representation, we begin with details on the coordinate systems.
Illustration of logical and Cartesian coordinates and the coordinate transforms in GVEC.
The logical domain with \((\rho,\thet,\zeta)\) coordinates is described by the unit disc, \(D^2\), and unit circle, \(S^1\), respectively. We assume a mapping \(\widetilde{X}\) from the logical domain to a toroidal domain \(\Omega_p\times S^1\), described by \((q^1,q^2)\) coordinates. Then, \(h\) maps from \((q^1,q^2,\zeta)\) to Cartesian coordinates \((x,y,z)\) of the real space domain \(\Omega\), as illustrated on the right.#
As illustrated in the Figure above, the full map \(f:= h\circ \tilde{X}\) is decomposed into two maps,
leaving \(X^1,X^2\) as functions of \((\rho,\thet,\zeta)\) to describe the geometry of each cross-section along \(\zeta\). The map \(h\) is fixed throughout the equilibrium calculation and can be specified by the user.
Simple examples of \(h\) are given by the periodic cylinder \((x,y,z) := (q^1,q^2,\zeta)\) and the conventional cylindrical representation \((x,y,z) := (q^1 \cos(\zeta),-q^1 \sin(\zeta),q^2)\).
A new possibility for \(h\) is the G-Frame, a flexible coordinate frame which is moving along a closed curve and is fully user-defined, details are given in [HPM25].
It is always assumed that \((x,y,z) = h(q^1,q^2,q^3)\) is an orientation-preserving coordinate transformation, i.e., the Jacobian determinant is strictly positive, \(\det (Dh) > 0\). (Here and in the following \(D\) denotes the derivative operator.) For the composition \(f = h \circ \tilde{X}\) to be defined, the function \(\tilde{X}\) must take values in the domain of definition of \(h\). This is the only constraint that links \(h\) and \(\tilde{X}\). In addition, we require (independently of \(h\)) that
which is the Jacobian of the transformation \((\rho,\thet) \mapsto (X^1,X^2)\).
Hence, for any fixed angle \(\zeta\), the map \((q^1, q^2) = \big(X^1(\rho,\thet,\zeta), X^2(\rho,\thet,\zeta)\big)\) is an orientation-preserving diffeomorphism from the unit disk, parametrized by polar coordinates \((\rho,\thet)\), into a domain in the \((q^1,q^2)\)-plane. By the chain rule, \(Df = Dh(\tilde{X}) D\tilde{X}\), we have that \(f\) is an orientation-preserving diffeomorphism away from the polar singularity at \(\rho=0\).
As the full map \(f\) is decomposed into \(f=h\circ \tilde{X}\), the Jacobian and metric terms are equally decomposed and computed as
with the toroidal magnetic flux \(\Phi\), the poloidal magnetic flux \(\chi\) and the straight field line angles \(\thet^\star\) and \(\zeta^\star\).
However, the straight-field line angles are a result of the equilibrium solution and therefore not known a priori.
Thus, we introduce an additional periodic function \(\lambda\), which maps the straight field line angles \((\thet^\star=\thet+\lambda(\rho,\thet,\zeta),\zeta^\star=\zeta)\) to general flux coordinates.
Note that the toroidal angle \(\zeta\) is fixed by the map \(h\), the boundary geometry then defines an arbitrary angular parameterization in \(\thet\), so that \(\lambda\) is free to set the straight field line angle \(\thet^\star\) at the boundary.
Moreover, the magnetic fluxes are provided as inputs to the problem, and depend only on the flux surface label \(\rho\). With that in mind, the magnetic field is given as
where the prime indicates the derivative with respect to \(\rho\).
Finally, we express the magnetic field into the two contravariant components and the tangent basis vectors in tangential direction of the flux surface,
In the previous sections, we have defined everything to be able to write the continuous MHD energy functional in terms of our unknowns \(u:= (X^1, X^2, \lambda)\).
Consider the test set of test functions \(v:=(Y^1(\rho,\thet,\zeta),Y^2(\rho,\thet,\zeta),\Lambda(\rho,\thet,\zeta))\), variations in the energy functional are then computed as
For simplicity, we explain the discretization using a placeholder scalar unknown \(U(\rho,\thet,\zeta)\), that can be any of the solution variables \(X^1(\rho,\thet,\zeta),X^2(\rho,\thet,\zeta),\lambda(\rho,\thet,\zeta)\).
\(U\) is discretised by a tensor-product of B-splines in the radial direction \(\rho\) and a double-angle Fourier series in poloidal and toroidal angles \((\thet,\zeta)\)
with coefficients \(\hat{U}_{k,\ell}\), B-Spline basis functions \(\rbasis_k(\rho)\) and Fourier basis functions \(\fbasis_\ell(\thet,\zeta)\).
The double-angle Fourier series is defined by the maximum mode numbers \((m\submax,n\submax)\) in poloidal and toroidal direction. The toroidal mode number on the full torus (\(\zeta=[0,2\pi]\)) is a product of the Fourier mode number \(n\) on one field period and the number of field periods \(\nfp\). We write all Fourier basis functions \(\fbasis_\ell(\thet,\zeta)\) as a list of length \(\ell\submax=(m\submax+1)(2n\submax+1)\),
The mode number \(m,n\) can be deduced from the index \(\ell\).
To impose stellarator symmetry [DH98], we restrict the list of Fourier basis functions to a subset of either cosines, using \(\ell\submin=1,\ell\submax=m\submax(2n\submax+1)+n\submax+1\), or sines, using \(\ell\submin=m\submax(2n\submax+1)+n\submax+2,\ell\submax=(m\submax+1)(2n\submax+1)\).
(In cylinder coordinates, stellarator symmetry implies \(R(\thet,\zeta)=R(-\thet,-\zeta)\) and \(Z(\thet,\zeta)=-Z(-\thet,-\zeta)\), thus cosine for \(R\) and sine for \(Z\).)
The B-Spline in \(\rho\) is defined by the polynomial degree \(p\) and a set of grid points \(\{\rho_i\}_{i=1}^{N_r}\) with \(\rho_1=0,\rho_{N_r}=1\). From the grid points, a knot sequence is constructed, with a multiplicity of \(p+1\) at the first and the last knot. As we do not allow for any multiplicity of internal knots, the continuity of the B-Spline is \(p-1\) and the number of basis functions is \(k\submax=N_r+(p-1)\).
Note that all variables \(X^1,X^2,\lambda\) share the same radial grid, but are allowed to have different polynomial degrees of the B-Spline.
The first and last B-Spline coefficient equals the value at the boundary. This allows to easily set Dirichlet boundary conditions.
As we only consider fixed-boundary equilibria in this work, we impose a Dirichlet boundary condition at \(\rho=1\) for the variables \(X^1,X^2\), by setting the last B-Spline coefficient of each Fourier modes to the value provided by the boundary geometry. For \(\lambda\), no boundary condition is imposed at \(\rho=1\), as its boundary value is an unknown of the solution.
We know from the mapping \(\widetilde{X}\) (see Coordinate maps) that each cross-section \(X^1(\rho,\thet,\zeta=\text{const.})\), \(X^2(\rho,\thet,\zeta=\text{const.})\) represents a map to the unit disc \(\rho\exp(\mathrm{i}\thet)\), which has to be smooth at any point inside the unit disc. Away from the singular point \(\rho=0\), the tensor-product of B-Splines and Fourier series is smooth, up to the polynomial degree of the B-Spline.
In order to preserve the same smoothness at the magnetic axis \(\rho=0\), we need to impose a boundary condition for the B-Spline representation of each Fourier mode that depends on the poloidal mode number \(m\).
The necessary and sufficient conditions for smoothness at the magnetic axis have been presented in [LB90].
First, the value of \(U\) at \(\rho=0\) must be unique and independent of \(\thet\), thus it is determined solely by the B-Spline representing the \(m=0\) poloidal mode. All B-Splines representing non-zero poloidal modes have zero Dirichlet boundary condition at \(\rho=0\).
Additionally, the boundary condition must involve radial derivatives of the B-Spline, up to the polynomial degree \(p\).
The argument in [LB90] is that on the unit disc, a polynomial of degree \(m\) can be expressed \((\rho\exp(\mathrm{i}\thet))^m=\rho^m\exp(\mathrm{i}m\thet)\).
Hence, for a poloidal mode \(f(\rho)\mathrm{e}^{\mathrm{i}m\thet}\), the radial function \(f(\rho\to 0)\) must exclude terms \(\rho^j\) where \(j<m\), in order to be smooth.
Hence, we have to impose that all radial derivatives \(<m\) must vanish
(28)#\[\begin{equation}
m \quad\text{odd}:\qquad \left.\pdv[j]{U}{\rho}\right|_{\rho=0}=0, \quad\forall j\quad \text{even}\,.
\end{equation}\]
The boundary condition at the axis results in a smoothness constraint that is imposed on all variables \(X^1,X^2\) and \(\lambda\).
Here is an explicit example of all boundary conditions set at the axis, for a B-Spline of degree \(p=5\) and \(m\submax=6\) poloidal modes:
where \(\omega_i\) is the quadrature weight and \(n_q\) is the total number of Gauss quadrature points in the radial direction. The total number is given by the number of grid elements of the B-Splines and the number of quadrature points in each B-Spline element, chosen to integrate piecewise-polynomial functions exactly up to degree \(2p+1\). The number of integration points in the poloidal and toroidal direction are \(n_\thet\), \(n_\zeta\) and we choose the positions as
While the degrees of freedom of \(\lambda(\rho,\thet,\zeta)\) are evolved in the minimization of the energy functional, an initial guess is required. One option is to simply choose \(\lambda(\rho,\thet,\zeta)=0\), however a better initial guess can be obtained by solving an elliptic equation for \(\lambda\).
The equation states that \(\vec{B}\) and \(\vec{J}\) are tangent along a given flux surface labelled by \(\rho\), combining with the result from earlier gives \(J^\rho=0\), or
By muliplying with the Fourier test function \(\fbasis(\thet,\zeta)\) and integrating over \(\thet\) and \(\zeta\) we obtain a weak equation for \(\lambda\) at a given \(\rho\),
with \(\iota(s)=\frac{\chi^\prime(\rho)}{\Phi^\prime(\rho)}\). We can change from one SFL coordinate to the other by adding a periodic function \(\nu\)
The natural SFL coordinates in GVEC (and VMEC) are PEST angles \(\thet_P,\zeta_P\), since we already know the transformation with \(\lambda\) from the VMEC angles \(\thet,\zeta\)
Here one sees that the integrability condition \(\partial_\zeta(\partial_\thet \nu)-\partial_\thet(\partial_\zeta \nu)=0\) is only satisfied if \(\partial_\zeta(B_\thet)-\partial_\thet(B_\zeta)=0\), which is analogue to \(J^\rho=0\).
The calculation of \(\nu\) is simplified by defining \(\nu=\frac{\omega+\lambda}{(\iota\Btavg+\Bzavg)}\), so that the unknown becomes simply
We can compute the Fourier expansion of \(\omega=\sum_{m,n} \omega_{mn} \sigma_{mn}(\thet,\zeta)\), with \(\omega_{00}=0\) (assume here that \(\sigma_{mn}(\thet,\zeta)=e^{\mathrm{i}(m\thet-n\zeta)}\))
with the norm of of each mode \(\sigma_{mn}(\thet,\zeta)=\sin(m\thet-n\zeta)/\cos(m\thet-n\zeta)\)
Now if the integrability condition would be satisfied, \(\omega_{mn}, m\neq 0,n\neq 0\), computed in the two ways must yield the same. The condition translates to
which results in the weak form of \(J^\rho=0\). Note that only if \(\lambda\) is recomputed from \(J^\rho=0\) (involving fluxes and the mapping), using the same basis functions as \(\omega\), one can guarantee the integrability condition of \(\nu\) to machine precision.
thus the variation on a flux surface only depends on \(1/\Jac_B\).
Recalling the mapping \(f:(\rho,\thet,\zeta)\mapsto(x,y,z)\), and introducing the mapping \(g: (\rho,\thet,\zeta)\mapsto(s,\thet^\star_B,\zeta^\star_B)\), and the mapping \(f^\star:(s,\thet^\star_B,\zeta^\star_B)\mapsto(x,y,z)\), its clear that \(f^\star=g^ {-1}\circ f\). Thus we find the Boozer Jacobian,
with the Jacobian and metric tensor \(\Jac_h=q^1\) and \(G_{ij}=\delta_{i1}\delta_{j1}+\delta_{i2}\delta_{j2}+\delta_{i3}\delta_{j3}\left(q^1\right)^2\).
The Jacobian and metric tensor are simply \(\Jac_h=\frac{L_c}{2\pi}\) and \(G_{ij}=\delta_{i1}\delta_{j1}+\delta_{i2}\delta_{j2}+\delta_{i3}\delta_{j3}\left(\frac{L_c}{2\pi}\right)^2\).
As an example of non-standard choice of the map we construct coordinates based on the \((k,l)\)-torus.
The map is a generalization of the standard cylindrical coordinates \((R,Z)\) given by
where \(\sigma\) is a sign function to compensate possible sign changes in the normal \(\vec{N}\) and bi-normal \(\vec{B}\) at points where curvature is zero. The \((TNB)\) frame is not defined at points with zero curvature. We assume that zero curvature only appears at a single point, thus the frame exists in the limit towards that point. The map can be evaluated only away from these points.
The curve parameter \(\zeta \in [0,2\pi]\) is not assumed to be the arclength \(\ell\), such that
Note that the sign of the Jacobian is chosen such that its always positive at \(q_1=0\), and positivity is only guaranteed for \(\sigma q_1 < \kappa^{-1}\) (!) Also note that the change of sign function \(\sigma\) coincides with \(\kappa=0\) and thus will not lead to any jump in the Jacobian.
At last, the derivatives of the Jacobian determinant are
The G-frame was introduced in [HPM25], it is a generalization of the Frenet frame. We can define the map \(h\) using a closed curve \(\X(\zeta)\) and two basis vectors \(\vec{N}(\zeta)\) and\(\vec{B}(\zeta)\) as an input:
Note, since \(\vec{N},\vec{B}\) are now input functions, they are not assumed to be unit length nor orthogonal, but together with the tangent of the curve \(\vec{T}=\Xp\), \((\vec{T},\vec{N},\vec{B})\) should form a linearly independent set of basis vectors, with \(\vec{T}\cdot(\vec{N}\times \vec{B})>0\).
R.L. Dewar and S.R. Hudson. Stellarator symmetry. Physica D: Nonlinear Phenomena, 112(1):275–280, 1998. Proceedings of the Workshop on Time-Reversal Symmetry in Dynamical Systems. doi:https://doi.org/10.1016/S0167-2789(97)00216-9.
W.D. Dhaeseleer, W.N.G. Hitchon, J.D. Callen, and J.L. Shohet. Flux Coordinates and Magnetic Field Structure, A Guide to a Fundamental Tool of Plasma Theory. Springer-Verlag, New York, 1991.
Per Helander. Theory of plasma confinement in non-axisymmetric magnetic fields. Reports on Progress in Physics, 77(8):087001, jul 2014. doi:10.1088/0034-4885/77/8/087001.
Florian Hindenlang, Gabriel G Plunk, and Omar Maj. Computing MHD equilibria of stellarators with a flexible coordinate frame. Plasma Physics and Controlled Fusion, 67(4):045002, mar 2025. doi:10.1088/1361-6587/adba11.
S. P. Hirshman and J. C. Whitson. Steepest‐descent moment method for three‐dimensional magnetohydrodynamic equilibria. The Physics of Fluids, 26(12):3553–3568, 1983. doi:10.1063/1.864116.
H. Ralph Lewis and Paul M. Bellan. Physical constraints on the coefficients of Fourier expansions in cylindrical coordinates. Journal of Mathematical Physics, 31(11):2592–2596, 11 1990. doi:10.1063/1.529009.
Maurice Maurer, A Bañón Navarro, Tilman Dannert, Marco Restelli, Florian Hindenlang, Tobias Görler, Daniel Told, Denis Jarema, Gabriele Merlo, and Frank Jenko. GENE-3D: a global gyrokinetic turbulence code for stellarators. Journal of Computational Physics, 420:109694, 2020.
A Banon Navarro, G Merlo, GG Plunk, P Xanthopoulos, A Von Stechow, A Di Siena, M Maurer, F Hindenlang, F Wilms, and F Jenko. Global gyrokinetic simulations of ITG turbulence in the magnetic configuration space of the Wendelstein 7-X stellarator. Plasma Physics and Controlled Fusion, 62(10):105005, 2020.
Nikita Nikulsin, Rohan Ramasamy, Matthias Hoelzl, Florian Hindenlang, Erika Strumberger, Karl Lackner, Sibylle Günter, Jorek Team, and others. JOREK3D: an extension of the JOREK nonlinear MHD code to stellarators. Physics of Plasmas, 2022.
Gabriel G Plunk, Michael Drevlak, Eduardo Rodríguez, Robert Babin, Alan Goodman, and Florian Hindenlang. Back to the figure-8 stellarator. Plasma Physics and Controlled Fusion, 67(3):035025, feb 2025. doi:10.1088/1361-6587/adb64b.
Jonas Puchmayr, Mike G Dunne, Erika Strumberger, Matthias Willensdorfer, Hartmut Zohm, and Florian Hindenlang. Helical mode localization and mode locking of ideal MHD instabilities in magnetically perturbed tokamak plasmas. Nuclear Fusion, 2023.
Felix Wilms, Alejandro Bañón Navarro, Gabriele Merlo, Leonhard Leppin, Tobias Görler, Tilman Dannert, Florian Hindenlang, and Frank Jenko. Global electromagnetic turbulence simulations of W7-X-like plasmas with GENE-3D. Journal of Plasma Physics, 87(6):905870604, 2021.