Near-axis measures of quasi-isodynamic configurations E. Rodríguez \aff 1, G. G. Plunk \aff 1 Abstract We present a number of measures and techniques to characterise and effectively construct quasi-isodynamic stellarators within the near-axis framework, without the need to resort to the computation of global equilibria. These include measures of the reliability of the model (including aspect-ratio limits and the appearance of ripple wells), quantification of omnigeneity through ϵ eff \epsilon_{\mathrm{eff}} , measure and construction of MHD stabilised fields, and the sensitivity of the field to the pressure gradient. The paper presents, discusses and gives examples of all of these, for which expansions to second order are crucial. This opens the door to the exploration of how key underlying choices of the field design govern the interaction of desired properties (“trade-offs”), and provides a practical toolkit to perform efficient optimisation directly within the space of near-axis QI configurations. 1 Introduction The range of stellarator magnetic confinement fields is broad ( Spitzer Jr, 1958 ; Boozer, 1998 ; Helander, 2014 ) , making it a daunting task both to understand and design them. This is true even when one restricts attention to particular subsets, known to have certain key properties such as omnigeneity ( Hall & McNamara, 1975 ; Bernardin et al., 1986 ; Cary & Shasharina, 1997 ; Helander, 2014 ) . Omnigenous fields are capable of confining, by definition, all collisionless charged particle orbits ( Northrop, 1961 ; Littlejohn, 1983 ; Wesson, 2011 ; Blank, 2004 ) , hence the particular interest in them. Even though the magnetic field magnitude |\mathbf{B}| on their nested flux surfaces requires careful consideration ( Boozer, 1983 ; Nührenberg & Zille, 1988 ; Cary & Shasharina, 1997 ; Parra et al., 2015 ) , there remains a wide range of choices to be made. This is true whether the problem is attacked from the optimisation perspective ( Mynick, 2006 ) or a more controlled analytical approach. One prominent case of the latter, which this paper shall be concerned with, is the near-axis description of the field ( Mercier, 1964 ; Solov’ev & Shafranov, 1970 ; Lortz & Nührenberg, 1976 ; Garren & Boozer, 1991b ) . Consisting of an asymptotic description of the equilibrium field in the distance (described by r ) from its centre (called the magnetic axis), the fields reduce to being described by only a few functions and parameters. These constitute a model for the field that has proved powerful in advancing the theoretical understanding of optimised omnigeneous stellarators ( Mercier, 1964 ; Lortz & Nührenberg, 1976 ; Landreman & Jorge, 2020 ; Landreman, 2021 ; Jorge & Landreman, 2020 ; Rodríguez et al., 2022b ; Rodríguez et al., 2024 ) as well as providing a practical tool in stellarator design ( Landreman & Sengupta, 2019 ; Landreman, 2022 ; Rodríguez et al., 2023 ; Jorge et al., 2022 ; Camacho Mata et al., 2022 ) . The latter has however been restricted for the most part to a particularly mature subclass of omnigeneous stellarators: namely quasisymmetric stellarators ( Boozer, 1983 ; Nührenberg & Zille, 1988 ; Rodríguez et al., 2020 ; Burby et al., 2020 ) . Only recently ( Plunk et al., 2019 ; Camacho Mata et al., 2022 ; Jorge et al., 2022 ; Camacho Mata & Plunk, 2023 ; Rodríguez & Plunk, 2023 ; Rodriguez et al., 2024 ) has the near-axis framework of quasi-isodynamic (QI) fields ( Cary & Shasharina, 1997 ; Helander & Nührenberg, 2009 ; Nührenberg, 2010 ) , the other big class of optimised stellarators, been sufficiently developed. The lateness of this development has been a consequence of the complex treatment that these fields demand; while QS fields possess a direction of symmetry in |\mathbf{B}| (either toroidal or helical), the QI fields do not (although they have closed poloidal contours). The objective of this work is to help enable full use of the recent advances in the near-axis description of QI stellarators. In particular, although Rodriguez et al. (2024) verified the construction of approximately QI fields to second order, it left open the issue of how to go about obtaining ‘good’ solutions, i.e. how to best select input parameters, how to evaluate candidate fields and how to navigate the extremely large design space that the near-axis construction opens up. To address this we develop a set of measures and techniques using second-order near axis expansion to incorporate notions of neoclassical transport, MHD stability and equilibrium sensitivity into the construction of QI stellarators. With these tools in hand, we are in a position to construct and more thoroughly evaluate stellarator design candidates, and conduct systematic studies exploring things like optimization trade-offs. The paper is organized as follows. In Section 2 essential definitions and notation of near-axis theory are provided. The rest of the paper is divided into sections describing different types of measures. In Section 3 we introduce the measure of field error \delta\!B that quantifies the deviation of a finite aspect ratio consistent equilibrium from its asymptotic near-axis description, following Landreman (2021) . This does however not qualify the physical impact of such deviations. Thus in section 4 we present calculations of the neoclassical \epsilon_{\mathrm{eff}} effective ripple ( Nemov et al., 1999b ) within the near-axis expansion, a form to quantify the lack of omnigeneity in which second order is central. In Section 5 we study the appearence of localised ripple wells in the field, a feature that the near-axis description of \epsilon_{\mathrm{eff}} cannot capture, focusing on finding what aspect ratio these first appear. Some questions of MHD stability are addressed in Section 6 , where we explore the sensitivity of the magnetic well ( Greene, 1997 ; Landreman & Jorge, 2020 ) of a near-axis field to the choice of second order shaping. Finally, in Section 7 we study the role played by the pressure gradient, and quantify the sensitivity of a given field to changes in plasma \beta . We conclude with some closing remarks. 2 Definitions and notation This paper does not re-derive the inverse-coordinate near-axis framework ( Garren & Boozer, 1991b ; Landreman & Sengupta, 2019 ) , but the work is best understood with some familiarity with how the equilibrium equations for an approximately QI field are solved through second order in the expansion. A full detailed and pedagogical account may be found in Rodriguez et al. (2024) and references within, but we provide some pointers on notation to help make the presentation as self-contained as possible. In the vain of the near-axis expansion, all equilibrium quantities are expanded in a Taylor-Fourier series in powers of r=\sqrt{2\psi/\bar{B}} (a pseudo-radial distance from the axis, where \psi is 2\pi the toroidal magnetic flux and \bar{B} a reference magnetic field) and cosine (sine) harmonic in the poloidal, \theta , (or helical, \chi=\theta-N\varphi for N\in\mathbb{Z} ) angle. Here the angles are part of the Boozer coordinate system ( Boozer, 1981 ) , which eases the description of the magnetic field. This way, any function f is written as f=\sum_{n=0}^{\infty}r^{n}f_{n} and f_{n}=\sum_{m=0}^{n}(f_{nm}^{c}(\varphi)\cos m\chi+f_{nm}^{s}(\varphi)\sin m\chi) , where the latter sum is over even or odd numbers depending on the parity of n . 1 1 1 We may use the following shorthand as well: F_{11}^{c}=F_{1c} , F_{11}^{s}=F_{1s} , F_{22}^{c}=F_{2c} , F_{22}^{s}=F_{2s} for any function that F may be. This subscript notation ( Rodriguez et al., 2024 , Sec. 2.3) will be repeatedly used, and we refer to n as the order (first, second, etc.) of the expansion. In the inverse-coordinate framework, a magnetic field is described by only a few functions. First, the magnetic field strength, B=|\mathbf{B}| , which in the near-axis notation reduces to a set of functions of \varphi , such as B_{2c} at second order. Because of the inverse-coordinate nature of the expansion, we describe flux surfaces of the magnetic field through the functions X,~Y and Z , which define the relative position of flux surfaces respect to the magnetic axis in the Frenet-Serret frame (normal, binormal and tangent respectively) of the latter ( Rodriguez et al., 2024 , Eq. (2.2)) . Finally, the covariant components of the field, \{G,I,B_{\psi}\} , are also explicitly involved ( Rodriguez et al., 2024 , Eq. (2.1)) , as is the rotational transform of the field, \iota . The governing equilibrium equations impose important relations between the components of all of these quantities involved, and that is what solving the near-axis expansion is focused on. It is however important to emphasise the ingredients required to uniquely define a field in this framework. An approximately QI near-axis field is uniquely defined to first order by the set \{\kappa(\ell),\tau(\ell),B_{0}(\varphi),\bar{d}(\varphi),\alpha_{1}(\varphi)\} , where the first two are the curvature and torsion defining the shape of a magnetic axis (which must have vanishing curvature points ( Plunk et al., 2019 ; Camacho Mata & Plunk, 2023 ; Rodriguez et al., 2024 ) ), the third is the magnetic field along the axis as a function of the toroidal Boozer angle, and the latter two define B_{1} ( Rodriguez et al., 2024 , Eq. (2.4)) , B_{1}=\kappa(\varphi)B_{0}(\varphi)\bar{d}(\varphi)\cos\left[\chi-\alpha_{1}(\varphi)\right]. (1) These first order choices also uniquely determine the elliptical shaping of flux surfaces around the magnetic axis. At second order, the key degrees of freedom (inputs) are \{p_{2},X_{2c}(\varphi),X_{2s}(\varphi)\} , where the former parameter is the pressure gradient and the latter two are related to triangular shaping. For the detailed role played by each of these, we again refer the reader to Rodriguez et al. (2024) . 3 Field truncation error \delta\!B The construction of QI fields using the near-axis expansion is rather non-trivial already at first order in the expansion. Different choices of magnetic axis and the shaping of elliptical cross-sections require a careful balance. Unless actively sought, such fields will tend to present particularly elongated and twisted shapes ( Camacho Mata et al., 2022 ) . Even when suitable parameters are found, we must always remember that the field resulting from the near-axis description is approximate in nature. The study and design of a stellarator field requires, in practice, the full non-expanded equilibrium field. Thus, we generally need to construct a finite aspect ratio version of the near-axis field, which will show some deviations from the purely asymptotic description. Significant deviations can lead to the loss of those properties of the field carefully instilled in the near-axis field. This particularly concerns |\mathbf{B}| , the field strength, which controls guiding centre dynamics of particles, and omnigeneity . When such deviations are limited, the near-axis description may be deemed good . This measure of goodness has been previously used ( Camacho Mata et al., 2022 ; Camacho Mata & Plunk, 2023 ) to gauge the suitability of 1st order near-axis QI fields as interesting candidates for optimised stellarators, and is thus of some interest. To define this goodness more precisely, let us introduce the field strengths B_{\mathrm{global}} and B_{\mathrm{nae}}^{(1)} . Define B_{\mathrm{global}} as the field strength of the global equilibrium at its outermost flux surface \psi=\psi_{a} parametrised by \theta and \varphi , angular poloidal and toroidal Boozer coordinates ( Boozer, 1981 ) . This global equilibrium is meant to be a finite aspect ratio representation of the near-axis field, and we follow the prescription of Landreman & Sengupta (2019) . That is, given a first order near-axis field, we calculate the shape of the elliptical flux surface at some radius r=a (i.e., a=\sqrt{2\psi_{a}/\bar{B}} ), and use it as the outer boundary of a global nested-flux surface, vacuum field. The solution then defines \mathbf{B}_{\mathrm{global}} . The comparison of this global field can then be made to the first order near-axis one, evaluated at the edge, B_{\mathrm{nae}}^{(1)}=B_{0}+a^{2}B_{1} . We define the field error as, \delta\!B=\sqrt{\int(B_{\mathrm{global}}-B_{\mathrm{nae}}^{1\mathrm{st}})^{2}\mathrm{d}\varphi\,\mathrm{d}\theta}\Bigg/\sqrt{\int B_{\mathrm{global}}^{2}\mathrm{d}\varphi\,\mathrm{d}\theta}; (2) the normalised root-mean-square difference. Large values imply significant differences between the realised field and the near-axis model, and thus the expectation of them behaving quite differently. Gauging the goodness of a NAE field as defined in Eq. ( 2 ) requires us to solve a global equilibrium. Whether one uses VMEC ( Hirshman & Whitson, 1983 ) , DESC ( Dudt & Kolemen, 2020 ) , GVEC ( Hindenlang et al., 2019 ) or any other nested flux surface solver, computing \delta\!B is numerically costly as compared to the near-axis field, impeding in addition its theoretical investigation. Can we make sense of this goodness of the field from within the near-axis framework? 3.1 Near-axis perspective on \delta\!B By definition, \delta\!B measures the discrepancy between the full- B and the truncation of an asymptotic form. That is, \delta\!B is, in a sense, a measure of the truncation error of the asymptotic expansion. The truncation error of an asymptotic series ( Bender & Orszag, 2013 , Sec. 3.5) can be gauged by the next order in the expansion, 2 2 2 Note that this is true by definition for sufficiently small r , the expansion variable. In any form, the next order bears information about the truncation error. and thus the calculation to 2nd order could possibly be used to estimate \delta\!B . There is however an important caveat: in the near-axis expansion, moving from order N to order N+1 in the expansion brings new degrees of freedom. From 1st to 2nd, we may shape the triangularity of surfaces in an infinite number of ways. Amongst this myriad of possibilities, we should pick that which most closely corresponds to our particular scenario. This was dealt with in Landreman (2021) and Landreman & Sengupta (2019) , which used the 1st order near-axis field of interest at r=a to impose the shape of the outermost boundary of a global equilibrium, which they then asymptotically described. Formally, the description of the global equilibrium field \tilde{\mathbf{B}} requires a double expansion in r (a near-axis expansion) and a (a large aspect ratio expansion to deal with the ‘global’ nature of the field). Asymptotically computing this field, and evaluating its difference with B_{\mathrm{nae}}^{(1)}(r=a)=B_{0}+aB_{1} can be shown to be ( Landreman, 2021 , Sec. 5.2) , 3 3 3 We note that the construction detailed in Landreman (2021) , in particular Eq. (C30), is not correct. This is apparent from the lack of symmetry of the expression respect to the mid-point of a field period. The expression should be correctly constructed taking the N -fold symmetry into account, \bar{f}^{(2)}(\varphi)=\int_{0}^{\varphi}\hat{B}(\varphi^{\prime})\mathrm{d}\varphi^{\prime}+\left(\frac{1}{2}-\frac{N\varphi}{2\pi}\right)\int_{0}^{2\pi/N}\hat{B}(\varphi^{\prime})\mathrm{d}\varphi^{\prime}-\frac{N}{2\pi}\int_{0}^{2\pi/N}\mathrm{d}\varphi^{\prime\prime}\int_{0}^{\varphi^{\prime\prime}}\hat{B}(\varphi^{\prime})\mathrm{d}\varphi^{\prime} . \tilde{B}_{2}=a^{2}\tilde{B}_{0}^{(2)}+r^{2}(\tilde{B}_{20}^{(0)}+\tilde{B}_{2c}^{(0)}\cos 2\chi+\tilde{B}_{2s}^{(0)}\sin 2\chi). (3) The first is a mirror term , Eq. (C24) in Landreman (2021) , arises from the finite aspect ratio construction (expansion in a ), and is necessary to guarantee a constant toroidal flux \psi_{a}=\bar{B}a^{2}/2 . As such, it is a perturbation on the near-axis input B_{0}(\varphi) , the magnetic field on axis that sets the leading trapping well structure. The r -dependent terms in Eq. ( 3 ) correspond to the 2nd order near-axis expansion of \tilde{B} , whose shaping is chosen to match the outermost surface. They may therefore be found in a form analogous to the regular second order construction, solving Eqs. (A41)-(A42) in Landreman & Sengupta (2019) using Eqs. (C9)-(C12) in Landreman (2021) and then applying Eqs. (A34)-(A36) in Landreman & Sengupta (2019) . The field error \delta\!B may therefore be estimated as, \delta\!B_{\mathrm{ar}}=a^{2}\sqrt{\frac{1}{2\pi}\int_{0}^{2\pi}\left[(\tilde{B}_{20}^{(0)}+\tilde{B}_{0}^{(2)})^{2}+\frac{(\tilde{B}_{2c}^{(0)})^{2}}{2}+\frac{(\tilde{B}_{2s}^{(0)})^{2}}{2}\right]\mathrm{d}\varphi}, (4) where all fields have been evaluated at the boundary r=a . 3.2 Numerical implementation We have implemented the computation of \delta\!B_{\mathrm{ar}} numerically in pyQIC 4 4 4 The code may be found in https://github.com/SebereX/pyQIC.git , a significantly different version of the original code in Jorge et al. (2022) , and the particular branch is specified in the Zenodo repository. , following the original work of Landreman (2021) , and introducing all the appropriate generalisations that apply to QI fields, especially the non-uniform B_{0} and correct handling of half helicity axes ( Camacho Mata & Plunk, 2023 ; Rodriguez et al., 2024 ) . In practice, the resources devoted to finding \tilde{B} quantities are analogous to those employed when solving the 2nd order equations of a near-axis equilibrium. In fact, the very equations involved are quite similar, and more specific details may be found in the code itself. To benchmark \delta\!B we need a set of near-axis configurations and their associated finite aspect ratio equilibria. The latter are obtained running the global flux-surface equilibrium code VMEC ( Hirshman & Whitson, 1983 ) , constructed using the near-axis surface at r/R=0.07 (roughly an aspect ratio of A=14 ). As for the benchmark set, we use a set of 1680 approximately QI, half-helicity near-axis fields (see some details in Appendix A and a fuller description in an upcoming publication). To compute \delta\!B as defined in Eq. ( 2 ) the field strength is computed in Boozer coordinates using BOOZXFORM ( Sanchez et al., 2000 ) . The comparison of \delta\!B to the near-axis estimate \delta\!B_{\mathrm{ar}} is shown in Figure 1 . Figure 1: Benchmark of the error field measure \delta\!B_{\mathrm{ar}} . The main plot compares the field error \delta\!B , Eq. ( 2 ), evaluated using the global equilibrium computed with VMEC , to the near-axis estimate \delta\!B_{\mathrm{ar}} for the QI near-axis configurations in the benchmark database of Appendix A.1 . The black broken line represents \delta\!B=\delta\!B_{\mathrm{nae}} , and the dotted one the moving average of the scatter. The colours for \delta\!B_{\mathrm{ar}} denote the number of field periods of the configurations (see legend). The inset plot shows the same data scaled by the field period number as 1/N^{2} . The agreement is excellent (the correlation is in excess of 0.99), especially strong for the lowest \delta\!B values. At larger \delta\!B , there is a clear systematic deviation, with the near-axis \delta\!B_{\mathrm{ar}} overestimating the field discrepancy. This overestimation is a result of fields with larger \delta\!B having a tendency for increased shaping and sensitivity, and thus smaller radii of convergence. Evaluation at a finite aspect ratio thus tends to overestimate the magnitude of the field. However, \delta\!B_{\mathrm{ar}} retains a monotonic relation with \delta\!B . The behaviour of the field error is clearly seen to depend on the number of field periods. They appear to form separate clusters, with the larger field period numbers leading to larger deviations (in agreement with the arguments before, with the exception of the special case N=1 ). Rescaling \delta\!B/N^{2} (see inset of Figure 1 ) clusters all different fields together. This quadratic scaling follows the involvement of second derivatives in \varphi in the construction of the 2nd order near-axis equilibrium expansion (see Rodriguez et al. (2024) ) and approximate scaling symmetries in axis shapes as discussed in Plunk et al. (2025) . All together, the error field near-axis measure \delta\!B_{\mathrm{ar}} is an excellent predictor of \delta\!B . The systematic deviation may lead to a failure of a qualitative agreement at larger errors, but even this departure could be refined by using a fit of the curve in Figure 1 to map \delta\!B_{\mathrm{ar}} to \delta\!B . 4 Effective ripple: \epsilon_{\mathrm{eff}} Although the simplicity of the field error \delta\!B makes it appealing as a measure of how ‘good’ a given 1st order near-axis field is, it ignores the fact that not all field deviations (even if they may correspond to the same \delta\!B ) affect the behaviour of the field equally. In particular, some deviations will spoil omnigeneity more than others. The field error measure overlooks a second important point, namely that deviations from omnigenity are unavoidable to a certain degree ( Cary & Shasharina, 1997 ) even at first order ( Plunk et al., 2019 ; Rodríguez & Plunk, 2023 ) , so it is important to separately evaluate such deviations at each order. Thus, we are in need of some way of measuring the departure from ideal omnigeneity, of which there are many ( Mynick, 2006 ; Nemov et al., 2008 ; Rodríguez et al., 2022a ; Goodman et al., 2023 ; Dudt et al., 2024 ) . In this paper we consider the effective ripple \epsilon_{\mathrm{eff}} as the measure of deviations from omnegeneity or “omnigeneity error”. This is a geometric, dimensionless scalar quantity defined by Nemov et al. (1999a) whose magnitude (or more precisely, that of \epsilon_{\mathrm{eff}}^{3/2} ) controls the neoclassical electron heat transport across a flux surface in a plasma that balances the radial losses with collisions; i.e. the so-called 1/\nu regime. Given its clear physical interpretation, the evaluation of \epsilon_{\mathrm{eff}} is commonly used to assess modern optimised stellarators, which aim at values below a percent. Here, we shall be interested in evaluating it within the near-axis framework. Doing so will: (i) avoid having to solve global equilibria and perform neoclassical calculations to assess fields, and (ii) provide insight on how near-axis choices affect it. Following ( Nemov et al., 1999a , Eq. (29)) , we express \epsilon_{\mathrm{eff}} in our own notation as \epsilon_{\mathrm{eff}}^{3/2}=\frac{\pi(\bar{R}\bar{B})^{2}}{8\sqrt{2}}\lim_{L\rightarrow\infty}F(L)\,\int_{1/B_{\mathrm{max}}}^{1/B_{\mathrm{min}}}\mathrm{d}\lambda\,\lambda\sum_{j=1}^{N_{\mathrm{well}}}\mathcal{E}_{j}(\lambda), (5) where, \displaystyle\mathcal{E}_{j}(\lambda) \displaystyle=\frac{H_{j}(\lambda)^{2}}{I_{j}(\lambda)}, (6a) \displaystyle H_{j}(\lambda) \displaystyle=\frac{1}{\bar{B}^{2}}\int_{\ell_{j,L}}^{\ell_{j,R}}\mathcal{H}(\lambda,B)\frac{\mathbf{B}\times\nabla B\cdot\nabla\psi}{B}\mathrm{d}\ell, (6b) \displaystyle I_{j}(\lambda) \displaystyle=\int_{\ell_{j,L}}^{\ell_{j,R}}\frac{\sqrt{1-\lambda B}}{B}\mathrm{d}\ell, (6c) \displaystyle F(L) \displaystyle=\left(\int_{0}^{L}\frac{\mathrm{d}\ell}{B}\right)\left(\int_{0}^{L}|\nabla\psi|\frac{\mathrm{d}\ell}{B}\right)^{-2}, (6d) and \mathcal{H}(\lambda,B)=\frac{\sqrt{1-\lambda B}}{(B/\bar{B})^{2}}\left(\frac{4}{\lambda B}-1\right). (7) The factors \bar{R} and \bar{B} are reference length (major radius) and magnetic field magnitudes that normalise \epsilon_{\mathrm{eff}} to make it a dimensionless quantity. The effective ripple is then to be understood as a sum over all trapped particles, \lambda , in all wells, labelled j , along the field line, running from 0 to L (in the limit of L\rightarrow\infty ). That is, on an irrational surface, over the whole flux surface. Note that this involves a sum over very different classes of trapped particles, including particles that travel over a fraction or many periods of the torus, which makes the calculation particularly hard. Each of these classes of particles contributes to the total ripple through \mathcal{E}_{j}(\lambda)\geq 0 , defined in Eq. ( 6a ), which for the field to be omnigeneous, must vanish for all trapped particles. The non-omnigeneous drive comes through H_{j} , an average between bounce points \ell_{j,R/L} of the off-surface magnetic drift, \mathbf{v}_{d}\cdot\nabla\psi , weighted by the parallel velocity \propto\sqrt{1-\lambda B} . The heat flux, \Gamma , depends quadratically on H_{j} . This dependence stems from having \Gamma\sim\delta\!f~\mathbf{v}_{d}\cdot\nabla\psi , where the perturbed particle distribution \delta\!f arises from a balance between the average drift and collisions. The competing mixing rate of collisions is related to the function I_{j} , which is formally similar to the second adiabatic invariant. Finally F(L) is a geometric normalisation factor that plays the role of normalising the off-surface projection of the drift. 4.1 Identification of the expansion Many of the complexities involved in evaluating \epsilon_{\mathrm{eff}} , Eq. ( 5 ), disappear when its asymptotic near-axis form is considered. To see this, let us start by introducing the asymptotic form of the magnetic field strength, which defines trapped particle classes and determines the radial drift. Concerned with the description of a magnetic field that is approximately QI, we can write B\approx B_{0}(\varphi)+rB_{1}(\chi,\varphi)+r^{2}B_{2}(\chi,\varphi) , where ( Rodriguez et al., 2024 ) \displaystyle B_{1} \displaystyle=-B_{0}(\varphi)d(\varphi)\sin\left[\alpha-\alpha_{\mathrm{buf}}(\varphi)\right], (8a) \displaystyle B_{2} \displaystyle=B_{20}(\varphi)+B_{2c}(\varphi)\cos 2\chi+B_{2s}(\varphi)\sin 2\chi. (8b) To zeroth order in r , B_{0}(\varphi) defines (by assumption) a single toroidal trapping well per field period. The higher order contributions in r=\sqrt{2\psi/\bar{B}} then deform this underlying well to make distinct ones for different field lines, labelled by \alpha=\theta-\iota\varphi . Asymptotically, they do not introduce additional wells. The particular form of B_{1} in Eq. ( 8a ) corresponds to that of an omnigeneous field (when taking d to be an odd function respect to B_{0} , and d=0 at the bottom and top of the trapping well), except where \alpha_{\mathrm{buf}}\neq 0 , i.e. the buffer regions. These are for the most part unavoidable near the edges of the toroidal domain ( Cary & Shasharina, 1997 ; Plunk et al., 2019 ; Rodríguez & Plunk, 2023 ) . The second order field contribution is for now chosen simply to satisfy stellarator symmetry, so B_{20} and B_{2c} are even, and B_{2s} odd. As a result of the trapping wells becoming labelled by \alpha , the infinite sum over trapping wells in the effective ripple, Eq. ( 5 ), becomes by Weyl’s lemma of equidistribution ( Weyl, 1916 ) ( Stein & Shakarchi, 2011 , Lemma 2.2) (assuming an irrational rotational transform), \sum_{j=1}^{N_{\mathrm{well}}}f_{j}\approx\frac{N_{\mathrm{well}}}{2\pi}\int_{0}^{2\pi}f(\alpha)\mathrm{d}\alpha, (9) where N_{\mathrm{well}} is the number of wells within a field line portion of length L . That is, the sum over wells simply corresponds to an average over \alpha . Changing variables from \ell to \varphi (with the appropriate Boozer Jacobian \mathcal{J}=(G+\iota I)/B^{2} ( D’haeseleer et al., 2012 , Eq. (6.6.8b)) ), and writing flux surface averages in terms of (\alpha,\varphi) , \epsilon_{\mathrm{eff}}^{3/2}=\frac{\pi}{8\sqrt{2}}\frac{(\bar{R}\bar{B})^{2}}{\mathcal{G}^{2}}\,\int_{1/B_{\mathrm{max}}}^{1/B_{\mathrm{min}}}\lambda\hat{\mathcal{E}}(\lambda)\,\mathrm{d}\lambda, (10) where \hat{\mathcal{E}}(\lambda)=\frac{1}{\pi}\int_{0}^{2\pi}\frac{\hat{H}(\lambda,\alpha)^{2}}{\hat{I}(\lambda,\alpha)}\,\mathrm{d}\alpha, (11) and all remaining definitions can be found explicitly at the beginning of Appendix B . The functions \hat{H} and \hat{I} (directly linked to the previous H_{j} and I_{j} of Nemov et al. (1999b) ), Eqs. ( 41a )-( 41b ), have been defined to be dimensionless, and \mathcal{G}^{2} (directly related to F ) has dimensions of [L]^{2} , which matches the presence of the normalising \bar{R} . In this form, the asymptotic expansion in powers of r can be carried out explicitly, and we do so in Appendix B . The details may be found there, and we emphasise the importance of carefully considering bounce integrals and 1/\sqrt{1-\lambda B} factors (as in Rodríguez & Mackenbach (2023) and Rodríguez et al. (2024) ). In the main text we summarise the resulting expressions in \epsilon_{\mathrm{eff}}^{3/2}\approx\epsilon_{\mathrm{eff}}^{3/2,(0)}+r^{2}\epsilon_{\mathrm{eff}}^{3/2,(2)}+O(r^{4}) , and focus on their significance. 4.2 Contribution from buffer regions: \epsilon_{\mathrm{eff}}^{3/2,(0)} The leading order contribution in the distance from the magnetic axis r to \epsilon_{\mathrm{eff}}^{3/2} is a constant offset that sets a lower bound to the effective ripple value in the limit of r\rightarrow 0 . The leading order asymptotic form can be written purely in terms of first (and 0th) order quantities (see the details in Appendix B ), \epsilon_{\mathrm{eff}}^{3/2,(0)}=\frac{\pi}{8\sqrt{2}}\frac{(\bar{R}\bar{B})^{2}}{(\mathcal{G}^{(1)})^{2}}\int_{1/B_{0}^{\mathrm{max}}}^{1/B_{0}^{\mathrm{min}}}\lambda\frac{(h^{(1)})^{2}}{I^{(0)}}\mathrm{d}\lambda, (12) where \displaystyle h^{(1)} \displaystyle=\int_{\varphi_{-}}^{\varphi_{+}}\frac{B_{0}}{\bar{B}}\mathcal{H}(\lambda,B_{0})d\sin\alpha_{\mathrm{buf}}\,\mathrm{d}\varphi, (13a) \displaystyle I^{(0)} \displaystyle=\int_{\varphi_{-}}^{\varphi_{+}}\frac{\sqrt{1-\lambda B_{0}}}{(B_{0}/\bar{B})^{2}}\mathrm{d}\varphi, (13b) \displaystyle(\mathcal{G}^{(1)})^{2} \displaystyle=2\left(\frac{1}{2\pi}\int_{0}^{2\pi}\mathrm{d}\alpha\int_{0}^{2\pi/N}\mathrm{d}\varphi\frac{\Psi^{(1)}}{B_{0}}\right)^{2}\Bigg/\left(\int_{0}^{2\pi/N}\frac{\mathrm{d}\varphi}{B_{0}^{2}}\right) (13c) where \Psi^{(1)}=\left[(X_{1c}\sin\chi-X_{1s}\cos\chi)^{2}+(Y_{1c}\sin\chi-Y_{1s}\cos\chi)^{2}\right]^{1/2}. (14) The expression \epsilon_{\mathrm{eff}}^{3/2,(0)} , as can be seen by inspecting h^{(1)} , measures the impact that buffer regions have on omnigeneity. If such buffers where not present (which may only happen if the rotational transform matches the helicity of the axis, \iota_{0}=M ( Plunk et al., 2019 ; Camacho Mata & Plunk, 2023 ; Rodriguez et al., 2024 ) ), then \alpha_{\mathrm{buf}}=0 and h^{(1)}=0 , implying \epsilon_{\mathrm{eff}}\rightarrow 0 as r\rightarrow 0 . In general, though, they will make a finite contribution, and the expression above allows us to gauge its magnitude. It is a measure of the level of non-omnigeneity of the first order construction. Only if this is sufficiently small is it reasonable to proceed to the next order in the expansion (2nd order) to evaluate the omnigeneity at that order ( Rodríguez & Plunk, 2023 ; Rodriguez et al., 2024 ) . The expression for h^{(1)} , Eq. ( 13a ), is then a local measure: trapped particles that do not venture into buffer regions near the trapping well tops, such as deeply trapped ones, will not contribute by any amount. And thus, the smaller the buffer, the smaller the fraction of particles contributing. Those trapped particles that do, contribute to h^{(1)} only through their radial magnetic drift (proportional to d ) in the buffer region. By construction, and to abide by the condition of pseudosymmetry that avoids losses at turning points of the magnetic field, d=0 is chosen to vanish at both the bottom and the top of the trapping well. Hence, we expect d\approx 0 near the trapping well tops and thus in the buffer regions, automatically limiting the magnitude of the effective ripple. To make this somewhat more quantitative, consider the buffer to have a toroidal extent \delta about the well top. For a magnetic axis with a curvature \kappa that has a zero of order v (fixing the form of d=\bar{d}\kappa ( Plunk et al., 2019 ; Rodríguez & Plunk, 2023 ) ), and a field B_{0} with a first derivative of order u-1 , following Eq. ( 13a ), we expect a scaling h^{(1)}\propto\delta^{u/2}\times\delta^{v}\times\delta\sim\delta^{u/2+v+1} . The first factor comes from the slowing down of the particle speed near the tops; the second, from the low radial drift linked to d itself; and the latter the size of the buffer domain. The natural impulse to take \delta\rightarrow 0 has, though, dire consequences on the shaping of the resulting field ( Plunk et al., 2019 ; Camacho Mata et al., 2022 ) . One could alternatively increase the order of the power of \delta , for instance, by making the top of the trapping well flatter. Without the need to resort to any of these, the behaviour of I^{(0)} helps reduce the buffer contribution even further. This second-adiabatic-invariant-like factor is largest for barely trapped particles, reducing the contribution of the buffer to the effective ripple. This physically corresponds to these particles being more strongly diffused by collisions in \lambda space, to a large extent because they travel for a longer time, and thus their drift contribution being offset to some degree. All in all, the contribution of the buffer tends to be small (see Figure 2 ), setting a negligible lower bound on \epsilon_{\mathrm{eff}} in the limit of r\rightarrow 0 . 4.3 Omnigeneity to second order: \epsilon_{\mathrm{eff}}^{3/2,(2)} Given the rather benign contribution to the effective ripple from 1st order, it is important to assess the next order contribtion to \epsilon_{\mathrm{eff}} . The evaluation of the order r^{2} correction to the effective ripple is presented in detail in Appendix B . The calculation is significantly more involved than 1st order, requiring the next two order corrections of many terms and even involving 3rd order quantities formally. Many of those terms do not, in practice, contribute significantly, and it is a great convenience to retain only 2nd order contributions. 5 5 5 One could carry out an analysis similar to that in Section 3 , to find the third order components corresponding to the finite build of a second-order finite aspect ratio equilibrium construction, but we shall not do that here. For this reason, we write a reduced, simplified form of these contributions (see the Appendix B for a more detailed account of this) that focuses on the next order contribution to H , \epsilon_{\mathrm{eff}}^{3/2,(2)}=\frac{\pi}{8\sqrt{2}}\frac{(\bar{R}\bar{B})^{2}}{(\mathcal{G}^{(1)})^{2}}\int_{1/B_{0}^{\mathrm{max}}}^{1/B_{0}^{\mathrm{min}}}\lambda\frac{(h^{(2)})^{2}}{I^{(0)}}\mathrm{d}\lambda, (15) where \displaystyle h^{(2)} \displaystyle=-2\int_{\varphi_{-}}^{\varphi_{+}}\mathcal{H}(\lambda,B_{0})\frac{\Delta B_{2c}^{\mathrm{QI}}}{\bar{B}}\,\mathrm{d}\varphi, (16a) \displaystyle\Delta B_{2c}^{\mathrm{QI}} \displaystyle=B_{2c}^{\mathrm{QI}}-\frac{1}{4}\partial_{\varphi}\left(\frac{B_{0}^{2}d^{2}}{B_{0}^{\prime}}\cos 2\alpha_{\mathrm{buf}}\right), (16b) and B_{2c}^{\mathrm{QI}}=-(B_{2c}\cos 2\bar{\iota}\varphi+B_{2s}\sin 2\bar{\iota}\varphi) . The expression in Eq. ( 16b ) is equivalent to the omnigeneity condition at second order when it vanishes, as derived explicitly in ( Rodríguez & Plunk, 2023 , Eq. (32c)) . Thus, this approximation to the asymptotic O(r^{2}) behaviour of the effective ripple is driven by the 2nd order non-omnigeneous behaviour, and will generally dominate \epsilon_{\mathrm{eff}}^{3/2,(0)} at a finite aspect ratio. Unlike to leading order, in this case the non-omnigeneous contribution is spread over the entirety of the trapping well, wherever \Delta B_{2c}^{\mathrm{QI}}\neq 0 , a local measure of radial drift imbalance. An imbalance at some point \varphi will affect all trapped particles with \lambda<1/B_{0}(\varphi) that pass over this point. Although they feel such deviation from omnigeneity, this is not to say that they will necessarily behave in a non-omnigeneous fashion, as the bounce-integral in Eq. ( 16a ) can lead to partial cancellations of \Delta B_{2c}^{\mathrm{QI}} , which can have either sign. However, it remains true that if \Delta B_{2c}^{\mathrm{QI}}\neq 0 , then \epsilon_{\mathrm{eff}}^{3/2,(2)}\neq 0 . The above then describes the significance of the omnigeneity condition of Rodríguez & Plunk (2023) , which is a property of 2nd order fields. As such, different choices of 2nd order shaping (namely, triangularity and Shafranov shift) will affect the omnigeneous behaviour of the field, and their choice becomes key in constructing the stellarator field. This is not to say that the 1st order near-axis construction no longer is important, as it will remain to strongly affect the amount and form of 2nd order shaping needed to make a field more omnigeneous. A clear example of this is the radial drift involved in Eq. ( 16b ), which by increasing axis curvature (and thus d for a controlled elongation of flux surfaces) will generally require stronger shaping. One may ask how can the shape at 2nd order be chosen to omnigenise a field, and if it is an example of an optimisation problem. As shown in Rodriguez et al. (2024) , Eqs. (3.6)-(3.7), there is however a unique, closed form choice of shaping that exactly achieves \Delta B_{2c}^{\mathrm{QI}}=0 . This excludes, though, the neighborhoods (in \varphi ) of flattening points of the magnetic axis, where the shaping necessary to achieve this ideal omnigeneous behaviour would diverge unless the first order construction was specially chosen. Excluding regions around flattening points (see further discussion below), and applying this choice of shaping, we say we have “omnigenised” the construction. 4.4 Numerical implementation and benchmark Let us first benchmark of the near-axis estimate of the effective ripple above. To that end, we take an extended set of second-order near-axis equilibria previously used in Rodriguez et al. (2024) , described in Appendix A , and their associated global equilibria at a number of different aspect ratios. We then compare the near-axis estimate of \epsilon_{\mathrm{eff}} (as a function of r ) implemented in the pyQIC framework 6 6 6 The implementation makes use of the newer version of the BAD code for bounce averaging. , to the effective ripple computed by the neoclassical code NEO of the finite aspect ratio equilibria. The comparison is presented in Figure 2 as a function of aspect ratio A=R/r . Figure 2: Benchmark of effective ripple calculation. The plots show, in log scale, a comparison of the effective ripple as calculated using the code NEO on global equilibria (scatter points) and calculated with the near-axis estimate (solid lines), for a number of different benchmark configurations (see Appendix A ). The two detail plots on the right show the individual comparison for two of the cases, including the 0th order ripple offset \epsilon_{\mathrm{eff}}^{(0)} as reference (dotted line). The ripple is normalised to a reference \bar{B}=1~ T and \bar{R}=1~ m. The agreement between the predicted near-axis \epsilon_{\mathrm{eff}} and the finite volume equilibria calculation, although not exact, is excellent over quite a large range of A . The buffer region contribution in all cases sets a rather benign lower bound to the value of \epsilon_{\mathrm{eff}} at large aspect ratios, and seems to be in agreement with the global calculation. This shows the critical role played by the second order in the expansion, which controls the dominant O(r^{4/3}) behaviour. At lower aspect ratios, A\lesssim 10 , the departures grow, as the deformation of the field increases and departs from its asymptotic description (see Figure 3 ). The latter is unable to capture local ripples 7 7 7 We do not consider the presence of \theta -independent sub-wells ( Parra et al., 2015 ) , and assume that any ripple will be localised in \theta , and thus will be non-omnigeneous. and the appearance of new trapped particle classes (as in Figure 3 b), nor misalignment of maxima (as in Figure 3 c) with the associated abrupt modification of trapped particle behaviour. These effects become increasingly prominent at lower aspect ratios, and thus additional deviations between the near-axis and global calculation are to be expected. Figure 3: Diagram with different contributions to \epsilon_{\mathrm{eff}} . a) Deformation of |\mathbf{B}| within the principal well violating the equal radial drift condition of omnigeneity (depicted by broken line). b) Appearance of local ripple or secondary wells. c) Misalignment of field maxima, leading to multiple-well trapped particles. 4.5 Measures of omnigeneity With the benchmark in place, we now introduce different measures based on the effective ripple to assess near-axis fields. We propose measures to characterise the effective ripple of 2nd order constructions, 1st order constructions, and the shaping involved when the latter are omnigenised at second order. We start with the fundamental form of the effective ripple, (a) Effective ripple from buffer regions , \epsilon_{\mathrm{eff}}^{3/2,(0)} : Leading order contribution to the effective ripple from the buffer regions, see Eq. ( 12 ). Its calculation requires information of 1st order, and the evaluation of bounce integrals between bounce points defined by B_{0}(\varphi) . (b) Second order effective ripple , \epsilon_{\mathrm{eff}}^{3/2,(2)} : Approximate, order O(r^{4/3}) contribution to the effective ripple due to omnigeneity breaking at 2nd order, see Eq. ( 15 ). It requires information of the 2nd order construction, and once again the evaluation of bounce integrals with bounce points defined by B_{0}(\varphi) . These combine into a single measure, (c) Effective ripple at the edge , \epsilon_{\mathrm{eff}}^{\mathrm{edge}} : Estimation of the effective ripple value at the flux surface corresponding to a reference aspect ratio of A_{\mathrm{ref}}=10 evaluated using the asymptotic expressions \epsilon_{\mathrm{eff}}^{\mathrm{edge}}=\left(\epsilon_{\mathrm{eff}}^{3/2,(0)}+r_{\mathrm{ref}}^{2}\epsilon_{\mathrm{eff}}^{3/2,(2)}\right)^{2/3}. (17) with r_{\mathrm{ref}}=R/A_{\mathrm{ref}} and R is the major radius calculated using the magnetic axis length, L , as R=L/2\pi . The \epsilon_{\mathrm{eff}}^{\mathrm{edge}} is a dimensionless measure that can be directly interpreted as one would the effective ripple of an optimised stellarator. This is a measure that diagnoses the effective ripple of a fully consistent 2nd order near-axis construction. However, as discussed previously in this section and in Rodriguez et al. (2024) , there are certain aspects of the field that are a result of lower order choices in the near-axis construction. Thus, we would like to have some way to assess this “intrinsic” behaviour. The simplest measure is (d) Non-omnigeneous mismatch at the well bottom 8 8 8 We could define an equivalent measure at the top of the well. However, the behaviour at the minimum is of greater importance as all trapped particles experience it. , \Delta B_{\mathrm{min}}^{\mathrm{QI}} : Define, \Delta B_{\mathrm{min}}^{\mathrm{QI}}=r_{\mathrm{ref}}^{2}\left.\frac{\Delta B_{2c}^{\mathrm{QI}}}{\bar{B}}\right|_{\mathrm{min}} (18) evaluated at the bottom of the trapping well. Here \bar{B} is the average value of B_{0} and r_{\mathrm{ref}} a reference radial value (which we compute for A_{\mathrm{ref}}=10 ). The measure provides a sense of omnigeneity breaking near the bottom of the trapping well normalised to the average field strength. It only requires 1st order quantities, following Eq. (3.8) in Rodriguez et al. (2024) . To translate this relative breaking of omnigeneity into the language of the effective ripple, we can evaluate \epsilon_{\mathrm{eff}}^{\mathrm{edge}} for a near-axis field constructed using the omnigeneising shaping at 2nd order. That is, the shaping that forces \Delta B_{2c}^{\mathrm{QI}}=0 for all \varphi , barring some masked region near the flattening points. The shaping needed to achieve this is given in Rodriguez et al. (2024) , Eqs. (3.6)-(3.7). The remaining ripple value is the result of the contribution from the straight sections, we denote (e) Effective ripple of omnigenised field , \epsilon_{\mathrm{eff}}^{\mathrm{shap}} Estimate of the effective ripple of an omnigenised near-axis field at r_{\mathrm{ref}} . It is defined as \epsilon_{\mathrm{eff}}^{\mathrm{edge}} for a field in which the 2nd order shaping has been chosen to enforce \Delta B_{2c}^{\mathrm{QI}}=0 everywhere except a 15% of the toroidal domain around the inflection points. This evaluation requires solving the 2nd order near-axis equations with the appropriate omnigeneising shaping, and computing the appropriate bounce integrals. To quantify how much shaping is required to construct this omnigenised field, we define (f) Average omnigenising shaping , \hat{T}^{\mathrm{shap}} : Averaged measure of the amount of shaping introduced at second order. We define \hat{T}^{2}=\frac{r_{\mathrm{ref}}^{2}}{2\pi}\int_{0}^{2\pi}\left(X_{20}^{2}+Y_{20}^{2}+Z_{20}^{2}+\frac{X_{2c}^{2}+X_{2s}^{2}+Y_{2c}^{2}+Y_{2s}^{2}+Z_{2c}^{2}+Z_{2s}^{2}}{2}\right)\,\mathrm{d}\varphi. (19) which we have non-dimensionalised with respect to the minor radius r_{\mathrm{ref}} , indicating the relative deformation of the elliptical cross-sections needed to omnigenise a field. We define \hat{T}^{\mathrm{shap}} as the shaping value of the omnigenised field at an aspect ratio A_{\mathrm{ref}}=10=R/r_{\mathrm{ref}} . Note that \hat{T}=\hat{T}[X_{2c},X_{2s}] may be considered a functional of the two free shaping functions at second order. The average measure \hat{T} quantifies second order shaping in absolute terms, but makes no reference to the first order shape that it modifies. To elucidate how shaped a configuration is, it is important to consider the interaction with first order shaping at finite radius r . To capture this, we introduce the critical radius r_{c} (or its reciprocal, the critical aspect ratio A_{c}\sim R/r_{c} ) defined in Landreman (2021) . This measure captures the complexity of flux surfaces by reflecting the maximal radial extent at which flux surfaces continue to exist without any unphysical intersection, i.e. before the Jacobian of the coordinate system vanishes. That way, low A_{c} indicates that the second order shaping is compatible with lower first order shaping for relatively compact fields. (g) Minimal aspect ratio of omnigenised field , A_{c}^{\mathrm{shap}} : Minimum value of the aspect ratio A for which the near-axis construction of the omnigenised field does not present locally self-intersecting flux surfaces. This is based on the definition of Landreman (2021) , A_{c}=R/\mathrm{min}\left[r~|~\exists~\theta,\varphi:\mathcal{J}(r,\theta,\varphi)=0\right], (20) where \mathcal{J} is the Jacobian of the \{r,\theta,\varphi\} coordinate system. We gather the above measures evaluated on the configurations in the benchmark in Table 1 . The first figure to look at is the effective ripple at the edge, which provides a single measure to contextualise these near-axis constructions amongst the space of optimised stellarators. Configurations with values below a percent are often regarded adequate with regards to neoclassical behaviour. It is clear that the second order ( O(r^{4/3}) ) contribution dominates the behaviour of \epsilon_{\mathrm{eff}} . To understand how much of the behaviour comes from the particular choice at 2nd order and how much is intrinsic to the lower orders, we then look at the properties of the omnigenised field. Configs 4.1 4.2 4.3 4.4 (unopt) 4.4 (opt) # 50 # 76 \epsilon_{\mathrm{eff}}^{3/2,(0)}\times 10^{5} 0.01 1.75 0.63 0.16 0.08 0.33 0.52 \epsilon_{\mathrm{eff}}^{3/2,(2)} [m -2 ] 0.290 3.079 0.643 0.790 0.313 3.829 0.263 \epsilon_{\mathrm{eff}}^{\mathrm{edge}}[\%] 2.46 13.5 3.46 5.47 3.10 11.4 1.91 \epsilon_{\mathrm{eff}}^{\mathrm{shap}}[\%] 2.41 3.20 4.12 2.67 0.059 7.74 0.063 \Delta B_{\mathrm{min}}^{\mathrm{QI}} [%] 5.78 0.94 2.53 0.94 0.08 4.17 0.21 A_{c} 2.09 5.84 2.38 4.46 4.93 3.00 1.59 A_{c}^{\mathrm{shap}} 19.8 22.0 10.9 24.0 19.0 11.2 12.6 \hat{T}^{\mathrm{shap}} 2.27 0.78 0.30 0.75 0.79 0.24 0.30 Table 1: Shaping configurations for effective ripple. The table shows information regarding the omnigeneous nature of the near-axis constructions in the benchmark. The table is separated into to main parts. (Top) rows show the measures of omnigeneity, in particular the effective ripple for the original second order field in the benchmark (top), and the omnigenised form of the field (bottom). (Bottom) The lower rows present information regarding the shaping of the original field (top) and the omnigenised field. All the measures are defined in the main text. The lack of omnigeneity near the inflection points is manifest in \epsilon_{\mathrm{eff}}^{\mathrm{shap}} , which does not approach the baseline value \epsilon_{\mathrm{eff}}^{(0)} for any of the configurations. This is also indicated by the non-zero values of \Delta B_{\mathrm{min}}^{\mathrm{QI}} . However, the optimised version of config. 4.4 (by construction) and #76, both show reduced ripple. What might appear most surprising, though, is that not all omnigenised configurations exhibit smaller ripple than their original forms, that is \epsilon_{\mathrm{eff}}^{\mathrm{shap}}>\epsilon_{\mathrm{eff}}^{\mathrm{edge}} in some cases. This is a result of a strong non-omnigeneous drive near the bottom of the well, which in the original configuration partially cancelled the \Delta B_{2c}^{\mathrm{QI}} away from it. Figure 4: Evolution of effective ripple with omnigeneising second order shaping. The plots show the evolution of the half helicity benchmark configuration #76 with changing 2nd order shaping. (Left) Evolution of \epsilon_{\mathrm{eff}}^{\mathrm{edge}} (solid) and A_{c} (broken) as a function of shaping. A value of 0 for the scaled shape corresponds to the original 2nd order benchmark configuration, while a value of 1 indicates the omnigenised construction. The shaping is scaled linearly in between. (Right) Examples of cross-section in cylindrical coordinates at three values of shaping, indicated as vertical lines on the left plot. Figure 4 shows in more detail what the act of omnigeneising is, presenting the case of configuration # 76. We choose this case because it has an intrinsic near-omnigeneous behaviour (small \Delta B_{\mathrm{min}}^{\mathrm{QI}} ) at the bottom of its trapping well, and thus illustrates nicely the omnigeneising effect of shaping. We observe that moderate variations in the cross-sections lead to significant changes on the ripple. The plot on the left shows how by gradually increasing the shaping to its perfect omnigeneising value (0 meaning unshaped, and 1 the completely shaped case) reduces the ripple, while the changes in the surfaces lead to a significant increase in A_{c} . This reflects a general tendency observed with near-axis QI constructions: 2nd order shaping to improve omnigeneity is often costly in terms of shaping. Freedom at first order must also be used to effectively construct omnigeneous fields. 5 Appearance of secondary trapping wells: A_{w} In the previous section we focused on assessing omnigeneity in terms of the asymptotic behavior of \epsilon_{\mathrm{eff}} . However, we noted that this did not account for the appearance of small localised secondary wells, which we now consider (see Figure 3 b). The formation of these defects is linked to increased neoclassical transport ( Ho & Kulsrud, 1987 ) and particle losses ( Mynick, 1983 ; Paul et al., 2022 ) . It is simple to picture a newly formed class of ripple trapped particles, which live on those local ripples and thus experience whichever the local non-zero radial drift is. The deeper the well, the more trapped particles, and the further from bottom and top along the trapping well, the stronger the local drift. Having a sense of the presence of such ripples is then important. 5.1 Construction of a ripple well measure, A_{w} How do these secondary wells appear in the approximately QI near-axis scenario? By construction choice, in the limit of an infinite aspect ratio equilibrium ( r\rightarrow 0 ) there is a single well defined by B_{0} , and thus no trace of any secondary wells. The ripple well question is then a finite aspect ratio one, which will require evaluating the asymptotic description at a finite A . We define A_{w} as the largest aspect ratio A for which a ripple well first appears along a magnetic field line within our asymptotic near-axis field model. Trapping wells are identified seeking points at which \partial_{\varphi}|_{\alpha}B=0 (i.e., partial toroidal derivative keeping the field line label constant, namely \partial_{\varphi}|_{\alpha}B=(\partial_{\varphi}+\iota\partial_{\theta})B ). To distinguish ripple wells from the main trapping well defined by B_{0}(\varphi) on axis, we shall picture the appearance of secondary wells as a ‘dynamic’ action in radius. As we look at surfaces of decreasing aspect ratio, ripples may start forming, but must do so by first forming inflection points, \partial_{\varphi}|_{\alpha}^{2}B=0 . We therefore define the ripple-well aspect ratio, A_{w}=R\big/\min\left\{r~|~\exists~\theta,\varphi:\partial_{\varphi}|_{\alpha}B(r,\theta,\varphi)=0,\partial_{\varphi}^{2}|_{\alpha}B(r,\theta,\varphi)=0\right\}. (21) In practice, finding A_{w} requires a procedure (detailed in Appendix C ) similar to the calculation of the critical radius r_{c} introduced above and originally in Landreman (2021) . Briefly put, the two conditions in the definition of Eq. ( 21 ) written in terms of B(r,\theta,\varphi)=\sum_{n=0}^{2}r^{n}B_{n}(\theta,\varphi) may be interpreted as simultaneous algebraic equations on r and \theta , which may be solved for every \varphi . The resulting multiple roots may be then written as a multi-valued function \hat{A}_{w}(\alpha) (eliminating \varphi ), of which the maximum is A_{w} . 5.2 Assessment and application Let us consider the behaviour of ripple wells in two of the example configurations in the benchmark (see Appendix A ) and plot in Figure 5 the multi-valued function 1/\hat{A}_{w} . For illustration purposes, we accompany these plots with the corresponding B contours. Figure 5: Ripple well diagnostic measure \hat{A}_{w} for configurations 4.1 and 4.3. The plots show (left) the function 1/\hat{A}_{w} as a function of \alpha , the field line label, for Configs. 4.1. (a) and 4.3 (b), the spaghetti diagrams . The hatched area represents \hat{A}_{w}>A_{w} , and the shaded regions the interval of \alpha that have a ripple well. The right plots show the |\mathbf{B}| contours corresponding to the r values indicated by the horizontal silver lines on the left plot. The solid black line in the contour plots shows the direction of a magnetic field line, the broken white line contours of \partial_{\varphi}|_{\alpha}B=0 and the scatter the corresponding inflections captured by the spaghetti diagram. The plots of 1/\hat{A}_{w} , which we refer to as spaghetti diagrams (borrowing from the condensed matter lingo), are best interpreted bottom to top. In the interval 0<1/\hat{A}_{w}<1/A_{w} the field does not present any secondary well, even though it may present topological defects in the contours of |\mathbf{B}| , i.e. puddles ( Rodríguez & Plunk, 2023 ) . At \hat{A}_{w}=A_{w} , a band is reached; that is, an inflection point appears along a field line for the first time. By symmetry, these inflections occur in pairs. Pairs of bifurcating branches appear and separate with increasing 1/\hat{A}_{w} . The shaded areas these curves bound represent every field line (i.e., intervals of \alpha ) containing secondary wells. This area grows at lower aspect ratios, and additional bifurcations do appear. We must mention the unpaired bifurcations that appear near \alpha/\pi\approx 1 of the top plot, which appear to contravene the general behaviour presented above, as they do not bound field lines with ripples. In fact, field lines in between have extended trapping wells. At least, until these branches cross. With all this into account, at a finite A0 , it would require relaxing the stability of the field. The ‘problem’, though, is that there is no unique way of choosing the shaping to satisfy this constraint. We must then impose some regularising choice, which we take to be one that minimises shaping in the form of an integral over the sum of squares of all the second order shaping functions, as defined in Eq. ( 19 ). 11 11 11 This is a natural regularising choice, L^{2} norm, but others would also be possible (especially those that include penalties penalising large toroidal variations). Simpler forms could also be constructed only minimising the choice of input functions, which does however capture the notion of second order shaping less accurately. The problem of finding the minimal stabilising shaping can then be formulated as one of finding X_{2c} and X_{2s} that minimise the following constrained variational problem T^{2}[X_{2c},X_{2s}]=\hat{T}^{2}[X_{2c},X_{2s}]-\lambda~\mathcal{C}[X_{2c},X_{2s}], (29) where \lambda is a Lagrange multiplier. We denote the resulting shaping as X_{2c}^{\mathrm{mhd}} and X_{2s}^{\mathrm{mhd}} , for which explicit expressions may be found in Appendix F . These expressions involve the shape gradients computed above, as well as some additional matrix multiplications, and could in principle be studied analytically. The main power of the approach is however providing a prescription to construct marginally stable approximately QI near-axis fields given a choice of axis, magnetic field strength on axis and first order information. To assess such stabilised constructions, we introduce some simple measures. One of the simplest is, (b) Average second order shaping of stabilised field , \hat{T}^{\mathrm{mhd}} : The root mean square value of the consistent stabilised second order shaping, evaluated using Eq. ( 19 ) using the minimal, stabilising choice of shaping, \hat{T}^{\mathrm{mhd}}=\hat{T}[X_{2c}^{\mathrm{mhd}},X_{2s}^{\mathrm{mhd}}] . It is therefore a simple measure of the amount of shaping necessary to stabilise a field, normalised to some reference r_{\mathrm{ref}} . A more acccurate measure of the shaping that takes toroidal variation into consideration may also be introduced, (c) Critical aspect ratio of stabilised field , A_{c}^{\mathrm{mhd}} : The minimum aspect ratio for which the near-axis construction of the stabilised configuration is physical (non-intersecting flux-surfaces). That is A_{c} for the near-axis field evaluated with X_{2c}^{\mathrm{mhd}} and X_{2s}^{\mathrm{mhd}} . It is a dimensionless quantity. Finally, to get a sense of the sensitivity of the shaping and the magnetic well, we also define \Delta A_{c}/\Delta W , (c) Magnetic well sensitivity , \Delta W/\Delta A_{c} : Change in the magnetic well W with the change of shaping as measured by A_{c} around the marginally stable point. Here we define it by finite differencing as, \frac{\Delta W}{\Delta A_{c}}=\frac{W(V^{\prime\prime}=1~\text{T}^{-2}\text{m}^{-1})}{A_{c}(V^{\prime\prime}=1~\text{T}^{-2}\text{m}^{-1})-A_{c}(V^{\prime\prime}=0)}, (30) a dimensionless quantity. A larger value indicates increased sensitivity to shaping. We leave a more precise (perhaps analytic) form of this quantity to future work. 6.2 Numerical implementation and benchmark Figure 6: Stabilised configurations and sensitivity of vacuum magnetic well to shaping. (a)-(b) The plots show (left) the shaping input for stabilising the near-axis fields and (left) the resulting re-shaped cross-sections for the first three configurations of the benchmark. The black solid lines represent the re-shaped configuration, while the dotted one denotes the starting point. (c) Change in the magnetic well as a function of the shaping measure A_{c} , illustrating the sensitivity of the fields to shaping. Configs 4.1 4.2 4.3 4.4 (unopt) 4.4 (opt) # 50 # 76 B_{20,\mathrm{min}} [%] -2.15 0.80 -2.10 -1.37 -0.99 -5.27 -0.52 W [%] 5.78 5.56 4.52 9.12 8.52 6.64 4.12 |W_{\mathrm{mhd}}|\times 10^{-16} 1.53 1.39 2.10 1.78 2.97 5.00 0.48 A_{c} 2.09 5.84 2.38 4.46 4.93 3.00 1.59 A_{c}^{\mathrm{mhd}} 5.17 6.10 4.70 6.43 6.23 5.91 4.82 \hat{T}^{\mathrm{mhd}} 0.20 0.17 0.16 0.22 0.19 0.22 0.13 |\Delta W/\Delta A_{c}| [%] 1.30 8.48 1.25 2.43 3.29 1.37 1.20 Table 3: Magnetic well sensitivity of benchmark configurations. The table shows the values of the magnetic well and re-shaped fields for the benchmark configurations, the shape \hat{T} and r_{c}^{\mathrm{mhd}} second order shaping measures. We apply the above measures to the configurations that constitute the benchmark for the this paper. We compute the shape gradient for all such configurations, compute their stabilised versions and evaluate the scalar measures presented above. A summary of the relevant vacuum well related properties are gathered in Table 3 . We start by noting that all configurations in the benchmark are MHD unstable, which appears to be the overwhelming tendency with constructed QI fields, as is the case with the other classes of omnigeneous fields ( Landreman & Jorge, 2020 ; Landreman, 2022 ; Rodríguez et al., 2023 ) ). All examples encountered require some concerted shaping to push them towards MHD stability, which we illustrate in Figure 6 . The correctness of the approach is evidenced in the vanishing of the magnetic well machine precision for the reshaped configurations, W_{\mathrm{mhd}} , in Table 3 . Beyond the qualitative assessment of the shaping needed from the cross-sections, both the measure \hat{T} and A_{c}^{\mathrm{mhd}} quantitatively describe the amount of shaping, with the simpler form correlating with the latter. Whenever the re-shaped configuration has a small value for the critical radius, it means that significant shaping is present, and if there is a large difference from the original benchmark field construction, A_{c} in Table 3 , we can conclude that the magnetic well is quite insensitive to shaping. Such sensitivity is more precisely measured by \Delta W/\Delta A_{c} . Note its large value in the case of config. 4.2, Figure 6 b, where very minor changes in the shape if the cross-sections are enough to stabilise the field (see Figure 6 c). This configuration is also special in that B_{20,\mathrm{min}}>0 , as we may expect from the help of having a finite plasma beta in that case. The high sensitivity is a potentially problematic feature of the field, if small changes in its shaping can change the response significantly. Note however that this sensitivity does change with W (see Figure 6 c), so that a given configuration could perhaps be made less sensisitive if sufficiently stabilised. This merits further study. If one was interested in finding the most MHD stable configurations, these measures could be used as a target of optimisation, which could be helped by exploitation of ideas from Rodríguez et al. (2024) and Plunk et al. (2024) . Before moving on, we note that this notion of MHD stability is only a minimal one, but not necessarily sufficient to achieve true MHD stability . Behaviour such as localised ballooning modes will react differently to the field geometry. In addition, this stabilising reshaping necessarily causes other 2nd order behaviour to change, and the ensuing tradeoffs are an important venue of future work. 7 \beta sensitivity of Shafranov shift So far in this paper we have made little explicit reference to plasma pressure. As we change the plasma pressure, though, we expect the magnetic field to change, as the Lorentz forces should continuously balance pressure gradients. One of the most notable consequences is the change in the Shafranov shift, the relative rigid displacement of nested flux surfaces with respect to each other. To describe this shift, we must define a reference point, a ‘centre’, for each cross-section at different radii, and define the Shafranov shift to be the \psi -derivative of the position of that mid-point. In the context of the near-axis description, the Shafranov shift can be defined as ( Rodríguez, 2023 , Eqs. (3.5)) ( Landreman, 2021 ) , \boldsymbol{\Delta}=\begin{pmatrix}\Delta_{x}\\ \Delta_{y}\end{pmatrix}=\begin{pmatrix}X_{20}+X_{2c}\\ Y_{20}+Y_{2c}\end{pmatrix}, (31) where the displacements are in the normal ( x ) or binormal ( y ) direction as defined by the signed Frenet-Serret frame of the magnetic axis. This expression matches the known definition in the tokamak limit, but one should bear in mind that there is no unique way in which to define the ‘centre’ of a non-elliptical cross-section. As the pressure gradient increases, so does the Shafranov shift, which results from the plasma pushing against the magnetic field (the poloidal field, and hence \iota , in a tokamak). Formally, as plasma pressure increases, so does B_{20} linearly, and with it the rigid displacement of surface X_{20} , eventually leading to two consecutive flux surfaces to touch (see Figure 9 ). This break-down limits the existence of the equilibrium, and thus it is important to gauge how sensitive a field is to changes in pressure. In the context of the near-axis expansion the sensitivity of a field to changes in the pressure is most readily formulated keeping the shape of the magnetic axis fixed. This is unlike the more physical scenario of fixing some given coil currents (and thus a vacuum field), and letting plasma pressure grow. The latter requires separation of the vacuum from the plasma field, and performing a double expansion, and we do not do that here. 7.1 Shafranov shift shape gradient, \mathcal{S} The variations problem is now one of \delta\!\boldsymbol{\Delta} , a change in the shift, with \delta\!p_{2} , a change in the pressure gradient. As a result of the change in the plasma pressure, from the definition in Eq. ( 31 ), \delta\!\boldsymbol{\Delta}=\underbrace{\begin{pmatrix}\delta\!X_{20}\\ \delta\!Y_{20}\end{pmatrix}}_{\text{Rigid shift}}+\underbrace{\begin{pmatrix}0\\ \delta\!Y_{2c}\end{pmatrix}}_{\text{Triangular shaping}}, (32) where we distinguish between the shift of the ‘cross-section’ due to a rigid displacement and due to triangular shaping. Although both contribute to the Shafranov shift, we shall here focus on the \theta -average, rigid shift, most useful when thinking of the problem in terms of shifted ellipses (see Figure 9 ). The variation required then simply involves the 2nd order equations in Appendix D , explicitly in Eq. ( 67 ). In this case, unlike for the magnetic well sensitivity, we need the variation respect to \delta\!p_{2} , a scalar, \hat{\mathbb{L}}\begin{pmatrix}\delta\!X_{20}\\ \delta\!Y_{20}\end{pmatrix}=\frac{\delta\!\boldsymbol{f}}{\delta\!p_{2}}\delta\!p_{2}, (33) the variation of \hat{\mathbb{L}} vanishing exactly. Solving this linear system we may define, \boldsymbol{\mathcal{S}}=\hat{\mathbb{L}}^{-1}\frac{\delta\!\boldsymbol{f}}{\delta\!p_{2}}, (34) which is a vector function of \varphi . This gradient holds for all 2nd order choices, as the equation is linear on p_{2} . That is, \boldsymbol{\mathcal{S}} is a property of the first order field. It is natural to introduce some normalisation for the gradient now. With [\Delta]=[L]^{-1} and [p_{2}]=[p][L]^{-2} , introducing the dimensionless plasma beta parameter \beta_{p,2}=\mu_{0}p_{2}/(\bar{B}^{2}/2) for some reference magnetic field and the reference r_{\mathrm{ref}}=R/A_{\mathrm{ref}} , we define \hat{\mathcal{\boldsymbol{S}}}=(\bar{B}^{2}/2\mu_{0}r_{\mathrm{ref}})\mathcal{\boldsymbol{S}} . We should therefore interpret this gradient as a fractional displacement of the surface at a reference aspect ratio A_{\mathrm{ref}} due to a change in plasma beta. We define (a) Maximum sensitivity of Shafranov shift , \hat{\mathcal{S}}_{\mathrm{max}} : Maximum relative value of the Shafranov shift gradient respect to changes of plasma \beta at a reference aspect ratio A_{\mathrm{ref}} , \hat{\mathcal{S}}_{\mathrm{max}}=\max_{\varphi}\left[\frac{\bar{B}^{2}}{2\mu_{0}r_{\mathrm{ref}}}|\mathcal{\boldsymbol{S}}|\right]. (35) It is illuminating to consider the familiar tokamak limit. Simplifying the system (see details in the Appendix D.3 ), and considering for simplicity an up-down symmetric configuration, \hat{\mathcal{S}}_{\mathrm{max}}=\frac{A_{\mathrm{ref}}}{\iota_{0}^{2}}\frac{\bar{d}^{4}}{\bar{d}^{4}-3}, (36) where all quantities have their usual meaning. The sensitivity grows with aspect ratio, as the same displacement becomes relatively larger compared to the minor radius. The scaling with \propto\iota_{0}^{-2} responds to the physical picture of the poloidal field balancing the pressure gradient. The stronger that poloidal component, the more resilient to the push of the pressure. The role of elongation is more involved, although it guarantees for vertically elongated configurations, \bar{d}<1 , \hat{\mathcal{S}}_{x}<0 . That is, the there will be bunching of surfaces in the outboard side. It also shows the artificial divergence discussed in the previous section. So far, the gradient measure defined in Eq. ( 35 ), \hat{S}_{\mathrm{max}} , provides a scalar measure of sensitivity without distinguishing direction. The significance of any given shift does however depend on the direction in which it occurs. It is not the same to rigidly shift nested ellipses in the direction of the minor axis or the major axis. For directions in which surfaces are closer to each other, the bunching of surfaces is easier, and so, potentially, is their intersection. We define an associated critical \beta as that value for which, due to the rigid Shafranov shift, the underlying first order ellipses just touch at a radius of r_{\mathrm{ref}} . This definition directly uses \hat{\boldsymbol{\mathcal{S}}} , as described in detail in Appendix G , and illustrated in Figure 9 . (b) Estimate of critical plasma \beta , \beta_{\Delta} : Estimate of the critical plasma \beta_{p} at which, due to the rigid part of the Shafranov shift, the first order near-axis elliptical flux surfaces of an equilibrium just touch at r=r_{\mathrm{ref}} . The value of the plasma beta is defined as a dimensionless scalar \beta_{\Delta} , for which a full definition is provided in Eqn. 92dc . Large values of \beta_{\Delta} indicate resilience of the Shafranov shift to changes in plasma \beta . The metric \beta_{\Delta} condenses the information of the gradient {\bf\mathcal{S}} into a single physically meaningful measure. However, it does so under certain simplifying assumptions. In particular, when it comes to describing when flux surfaces touch each other, it ignores the triangular shaping of flux surfaces, approximating them as ellipses. Thus \beta_{\Delta} is only an estimate of the true critical plasma \beta , which we may compute numerically. (c) Numerical critical plasma \beta , \beta_{c} : Critical value of \beta_{p}=r_{\mathrm{ref}}^{2}\beta_{p,2} , for an assumed aspect ratio A_{\mathrm{ref}} , at which the flux surfaces of the near-axis construction just touch. That is, for \beta_{p}=\beta_{c} we have A_{c}=A_{\mathrm{ref}} . In other words, fixing \beta_{p}=\beta_{c} the near-axis construction will not succeed for aspect ratios below A_{\mathrm{ref}} . The value of \beta_{c} may be found by a root search (and thus is more numerically costly) and includes all elements of shaping up to (and including) 2nd order. We emphasise that this quantity, although defined in exact terms, may still not be the most realistic \beta limit, because it is calculated taken the axis fixed, allowing flux surfaces to move around it as the plasma beta is changed. 7.2 Implementation and examples We assess the Shafranov shift sensitivity in the configurations of the benchmark. Figure 7 shows the shape gradient of the Shafranov shift for two different examples, and Table 4 summarises scalar features of the configurations. 12 12 12 The gradient calculation can be shown by finite differencing to be correct to machine precision. Configs 4.1 4.2 4.3 4.4 (unopt) 4.4 (opt) # 50 # 76 \hat{\mathcal{S}}_{\mathrm{max}} 17.82 2.52 4.30 7.02 6.02 2.40 3.31 \beta_{\Delta} [%] 3.98 24.30 20.20 11.57 16.15 47.61 22.51 \beta_{c} [%] 8.30 15.29 23.66 14.13 19.31 48.65 22.47 |\iota_{0}| 0.110 1.230 0.768 0.385 0.359 0.943 0.918 Table 4: Shafranov shift sensitivity to plasma pressure. The table shows the values of the maximum sensitivity of the Shafranov shift, the estimate and umerical critical \beta as well as the reference rotational transform on axis. The half-helicity fields appear to be the most resilient in the benchmark set. The comparison of \beta_{c} to \beta_{\Delta} show that although \beta_{c} includes some key elements of the full phenomena, it can deviate significantly. Figure 7: Shafranov shift sensitivity to plasma \beta . The plots show the shape gradient \hat{\mathcal{S}}_{x} and \hat{\mathcal{S}}_{y} for configurations 4.1 (a) and 4.3 (b) in the benchmark set. The sensitivity \mathcal{S}_{\mathrm{max}} shows that there exists a wide range of sensitivities to changes in plasma \beta . The gradient as a function of \varphi delves deeper into these differences showing the stark difference in the binormal shift of the surfaces (which the half helicity field 4.3 appears to avoid to a large extent). The gradients also vanish at certain points in \varphi , corresponding to the directions that would break the up-down symmetry of the cross-sections at stellarator symmetric points. From this benchmark, the lowest number of field period configuration (config. 4.1) is the most sensitive, which also has the lowest value of rotational transform. This is true of \beta_{\Delta} as well, showing that half-helicity configurations (namely configs. 4.3, #50 and #76) consistently exhibit a larger beta limits. The tools introduced here make it possible, in principle, to explore the generality of such observations, but an in depth analysis is left for future work. 8 Conclusions Recent works have demonstrated that it is possible to find approximately quasi-isodynamic stellarator equilibria to second order using near axis theory, and faithfully reproduce their properties in global equilibria at finite aspect ratio. Such “directly constructed” stellarator equilibria can in principle be used as the basis for further integrated optimization to develop new stellarator designs. However, to make the near-axis construction really practically useful, both for developing fundamental understanding, and as a tool for stellarator optimization, it is critical to develop techniques to navigate the space of second order solutions. The present work tackles this task by defining a set of measures designed to assess the key properties that a quasi-isodynamic stellarator strives for, including low neoclassical transport, quality of omnigeneity, and robust stability. Other measures already implemented (although not mentioned in the text) include the coil complexity proxy L_{\nabla B} ( Landreman, 2021 ; Kappel et al., 2024 ) , the effective Rosenbluth-Hinton residual ( Rosenbluth & Hinton, 1998 ; Rodriguez & Plunk, 2024 ; Zhu et al., 2025 ) and proxies to evaluate the maximum- J property ( Rodríguez et al., 2024 ) . Virtually any other measure that depends on magnetic geometry, for instance MHD ballooning stability or micro-turbulence, can be readily implemented as well in the future. The procedure for obtaining fields to second order involves fixing a set of free functions at zeroth, first, and second order. Unsurprisingly, there is a certain interaction between these choices, and the metrics have been formulated in a manner to help assess these choices. We also propose constructive approaches to make these choices, e.g. a way to obtain a minimally shaped, marginally stable (in the magnetic well sense) field or to construct an optimally “omnigenised” configuration given a 1st order construction. The toolset presented here, consisting of both absolute measures ( e.g. \epsilon_{\mathrm{eff}} on edge) and sensitivity measures (shape gradient of magnetic well) now opens the way to exploratory studies of the broad parameter space of QI stellarators, and systematic investigation of “trade-offs” – i.e. , the compatibility of desired stellarators properties, underlying reasons, and strategies for effectively striking compromises. Data availability The data and scripts that support the findings of this study are openly available at the Zenodo repository with DOI/URL 10.5281/zenodo.15340967. Declaration of interests The authors report no conflict of interest. Funding E. R. was partially supported by a grant by Alexander-von-Humboldt-Stiftung, Bonn, Germany, through a postdoctoral research fellowship. Appendix A Benchmark configuration summary Throughout the paper we use a number of near-axis fields as a way of benchmark or illustration of the various measures introduced. In this section we summarise what those configurations consist of, indicating their main features and referring to the right piece of literature where appropriate. A.1 QI database In Section 3 we use a large set of QI configurations as a way to benchmark the \delta\!B measure. This benchmark set had previously been used in work like Rodriguez & Plunk (2024) , and we now present some of its details. A full description of its construction and the theoretical elements that go into it will be the focus of future publication ( Plunk et al., 2025 ) . For a specific example, see Plunk et al. (2024) . The benchmark set consists of first order QI configurations of number of field periods ranging N=1 to 6 , constructed as a three-parameter family as follows. The first parameter is related to the shape of the magnetic axis, which is described by its curvature, \kappa , and torsion, \tau . For technical reasons, these must be defined differently for the case N=1 , as compared to N\geq 2 . For the former we define \displaystyle\kappa=\cos^{2}\left(\frac{N\ell}{2}\right)\sin\left(\frac{N\ell}{2}\right)\left(\kappa_{1}\sin(N\ell)+\kappa_{2}\sin(2N\ell)\right), (37) \displaystyle\tau=\tau_{0}+\tau_{1}\cos(N\ell)+\tau_{2}\cos(2N\ell), (38) while in the latter case ( N\geq 2 ) we set \kappa_{2}=0 and \tau_{2}=0 . This difference is because four degrees of freedom are here used to close the curve smoothly for the case N=1 , while only two degrees of freedom are required for N\geq 2 . Thus, a single parameter remains to define a one-parameter family of curves. The variable \ell is the length along the curve. This describes a stellarator symmetric axis with zeroes of second order at the tops and third order at the bottom. This is consistent with a curve of half-helicity ( Rodriguez et al., 2024 ; Camacho Mata & Plunk, 2023 ) . The total length of the axis is taken to be L=2\pi . The magnetic field on axis B_{0} is chosen to match the zeroes of \kappa , B_{0}=1+0.25\cos(N\ell)+0.0625\cos(2N\ell), (39) and to have a mirror ratio of \sim 24\% . 13 13 13 Here mirror ratio is defined as \Delta_{\mathrm{mirr}}=(B_{0,\mathrm{max}}-B_{0,\mathrm{min}})/(B_{0,\mathrm{max}}+B_{0,\mathrm{min}}) , which is the most used form. The breaking of omnigeneity necessary at first order is done through a smooth buffer region as described in ( Rodriguez et al., 2024 , Sec. B.2.3) , of order k=3 . The first order construction is finalised by the choice of the elongation-profile , \rho=\rho_{0}+\rho_{1}\cos(N\varphi), (40) which is directly related to the more common near-axis quantities of Landreman & Sengupta (2019) and Rodriguez et al. (2024) by \rho=\bar{e}+(1+\sigma^{2})/\bar{e} where \bar{e}=\bar{d}^{2}B_{0}/\bar{B} (which is intimately related to the true elongation of the flux surface) ( Plunk et al., 2024 ) . These two parameters \{\rho_{0},\rho_{1}\} , together with \tau_{1} are our three parameters that span the QI database set considered. Considering different values of these parameters, the QI database is constructed with a total of 1680 configurations distributed in \{63,502,358,244,250,263\} between number of field periods \{1,2,3,4,5,6\} . Further details on the procedure followed to construct such configurations will follow in a future paper. A.2 Benchmark configurations from Rodriguez et al. (2024) In the rest of the paper we use a reduced set of benchmark configurations, mainly based on those used and explored in ( Rodriguez et al., 2024 , Sec. 4) to test the correct near-axis construction to 2nd order. Here we briefly summarise the key properties of each of those configurations, • Configuration 4.1 : minimally shaped 2nd order stellarator symmetric, vacuum configuration with N=2 , a smooth buffer region with k=5 , mirror ratio 15\% , and first order zeroes of curvature (zero helicity axis). • Configuration 4.2 : shaped 2nd order stellarator symmetric, finite beta and current configuration with N=3 , a smooth buffer region with k=5 , mirror ratio 25\% , and first order zeroes of curvature (zero helicity axis). • Configuration 4.3 : minimally shaped 2nd order stellarator symmetric, vacuum configuration with N=3 , a smooth buffer region with k=5 , mirror ratio 25\% , and third order zero of curvature at the bottom, and two at the top (half-helicity axis). • Configuration 4.4 : minimally shaped 2nd order stellarator symmetric, vacuum configuration with N=3 , a smooth buffer region with k=5 , mirror ratio 25\% , and third order zero of curvature at the bottom, and first order zeroes of curvature (zero helicity axis). The first order choices were then optimised to minimise the second order QI error in the central 20\% of the toroidal domain. In this paper we include both the unoptimised and optimised versions. Figure 8 shows 3D renditions of these configurations for reference. Figure 8: 3D rendition of configurations in the benchmark set. 3D rendition of configurations in the benchmark set constructed for r=0.1 and with the colormap denoting the strength of the magnetic field |\mathbf{B}| . A.3 Additional half-helicity configurations In addition to the above, we also include two additional half-helicity fields constructed much in the same way as Config. 4.4, but corresponding to other constructions in the same parameter family, • Config. #50: \kappa_{1}=-7.451287 , \tau_{0}=1.379097 , \tau_{1}=-0.444444 , \rho_{0}=4.5 , \rho_{1}=-0.9 • Config. #76: \kappa_{1}=-8.938611 , \tau_{0}=1.284143 , \tau_{1}=-0.177778 , \rho_{0}=4.5 , \rho_{1}=-0.9 . The case of # 76 is particularly interesting, as it has a rather omnigeneous intrinsic second order behaviour. See Figure 8 for the configurations. Appendix B Details on the near-axis form of \epsilon_{\mathrm{eff}} In this Appendix we present the details in the asymptotic treatment of the effective ripple of a magnetic field with poloidal contours of |\mathbf{B}| within the near-axis framework. The expression we must evaluate asymptotically is the following, \epsilon_{\mathrm{eff}}^{3/2}=\frac{\pi}{8\sqrt{2}}\frac{(\bar{R}\bar{B})^{2}}{\mathcal{G}^{2}}\,\int_{1/B_{\mathrm{max}}}^{1/B_{\mathrm{min}}}\lambda\hat{\mathcal{E}}(\lambda)\,\mathrm{d}\lambda, ( 10 ) where, \displaystyle\hat{\mathcal{E}}(\lambda) \displaystyle=\frac{1}{\pi}\int_{0}^{2\pi}\frac{\hat{H}(\lambda,\alpha)^{2}}{\hat{I}(\lambda,\alpha)}\,\mathrm{d}\alpha, ( 11 ) \displaystyle\hat{H}(\lambda,\alpha) \displaystyle=\frac{1}{\bar{B}}\int_{\varphi_{-}}^{\varphi_{+}}\frac{\mathcal{H}(\lambda,B)}{B^{2}}\mathbf{B}\times\nabla B\cdot\nabla\psi\,\mathrm{d}\varphi, (41a) \displaystyle\hat{I}(\lambda,\alpha) \displaystyle=\int_{\varphi_{-}}^{\varphi_{+}}\frac{\sqrt{1-\lambda B}}{(B/\bar{B})^{2}}\mathrm{d}\varphi, (41b) \displaystyle\mathcal{G}^{2} \displaystyle=2\left(\frac{1}{2\pi}\int_{0}^{2\pi}\mathrm{d}\alpha\int_{0}^{2\pi/N}\mathrm{d}\varphi\frac{|\nabla\psi|}{B^{2}}\right)^{2}\Bigg/\left(\frac{1}{2\pi}\int_{0}^{2\pi}\mathrm{d}\alpha\int_{0}^{2\pi/N}\frac{\mathrm{d}\varphi}{B^{2}}\right), (41c) \mathcal{H}(\lambda,B)=\frac{\sqrt{1-\lambda B}}{(B/\bar{B})^{2}}\left(\frac{4}{\lambda B}-1\right). ( 7 ) where we have explicitly applied the considerations in Section 4.1 to write the expressions in the most near-axis friendly form. B.1 Expansion of \hat{H} For the expansion of \hat{H} , let us write using Boozer coordinates \mathbf{B}\times\nabla B\cdot\nabla\psi=\frac{B^{2}}{G+\iota I}(I\partial_{\varphi}-G\partial_{\theta})B, (42) which may be directly expanded, \displaystyle\frac{\mathbf{B}\times\nabla B\cdot\nabla\psi}{B^{2}}\approx\, \displaystyle rB_{0}d\cos(\alpha-\alpha_{\mathrm{buf}})+ (43) \displaystyle+r^{2}\left(B_{2s}^{\mathrm{QI}}\cos 2\alpha-B_{2c}^{\mathrm{QI}}\sin 2\alpha+\frac{I_{2}B_{0}^{\prime}}{G_{0}}\right)+O(r^{3}), (44) where the order O(r^{3}) term will include third order elements of the magnetic field magnitude, and thus we shall not include. With this expansion of the radial drift, and noting that \mathcal{H} vanishes at bounce points, the perturbation of \hat{H} is a combination of the asymptotic form of the drift and that of the integrand \mathcal{H} . At first order, we easily obtain \hat{H}\approx rh^{(1)}\sin\alpha , h^{(1)}=\int_{\varphi_{-}}^{\varphi_{+}}\frac{B_{0}}{\bar{B}}\mathcal{H}(\lambda,B_{0})d\sin\alpha_{\mathrm{buf}}\,\mathrm{d}\varphi, ( 13a ) where the odd part of the radial drift does not contribute, as its contributions from each side of the well precisely cancel out. At second order we must consider both the contributions from the modification in the drift, but also the measure \mathcal{H} . To avoid the explicit appearance of the singular integrand 1/\sqrt{1-\lambda B_{0}} , we integrate the resulting expression by parts (the boundary term being guaranteed to vanish for a field without puddles ( Rodríguez & Plunk, 2023 ) ), and thus, after enforcing parity in \varphi and collecting terms, \hat{H} from both the perturbed \hat{H}\approx rh^{(1)}\sin\alpha+r^{2}h^{(2)}\sin 2\alpha , \displaystyle h^{(2)} \displaystyle=-2\int_{\varphi_{-}}^{\varphi_{+}}\mathcal{H}(\lambda,B_{0})\frac{\Delta B_{2c}^{\mathrm{QI}}}{\bar{B}}\,\mathrm{d}\varphi, ( 16a ) \displaystyle\Delta B_{2c}^{\mathrm{QI}} \displaystyle=B_{2c}^{\mathrm{QI}}-\frac{1}{4}\partial_{\varphi}\left(\frac{B_{0}^{2}d^{2}}{B_{0}^{\prime}}\cos 2\alpha_{\mathrm{buf}}\right). ( 16b ) B.2 Expansion of \hat{I} We may now proceed in a similar fashion with the asymptotic evaluation of \hat{I} . It is useful to note that \hat{I} is almost the expression for the second adiabatic invariant \mathcal{J}_{\parallel} for trapped particles labelled by \lambda . Fortunately, the asymptotic treatment of such expressions (especially at higher order), with the careful handling of the boundary contributions, has already been done elsewhere, and thus we simply need to get the appropriate expressions from Rodríguez et al. (2024) . The leading order asymptotic form is simple, \hat{I}\approx I^{(0)} , I^{(0)}=\int_{\varphi_{-}}^{\varphi_{+}}\frac{\sqrt{1-\lambda B_{0}}}{(B_{0}/\bar{B})^{2}}\mathrm{d}\varphi. ( 13b ) For the next orders, we can directly draw from Eq. (A14) in Rodríguez et al. (2024) , and thus write separating \hat{I}\approx I^{(0)}+rI^{(1)}\cos\alpha+r^{2}(\bar{I}^{(2)}+\tilde{I}^{(2)}\cos 2\alpha) , I^{(1)}=-2\int_{\varphi_{-}}^{\varphi_{+}}F^{\star}(\lambda,B_{0})d\sin\alpha_{\mathrm{buf}}\,\mathrm{d}\varphi, (46) and \displaystyle\bar{I}^{(2)}= \displaystyle-2\int_{\varphi_{-}}^{\varphi_{+}}\frac{F^{\star}(\lambda,B_{0})}{B_{0}}\left[B_{20}-\frac{1}{4}\partial_{\varphi}\left(\frac{B_{0}^{2}d^{2}}{B_{0}^{\prime}}\right)\right]\,\mathrm{d}\varphi, (47a) \displaystyle\tilde{I}^{(2)}= \displaystyle 2\int_{\varphi_{-}}^{\varphi_{+}}\frac{F^{\star}(\lambda,B_{0})}{B_{0}}\left[B_{2c}^{\mathrm{QI}}-\frac{1}{4}\partial_{\varphi}\left(\frac{B_{0}^{2}d^{2}}{B_{0}^{\prime}}\cos 2\alpha_{\mathrm{buf}}\right)\right]\,\mathrm{d}\varphi, (47b) where F^{\star}(\lambda,B_{0})=\frac{1}{\sqrt{1-\lambda B_{0}}}\frac{1-3\lambda B_{0}/4}{(B_{0}/\bar{B})^{2}}. (48) Note that all the \alpha dependence of \hat{I} vanishes in the QI limit, as it must given the similarity of \hat{I} with \mathcal{J}_{\parallel} ; the second adiabatic invariant is a flux function in an omnigeneous field ( Bernardin et al., 1986 ) . The first order correction is purely driven by the buffer region, while the second comes from the second order QI mismatch. In that omnigeneous limit, \bar{I}^{(2)} is the only higher order correction left to second order, and it represents the change in the field line length ( B_{20} ) but also in the velocity of the trapped particle along the bounce trajectory. B.3 Constructing \mathcal{E} Let us then consider now using the asymptotic definitions \hat{H}\approx rh^{(1)}\sin\alpha+r^{2}h^{(2)}\sin 2\alpha and \hat{I}\approx I^{(0)}+rI^{(1)}\cos\alpha+r^{2}(\bar{I}^{(2)}+\tilde{I}^{(2)}\cos 2\alpha) , \displaystyle\frac{1}{2\pi}\int_{0}^{2\pi}\frac{\hat{H}^{2}}{\hat{I}}\mathrm{d}\alpha\approx \displaystyle\frac{r^{2}}{2}\left[\frac{(h^{(1)})^{2}}{I^{(0)}}+\right. (49) \displaystyle r^{2}\Bigg(\frac{(h^{(2)})^{2}}{I^{(0)}}\underbrace{-\frac{h^{(2)}h^{(1)}}{I^{(0)}}\frac{I^{(1)}}{I^{(0)}}}_{\textcircled{1}}+\underbrace{\frac{(h^{(1)})^{2}}{I^{(0)}}\Bigg[\Bigg(\frac{I^{(1)}}{2I^{(0)}}\Bigg)^{2}-\frac{\bar{I}^{(2)}-\tilde{I}^{(2)}/2}{I^{(0)}}\Bigg]}_{\textcircled{2}}\Bigg)\Bigg]. (50) A careful consideration of this expansion will show that we have a priori unfairly omitted a contribution that is also of order r^{4} , and that comes from beating of h^{(1)} with what would be h^{(3)} , and in particular its \sin\alpha harmonic. That term involves higher order magnetic field components, notably B_{31}^{c} , and thus goes beyond the second order considerations here. Setting this third component aside, the term will also have components inherited from lower orders, which can be evaluated explicitly to assess their magnitude. In practice, these contributions appear to be small. All in all, we shall ignore such contribution. In fact, in practice, at order O(r^{4}) the main contribution comes from h^{(2)} ; namely, the breaking of omnigeneity at second order. Thus, in practice, and as explicitly presented in the text, we will focus on this term. B.4 Expansion of geometric factor \mathcal{G} Let us write the geometric factor \mathcal{G}^{2}=2D^{2}/L and consider the asymptotic expansion of the integrals. Following ( Jorge & Landreman, 2020 , Eq. (33)) and carrying it out to higher order, we write \displaystyle D=\frac{1}{2\pi}\int\mathrm{d}\alpha\int\frac{\mathrm{d}\varphi}{B^{2}}|\nabla\psi|\approx \displaystyle\,r\overbrace{\frac{1}{2\pi}\int\mathrm{d}\alpha\int\frac{\mathrm{d}\varphi}{B_{0}}T_{1}}^{D_{1}}+r^{2}\overbrace{\frac{1}{2\pi}\int\mathrm{d}\alpha\int\frac{\mathrm{d}\varphi}{B_{0}}T_{1}\left(\frac{T_{2}}{T_{1}}-2\frac{B_{1}}{B_{0}}\right)}^{D_{2}}+ \displaystyle+r^{3}\underbrace{\frac{1}{2\pi}\int\mathrm{d}\alpha\int\frac{\mathrm{d}\varphi}{B_{0}^{2}}T_{1}\left(\frac{T_{3}}{T_{1}}-2\frac{B_{1}T_{2}}{B_{0}T_{1}}+3\left(\frac{B_{1}}{B_{0}}\right)^{2}-2\frac{B_{2}}{B_{0}}\right)}_{D_{3}}, (51) where |\nabla\psi|/B_{0}\approx rT_{1}+r^{2}T_{2}+\dots , and we may explicitly write \displaystyle T_{1}= \displaystyle\sqrt{(\partial_{\chi}X_{1})^{2}+(\partial_{\chi}Y_{1})^{2}}, (52a) \displaystyle T_{2}= \displaystyle\frac{1}{T_{1}}\left[T_{1}^{2}\frac{B_{1}}{B_{0}}+\partial_{\chi}X_{1}\partial_{\chi}X_{2}+\partial_{\chi}Y_{1}\partial_{\chi}Y_{2}\right], (52b) and we omit the explicit form of T_{3} for brevity. Note that D_{2}\approx 0 as we have odd \alpha -harmonics that average to zero (even if there is a complicated \alpha dependence in T_{1} ). To evaluate the \alpha -average of the other quantities, we must explicitly write their poloidal angle dependence. For instance, T_{1} )in the text Eq. ( 14 )), ( Jorge & Landreman, 2020 , Eq. (33)) , |\nabla\psi|^{2}\approx r^{2}B_{0}^{2}\left[\left(X_{1c}\sin\chi-X_{1s}\cos\chi\right)^{2}+\left(Y_{1c}\sin\chi-Y_{1s}\cos\chi\right)^{2}\right]. (53) Because we have |\nabla\psi| instead of |\nabla\psi|^{2} the integral over \chi must be performed numerically (or related to elliptic integrals ( Gradshteyn & Ryzhik, 2014 , Eq. (3.670.1)) ). The expansion of L is simpler, and only the expansion in B is necessary. Considering the average over \alpha to eliminate the bare harmonics of \chi , we write, L=\frac{1}{2\pi}\int\mathrm{d}\alpha\int\frac{\mathrm{d}\varphi}{B^{2}}\approx\underbrace{\int\frac{\mathrm{d}\varphi}{B_{0}^{2}}}_{L_{0}}+r^{2}\underbrace{\frac{1}{2\pi}\int\mathrm{d}\alpha\int\frac{\mathrm{d}\varphi}{B_{0}^{2}}\left[3\left(\frac{B_{1}}{B_{0}}\right)^{2}-2\frac{B_{2}}{B_{0}}\right]}_{L_{2}}. (54) With both of these, \frac{1}{\mathcal{G}^{2}}\approx\frac{L_{0}}{G_{0}D_{1}^{2}}\bigg[1+r^{2}\underbrace{\bigg(\frac{L_{2}}{L_{0}}-\frac{G_{2}}{G_{0}}-2\frac{D_{3}}{D_{1}}\bigg)}_{\textcircled{3}}\bigg]. (55) In practice, it is the leading order piece that matters, and which we defined as \mathcal{G}^{(0)} in the main text. B.5 Assessment of approximation With the approximations and expansions considered above, we may then construct the leading order forms of \epsilon_{\mathrm{eff}}^{3/2} as presented in Section 4 . We had argued that some of the terms involved in the asymptotic expression of the effective ripple are, in practice, subsidiary, even though not in the O(r) sense. We now provide some numerical evidence in such regard using the benchmark configurations in the paper as test-bed. In Table 5 we summarise the relative magnitude of different contributions in an attempt to argue the correctness of the approximation to \epsilon_{\mathrm{eff}} . We show by \textcircled{1} , \textcircled{2} and \textcircled{3} the relative contribution by the terms denoted by these symbols in the asymptotic expansions above to \epsilon_{\mathrm{eff}}^{3/2,(2)} . The smallness of these terms gives us an argument to focus on the contribution by the second order QI breaking and use it as apart of our effective ripple measure. The benchmark in Figure 2 also seconds this. Configs 4.1 4.2 4.3 4.4 (unopt) 4.4 (opt) # 50 # 76 \textcircled{1} 9.99E-06 2.37E-04 -2.99E-04 4.80E-05 2.35E-05 -8.30E-05 2.31E-04 \textcircled{2} -1.72E-06 -2.69E-05 -5.76E-05 -1.66E-05 -1.83E-05 -7.11E-06 -9.91E-05 \textcircled{3} 6.26E-08 -1.85E-06 3.25E-06 -3.31E-07 -1.04E-06 1.98E-07 6.68E-06 Table 5: Relative magnitude of additional asymptotic terms in \epsilon_{\mathrm{eff}}^{3/2,(2)} . The table shows the relative contribution to \epsilon_{\mathrm{eff}}^{3/2,(2)} of the asymptotic terms \textcircled{1} , \textcircled{2} and \textcircled{3} . The smallness of these contributions throughout the benchmark configurations supports, along with the role of QI breaking, the expression for the effective ripple measure used. Appendix C Details of the ripple well measure A_{w} calculation In this appendix we develop the formalism necessary to efficiently evaluate the ripple well measure A_{w} presented in the main text, Section 5 ; namely, A_{w}=R/\min\left\{r~|~\exists~\theta,\varphi:\partial_{\varphi}|_{\alpha}B(r,\theta,\varphi)=0,\partial_{\varphi}^{2}|_{\alpha}B(r,\theta,\varphi)=0\right\}. ( 21 ) The multi-valued form of A_{w} for each fixed \varphi was defined as \hat{A}_{w} , with A_{w}=\mathrm{max}_{\varphi}\hat{A}_{w} . C.1 First order construction: too simple Let us consider first, as a way of introduction, A_{w} for the simplest case of a first order field: B(\theta,\varphi)=B_{0}(\varphi)+rB_{1}(\theta,\varphi) , where B_{1}(\theta,\varphi) is given in Eq. ( 8a ). The two conditions in Eq. ( 21 ) to solve simultaneously are, \displaystyle B_{0}^{\prime}+r(S^{\prime}\cos\alpha-C^{\prime}\sin\alpha)=0, (56a) \displaystyle B_{0}^{\prime\prime}+r(S^{\prime\prime}\cos\alpha-C^{\prime\prime}\sin\alpha)=0, (56b) where S=B_{0}d\sin\alpha_{\mathrm{buf}} , C=B_{0}d\cos\alpha_{\mathrm{buf}} and primes denote derivatives in \varphi . Combining these equations and assuming r\neq 0 , one may solve for \tan\alpha and substitute it back to retain a real, positive root for r , R/\hat{A}^{(1)}_{w}=\left|\frac{B_{0}^{\prime}}{S^{\prime}-C^{\prime}\tan\alpha}\sqrt{1+\tan^{2}\alpha}\right|, (57) where \alpha is given by, \tan\alpha=\frac{(S^{\prime}/B_{0}^{\prime})^{\prime}}{(C^{\prime}/B_{0}^{\prime})^{\prime}}, (58) defined in the appropriate quadrant so that 1/\hat{A}_{w}^{(1)} solves the original set of equations. Note that in obtaining an expression for \tan\alpha we have assumed that the equation is not trivially satisfied by r=0 . This would have worked for B_{0}^{\prime}=0=B_{0}^{\prime\prime} , which now instead sees \hat{r}_{w}\rightarrow\infty . 14 14 14 To show this it is sufficient to consider the no-buffer limit of Eq. ( 57 ), which at the bottom of the well requires B_{0}^{\prime\prime}d^{\prime}=0 and r\sin\alpha=B_{0}^{\prime}/C^{\prime} , so that r_{w}=B_{0}^{\prime}/C^{\prime}=\frac{1}{d}+\frac{B_{0}^{\prime}}{B_{0}d^{\prime}} . Regardless of how one chooses the orders of B_{0} and d , this expression diverges as the bottom of the well is approached. This should make it clear that the appearence of secondary wells is not the same as the break-down of |\mathbf{B}| contour topology. In practice, the appearence of secondary wells due to the first order variation of the field is too simplistic. It is far from capturing the evolution of a second order near-axis field construction. We must therefore turn to the more complex higher order consideration. C.2 Higher order form The procedure at higher orders resembles the procedure followed in the construction of the critical radius r_{c} in Landreman (2021) . The latter corresponds to the smallest distance from the axis at which flux surfaces become ill-behaved; namely, the first instance of a vanishing coordinate Jacobian \mathcal{J}=\partial_{\psi}\mathbf{x}\times\partial_{\theta}\mathbf{x}\cdot\partial_{\varphi}\mathbf{x}=0 . That problem requires the solution of a set of equations formally analogous to those for A_{w} , see ( Landreman, 2021 , Sec. 4) . We exploit that analogy and adapt that work to our problem. Using the helical angle \chi=\theta-N\varphi where N is the helicity of the magnetic axis ( Rodríguez et al., 2022b ; Camacho Mata & Plunk, 2023 ; Rodriguez et al., 2024 ) , and writing B_{1}(\chi,\varphi)=B_{1c}(\varphi)\cos\chi+B_{1s}(\varphi)\sin\chi and B_{2}(\chi,\varphi)=B_{20}(\varphi)+B_{2c}(\varphi)\cos 2\chi+B_{2s}(\varphi)\sin 2\chi , the first condition that \hat{A}_{w} must satisfy is \partial_{\varphi}B|_{\alpha}=0 , which explicitly reads, g_{0}+r\left(g_{1c}\cos\chi+g_{1s}\sin\chi\right)+r^{2}\left(g_{20}+g_{2c}\cos 2\chi+g_{2s}\sin 2\chi\right)=0, (59) where \displaystyle g_{0} \displaystyle=B_{0}^{\prime}, (60a) \displaystyle g_{1c} \displaystyle=B_{1c}^{\prime}+\bar{\iota}B_{1s}, \displaystyle g_{1s} \displaystyle=B_{1s}^{\prime}-\bar{\iota}B_{1c}, (60b) \displaystyle g_{20} \displaystyle=B_{20}^{\prime}, \displaystyle g_{2c} \displaystyle=B_{2c}^{\prime}+2\bar{\iota}B_{2s}, \displaystyle g_{2s} \displaystyle=B_{2s}^{\prime}-2\bar{\iota}B_{2c}. (60c) The second condition, namely \partial_{\varphi}^{2}B|_{\alpha}=0 can also be found explicitly and written in a form analogous to Eq. ( 59 ). We shall not give it explicitly for brevity. Given these two equations, we approach their solution by isolating r for every \varphi and eliminating it from the equations, reducing the system to a single equation on harmonics of \chi . We shall call this the K-equation . Following this procedure, we may write r=\frac{f_{1c}\cos\chi+f_{1s}\sin\chi}{f_{20}+f_{2c}\cos 2\chi+f_{2s}\sin 2\chi}, (61) where \displaystyle f_{1c} \displaystyle=B_{0}^{\prime}(B_{1c}^{\prime\prime}+2\bar{\iota}_{0}B_{1s}^{\prime}-\bar{\iota}_{0}^{2}B_{1c})-B_{0}^{\prime\prime}(B_{1c}^{\prime}+\bar{\iota}_{0}B_{1s}), (62a) \displaystyle f_{1s} \displaystyle=B_{0}^{\prime}(B_{1s}^{\prime\prime}-2\bar{\iota}_{0}B_{1c}^{\prime}-\bar{\iota}_{0}^{2}B_{1s})+B_{0}^{\prime\prime}(-B_{1s}^{\prime}+\bar{\iota}_{0}B_{1c}), (62b) \displaystyle f_{20} \displaystyle=B_{0}^{\prime\prime}B_{20}^{\prime}-B_{0}^{\prime}B_{20}^{\prime\prime}, (62c) \displaystyle f_{2c} \displaystyle=-B_{0}^{\prime}(B_{2c}^{\prime\prime}+4\bar{\iota}_{0}B_{2s}^{\prime}-4\bar{\iota}_{0}^{2}B_{2c})+B_{0}^{\prime\prime}(B_{2c}^{\prime}+2\bar{\iota}_{0}B_{2s}), (62d) \displaystyle f_{2s} \displaystyle=B_{0}^{\prime}(-B_{2s}^{\prime\prime}+4\bar{\iota}_{0}B_{2c}^{\prime}+4\bar{\iota}_{0}^{2}B_{2s})+B_{0}^{\prime\prime}(B_{2s}^{\prime}-2\bar{\iota}_{0}B_{2c}). (62e) Eliminating r from Eq. ( 59 ), we are left with the following K-equation in the coordinates \chi and \varphi , K_{0}+K_{2c}\cos 2\chi+K_{2s}\sin 2\chi+K_{4s}\sin 4\chi+K_{4s}\sin 4\chi=0, (63) where K_{0}=\frac{1}{4}\left[2g_{0}(f_{2c}^{2}+2f_{20}^{2}+f_{2s}^{2})+f_{1c}(f_{2c}g_{1c}+f_{2s}g_{1s})+f_{1s}(f_{2s}g_{1c}-f_{2c}g_{1s})+\right.\\ \left.2f_{20}(f_{1c}g_{1c}+f_{1s}g_{1s})+2(f_{1c}^{2}+f_{1s}^{2})g_{20}+(f_{1c}^{2}-f_{1s}^{2})g_{2c}+2f_{1c}f_{1s}g_{2s}\right], (64a) K_{2c}=\frac{1}{2}\left[f_{1c}f_{2c}g_{1c}+f_{20}(4f_{2c}g_{0}+f_{1c}g_{1c}-f_{1s}g_{1s})+f_{1c}^{2}(g_{20}+g_{2c})+\right.\\ \left.f_{1s}(f_{2c}g_{1s}-f_{1s}g_{20}+f_{1s}g_{2c})\right] (64b) K_{2s}=\frac{1}{2}\left[f_{1c}f_{2s}g_{1c}+f_{1s}f_{2s}g_{1s}+f_{20}(4f_{2s}g_{0}+f_{1s}g_{1c}+f_{1c}g_{1s})+\right.\\ \left.2f_{1c}f_{1s}g_{20}+(f_{1c}^{2}+f_{1s}^{2})g_{2s}\right] (64c) K_{4c}=\frac{1}{4}\left[2(f_{2c}^{2}-f_{2s}^{2})g_{0}-f_{2s}(f_{1s}g_{1c}+f_{1c}g_{1s})+f_{2c}(f_{1c}g_{1c}-f_{1s}g_{1s})+\right.\\ \left.(f_{1c}^{2}-f_{1s}^{2})g_{2c}-2f_{1c}f_{1s}g_{2s}\right], (64d) K_{4s}=\frac{1}{4}\left[f_{2c}(4f_{2s}g_{0}+f_{1s}g_{1c}+f_{1c}g_{1s})+f_{1c}(f_{2s}g_{1c}+2f_{1s}g_{2c})+\right.\\ \left.(f_{1c}^{2}-f_{1s}^{2})g_{2s}-f_{1s}f_{2s}g_{1s}\right]. (64e) With the equation cast this way, we may then proceed the way that is detailed in ( Landreman, 2021 , Sec. 4.2) . That is, we solve the K -equation for \sin 2\chi which is a quartic, being careful about the sign of the trigonometric functions. As a result, we have up to four real roots for each value of \varphi considered in the toroidal domain. Each one of these roots corresponds to a value of r using Eq. ( 61 ), and thus represents a triplet (r,\chi,\varphi) . Finding \alpha=\chi-\bar{\iota}\varphi , we may then represent the values of r for these multitude of roots as a function of \alpha , namely \hat{A}_{w} . This is what we represent in Figures 5 in Section 5 . The largest of all these roots is A_{w} . Appendix D Linear system of equations at second order The construction of the near axis field at second order has been detailed elsewhere, most notably in Landreman & Sengupta (2019) , and in the QI scenario in Rodriguez et al. (2024) , where a thorough and pedagogical description is provided. Here we shall not reproduce the derivation of the construction, nor the way in which this is solved. However we shall for completeness write some of the key equations involved in the near-axis construction to 2nd order. In particular, the equations that the different pieces of the second order shaping satisfy, focusing on the operator notation that we use in this paper. D.1 Expressions for Y_{2} The harmonics of Y_{2} are defined through equations (A32)-(A33) of ( Landreman & Sengupta, 2019 ) as, \begin{pmatrix}Y_{2c}\\ Y_{2s}\end{pmatrix}=\underbrace{\begin{pmatrix}\mathcal{Y}_{2c}^{0}\\ \mathcal{Y}_{2s}^{0}\end{pmatrix}}_{\boldsymbol{\mathcal{Y}}_{0}}+\underbrace{\begin{pmatrix}\mathcal{Y}_{2c}^{X_{20}}&\mathcal{Y}_{2c}^{Y_{20}}\\ \mathcal{Y}_{2s}^{X_{20}}&\mathcal{Y}_{2s}^{Y_{20}}\end{pmatrix}}_{\bar{\mathsfbi{Y}}}\begin{pmatrix}X_{20}\\ Y_{20}\end{pmatrix}+\underbrace{\begin{pmatrix}\mathcal{Y}_{2c}^{X_{2c}}&\mathcal{Y}_{2c}^{X_{2s}}\\ \mathcal{Y}_{2s}^{X_{2c}}&\mathcal{Y}_{2s}^{X_{2s}}\end{pmatrix}}_{\hat{\mathsfbi{Y}}}\begin{pmatrix}X_{2c}\\ X_{2s}\end{pmatrix} (65) where the components of each matrix are This is a purely algebraic equation, which involves no derivatives. D.2 Equation for X_{20} and Y_{20} To complete the construction at second order, using X_{2c} and X_{2s} as inputs to the problem, we need to solve for X_{20} and Y_{20} . The equations to solve are (A41)-(A42) of Landreman & Sengupta (2019) , which constitute two coupled first order ODEs in \varphi to be solved simultaneously. Explicitly solving such a system requires rewriting all second order quantities explicitly in terms of X_{20},Y_{20},X_{2c},X_{2s} and their derivatives, which involves Eq. ( 65 ). Instead of writing all the components of these operators out explicitly, we show how one should systematically proceed to find these through one particular example. The fully fleshed components may be found in the numerical implementation of the near-axis construction presented in the repository published alongside this work. In its operator form, the full expression is \hat{\mathbb{L}}\begin{pmatrix}X_{20}\\ Y_{20}\end{pmatrix}=-\hat{\mathbb{F}}\begin{pmatrix}X_{2c}\\ X_{2s}\end{pmatrix}+\boldsymbol{f}, (67) and now we focus on constructing explicitly, say, \mathbb{L}_{00} . That is, the piece of the operator acting on X_{20} in Eq. (A41) of Landreman & Sengupta (2019) , not just explicitly, but also through other 2nd order functions. Here both \hat{\mathbb{L}} and \hat{\mathbb{F}} represent linear differential operators of first order that act on a vector of dimension 2, as shown. The vector \boldsymbol{f} represents combination of first order terms. Let us be more explicit, and consider the contributions one by one. First, the explicit X_{20}^{\prime} components, A_{X_{20}^{\prime}}=-X_{1s}\frac{\mathrm{d}}{\mathrm{d}\varphi}, (68a) and explicit in X_{20} , A_{X_{20}}=-Y_{1s}\left(\tau\ell^{\prime}-2\frac{I_{2}}{\bar{B}}\ell^{\prime}\right)-4Y_{1c}\frac{G_{0}}{\bar{B}}Z_{2c}-4Y_{1s}\frac{G_{0}}{\bar{B}}Z_{2s}. (68b) We must then also consider the pieces that depend on Y_{2c} and Y_{2s} , which we know are also related to X_{20} by Eq. ( 65 ). So we write again, \displaystyle A_{Y_{2c}}=4X_{1s}\frac{G_{0}}{\bar{B}}Z_{2s}-X_{1c}\left(4\frac{G_{0}}{\bar{B}}Z_{20}-2\beta_{0}\ell^{\prime}\right)+X_{1s}\left(\tau\ell^{\prime}-2\ell^{\prime}\frac{I_{2}}{\bar{B}}\right)-2Y_{1c}\bar{\iota}_{0} (68c) \displaystyle A_{Y_{2s}}=-4X_{1s}\frac{G_{0}}{\bar{B}}Z_{2c}-X_{1c}\left(\tau\ell^{\prime}-2\ell^{\prime}\frac{I_{2}}{\bar{B}}\right)-X_{1s}\left(4\frac{G_{0}}{\bar{B}}Z_{20}-2\beta_{0}\ell^{\prime}\right)-2Y_{1s}\bar{\iota}_{0}, (68d) and finally the terms that depend on the derivatives of these, \displaystyle A_{Y_{2c}^{\prime}}=-Y_{1s}\frac{\mathrm{d}}{\mathrm{d}\varphi}, (68e) \displaystyle A_{Y_{2s}^{\prime}}=Y_{1c}\frac{\mathrm{d}}{\mathrm{d}\varphi}. (68f) With these expressions, we may then write \hat{\mathbb{L}}_{00} explicitly, \hat{\mathbb{L}}_{00}=A_{X_{20}}+\mathcal{Y}_{2c}^{X_{20}}A_{Y_{2c}}+\mathcal{Y}_{2s}^{X_{20}}A_{Y_{2s}}-Y_{1s}(\mathcal{Y}_{2c}^{X_{20}})^{\prime}+Y_{1c}(\mathcal{Y}_{2s}^{X_{20}})^{\prime}-(X_{1s}+Y_{1s}\mathcal{Y}_{2c}^{X_{20}}-Y_{1c}\mathcal{Y}_{2s}^{X_{20}})\frac{\mathrm{d}}{\mathrm{d}\varphi}. (69) Following a similar procedure with the other components (which we spare the reader from) the remainder terms of \hat{\mathbb{L}} may be found, as well as those of \hat{\mathbb{F}} and \boldsymbol{f} . D.3 Tokamak limit simplification Even though the topology of |\mathbf{B}| contours over flux surfaces is different in tokamaks compared to QI configurations, the equilibrium construction remains largely the same. For the tokamak limit expressions evaluated in the main text it is then appropriate to consider the tokamak limit of the operators above. The toroidal coordinate \varphi being one of symmetry simplifies the evaluation of the expressions significantly, especially because the toroidal derivatives may be taken to vanish exactly. In the near-axis tokamak notation, we also have X_{1c}=\bar{d} and X_{1s}=0 , with Y_{1s}=1/\bar{d} , and defining the major radius R_{0}=G_{0}/B_{0} . Taking this into consideration, and going through the equations, the following is true in the tokamak limit. The operator \hat{\mathbb{L}} becomes, \hat{\mathbb{L}}_{\mathrm{tok}}=-\bar{\iota}_{0}\frac{B_{0}}{\bar{d}}\begin{pmatrix}\bar{d}^{2}-\frac{3}{\bar{d}^{2}}(1+\sigma^{2})&4\sigma\\ 0&2\end{pmatrix}, (70) which becomes diagonal in the case of an up-down symmetric tokamak (i.e. \sigma=0 ). Note here the possibility of a singular matrix if, in the up-down symmetric scenario, \bar{d}^{4}=3 . This singularity was discussed in the main text and is directly related to how the equilibrium problem is being solved. This is however seldom a problem given the typical values of elongation considered. For \hat{\mathbb{F}} , \hat{\mathbb{F}}_{\mathrm{tok}}=-\bar{\iota}_{0}\frac{3B_{0}}{\bar{d}^{3}}\begin{pmatrix}\bar{d}^{4}-1+\sigma^{2}&2\sigma\\ 2\sigma&-(\bar{d}^{4}-1+\sigma^{2})\end{pmatrix}, (71) which is a symmetric matrix. Finally, \boldsymbol{f}_{\mathrm{tok}}=\frac{B_{0}\bar{\iota}_{0}}{\bar{d}R_{0}}\begin{pmatrix}\frac{1}{2}[1+2(\bar{d}^{4}+\sigma^{2})]-\left(\frac{\bar{d}}{\bar{\iota}_{0}}\right)^{2}\frac{\mu_{0}p_{2}}{B_{0}^{2}/2}\\ \frac{5}{2}\sigma\end{pmatrix}. (72) The matrix operators can be easily inverted and thus used for the shape gradient calculations in the paper. D.4 Triangularity It is often illuminating to use more geometrical definitions of the shaping other than those directly involved in the near-axis construction. At second order, we may define an approximation to triangularity following Rodríguez (2023) , \delta=2\left(\frac{Y_{2s}}{Y_{1s}}-\frac{X_{2c}}{X_{1c}}\right), (73) which through Eq. ( 65 ) depends on all X_{20},X_{2s},X_{2c} and Y_{20} . For the purpose of this paper we are interested on the variations of this expression respect to the second order shape choices. That is, \delta\!\delta=-\frac{2}{Y_{1s}}\left[\begin{pmatrix}\mathcal{Y}_{2s}^{X_{20}}\\ \mathcal{Y}_{2s}^{Y_{20}}\end{pmatrix}^{T}\hat{\mathbb{L}}^{-1}\hat{\mathbb{F}}-\begin{pmatrix}\mathcal{Y}_{2s}^{X_{2c}}\\ \mathcal{Y}_{2s}^{X_{2s}}\end{pmatrix}^{T}\right]\begin{pmatrix}\delta\!X_{2c}\\ \delta\!X_{2s}\end{pmatrix}-\frac{2}{X_{1c}}\delta\!X_{2c}, (74) which is rather complicated. In the tokamak limit, using the expressions in Eqs. ( 70 ) and ( 71 ), the expression simplifies significantly to give, \delta\!\delta_{\mathrm{tok}}=\frac{2}{\bar{d}}\frac{\bar{d}^{4}+3}{\bar{d}^{4}-3}\delta\!X_{2c}, (75) as used in the main text. Note the appearence of the diverging denominator here, which signals the huge variation in the geometric triangularity due to a change in the input function X_{2c} when close to the resonance, emphasising the perilous balance there. Appendix E General sensitivity theory In this appendix we consider the evaluation of the shape gradient of some functional S with respect to the shaping degrees of freedom at second order. Let such a functional be of the form, S[B_{20},B_{2c},B_{2s}]=\int_{0}^{2\pi}f(B_{20},B_{2c},B_{2s},\varphi)\,\mathrm{d}\varphi, (76) functional that depends directly on the second order magnetic field functions. As we change the second order shaping, we are interested in how S changes, call it \delta\!S . Assuming f to be differentiable with respect to the three components of the second order magnetic field magnitude, \delta\!S=\int_{0}^{2\pi}\left(\frac{\partial f}{\partial B_{20}}\delta\!B_{20}+\frac{\partial f}{\partial B_{2c}}\delta\!B_{2c}+\frac{\partial f}{\partial B_{2s}}\delta\!B_{2s}\right)\,\mathrm{d}\varphi, (77) and the partial derivatives are meant to be taken keeping the other second order magnetic field components fixed 15 15 15 It truly is a variation in the functional theory sense. . In order to proceed further, we must relate the variation of these magnetic field components to the shaping. To that end, we draw from the presentation of the second order construction in Section 2.4 of RPJ ( Rodriguez et al., 2024 ) , and the explicit equations in Appendix A of LS ( Landreman & Sengupta, 2019 ) . The shaping freedom is on the functions X_{2s} and X_{2c} , which represent in some form the triangularity that we may exploit to modify S . More precisely, they describe the m=2 variation of the distance of the flux surfaces from the magnetic axis along the normal of the latter. As the flux surface is deformed, the magnetic field magnitude must change accordingly, and thus B_{2c} and B_{2s} are quite directly modified. From Eq. (2.7) in RPJ or Eqs. (A35-36) in LS, \displaystyle\delta\!B_{2c}=\kappa B_{0}\,\delta\!X_{2c}, (78) \displaystyle\delta\!B_{2s}=\kappa B_{0}\,\delta\!X_{2s}. (79) The larger the curvature of the magnetic axis, the stronger the supported perpendicular gradient of the magnetic field, and thus the easier the magnitude of the magnetic field can be shaped. The variation of B_{20} (Eq. (A34) in LS) depends directly on X_{20} , which must be self-consistently solved alongside Y_{20} in Eq. ( 67 ). The dependence on X_{2c} and X_{2s} (and their derivatives) do therefore involve the inversion of differential operators, which in the notation of Appendix D.2 , \delta\!B_{20}=-\kappa B_{0}\begin{pmatrix}1&0\end{pmatrix}\hat{\mathbb{L}}^{-1}\hat{\mathbb{F}}\begin{pmatrix}\delta\!X_{2c}\\ \delta\!X_{2s}\end{pmatrix}. (80) Once again, we encounter the proportionality to \kappa , which denotes that partial inability of the shaping to modify the field especially near inflection points. However, this does not mean that the shaping at these points has no influence on S . Effects lose locality through the inversion of \hat{\mathbb{L}} . With this we write, \delta\!S=\int_{0}^{2\pi}\underbrace{\kappa B_{0}\left[-\begin{pmatrix}\frac{\partial f}{\partial B_{20}}&0\end{pmatrix}\hat{\mathbb{L}}^{-1}\hat{\mathbb{F}}+\begin{pmatrix}\frac{\partial f}{\partial B_{2c}}&\frac{\partial f}{\partial B_{2s}}\end{pmatrix}\right]}_{=\mathcal{G}^{T}}\delta\!X_{2}\,\mathrm{d}\varphi, (81) where \mathcal{G} can be though of as the shape gradient \mathcal{G}=(\mathcal{G}_{2c},\mathcal{G}_{2s}) and \delta\!X_{2}=(\delta\!X_{2c},\delta\!X_{2s}) . The function \mathcal{G} can then be interpreted as the so-called shape-gradient of S respect to the shaping X_{2} . That is, it measures the amount by which an infinitesimal local variation of second order shaping would change the non-local value of S . A priori, and with all the quantities in \mathcal{G} being known (they belong to the first order NAE), we could directly calculate it. However, it is in practice convenient to avoid having to invert \hat{\mathbb{L}} explicitly 16 16 16 Avoiding explicit inversion of the matrix in solving a linear system tends to be numerically faster and more stable ( Cormen et al., 2022 , Chap. 28) . . Instead, we may formulate the calculation of \mathcal{G} through an adjoint problem. For simplicity, let us discretise the equation, as we will do anyways in practice. Defining a grid \{\varphi_{0},\varphi_{1},\dots,\varphi_{N-1}\} , and discretising integrals with the appropriate numerical scheme weight \int f\mathrm{d}\varphi\approx\sum w_{i}f(\varphi_{i}) , we write, \delta\!S=\sum_{i=0}^{2(N-1)}w_{i}\mathcal{G}_{i}\delta\!X_{2,i}, (82) where \mathcal{G}_{i}=-\frac{1}{w_{i}}\left(\mathbb{F}^{T}\right)_{ij}\boldsymbol{y}_{j}+\kappa B_{0}\begin{pmatrix}\frac{\partial f}{\partial B_{2c}}\\ \frac{\partial f}{\partial B_{2s}}\end{pmatrix}, (83) and \boldsymbol{y} is the solution to the following adjoint problem, \mathbb{L}^{T}\boldsymbol{y}=\begin{pmatrix}\kappa B_{0}w\frac{\partial f}{\partial B_{20}}\\ 0\end{pmatrix}. (84) Thus, to compute the shape gradient \mathcal{G} , the key is to perform an adjoint solve to find \boldsymbol{y} . The system to solve is nevertheless almost the same as for the direct second order solve problem, Eq. ( 67 ), as it involves \mathbb{L} , and thus it involves a complexity analogous to a second order solve itself. This construction presented in generality may be used for a variety of different measures. The answer will depend on how we discretise the integral, and thus on the weights w . This is the price to pay for not having to integrate by parts. In its most basic form, using the standard trapezoidal scheme, the weight ( Süli & Mayers, 2003 , pg. 202) w_{i}=\begin{cases}\frac{1}{2}\left(P+\varphi_{1}-\varphi_{N-1}\right),\quad(i=0)\\ \frac{1}{2}\left(\varphi_{i+1}-\varphi_{i-1}\right),\quad(0