Hostname: page-component-745bb68f8f-g4j75 Total loading time: 0 Render date: 2025-02-10T13:26:07.608Z Has data issue: false hasContentIssue false

Adjoint methods for quasi-symmetry of vacuum fields on a surface

Published online by Cambridge University Press:  21 January 2022

Richard Nies*
Affiliation:
Department of Astrophysical Sciences, Princeton University, Princeton, NJ 08543, USA Princeton Plasma Physics Laboratory, Princeton, NJ 08540, USA
Elizabeth J. Paul
Affiliation:
Department of Astrophysical Sciences, Princeton University, Princeton, NJ 08543, USA Princeton Plasma Physics Laboratory, Princeton, NJ 08540, USA
Stuart R. Hudson
Affiliation:
Princeton Plasma Physics Laboratory, Princeton, NJ 08540, USA
Amitava Bhattacharjee
Affiliation:
Department of Astrophysical Sciences, Princeton University, Princeton, NJ 08543, USA Princeton Plasma Physics Laboratory, Princeton, NJ 08540, USA
*
Email address for correspondence: rnies@pppl.gov
Rights & Permissions [Opens in a new window]

Abstract

Adjoint methods can speed up stellarator optimisation by providing gradient information more efficiently compared with finite-difference evaluations. Adjoint methods are herein applied to vacuum magnetic fields, with objective functions targeting quasi-symmetry and a rotational transform value on a surface. To measure quasi-symmetry, a novel way of evaluating approximate flux coordinates on a single flux surface without the assumption of a neighbourhood of flux surfaces is proposed. The shape gradients obtained from the adjoint formalism are evaluated numerically and verified against finite-difference evaluations.

Type
Research Article
Copyright
Copyright © The Author(s), 2022. Published by Cambridge University Press

1. Introduction

The stellarator concept (Spitzer Reference Spitzer1958) offers a path to a steady-state and disruption-free fusion reactor with low recirculating power, but its complex three-dimensional geometry must be carefully designed to guarantee good plasma properties. In particular, the stellarator does not generally guarantee confinement of particles on collisionless trajectories due to its lack of continuous symmetry, leading to large neoclassical transport (Helander Reference Helander2014). However, the use of numerical optimisation techniques has led to advanced stellarator designs with good confinement properties, culminating in the design and construction of the HSX (Anderson et al. Reference Anderson, Almagri, Anderson, Matthews, Talmadge and Shohet1995) and W7-X (Beidler et al. Reference Beidler, Grieger, Herrnegger, Harmeyer, Kisslinger, Lotz, Maassberg, Merkel, Nührenberg and Rau1990) stellarators.

Although gradient-based optimisation algorithms are generally more efficient than gradient-free algorithms, because of the large number of parameters (e.g. to represent the plasma boundary) they can be prohibitively expensive computationally if the gradients are evaluated via finite differences. A more efficient way of obtaining gradient information is provided by adjoint methods, which were recently introduced in the stellarator optimisation field and have already found widespread application (Landreman & Paul Reference Landreman and Paul2018; Paul et al. Reference Paul, Landreman, Bader and Dorland2018; Antonsen, Paul & Landreman Reference Antonsen, Paul and Landreman2019; Paul et al. Reference Paul, Abel, Landreman and Dorland2019Reference Paul, Antonsen, Landreman and Cooper2020; Giuliani et al. Reference Giuliani, Wechsung, Cerfon, Stadler and Landreman2020; Paul Reference Paul2020; Geraldini, Landreman & Paul Reference Geraldini, Landreman and Paul2021; Paul, Landreman & Antonsen Reference Paul, Landreman and Antonsen2021).

Previous work (Antonsen et al. Reference Antonsen, Paul and Landreman2019; Paul et al. Reference Paul, Antonsen, Landreman and Cooper2020Reference Paul, Landreman and Antonsen2021) applied adjoint methods to ideal magnetohydrostatic (MHS) equilibria, building in the assumption of integrability, i.e. the existence of a set of nested flux surfaces. However, three-dimensional magnetic fields are generally not integrable due to the lack of continuous symmetry. Moreover, singularities arise at rational surfaces for linearised ideal MHS equilibria, making the computation of derivatives challenging (Paul et al. Reference Paul, Landreman and Antonsen2021). To overcome these challenges, different equilibrium models can be considered, such as vacuum or force-free fields. We herein apply adjoint methods to vacuum magnetic fields, relinquishing the assumption of global integrability, and avoiding the singular behaviour of MHS equilibria. Modelling the plasma magnetic field as a vacuum field is justified in the limit of vanishing plasma current and $\beta$, the ratio of thermal pressure to magnetic pressure. Vacuum fields are thus broadly relevant for stellarator configurations, which tend to operate at low $\beta$ and low plasma current, as non-axisymmetric shaping of the coils is used to generate rotational transform. Moreover, optimised vacuum solutions can serve as useful starting points for the optimisation of finite-pressure equilibria (Boozer Reference Boozer2019).

We consider two objective functions, one targeting a rotational transform value on the boundary and another targeting quasi-symmetry on the boundary. As a subset of the larger class of omnigenous fields (Hall & McNamara Reference Hall and McNamara1975), for which particles are confined on collisionless trajectories, quasi-symmetric fields (Nührenberg & Zille Reference Nührenberg and Zille1988) have attracted strong interest, notably leading to the designs of the HSX (Anderson et al. Reference Anderson, Almagri, Anderson, Matthews, Talmadge and Shohet1995) and NCSX (Zarnstorff et al. Reference Zarnstorff, Berry, Brooks, Fredrickson, Fu, Hirschman, Hudson, Ku., Lazarus and Mikkelsen2001) stellarators. The existence of a continuous set of nested flux surfaces is a necessary condition for quasi-symmetry (Rodríguez, Helander & Bhattacharjee Reference Rodríguez, Helander and Bhattacharjee2020). In particular, quasi-symmetry is typically formulated in flux coordinates (Helander Reference Helander2014; Burby, Kallinikos & MacKay Reference Burby, Kallinikos and MacKay2020; Rodríguez et al. Reference Rodríguez, Helander and Bhattacharjee2020), the construction of which is, however, not generally possible for three-dimensional magnetic fields. We propose a method of constructing approximate flux coordinates on an isolated flux surface, on which quasi-symmetry can then be defined and optimised for. The existence of at least one isolated flux surface will be guaranteed, by imposing the boundary condition that the magnetic field be tangential on a prescribed boundary. Note that we do not consider whether this boundary condition can actually be realised with a set of coils, a task pursued by codes like FOCUS (Zhu et al. Reference Zhu, Hudson, Song and Wan2018).

With the exception of Landreman & Paul (Reference Landreman and Paul2021), previous optimisation studies targeted quasi-helical symmetry (Nührenberg & Zille Reference Nührenberg and Zille1988; Ku & Boozer Reference Ku and Boozer2011; Bader et al. Reference Bader, Drevlak, Anderson, Faber, Hegna, Likin, Schmitt and Talmadge2019) or quasi-axisymmetry (Drevlak et al. Reference Drevlak, Brochard, Helander, Kisslinger, Mikhailov, Nührenberg, Nührenberg and Turkin2013; Henneberg et al. Reference Henneberg, Drevlak, Nührenberg, Beidler, Turkin, Loizu and Helander2019; Henneberg, Drevlak & Helander Reference Henneberg, Drevlak and Helander2020; Landreman, Medasani & Zhu Reference Landreman, Medasani and Zhu2021) by minimising the symmetry-breaking components of the magnetic field strength in Boozer coordinates (typically the $L^2$-norm), often for vacuum magnetic fields. The aforementioned studies either relied on derivative-free optimisation algorithms (Drevlak et al. Reference Drevlak, Brochard, Helander, Kisslinger, Mikhailov, Nührenberg, Nührenberg and Turkin2013; Bader et al. Reference Bader, Drevlak, Anderson, Faber, Hegna, Likin, Schmitt and Talmadge2019; Henneberg et al. Reference Henneberg, Drevlak, Nührenberg, Beidler, Turkin, Loizu and Helander2019Reference Henneberg, Drevlak and Helander2020) or computed derivatives using finite differences (Landreman & Paul Reference Landreman and Paul2021; Landreman et al. Reference Landreman, Medasani and Zhu2021). The most widely used magnetic field solver, whether for vacuum fields or plasmas with finite pressure, is the VMEC code (Hirshman, van RIJ & Merkel Reference Hirshman, van RIJ and Merkel1986), which notably assumes the existence of nested flux surfaces. We compute the vacuum magnetic field through single-volume SPEC (Hudson et al. Reference Hudson, Dewar, Dennis, Hole, McGann, von Nessi and Lazerson2012) calculations, making no assumptions on integrability. Furthermore, in contrast to most previous studies, we use a formulation of quasi-symmetry that does not rely on a Boozer coordinate transformation, although it still enables the specification of a desired helicity of the magnetic field strength. A comparison of various quasi-symmetry targets can be found in Rodriguez, Paul & Bhattacharjee (Reference Rodriguez, Paul and Bhattacharjee2021).

Previous studies have sought to optimise for quasi-symmetry either on a single flux surface (e.g. Henneberg et al. Reference Henneberg, Drevlak and Helander2020) or on multiple flux surfaces (e.g. Landreman & Paul Reference Landreman and Paul2021) with the aim of approximating quasi-symmetry in a finite volume. We herein consider quasi-symmetry on a single flux surface only. Note that, away from a surface with exact quasi-symmetry, the deviation from quasi-symmetry will generally increase linearly in the flux difference (Sengupta et al. Reference Sengupta, Paul, Weitzner and Bhattacharjee2021).

This paper is structured as follows. We begin with a brief introduction to adjoint methods in § 2. A method of constructing approximate flux coordinates on a single flux surface is introduced in § 3. The derived adjoint equations for vacuum fields are presented in § 4, first for a simpler objective function targeting a given rotational transform value on the boundary in § 4.1, then for one targeting quasi-symmetry on the boundary with a given helicity in § 4.2. The resulting shape gradients are evaluated numerically and benchmarked against finite-difference calculations.

2. Basics of adjoint methods

This section aims to briefly introduce adjoint methods, without delving deeply in the mathematical formalism. More details can be found in, for example, Delfour & Zolésio (Reference Delfour and Zolésio2011) and Paul et al. (Reference Paul, Antonsen, Landreman and Cooper2020). Note that here we exclusively consider volumes $\mathcal {V}$ with closed, smooth, connected and orientable boundaries $\mathcal {S}=\partial \mathcal {V}$, such that there is a one-to-one correspondence between $\mathcal {V}$ and $\mathcal {S}$, a proof of which can be found in McGrath (Reference McGrath2016). For the specific case of closed $\mathcal {S}$, it is therefore equivalent to denote shape functionals as depending either on the volume, e.g. $J(\mathcal {V})$, or on the surface, e.g. $J(\mathcal {S})$. We choose the latter approach for greater clarity to the reader, as the boundary is the object that will ultimately be optimised over. However, note that the mathematical literature (Delfour & Zolésio Reference Delfour and Zolésio2011) would emphasise the dependence on volumes instead.

We are interested in obtaining derivative information for a shape functional $J(\mathcal {S}) = f(\mathcal {S}, u(\mathcal {S}))$, called hereafter the objective function. This functional depends on the closed surface $\mathcal {S}$ explicitly and also implicitly through the solution $u(\mathcal {S})$ to a partial differential equation (PDE) $\mathcal {P}(\mathcal {S},u(\mathcal {S})) = 0$ on $\mathcal {S}$. Here, we consider $u$ to be a scalar function on the boundary $\mathcal {S}$, with a sufficient number of continuous derivatives for the operator $\mathcal {P}$ under consideration. The differential operator $\mathcal {P}$ can be linear or nonlinear, and is assumed to map back to a space of scalar functions on the boundary.

Consider a displacement of the surface $\mathcal {S}$ in the direction $\delta \boldsymbol {x}$ with magnitude $\epsilon$, resulting in a perturbed surface $\mathcal {S}_\epsilon = \{ \boldsymbol {x}_0 + \epsilon \delta \boldsymbol {x}(\boldsymbol {x}_0) : \boldsymbol {x}_0 \in \mathcal {S}\}$. The shape derivative of an arbitrary function $g(\mathcal {S})$ in the direction $\delta \boldsymbol {x}$ is now defined as

(2.1)\begin{equation} \delta g(\mathcal{S})[\delta\boldsymbol{x}] = \lim_{\epsilon\rightarrow 0} \frac{g(\mathcal{S_\epsilon}) - g(\mathcal{S})}{\epsilon}. \end{equation}

If $g(\mathcal {S})$ depends only on the geometrical shape of the surface, the shape derivative $\delta g(\mathcal {S})[\delta \boldsymbol {x}]$ will be a function of only the normal component $ {\delta \boldsymbol {{x}}\boldsymbol {\cdot } {\boldsymbol {\hat {{n}}}}}$ of the displacement, as any tangential component of $\delta \boldsymbol {x}$ leaves the shape of $\mathcal {S}$ unchanged to first order. Here, $ {\boldsymbol {\hat {{n}}}}$ is a normal vector on $\mathcal {S}$.

Obtaining the shape derivative of the objective function is non-trivial due to the implicit dependence on $\mathcal {S}$ through $u(\mathcal {S})$. Let us consider instead the Lagrangian

(2.2)\begin{equation} \mathcal{L}(\mathcal{S},u,q) = f(\mathcal{S},u) + \int_\mathcal{S} \,\mathrm{d} S \; q \; \mathcal{P}(\mathcal{S},u), \end{equation}

with the Lagrange multiplier $q$. Note that $\mathcal {S}$, $u$ and $q$ are independent variables in the above definition. When $u=u(\mathcal {S})$ such that the PDE constraint $\mathcal {P}(\mathcal {S},u(\mathcal {S})) = 0$ is satisfied, the Lagrangian is equal to the objective function for any choice of $q$, i.e. $\mathcal {L}(\mathcal {S}, u(\mathcal {S}), q)=f(\mathcal {S}, u(\mathcal {S})) = J(\mathcal {S})$. It then follows from (2.1) that $\delta \mathcal {L}(\mathcal {S}, u(\mathcal {S}), q)[\delta \boldsymbol {x}]=\delta J(\mathcal {S})[\delta \boldsymbol {x}]$, i.e. we can obtain the objective function's shape derivative by computing that of the Lagrangian. The adjoint method now makes use of the freedom in $q$ to cancel the contribution $\delta u(\mathcal {S})[\delta \boldsymbol {x}]$ contained in $\delta \mathcal {L}(\mathcal {S}, u(\mathcal {S}), q)[\delta \boldsymbol {x}]$, i.e. $q$ is chosen such that the Lagrangian is stationary with respect to $u(\mathcal {S})$. This leads to an adjoint PDE for $q$, the solution of which we denote by $q(\mathcal {S})$.

Due to the Hadamard–Zolésio structure theorem (Delfour & Zolésio Reference Delfour and Zolésio2011), the shape derivative of our objective function can ultimately be expressed as

(2.3)\begin{equation} \delta J(\mathcal{S})[\delta\boldsymbol{x}] = \delta\mathcal{L}(\mathcal{S},u(\mathcal{S}),q(\mathcal{S}))[\delta\boldsymbol{x}] = \int_\mathcal{S} \,\mathrm{d} S \;({\delta\boldsymbol{{x}}\boldsymbol{\cdot} {\boldsymbol{\hat{{n}}}}})\; \mathcal{G}(\mathcal{S},u(\mathcal{S}),q(\mathcal{S})), \end{equation}

where $\mathcal {G}$ is called the shape gradient, and can be interpreted as the local sensitivity of the objective function to perturbations of $\mathcal {S}$.

In practice, the surface $\mathcal {S}$ is typically represented by a finite set of parameters $\varOmega = \{\varOmega _i,\; i = 1, 2, \ldots N\}$, e.g. Fourier coefficients $\{R_{m,n}, Z_{m,n}\}$. The functional $J(\mathcal {S})$ is approximated by a function $J(\varOmega )$, and similarly for $\mathcal {G}$, $u(\mathcal {S})$ and $q(\mathcal {S})$. The derivative of $J(\varOmega )$ with respect to a parameter $\varOmega _i$ is then approximated as

(2.4)\begin{equation} \frac{\partial J(\varOmega)}{\partial \varOmega_i} = \int_\mathcal{S} \,\mathrm{d} S\; \frac{\partial \boldsymbol{x}}{\partial \varOmega_i}\boldsymbol{\cdot} {\boldsymbol{\hat{{n}}}} \; \mathcal{G}(\varOmega,u(\varOmega),q(\varOmega)). \end{equation}

When evaluating the parameter derivatives numerically through (2.4), errors are introduced from the inexact solutions to the original and adjoint PDEs. Indeed, these PDEs are assumed to be exactly satisfied in the preceding derivation, and also typically when deriving an expression for the shape gradient $\mathcal {G}$.

The formalism presented above can be generalised to multiple PDE constraints. We can also consider PDEs satisfied not on $\mathcal {S}$ but in the volume enclosed by it, in which case $u$ would be a scalar function in the volume, the second term on the right-hand side of (2.2) would be a volume integral and the Hadamard–Zolésio structure theorem (Delfour & Zolésio Reference Delfour and Zolésio2011) would still guarantee that we can ultimately express the shape derivative of the objective as the boundary integral (2.3). In § 4, we consider two PDE constraints: the Laplace equation for the vacuum field and the straight field line equation, respectively valid in the volume and on the boundary, with two corresponding adjoint variables.

3. Evaluating approximate flux coordinates on an isolated flux surface

The existence of toroidally nested flux surfaces (closed orientable surfaces on which the magnetic field is everywhere tangent and non-vanishing) is commonly assumed in theoretical studies of magnetically confined plasmas. In particular, many formulas involve $\boldsymbol {\nabla }\psi$, where the toroidal flux $\psi$ is a global flux surface label. However, three-dimensional magnetic fields lacking a continuous symmetry are not generally integrable. It is desirable to generalise $\boldsymbol {\nabla }\psi$ to the case of an isolated flux surface, i.e. a flux surface in whose neighbourhood the field is generally non-integrable.

Consider a toroidal flux surface $\mathcal {S}$ with a magnetic field that is nowhere vanishing. On $\mathcal {S}$, the magnetic field's normal component vanishes by definition, i.e. $\boldsymbol {B}\boldsymbol {\cdot } {\boldsymbol {\hat {{n}}}} = 0$ with $ {\boldsymbol {\hat {{n}}}}$ the unit normal vector on $\mathcal {S}$. The field line label $\alpha$ on $\mathcal {S}$ is defined through the straight field line equation $\boldsymbol {B}\boldsymbol {\cdot }\boldsymbol {\nabla }_{\varGamma }\alpha = 0$. Here, the tangential gradient $\boldsymbol {\nabla }_{\varGamma }$, defined in Appendix A.1, is the component of the three-dimensional gradient tangential to the surface (A 1). Uniqueness of $\boldsymbol {\nabla }_{\varGamma }\alpha$ is guaranteed by fixing the secular component in the poloidal angle $\theta$ to be unity, i.e. $\alpha =\theta -\iota \phi +\lambda (\theta,\phi )$, with arbitrary poloidal and toroidal angles $\theta$ and $\phi$ on $\mathcal {S}$, the rotational transform $\iota$ and the single-valued function $\lambda$. We here assume the toroidal component of the field $\boldsymbol {B}\boldsymbol {\cdot }\boldsymbol {\nabla }\phi$ is nowhere vanishing, as this allows the construction of an area-preserving mapping, from a toroidal cut of the boundary onto itself (Meiss Reference Meiss1992). This mapping can be associated with a rotation number (Greene, Mackay & Stark Reference Greene, Mackay and Stark1986) equivalent to the rotational transform $\iota$, implying that the straight field line equation can be solved.

In the integrable case, $\boldsymbol {\nabla }\psi$ is normal to the flux surfaces, and the magnetic field satisfies $\boldsymbol {B} = \boldsymbol {\nabla }\psi \times \boldsymbol {\nabla }\alpha$. We now define the generalisation $\boldsymbol {g}_{\psi }$ on $\mathcal {S}$ of the toroidal flux gradient $\boldsymbol {\nabla }\psi$, by setting $\boldsymbol {g}_{\psi }$ normal to $\mathcal {S}$, and by requiring $\boldsymbol {B} = \boldsymbol {g}_{\psi }\times \boldsymbol {\nabla }\alpha$ to be satisfied on $\mathcal {S}$. Squaring the latter equality and using $\boldsymbol {g}_{\psi } = {\boldsymbol {\hat {{n}}}} |\boldsymbol {g}_{\psi }|$ yields

(3.1)\begin{equation} \boldsymbol{g}_{\psi} = {\boldsymbol{\hat{{n}}}} \; \frac{B}{{\left| \boldsymbol{\nabla}_{\varGamma} \alpha \right|}}, \end{equation}

where $B = {\left | \boldsymbol {B} \right |}$ is the magnetic field strength.

The defining expression for $\boldsymbol {g}_{\psi }$ (3.1) can be evaluated on any flux surface without requiring nested flux surfaces in its neighbourhood, and will revert to $\boldsymbol {g}_{\psi } = \boldsymbol {\nabla }\psi$ when the field is integrable in the neighbourhood of that flux surface. In practice, one might couple objective functions relying on (3.1) with a figure of merit targeting integrability, aiming for a final plasma shape for which the field is integrable, such that $\boldsymbol {g}_{\psi } = \boldsymbol {\nabla }\psi$ and the minimised objective function represents the physical quantity of interest.

The generalised toroidal flux gradient (3.1) is evaluated in figure 1(b) for a rotating ellipse configuration, with the magnetic field computed using the SPEC code and the straight field line equation solved using a Fourier–Galerkin spectral solver. It agrees excellently with the toroidal flux gradient evaluated by VMEC, which can be calculated directly due to the imposed nestedness of flux surfaces, shown in figure 1(a). The relative difference between the two is below a percentage point in this case, as shown in figure 1(c). The difference is expected to be small when integrability is satisfied, which indeed seems to hold here, as attested by the absence of islands and chaotic regions in the SPEC Poincaré plot shown in figure 1(d). Note that SPEC solves for a vacuum magnetic field, while VMEC computes an ideal MHS equilibrium with vanishing thermal pressure, and with a plasma current that is small but finite due to the constraint of integrability.

Figure 1. Comparison of (a) the toroidal flux gradient ${\left | \boldsymbol {\nabla }\psi \right |}$ evaluated using VMEC with (b) the generalised toroidal flux gradient $|\boldsymbol {g}_{\psi }|$ (3.1) obtained in SPEC, for a $5$-period rotating ellipse case with half a rotation per field period, major radius at the ellipse centre $R_0 = 5$ m and ellipse major and minor axes values of $2$ and $1$ m, respectively. The relative difference between the two quantities is below $1\,\%$, as shown in (c). A small difference is to be expected in this case, where integrability is well satisfied, as attested in (d) by the Poincaré plot at toroidal angle $\phi =0$ from the SPEC calculation, which agrees well with the flux surfaces computed by VMEC. All data generated in this paper can be obtained from Nies (Reference Nies2021).

The generalised toroidal flux gradient $\boldsymbol {g}_{\psi }$ can be applied generally in any situation where local flux coordinates need to be evaluated, e.g. in calculations of perpendicular transport or magnetohydrodynamic stability. Isolated flux surfaces occur, for example, in fixed-boundary equilibrium calculations, where the plasma outer boundary is constrained to be a flux surface as a boundary condition on the magnetic field, or at the interfaces of multi-region relaxed magnetohydrodynamic (MRxMHD) equilibria computed by, for example, SPEC (Hudson et al. Reference Hudson, Dewar, Dennis, Hole, McGann, von Nessi and Lazerson2012) or BIEST (Malhotra et al. Reference Malhotra, Cerfon, Imbert-Gérard and O'Neil2019). In the following, we employ (3.1) specifically for a fixed-boundary vacuum field to formulate quasi-symmetry on the boundary.

4. Application of adjoint formalism to vacuum fields

Consider a vacuum magnetic field $\boldsymbol {B}$ in a toroidal domain $\mathcal {V}$ bounded by the surface $\mathcal {S} = \partial \mathcal {V}$. As the vacuum magnetic field is curl-free, it can be expressed as $\boldsymbol {B}=\boldsymbol {\nabla }\varPhi$, with the scalar potential $\varPhi$. Because we consider a simple torus $\mathcal {V}$, the most general form for the scalar potential is $\varPhi =G (\omega +\phi )$, where $G$ is a constant, $\omega$ is a single-valued function on $\mathcal {S}$ and $\phi$ is an arbitrary toroidal angle. By integrating the magnetic field along a toroidal loop around the torus, the constant $G$ is found to be proportional to the net external current through the ‘hole’ of the torus.

As the magnetic field is divergence-less, the magnetic scalar potential satisfies the Laplace equation. The field's normal component is constrained to vanish on $\mathcal {S}$ by imposing a Neumann boundary condition on the magnetic scalar potential. Further prescribing, for example, $G$, or the toroidal flux, guarantees a unique solution to Laplace's equation. We herein opt to hold the toroidal flux fixed, although the shape derivative $\delta G[\delta \boldsymbol {x}]$ will not appear in this study due to our normalisation of the figure of merit for quasi-symmetry (4.18). A different choice of normalisation would lead to an additional contribution proportional to $\delta G[\delta \boldsymbol {x}]$ in the shape derivative of the Lagrangian.

For convenience, we define the normalised magnetic field $\boldsymbol {\breve {B}}$ as

(4.1)\begin{equation} \boldsymbol{\breve{B}} \equiv \boldsymbol{B}/G = \boldsymbol{\nabla}\left(\omega + \phi\right). \end{equation}

Let us further assume the toroidal angle $\phi$ to be the azimuthal angle in cylindrical coordinates, satisfying $\Delta \phi =0$ in the domain of interest. We can thus write

(4.2a)\begin{gather} \boldsymbol{\nabla}\boldsymbol{\cdot}\boldsymbol{\breve{B}} = \Delta\omega = 0, \quad \mathrm{in}\ \mathcal{V}, \end{gather}
(4.2b)\begin{gather}\boldsymbol{\breve{B}}\boldsymbol{\cdot}{\boldsymbol{\hat{{n}}}} = \boldsymbol{\nabla}(\omega+\phi)\boldsymbol{\cdot}{\boldsymbol{\hat{{n}}}} = 0, \quad\mathrm{on}\ \mathcal{S}, \end{gather}

with $ {\boldsymbol {\hat {{n}}}}$ the normal unit vector on $\mathcal {S}$. Furthermore, the shape derivative $\delta \omega [\delta \boldsymbol {x}]$ satisfies

(4.3a)\begin{gather} \Delta(\delta\omega[\delta\boldsymbol{x}]) = 0, \quad \mathrm{in}\ \mathcal{V}, \end{gather}
(4.3b)\begin{gather}\boldsymbol{\breve{B}}\boldsymbol{\cdot}\delta{\boldsymbol{\hat{{n}}}}[\delta\boldsymbol{x}] + \boldsymbol{\nabla}(\delta\omega[\delta\boldsymbol{x}])\boldsymbol{\cdot}{\boldsymbol{\hat{{n}}}} + ({\delta\boldsymbol{{x}}\boldsymbol{\cdot} {\boldsymbol{\hat{{n}}}}}){\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla} \boldsymbol{\breve{B}}\boldsymbol{\cdot}{\boldsymbol{\hat{{n}}}} = 0, \quad\mathrm{on}\ \mathcal{S}, \end{gather}

where the Laplace equation is obtained from noting the commutative property of shape and spatial derivatives, and the normal boundary condition on $\delta \omega$ was derived in, for example, Sokołowski & Zolésio (Reference Sokołowski and Zolésio1992, § 3.2). The shape derivative of the normal vector $\delta {\boldsymbol {\hat {{n}}}}[\delta \boldsymbol {x}]=-\boldsymbol {\nabla }_{\varGamma }( {\delta \boldsymbol {{x}}\boldsymbol {\cdot } {\boldsymbol {\hat {{n}}}}})$ is derived in Appendix A.3.

Evaluating the rotational transform and quasi-symmetry figures of merit further requires the solution to the straight field line equation

(4.4)\begin{equation} 0 = \boldsymbol{B}\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}\alpha, \quad\mathrm{on}\ \mathcal{S}, \end{equation}

with the field line label

(4.5)\begin{equation} \alpha \equiv \theta-\iota\phi+\lambda(\theta,\phi), \end{equation}

where $\theta$ is a general poloidal angle, $\lambda$ is a single-valued function of $\theta$ and $\phi$ and $\iota$ is a scalar. Note that both $\lambda$ and $\iota$ are defined on the boundary $\mathcal {S}$ only, through (4.5).

Let us define the Lagrangian corresponding to an arbitrary objective function $f(\mathcal {S},\omega,\iota,\lambda )$:

(4.6)\begin{equation} \mathcal{L}(\mathcal{S}, \omega, q_\omega, \iota, \lambda, q_\alpha ) = f(\mathcal{S},\omega,\iota,\lambda) + \mathcal{M}(\mathcal{S}, \omega, q_\omega) + \mathcal{N}(\mathcal{S}, \omega, \iota, \lambda, q_\alpha), \end{equation}

with the weak form of the Laplace equation (4.2a):

(4.7)\begin{equation} \mathcal{M}(\mathcal{S}, \omega, q_\omega) = \int_{\mathcal{V}} \,\mathrm{d} V \; q_\omega \Delta \omega \end{equation}

and the weak form of the straight field line equation (4.4) normalised by $G$:

(4.8)\begin{equation} \mathcal{N}(\mathcal{S}, \omega, \iota, \lambda, q_\alpha) = \int_{\mathcal{S}} \,\mathrm{d} S \; q_\alpha \boldsymbol{\breve{B}} \boldsymbol{\cdot} \boldsymbol{\nabla}_{\varGamma} \alpha. \end{equation}

Here, the Lagrange multipliers $q_\alpha$ and $q_\omega$ are single-valued functions on the surface $\mathcal {S}$ and in the volume $\mathcal {V}$, respectively.

In the following, we assume that $\omega =\omega (\mathcal {S})$ satisfies (4.2a) and $\alpha =\alpha (\mathcal {S})$ satisfies (4.4). For ease of notation, we do not write out the dependencies on $\mathcal {S}$ explicitly, and we also omit writing the arguments of, for example, $f$, $\mathcal {M}$, $\mathcal {N}$ and $\mathcal {L}$. This means that the shape derivative $\delta \mathcal {M}[\delta \boldsymbol {x}]$ (4.9) should be understood as $\delta \mathcal {M}(\mathcal {S}, \omega (\mathcal {S}), q_\omega )[\delta \boldsymbol {x}]$, with contributions from $\delta \omega (\mathcal {S})[\delta \boldsymbol {x}]$; and similarly for other shape derivatives.

To evaluate the shape derivative of the Lagrangian (4.6), we first compute the shape derivatives of $\mathcal {M}$ and $\mathcal {N}$, before turning to the shape derivatives of our objective functions in §§ 4.1 and 4.2. First, the shape derivative of $\mathcal {M}$ (4.7), derived in Appendix B.1, is

(4.9)\begin{equation} \delta\mathcal{M}[\delta\boldsymbol{x}] = \int_{\mathcal{V}} \,\mathrm{d} V \; \delta\omega[\delta\boldsymbol{x}] \Delta q_\omega - \int_{\mathcal{S}} \,\mathrm{d} S \; \left[ \delta \omega[\delta\boldsymbol{x}] \boldsymbol{\nabla} q_\omega \boldsymbol{\cdot} {\boldsymbol{\hat{{n}}}} - ({\delta\boldsymbol{{x}}\boldsymbol{\cdot} {\boldsymbol{\hat{{n}}}}}) \boldsymbol{\breve{B}}\boldsymbol{\cdot}\boldsymbol{\nabla} q_\omega \right]. \end{equation}

Second, the shape derivative of $\mathcal {N}$ (4.8), derived in Appendix B.2, is

(4.10)\begin{align} \delta\mathcal{N}[\delta\boldsymbol{x}] & = \int_{\mathcal{S}} \mathrm{d} S \left[ - \delta\omega[\delta\boldsymbol{x}] \boldsymbol{\nabla}_{\varGamma} \boldsymbol{\cdot} \left(q_\alpha \boldsymbol{\nabla}_{\varGamma} \alpha\right) - \delta\iota[\delta\boldsymbol{x}] q_\alpha \boldsymbol{\breve{B}} \boldsymbol{\cdot} \boldsymbol{\nabla}\phi\right.\nonumber\\ & \quad \left.- \delta\lambda[\delta\boldsymbol{x}] \boldsymbol{\nabla}_{\varGamma} \boldsymbol{\cdot} \left( q_\alpha \boldsymbol{\breve{B}} \right) + ({\delta\boldsymbol{{x}}\boldsymbol{\cdot} {\boldsymbol{\hat{{n}}}}}) q_\alpha \left( {\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\boldsymbol{\breve{B}}\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}\alpha - \boldsymbol{\breve{B}}\boldsymbol{\cdot}\boldsymbol{\nabla}{\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}\alpha \right) \right]. \end{align}

The tangential gradient $\boldsymbol {\nabla }_{\varGamma }(\boldsymbol {\cdot })$ and tangential divergence $\boldsymbol {\nabla }_{\varGamma }\boldsymbol {\cdot }(\boldsymbol {\cdot })$ operators are defined in Appendix A.1.

We now proceed by computing the shape derivatives of two objective functions, first targeting a given rotational transform value on $\mathcal {S}$ (§ 4.1) and second targeting quasi-symmetry on $\mathcal {S}$ with a given helicity value (§ 4.2). We will then be able to evaluate the shape derivative of the Lagrangian (4.6), yielding the adjoint equations and shape gradient formulas. Numerical verification and example shape gradients are shown for each figure of merit.

4.1. Rotational transform objective function

Before evaluating the more complicated shape gradient for the quasi-symmetry figure of merit in § 4.2, we consider a simple figure of merit targeting a given target rotational transform $\iota _T$ on the surface $\mathcal {S}$. We thus define

(4.11)\begin{equation} f_\iota = \tfrac{1}{2} ( \iota - \iota_T )^2, \end{equation}

where $\iota$ is the rotational transform on $\mathcal {S}$, obtained by solving the straight field line equation (4.4). The shape derivative of $f_\iota$ is simply

(4.12)\begin{equation} \delta f_\iota [\delta\boldsymbol{x}] = \delta \iota[\delta\boldsymbol{x}] ( \iota - \iota_T ). \end{equation}

By combining (4.9), (4.10) and (4.12), we obtain the shape derivative of the Lagrangian $\mathcal {L}_\iota$ ((4.6) with $f=f_\iota$):

(4.13)\begin{align} \delta\mathcal{L}_\iota[\delta\boldsymbol{x}] & = \int_{\mathcal{V}} \,\mathrm{d} V \; \delta\omega[\delta\boldsymbol{x}] \Delta q_\omega - \int_{\mathcal{S}} \,\mathrm{d} S \; \delta \omega [\delta\boldsymbol{x}] \left[ \boldsymbol{\nabla} q_\omega \boldsymbol{\cdot} {\boldsymbol{\hat{{n}}}} + \boldsymbol{\nabla}_{\varGamma} \boldsymbol{\cdot} \left(q_\alpha \boldsymbol{\nabla}_{\varGamma} \alpha \right) \right]\nonumber\\ & \quad - \delta\iota[\delta\boldsymbol{x}] \left[ \int_{\mathcal{S}} \,\mathrm{d} S \; q_\alpha \boldsymbol{\breve{B}} \boldsymbol{\cdot} \boldsymbol{\nabla}\phi - ( \iota - \iota_T ) \right] - \int_{\mathcal{S}} \,\mathrm{d} S \;\delta\lambda[\delta\boldsymbol{x}] \boldsymbol{\nabla}_{\varGamma} \boldsymbol{\cdot} \left( q_\alpha \boldsymbol{\breve{B}} \right)\nonumber\\ & \quad + \int_{\mathcal{S}} \,\mathrm{d} S ({\delta\boldsymbol{{x}}\boldsymbol{\cdot} {\boldsymbol{\hat{{n}}}}}) \left[\boldsymbol{\nabla} q_\omega \boldsymbol{\cdot} \boldsymbol{\breve{B}} + q_\alpha \left({\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\boldsymbol{\breve{B}}\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}\alpha - \boldsymbol{\breve{B}}\boldsymbol{\cdot}\boldsymbol{\nabla}{\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}\alpha \right) \right]. \end{align}

First, we obtain the adjoint equation for $q_\alpha$ by requiring the second line of (4.13) to vanish:

(4.14a)\begin{gather} \boldsymbol{\nabla}_{\varGamma} \boldsymbol{\cdot} \left( q_\alpha \boldsymbol{\breve{B}} \right) = 0, \end{gather}
(4.14b)\begin{gather}\int_{\mathcal{S}} \,\mathrm{d} S \; q_\alpha \boldsymbol{\breve{B}} \boldsymbol{\cdot} \boldsymbol{\nabla}\phi - ( \iota - \iota_T ) = 0, \end{gather}

with both equations defined on $\mathcal {S}$. Using (A 3), the surface integral of (4.14a) yields $0 = \boldsymbol {\breve {B}}\boldsymbol {\cdot } {\boldsymbol {\hat {{n}}}}$, which is consistent with the boundary condition on the magnetic field (4.2b). The first equation (4.14a) can be recast in the form of a magnetic differential equation $\boldsymbol {B}\boldsymbol {\cdot }\boldsymbol {\nabla } q_\alpha = - q_\alpha \boldsymbol {\nabla }_{\varGamma }\boldsymbol {\cdot }\boldsymbol {B}$, while the second equation (4.14b) is an integral condition on $q_\alpha$ that ensures uniqueness of the solution.

Second, the adjoint equation for $q_\omega$ is obtained by requiring the first line of (4.13) to vanish:

(4.15a)\begin{gather} \Delta q_\omega = 0, \quad \mathrm{in}\ \mathcal{V}, \end{gather}
(4.15b)\begin{gather}\boldsymbol{\nabla} q_\omega\boldsymbol{\cdot}{\boldsymbol{\hat{{n}}}} ={-}\boldsymbol{\nabla}_{\varGamma} \boldsymbol{\cdot} \left(q_\alpha \boldsymbol{\nabla}_{\varGamma} \alpha \right), \quad\mathrm{on}\ \mathcal{S}. \end{gather}

Like the magnetic potential $\omega$, the adjoint variable $q_\omega$ satisfies the Laplace equation in $\mathcal {V}$ (4.15a). However, contrary to $\omega$, $q_\omega$ has a non-zero normal boundary condition on $\mathcal {S}$ (4.15b), which notably depends on the straight field line adjoint variable $q_\alpha$. Equations (4.15b) and (4.15a) are consistent, as $\int _\mathcal {V} \,\mathrm {d} V\; \Delta q_\omega = \int _\mathcal {S} \,\mathrm {d} S\; \boldsymbol {\nabla } q_\omega \boldsymbol {\cdot } {\boldsymbol {\hat {{n}}}} = 0$, by (A 3).

Finally, the remaining contribution from the last line of (4.13) yields the shape gradient

(4.16)\begin{equation} \mathcal{G_\iota} = \frac{1}{G} \left[ \boldsymbol{B}\boldsymbol{\cdot} \boldsymbol{\nabla} q_\omega + q_\alpha \left( {\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\boldsymbol{B} - \boldsymbol{B}\boldsymbol{\cdot}\boldsymbol{\nabla}{\boldsymbol{\hat{{n}}}} \right)\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma} \alpha \right], \end{equation}

with $\delta \mathcal {L}_\iota [\delta \boldsymbol {x}] = \int _{\mathcal {S}} \,\mathrm {d} S ( {\delta \boldsymbol {{x}}\boldsymbol {\cdot } {\boldsymbol {\hat {{n}}}}}) \mathcal {G_\iota }$.

We now calculate the shape gradient numerically and verify it against a finite-difference evaluation. The solutions to Laplace's equation for the vacuum magnetic field (4.2a) and adjoint equation for $q_\omega$ (4.15a) are calculated with the SPEC code (Hudson et al. Reference Hudson, Dewar, Dennis, Hole, McGann, von Nessi and Lazerson2012), employing the new Zernike polynomial implementation (Qu et al. Reference Qu, Pfefferlé, Hudson, Baillod, Kumar, Dewar and Hole2020). In all results shown, the radial resolution $L_\mathrm {rad}$ in SPEC is tied to the poloidal Fourier resolution $M_\mathrm {pol}$ through $L_\mathrm {rad} = M_\mathrm {pol} + 4$. The solutions to the straight field line and $q_\alpha$ adjoint equations are obtained with a Fourier–Galerkin spectral solver.

The shape gradient (4.16) is shown in figure 2(a) for the example rotating ellipse case introduced in figure 1. The localisation at the ellipse tips is unsurprising, as near-axis expansions show that ellipticity of the flux surfaces generates rotational transform (Mercier Reference Mercier1964). This shape gradient $\mathcal {G}_\mathrm {adjoint}$ can be verified against the direct finite-difference evaluation $\mathcal {G}_\mathrm {FD}$ shown in figure 2(b), obtained by evaluating the parameter derivatives $\partial f/\partial \varOmega _i$ through finite differences and inverting (2.4) (see Landreman & Paul Reference Landreman and Paul2018). On the scale of the figure, the two shape gradients seem identical. The relative error is shown in figure 2(c) to be small, limited to ${\sim }2\,\%$ at the ellipse tips, and exhibits oscillations typical of a truncated Fourier resolution. The relative error is here defined as the absolute error normalised by the $L^\infty$-norm of $\mathcal {G}_\mathrm {adjoint}$, i.e. its maximum absolute value. This choice is preferable to, for example, the $L^2$-norm, as the shape gradient and the error thereof have small average values on the boundary compared withtheir large values at the ellipse tips, such that unreasonably high relative errors would result at these locations if using the $L^2$-norm as normalisation.

Figure 2. Shape gradient for the rotational transform objective function with $\iota _T = 1$, evaluated through (a) adjoint methods and (b) a forward finite-difference scheme with step size $\epsilon _\mathrm {FD}=10^{-7}$, for the example rotating ellipse case introduced in figure 1, with Fourier resolution $(N_\mathrm {tor}, M_\mathrm {pol}) = (16,16)$. The relative error, defined as the absolute error normalised by the maximal absolute value of the adjoint shape gradient, is shown in (c). The convergence of the relative error in the parameter derivative (2.4) for a random direction in $\varOmega$ is shown in (d) as a function of the step size $\epsilon _\mathrm {FD}$ and Fourier resolution $(N_\mathrm {tor}, M_\mathrm {pol})$. The black dashed line indicates the linear scaling in $\epsilon _\mathrm {FD}$ expected from the employed forward finite-difference scheme.

Furthermore, we test convergence of the shape gradient by evaluating a parameter derivative (2.4) for a random direction in $\varOmega$. The parameter derivative is evaluated both through the adjoint shape gradient and by a forward finite-difference scheme. The relative error is shown in figure 2(d) as a function of the finite-difference step size $\epsilon _\mathrm {FD}$ and the Fourier resolution, which is used in both SPEC and the Fourier–Galerkin spectral solver. As $\epsilon _\mathrm {FD}$ is reduced, the error initially decreases linearly with $\epsilon _\mathrm {FD}$, as expected from the employed forward finite-difference scheme, until it plateaus at a value governed by the finite Fourier or radial resolution. As mentioned in § 2, errors in the adjoint shape gradient are introduced by the assumption that the constraint and adjoint PDEs are exactly satisfied. In practice, these PDEs are solved only approximately, limited by the finite Fourier and radial resolution, such that a reduction of the error with increasing resolution is to be expected.

4.2. Quasi-symmetry objective function

For a general (non-vacuum) magnetic field with nested flux surfaces, quasi-symmetry can be expressed as

(4.17)\begin{equation} \frac{\boldsymbol{B}\boldsymbol{\cdot}\boldsymbol{\nabla}\psi\times\boldsymbol{\nabla} B}{\boldsymbol{B}\boldsymbol{\cdot}\boldsymbol{\nabla} B} ={-}\frac{MG + NI}{N-\iota M}, \end{equation}

where $I$ is the net toroidal plasma current and $N/M$ is the helicity of the field strength in Boozer coordinates (see e.g. Helander Reference Helander2014). For the vacuum field considered here, $I=0$. In the following, we do not consider quasi-poloidal symmetry, i.e. we assume $M\ne 0$. If desired, it would be straightforward to extend the derived results to include the case $M=0$.

For magnetic fields with globally nested flux surfaces labelled by $\psi$, (4.17) is defined globally. However, we are considering a generally non-integrable field, assuming only that the boundary $\mathcal {S}$ is a flux surface. Using the generalised toroidal flux gradient defined in (3.1), we are able to define quasi-symmetry on the isolated flux surface $\mathcal {S}$, leading to the quasi-symmetry objective function

(4.18)\begin{equation} f_\mathrm{QS} = \frac{1}{2} \int_\mathcal{S} \,\mathrm{d} S\; v_\mathrm{QS}^2, \end{equation}

with

(4.19)\begin{equation} v_\mathrm{QS} = \boldsymbol{\breve{B}}\boldsymbol{\cdot}\boldsymbol{\nabla} \breve{B} - \boldsymbol{\breve{B}}\times\boldsymbol{\breve{g}}_\psi\boldsymbol{\cdot}\boldsymbol{\nabla} \breve{B} \left( \iota - N/M\right), \end{equation}

where we defined $\boldsymbol {\breve {g}}_\psi \equiv \boldsymbol {g}_{\psi }/G$. If $f_\mathrm {QS}=0$ and the field is integrable in the neighbourhood of $\mathcal {S}$, (4.17) will be satisfied on $\mathcal {S}$, i.e. the field is quasi-symmetricon the boundary.

The shape derivative of $f_\mathrm {QS}$ is derived in Appendix B.3, with the final expression given in (B 24). Combined with the shape derivatives of $\mathcal {M}$ (4.9) and $\mathcal {N}$ (4.10), the shape derivative of the Lagrangian (4.6) with the quasi-symmetric figure of merit follows (B 26).

Requiring the Lagrangian to be stationary with respect to variations in $\iota$ and $\lambda$, the first two lines of (B 26) yield the adjoint equations for $q_\alpha$:

(4.20a)\begin{gather} \boldsymbol{\nabla}_{\varGamma} \boldsymbol{\cdot} \left( q_\alpha \boldsymbol{\breve{B}} \right) ={-}\boldsymbol{\nabla}_{\varGamma}\boldsymbol{\cdot}\left[ \boldsymbol{\nabla}_{\varGamma}\alpha \left( v_\mathrm{QS}\; \boldsymbol{\breve{B}}\times\boldsymbol{\breve{g}}_\psi\boldsymbol{\cdot}\boldsymbol{\nabla} \breve{B}\; \frac{\iota - N/M}{{\left| \boldsymbol{\nabla}_{\varGamma} \alpha \right|}^2}\right) \right] , \end{gather}
(4.20b)\begin{gather}0=\int_{\mathcal{S}} \,\mathrm{d} S \left\{ q_\alpha \boldsymbol{\breve{B}} \boldsymbol{\cdot} \boldsymbol{\nabla}\phi + v_\mathrm{QS}\; \boldsymbol{\breve{B}}\times\boldsymbol{\breve{g}}_\psi\boldsymbol{\cdot}\boldsymbol{\nabla} \breve{B} \left[ \frac{\boldsymbol{\nabla}_{\varGamma}\alpha\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma} \phi}{{\left| \boldsymbol{\nabla}_{\varGamma} \alpha \right|}^2} (\iota-N/M) + 1 \right] \right\}. \end{gather}

Similarly to the rotational transform objective function case, $q_\alpha$ satisfies a magnetic differential equation (4.20a) on $\mathcal {S}$, with integral condition (4.20b). By (A 3), the surface integral of (4.20a) is consistent with the magnetic field's normal component vanishing on the boundary (4.2b).

Furthermore, requiring the Lagrangian to be stationary with respect to variations in $\omega$, we obtain the adjoint equations for $q_\omega$ from the third and fourth lines of (B 26):

(4.21a)\begin{equation} \Delta q_\omega = 0, \quad\mathrm{in}\ \mathcal{V}, \end{equation}
(4.21b)\begin{align} & \boldsymbol{\nabla} q_\omega \boldsymbol{\cdot} {\boldsymbol{\hat{{n}}}} ={-}\boldsymbol{\nabla}_{\varGamma} \boldsymbol{\cdot} \left\{ q_\alpha \boldsymbol{\nabla}_{\varGamma} \alpha + v_\mathrm{QS} \;\boldsymbol{\nabla}_{\varGamma} \breve{B} - \frac{\boldsymbol{\breve{B}}}{\breve{B}} \boldsymbol{\nabla}_{\varGamma} \boldsymbol{\cdot} (v_\mathrm{QS} \; \boldsymbol{\breve{B}})\right.\nonumber\\ & \quad \left.+ \left(\iota-N/M\right) \left[ v_\mathrm{QS} \; \boldsymbol{\breve{g}}_\psi\times\boldsymbol{\nabla}_{\varGamma}\breve{B} - \boldsymbol{\breve{B}}\; \boldsymbol{\nabla}_{\varGamma}\boldsymbol{\cdot}\left(\frac{1}{\breve{B}}v_\mathrm{QS} \boldsymbol{\breve{B}}\times\boldsymbol{\breve{g}}_\psi\right) \right] \vphantom{\left\{ q_\alpha \boldsymbol{\nabla}_{\varGamma} \alpha + v_\mathrm{QS} \;\boldsymbol{\nabla}_{\varGamma} \breve{B} - \frac{\boldsymbol{\breve{B}}}{\breve{B}} \boldsymbol{\nabla}_{\varGamma} \boldsymbol{\cdot} (v_\mathrm{QS} \; \boldsymbol{\breve{B}})\right.}\right\}, \quad \text{on } \mathcal{S}. \end{align}

Again, $q_\omega$ satisfies the Laplace equation in $\mathcal {V}$ (4.21a), with a normal boundary condition on $\mathcal {S}$ that is the tangential divergence of a vector tangential to the surface (4.21b). The boundary condition (4.21b) is consistent with the Laplace equation, as $\int _\mathcal {V} \,\mathrm {d} V\; \Delta q_\omega = \int _\mathcal {S} \,\mathrm {d} S\; \boldsymbol {\nabla } q_\omega \boldsymbol {\cdot } {\boldsymbol {\hat {{n}}}} = 0$, by (A 3).

Finally, we obtain the shape gradient from the last three lines of (B 26):

(4.22)\begin{align} \mathcal{G}_\mathrm{QS} & ={-} ({\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\breve{B}) \boldsymbol{\nabla}_{\varGamma}\boldsymbol{\cdot}\left( v_\mathrm{QS} \boldsymbol{\breve{B}} \right) - v_\mathrm{QS}\;\left(\boldsymbol{\breve{B}}\boldsymbol{\cdot}\boldsymbol{\nabla}{\boldsymbol{\hat{{n}}}} - {\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\boldsymbol{\breve{B}} \right)\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}\breve{B} \nonumber\\ & \quad + \left(\iota-N/M\right)\; {\left| \boldsymbol{\breve{g}}_\psi \right|} \; \boldsymbol{\breve{B}}\times\boldsymbol{\nabla}\breve{B}\boldsymbol{\cdot} \left[ {\left| \boldsymbol{\nabla}_{\varGamma}\alpha \right|} \boldsymbol{\nabla}_{\varGamma}\left( \frac{v_\mathrm{QS}}{{\left| \boldsymbol{\nabla}_{\varGamma}\alpha \right|}} \right)\right.\nonumber\\ & \quad + \left.{\boldsymbol{\hat{{n}}}}\; v_\mathrm{QS}\; \left( \frac{\boldsymbol{\nabla}_{\varGamma}\alpha\boldsymbol{\cdot}\boldsymbol{\nabla}{\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}\alpha}{{\left| \boldsymbol{\nabla}_{\varGamma} \alpha \right|}^2} -h \right) \right] \nonumber\\ & \quad + \boldsymbol{\breve{B}}\boldsymbol{\cdot}\boldsymbol{\nabla} q_\omega + q_\alpha \left( {\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\boldsymbol{\breve{B}} - \boldsymbol{\breve{B}}\boldsymbol{\cdot}\boldsymbol{\nabla}{\boldsymbol{\hat{{n}}}} \right)\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}\alpha + \frac{h}{2} v_\mathrm{QS}^2, \end{align}

with $\delta \mathcal {L}_\mathrm {QS}[\delta \boldsymbol {x}] = \int _{\mathcal {S}} \,\mathrm {d} S \;( {\delta \boldsymbol {{x}}\boldsymbol {\cdot } {\boldsymbol {\hat {{n}}}}})\;\mathcal {G_\mathrm {QS}}$ and $h$ the summed curvature (A 4).

The shape gradient (4.22) for targeted quasi-helical symmetry with helicity $N/M = 5$ is shown in figure 3(a) for the example rotating ellipse case introduced in figure 1. The shape gradient obtained through adjoint methods is verified against a finite-difference evaluation in figure 3(b). The error is visibly small, as is attested by the small relative error of the shape gradient shown in figure 3(c). Convergence of the relative error for a parameter derivative in a random direction in $\varOmega$, evaluated with the adjoint method and with a forward finite-difference scheme, is shown in figure 3(d). Akin to the rotational transform figure of merit convergence study in figure 2(d), the error decreases linearly with $\epsilon _\mathrm {FD}$ until it plateaus due to finite Fourier or radial resolution. While the lowest resolution of $(N_\mathrm {tor}, M_\mathrm {pol}) = (8,8)$ seemed reasonable for the rotational transform figure of merit in figure 2(d), a higher resolution is clearly required for the quasi-symmetry figure of merit. This could be due to the fact that higher derivatives of the magnetic field are involved in the shape gradient for quasi-symmetry (4.22) than in that for rotational transform (4.16), through derivatives of $v_\mathrm {QS}$. The resulting fine-scale structure of $\mathcal {G}$ is harder to resolve with a truncated Fourier series. However, the relative errors in figures 2(d) and 3(d) are similarly small at the highest Fourier resolutions employed.

Figure 3. Shape gradient for the quasi-symmetry objective function with helicity $N/M=5$, evaluated through (a) adjoint methods and (b) a forward finite-difference scheme with step size $\epsilon _\mathrm {FD}=10^{-9}$, for the example rotating ellipse case introduced in figure 1, with Fourier resolution $(N_\mathrm {tor}, M_\mathrm {pol}) = (16,16)$. The relative error, defined as the absolute error normalised by the maximal absolute value of the adjoint shape gradient, is shown in (c). The convergence of the relative error in the parameter derivative (2.4) for a random direction in $\varOmega$ is shown in (d) as a function of the step size $\epsilon _\mathrm {FD}$ and Fourier resolution $(N_\mathrm {tor}, M_\mathrm {pol})$. The black dashed line indicates the linear scaling in $\epsilon _\mathrm {FD}$ expected from the employed forward finite-difference scheme.

5. Conclusions

In this work, we have derived the adjoint equations and shape gradient for the rotational transform and quasi-symmetry of a vacuum field on a surface. The shape gradients allow fast computation of derivatives with respect to the parameters that describe the geometry of the surface, which are used in optimisation and sensitivity analyses. For a boundary represented by $N$ parameters, the speed-up from the adjoint method is $O(N)$ compared to a finite-difference evaluation.

This should enable future use of codes such as SPEC (Hudson et al. Reference Hudson, Dewar, Dennis, Hole, McGann, von Nessi and Lazerson2012) in optimisation calculations, which was hitherto neglected in favour of the more widely used VMEC code (Hirshman et al. Reference Hirshman, van RIJ and Merkel1986). Contrary to VMEC, SPEC does not rely on the assumption of nested flux surfaces and can therefore model stochastic and island regions. In practice, employing adjoint methods and computing derivatives of quantities arising from ideal MHS equilibria are challenging, as the linearised MHS equilibrium equations possess regular singular points at every rational surface that resonates with the perturbation. These challenges can be avoided by the use of alternative equilibrium models, such as force-free magnetic fields, or the vacuum fields considered in this work. The generality of the results presented herein would also allow for their implementation in other solvers such as BIEST (Malhotra et al. Reference Malhotra, Cerfon, Imbert-Gérard and O'Neil2019). It is left for future work to extend the vacuum field results presented herein to the more general force-free fields modelled by SPEC. In particular, it will be of interest to extend the present work on vacuum fields to MRxMHD equilibria (Dewar et al. Reference Dewar, Hole, McGann, Mills and Hudson2008; Hudson et al. Reference Hudson, Dewar, Dennis, Hole, McGann, von Nessi and Lazerson2012). In this model, the interfaces between force-free regions are flux surfaces, such that quasi-symmetry can be optimised for on multiple flux surfaces. Finally, the adjoint methods for vacuum fields introduced in this work could be fruitfully applied to other optimisation problems, e.g. in neoclassical transport calculations.

It is generally believed that exact quasi-symmetry cannot be obtained exactly in a finite volume as near-axis expansions lead to an an overdetermined system of equations (Garren & Boozer Reference Garren and Boozer1991), although that can be resolved by allowing for an anisotropic plasma pressure (Rodríguez & Bhattacharjee Reference Rodríguez and Bhattacharjee2021a, Reference Rodríguez and Bhattacharjeeb). Exact quasi-symmetry on a surface is thought generally possible (Garren & Boozer Reference Garren and Boozer1991; Plunk & Helander Reference Plunk and Helander2018); and indeed, a vacuum solution near axisymmetry was recently found (Sengupta et al. Reference Sengupta, Paul, Weitzner and Bhattacharjee2021). The shape gradient for quasi-symmetry derived in this work could be used to numerically probe the existence of quasi-symmetric solutions on a surface that are not close to axisymmetry. For this purpose, the shape gradient for the rotational transform objective function (4.16) could be used to avoid the axisymmetric solution at $\iota = 0$, or also to avoid low-order rationals. Furthermore, the shape gradients derived herein could be used to investigate if and how optimisation for quasi-symmetry and for the rotational transform compete with each other. Finally, combining the derivatives of quasi-symmetry and rotational transform with previously obtained derivatives of coil shapes (Hudson et al. Reference Hudson, Zhu, Pfefferlé and Gunderson2018) and island size (Geraldini et al. Reference Geraldini, Landreman and Paul2021) should, in principle, allow for the efficient search for a stellarator configuration with significant rotational transform, good integrability and neoclassical confinement at the boundary, realised by simple coils.

Acknowledgements

Editor P. Helander thanks the referees for their advice in evaluating this article.

Funding

This work was supported by US DOE DE-AC02-09CH11466, DE-SC0016072 and DE-AC02–76CH03073. A.B. acknowledges the generous support of the Simons Foundation.

Declaration of interests

The authors report no conflict of interest.

Appendix A. Basics of shape differential calculus

This appendix aims to provide a brief introduction to calculus on surfaces, mainly providing useful identities required in the derivation of the adjoint equations. For more details of the subject, we refer the interested reader to Walker (Reference Walker2015) for a practical introduction and to Delfour & Zolésio (Reference Delfour and Zolésio2011) for a more thorough treatment.

In this section, we take $\mathcal {S} = \partial \mathcal {V}$ to be a closed two-dimensional surface bounding the volume $\mathcal {V}$. Let $f$ and $\boldsymbol {v}$ be respectively scalar and vector functions defined on $\mathcal {S}$. The extensions of these functions to a neighbourhood of $\mathcal {S}$ are denoted by $\tilde {f}$ and $\tilde {\boldsymbol {v}}$. Note that $f$ and $\boldsymbol {v}$ can also be functions defined in $\mathcal {V}$, in which case $\tilde {f}$ and $\boldsymbol {\tilde {v}}$ are chosen to be equal to $f$ and $\boldsymbol {v}$, respectively; the tangential gradient $\boldsymbol {\nabla }_{\varGamma } f$ and tangential divergence $\boldsymbol {\nabla }_{\varGamma }\boldsymbol {\cdot } \boldsymbol {v}$ remain defined on $\mathcal {S}$.

A.1. Differential operators on surfaces

The tangential gradient $\boldsymbol {\nabla }_{\varGamma }$ can be defined in terms of an extension as

(A 1)\begin{equation} \boldsymbol{\nabla}_{\varGamma} f \equiv \boldsymbol{\nabla} \tilde{f} - {\boldsymbol{\hat{{n}}}} \left({\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla} \tilde{f} \right), \end{equation}

where $ {\boldsymbol {\hat {{n}}}}$ is the unit normal vector on $\mathcal {S}$. The tangential gradient can thus simply be viewed as the component of the three-dimensional gradient tangential to the surface, satisfying $ {\boldsymbol {\hat {{n}}}}\boldsymbol {\cdot }\boldsymbol {\nabla }_{\varGamma } f = 0$.

Similarly to the tangential gradient, the tangential divergence $\boldsymbol {\nabla }_{\varGamma } \boldsymbol {\cdot }$ can be defined in terms of an extension as

(A 2)\begin{equation} \boldsymbol{\nabla}_{\varGamma}\boldsymbol{\cdot} \boldsymbol{v} = \boldsymbol{\nabla}\boldsymbol{\cdot}\boldsymbol{\tilde v} - {\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla} \boldsymbol{\tilde v} \boldsymbol{\cdot} {\boldsymbol{\hat{{n}}}}. \end{equation}

The related divergence theorem is particularly useful in our derivation of the adjoint equations:

(A 3)\begin{equation} \int_\mathcal{S} \,\mathrm{d} S \; \boldsymbol{\nabla}_{\varGamma}\boldsymbol{\cdot} \boldsymbol{v} = \int_\mathcal{S} \,\mathrm{d} S \; h \; {\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{v}, \end{equation}

where $\boldsymbol {v}$ is assumed to be single-valued, and the summed curvature $h$ can be obtained from the unit normal vector through

(A 4)\begin{equation} h = \boldsymbol{\nabla}_{\varGamma} \boldsymbol{\cdot} {\boldsymbol{\hat{{n}}}}. \end{equation}

It follows from (A 3) that $\int _\mathcal {S} \,\mathrm {d} S \; \boldsymbol {\nabla }_{\varGamma }\boldsymbol {\cdot } \boldsymbol {v}=0$ for a single-valued $\boldsymbol {v}$ with $ {\boldsymbol {\hat {{n}}}}\boldsymbol {\cdot }\boldsymbol {v} = 0$.

A.2. Transport theorems

To evaluate the shape derivative of the Lagrangian (see § 2) and obtain the adjoint equations, we need expressions for the shape derivatives of volume and surface integrals. These are called transport theorems. First, for a volume functional

(A 5)\begin{equation} J_V = \int_\mathcal{V} \,\mathrm{d} V\; f, \end{equation}

the shape derivative of $J_V$ is given by

(A 6)\begin{equation} \delta J_V[\delta\boldsymbol{x}] = \int_\mathcal{V} \,\mathrm{d} V\; \delta f [\delta\boldsymbol{x}] + \int_{\mathcal{S}} \,\mathrm{d} S ({\delta\boldsymbol{{x}}\boldsymbol{\cdot} {\boldsymbol{\hat{{n}}}}}) f. \end{equation}

Second, for a surface functional

(A 7)\begin{equation} J_S = \int_\mathcal{S} \,\mathrm{d} S\; f, \end{equation}

the shape derivative of $J_S$ is

(A 8)\begin{equation} \delta J_S[\delta\boldsymbol{x}] = \int_{\mathcal{S}} \,\mathrm{d} S \; \left[ \delta f [\delta\boldsymbol{x}] + ({\delta\boldsymbol{{x}}\boldsymbol{\cdot} {\boldsymbol{\hat{{n}}}}}) \left( {\boldsymbol{\hat{{n}}}} \boldsymbol{\cdot} \boldsymbol{\nabla} \tilde{f} + h f \right) \right]. \end{equation}

In both (A 6) and (A 8), the first term originates from the direct perturbation of the integrand while the second term accounts for the change of the boundary.

A.3. Normal extension and the normal vector's shape derivative

The signed distance function $b$ is defined in a sufficiently small neighbourhood of $\mathcal {S}$ as

(A 9)\begin{equation} b(\boldsymbol{r}) = \left \{ \begin{array}{@{}ll} \text{dist}(\boldsymbol{r},\mathcal{S}), & \boldsymbol{r} \in \mathbb{R}^3 \setminus \mathcal{V},\\ 0, & \boldsymbol{r} \in \mathcal{S}, \\ - \text{dist}(\boldsymbol{r},\mathcal{S}), & \boldsymbol{r} \in \mathcal{V}. \end{array} \right. \end{equation}

Here, $\text {dist}(\boldsymbol {r},\mathcal {S})$ is the closest distance from a point $\boldsymbol {r}$ to the surface $\mathcal {S}$.

For quantities defined only on the surface $\mathcal {S}$, like the normal vector $ {\boldsymbol {\hat {{n}}}}$ or the field line label $\alpha$, one is free to choose an arbitrary extension to the neighbourhood of $\mathcal {S}$. Any final result (e.g. the shape gradient or adjoint equations) should be independent of this choice. A particularly convenient choice is the normal extension $\tilde {f}(\boldsymbol {x}) = f(\boldsymbol {x}-b(\boldsymbol {x})\boldsymbol {\nabla } b(\boldsymbol {x}))$, as it implies $ {\boldsymbol {\hat {{n}}}}\boldsymbol {\cdot }\boldsymbol {\nabla } \tilde {f} = 0$ on $\mathcal {S}$. Vector functions $\boldsymbol {v}$ can be similarly extended.

The signed distance function can also be used to express the unit normal vector on $\mathcal {S}$ as $ {\boldsymbol {\hat {{n}}}} = \boldsymbol {\nabla } b$. Let us define

(A 10)\begin{equation} J_n = \int_\mathcal{S} \,\mathrm{d} S\; \chi\;b = 0, \end{equation}

with an arbitrary function $\chi$. The transport theorem (A 8) then yields

(A 11)\begin{equation} 0 = \delta J_n[\delta\boldsymbol{x}] = \int_{\mathcal{S}} \,\mathrm{d} S \; \chi\left[ \delta b [\delta\boldsymbol{x}] + ({\delta\boldsymbol{{x}}\boldsymbol{\cdot} {\boldsymbol{\hat{{n}}}}}) \right], \end{equation}

which must hold for any $\chi$, such that $\delta b[\delta \boldsymbol {x}] = - {\delta \boldsymbol {{x}}\boldsymbol {\cdot } {\boldsymbol {\hat {{n}}}}}$. Then, the shape derivative of the normal vector follows as $\delta {\boldsymbol {\hat {{n}}}}[\delta \boldsymbol {x}] = \boldsymbol {\nabla }(\delta b[\delta \boldsymbol {x}]) = -\boldsymbol {\nabla }( {\delta \boldsymbol {{x}}\boldsymbol {\cdot } {\boldsymbol {\hat {{n}}}}})$. If the unit normal vector is normally extended off $\mathcal {S}$, as is assumed in the remainder of this paper, it follows from (A 1) that

(A 12)\begin{equation} \delta{\boldsymbol{\hat{{n}}}} ={-}\boldsymbol{\nabla}_{\varGamma}({\delta\boldsymbol{{x}}\boldsymbol{\cdot} {\boldsymbol{\hat{{n}}}}}). \end{equation}

Appendix B. Derivations of shape derivatives

For ease of notation, we will in the following derivations write shape derivatives without the $[\delta \boldsymbol {x}]$ bracket, e.g. $\delta \omega [\delta \boldsymbol {x}]\rightarrow \delta \omega$, and drop tildes for extensions off the surface $\mathcal {S}$. Furthermore, we will take the field line label $\alpha$ (4.5) and the normal vector $ {\boldsymbol {\hat {{n}}}}$ to be normally extended off $\mathcal {S}$, such that $ {\boldsymbol {\hat {{n}}}}\boldsymbol {\cdot }\boldsymbol {\nabla }\tilde {\alpha }=0$ and $ {\boldsymbol {\hat {{n}}}}\boldsymbol {\cdot }\boldsymbol {\nabla }\boldsymbol {\tilde {\hat {n}}}=0$. See Appendix A.3 for more details on normal extensions.

B.1. Weak form of the Laplace equation

The weak form of the Laplace equation, previously given in (4.7), can be partially integrated to facilitate the calculation of the shape derivative:

(B 1)\begin{align} \mathcal{M} & = \int_{\mathcal{V}} \,\mathrm{d} V \; q_\omega \Delta \omega = \int_{\mathcal{V}} \,\mathrm{d} V \; \omega \Delta q_\omega + \int_{\mathcal{S}} \,\mathrm{d} S \left( q_\omega \boldsymbol{\nabla} \omega - \omega \boldsymbol{\nabla} q_\omega \right) \boldsymbol{\cdot} {\boldsymbol{\hat{{n}}}}\nonumber\\ & = \int_{\mathcal{V}} \,\mathrm{d} V \; \omega \Delta q_\omega - \int_{\mathcal{S}} \,\mathrm{d} S \; \left( q_\omega \boldsymbol{\nabla}\phi + \omega \boldsymbol{\nabla} q_\omega \right) \boldsymbol{\cdot} {\boldsymbol{\hat{{n}}}}, \end{align}

where the boundary condition on the magnetic field (4.2b) was used in the last equality. Using the transport theorems (A 6) and (A 8), the shape derivative of (B 1) is computed to be

(B 2)\begin{align} \delta\mathcal{M} & = \int_{\mathcal{V}} \,\mathrm{d} V \; \delta\omega \Delta q_\omega + \int_{\mathcal{S}} \,\mathrm{d} S \; \left\{ - \delta \omega \boldsymbol{\nabla} q_\omega \boldsymbol{\cdot} {\boldsymbol{\hat{{n}}}} - (q_\omega \boldsymbol{\nabla}\phi + \omega \boldsymbol{\nabla} q_\omega) \boldsymbol{\cdot} \delta{\boldsymbol{\hat{{n}}}} \right.\nonumber\\ & \left.\quad +\, ({\delta\boldsymbol{{x}}\boldsymbol{\cdot} {\boldsymbol{\hat{{n}}}}}) \left[ \omega \Delta q_\omega - ({\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla} + h) \left( q_\omega \boldsymbol{\nabla}\phi\boldsymbol{\cdot}{\boldsymbol{\hat{{n}}}} + \omega \boldsymbol{\nabla} q_\omega\boldsymbol{\cdot}{\boldsymbol{\hat{{n}}}} \right) \right]\right\}. \end{align}

The term involving the normal vector's shape derivative $\delta {\boldsymbol {\hat {{n}}}}$ can be further simplified using (A 12):

(B 3)\begin{align} & - \int_{\mathcal{S}} \,\mathrm{d} S (q_\omega \boldsymbol{\nabla}\phi + \omega \boldsymbol{\nabla} q_\omega) \boldsymbol{\cdot} \delta{\boldsymbol{\hat{{n}}}} = \int_{\mathcal{S}} \,\mathrm{d} S \left[ - ({\delta\boldsymbol{{x}}\boldsymbol{\cdot} {\boldsymbol{\hat{{n}}}}}) \boldsymbol{\nabla}_{\varGamma}\boldsymbol{\cdot} (q_\omega \boldsymbol{\nabla}_{\varGamma}\phi + \omega \boldsymbol{\nabla}_{\varGamma} q_\omega) \right]\nonumber\\ & \quad = \int_{\mathcal{S}} \,\mathrm{d} S ({\delta\boldsymbol{{x}}\boldsymbol{\cdot} {\boldsymbol{\hat{{n}}}}}) \left[\vphantom{\left.+ \omega\boldsymbol{\nabla}\boldsymbol{\nabla} q_\omega)\boldsymbol{\cdot}{\boldsymbol{\hat{{n}}}} -\omega \Delta q_\omega - \boldsymbol{\nabla} q_\omega \boldsymbol{\cdot} \boldsymbol{\breve{B}} \right]} h {\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}( q_\omega \boldsymbol{\nabla}\phi + \omega\boldsymbol{\nabla} q_\omega) + {\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}(q_\omega\boldsymbol{\nabla}\boldsymbol{\nabla}\phi\right.\nonumber\\ & \qquad \left.+\, \omega\boldsymbol{\nabla}\boldsymbol{\nabla} q_\omega)\boldsymbol{\cdot}{\boldsymbol{\hat{{n}}}} -\omega \Delta q_\omega - \boldsymbol{\nabla} q_\omega \boldsymbol{\cdot} \boldsymbol{\breve{B}} \right], \end{align}

where the surface divergence theorem (A 3) was used in the second equality. Inserting this expression back into (B 2), the shape derivative of $\mathcal {M}$ simplifies to

(B 4)\begin{equation} \delta\mathcal{M} = \int_{\mathcal{V}} \,\mathrm{d} V \; \delta\omega \Delta q_\omega - \int_{\mathcal{S}} \,\mathrm{d} S \; \left[ \delta \omega \boldsymbol{\nabla} q_\omega \boldsymbol{\cdot} {\boldsymbol{\hat{{n}}}} - ({\delta\boldsymbol{{x}}\boldsymbol{\cdot} {\boldsymbol{\hat{{n}}}}}) \boldsymbol{\breve{B}}\boldsymbol{\cdot}\boldsymbol{\nabla} q_\omega \right], \end{equation}

where we used (4.1).

B.2. Weak form of the straight field line equation

The shape derivative of the straight field line equation's weak form (4.8) follows from the transport theorem (A 8), as well as the shape derivatives of the field line label $\delta \alpha = -\phi \; \delta \iota + \delta \lambda$ and the normalised magnetic field $\delta \boldsymbol {\breve {B}} = \boldsymbol {\nabla }(\delta \omega )$:

(B 5)\begin{equation} \delta\mathcal{N} = \int_{\mathcal{S}} \,\mathrm{d} S \left[ q_\alpha \boldsymbol{\nabla}(\delta\omega) \boldsymbol{\cdot} \boldsymbol{\nabla}\alpha + q_\alpha \boldsymbol{\breve{B}} \boldsymbol{\cdot} \left( \boldsymbol{\nabla}(\delta\lambda) - \delta\iota \boldsymbol{\nabla}\phi \right) + ({\delta\boldsymbol{{x}}\boldsymbol{\cdot} {\boldsymbol{\hat{{n}}}}}){\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla} \left( q_\alpha \boldsymbol{\breve{B}} \boldsymbol{\cdot} \boldsymbol{\nabla}\alpha \right) \right], \end{equation}

where the summed curvature term in (A 8) vanishes here due to the straight field line equation (4.4). The first term is partially integrated using (A 3):

(B 6)\begin{equation} \int_{\mathcal{S}} \,\mathrm{d} S\; q_\alpha \boldsymbol{\nabla}(\delta\omega) \boldsymbol{\cdot} \boldsymbol{\nabla}\alpha = \int_{\mathcal{S}} \,\mathrm{d} S\; q_\alpha \boldsymbol{\nabla}_{\varGamma}(\delta\omega) \boldsymbol{\cdot} \boldsymbol{\nabla}_{\varGamma} \alpha = \int_{\mathcal{S}} \,\mathrm{d} S \left[ - \delta\omega \boldsymbol{\nabla}_{\varGamma} \boldsymbol{\cdot} \left(q_\alpha \boldsymbol{\nabla}_{\varGamma} \alpha\right) \right], \end{equation}

as well as the $\delta \lambda$ term:

(B 7)\begin{equation} \int_{\mathcal{S}} \,\mathrm{d} S\; q_\alpha \boldsymbol{\breve{B}} \boldsymbol{\cdot} \boldsymbol{\nabla}(\delta\lambda) = \int_{\mathcal{S}} \,\mathrm{d} S\; q_\alpha \boldsymbol{\breve{B}} \boldsymbol{\cdot} \boldsymbol{\nabla}_{\varGamma}(\delta\lambda) ={-} \int_{\mathcal{S}} \,\mathrm{d} S\; \delta\lambda\; \boldsymbol{\nabla}_{\varGamma} \boldsymbol{\cdot} \left( q_\alpha \boldsymbol{\breve{B}} \right). \end{equation}

The last term in (B 5) can also be simplified using (4.4):

(B 8)\begin{equation} {\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\left( q_\alpha \boldsymbol{\breve{B}} \boldsymbol{\cdot} \boldsymbol{\nabla}\alpha \right) = q_\alpha \left( {\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\boldsymbol{\breve{B}}\boldsymbol{\cdot}\boldsymbol{\nabla}\alpha + \boldsymbol{\breve{B}}\boldsymbol{\cdot}\boldsymbol{\nabla}\boldsymbol{\nabla}\alpha\boldsymbol{\cdot}{\boldsymbol{\hat{{n}}}} \right) = q_\alpha \left( {\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\boldsymbol{\breve{B}} - \boldsymbol{\breve{B}}\boldsymbol{\cdot}\boldsymbol{\nabla}{\boldsymbol{\hat{{n}}}} \right)\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}\alpha. \end{equation}

The shape derivative of $\mathcal {N}$ (B 5) finally reduces to

(B 9)\begin{align} \delta\mathcal{N} & = \int_{\mathcal{S}} \,\mathrm{d} S \left[ - \delta\omega \;\boldsymbol{\nabla}_{\varGamma} \boldsymbol{\cdot} \left(q_\alpha \boldsymbol{\nabla}_{\varGamma} \alpha\right) - \delta\iota\; q_\alpha \boldsymbol{\breve{B}} \boldsymbol{\cdot} \boldsymbol{\nabla}\phi - \delta\lambda\; \boldsymbol{\nabla}_{\varGamma} \boldsymbol{\cdot} \left( q_\alpha \boldsymbol{\breve{B}} \right)\right. \nonumber\\ & \quad\left. + ({\delta\boldsymbol{{x}}\boldsymbol{\cdot} {\boldsymbol{\hat{{n}}}}}) q_\alpha \left( {\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\boldsymbol{\breve{B}} - \boldsymbol{\breve{B}}\boldsymbol{\cdot}\boldsymbol{\nabla}{\boldsymbol{\hat{{n}}}} \right)\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}\alpha \right]. \end{align}

B.3. Quasi-symmetry figure of merit

Using the transport theorem (A 8), we can express the shape derivative of the quasi-symmetry figure of merit (4.18) as

(B 10)\begin{equation} \delta f_\mathrm{QS} = \int_{\mathcal{S}} \,\mathrm{d} S \left\{ v_\mathrm{QS}\; \delta v_\mathrm{QS} + \frac{1}{2} ({\delta\boldsymbol{{x}}\boldsymbol{\cdot} {\boldsymbol{\hat{{n}}}}})({\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}+h)v_\mathrm{QS}^2 \right\}. \end{equation}

First, note $\delta \boldsymbol {\breve {B}} = \boldsymbol {\nabla }(\delta \omega )$, which also gives the shape derivative of the normalised magnetic field strength as

(B 11)\begin{equation} \delta \breve{B} = \delta \left( \sqrt{\boldsymbol{\breve{B}}\boldsymbol{\cdot}\boldsymbol{\breve{B}}} \right) = \frac{\boldsymbol{\breve{B}}\boldsymbol{\cdot}\boldsymbol{\nabla}(\delta\omega)}{\breve{B}}. \end{equation}

Furthermore, recalling $|\boldsymbol {g}_{\psi }|/G = \breve {B}/{\left | \boldsymbol {\nabla }_{\varGamma }\alpha \right |}$ from (3.1), we obtain

(B 12)\begin{equation} \delta\left( {\left| \boldsymbol{\breve{g}}_\psi \right|} \right) = {\left| \boldsymbol{\breve{g}}_\psi \right|} \left[ \frac{\boldsymbol{\breve{B}}\boldsymbol{\cdot}\boldsymbol{\nabla}(\delta\omega)}{\breve{B}^2} - \frac{\boldsymbol{\nabla}_{\varGamma}\alpha\boldsymbol{\cdot} \left( -\delta\iota \boldsymbol{\nabla}_{\varGamma}\phi + \boldsymbol{\nabla}_{\varGamma} (\delta\lambda) \right) }{{\left| \boldsymbol{\nabla}_{\varGamma} \alpha \right|}^2} \right]. \end{equation}

Using (B 11), (B 12), (4.3b) and (A 12), the shape derivative of $v_\mathrm {QS}$ (4.19) can be written as

(B 13)\begin{align} \delta v_\mathrm{QS} & = \boldsymbol{\nabla}_{\varGamma}(\delta\omega)\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}\breve{B} + ({\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\breve{B})\left[ -({\delta\boldsymbol{{x}}\boldsymbol{\cdot} {\boldsymbol{\hat{{n}}}}}) {\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\boldsymbol{\breve{B}}\boldsymbol{\cdot}{\boldsymbol{\hat{{n}}}} + \boldsymbol{\breve{B}}\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}({\delta\boldsymbol{{x}}\boldsymbol{\cdot} {\boldsymbol{\hat{{n}}}}}) \right]\nonumber\\ & \quad + \boldsymbol{\breve{B}}\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma} \left( \frac{\boldsymbol{\breve{B}}\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}(\delta\omega)}{\breve{B}} \right) - \delta\iota \; \boldsymbol{\breve{B}}\times{\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma} \breve{B} \; {\left| \boldsymbol{\breve{g}}_\psi \right|} -\left(\iota-N/M\right)\;{\left| \boldsymbol{\breve{g}}_\psi \right|}\nonumber\\ & \quad \times\left[ \boldsymbol{\nabla}_{\varGamma}(\delta\omega)\!\times\!{\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma} \breve{B} \!-\! \boldsymbol{\breve{B}}\!\times\!\boldsymbol{\nabla}_{\varGamma}({\delta\boldsymbol{{x}}\boldsymbol{\cdot} {\boldsymbol{\hat{{n}}}}})\boldsymbol{\cdot}{\boldsymbol{\hat{{n}}}} ({\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla} \breve{B}) \!+\! \boldsymbol{\breve{B}}\!\times\!{\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma} \left( \frac{\boldsymbol{\breve{B}}\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}(\delta\omega)}{\breve{B}} \right)\right.\nonumber\\ & \left. \quad + \left( \frac{\boldsymbol{\breve{B}}\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}(\delta\omega)}{\breve{B}^2} - \frac{\boldsymbol{\nabla}_{\varGamma}\alpha\boldsymbol{\cdot} \left( -\delta\iota \boldsymbol{\nabla}_{\varGamma}\phi + \boldsymbol{\nabla}_{\varGamma} (\delta\lambda) \right) }{{\left| \boldsymbol{\nabla}_{\varGamma} \alpha \right|}^2} \right) \boldsymbol{\breve{B}}\times{\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}\breve{B} \right]. \end{align}

The first term in (B 10) can then be partially integrated to

(B 14)\begin{align} & \int_{\mathcal{S}} \,\mathrm{d} S\; v_\mathrm{QS}\; \delta v_\mathrm{QS} = \int_{\mathcal{S}} \,\mathrm{d} S \left\{ \delta\omega \;\boldsymbol{\nabla}_{\varGamma}\boldsymbol{\cdot} \left[{-}v_\mathrm{QS} \boldsymbol{\nabla}_{\varGamma} \breve{B} + \frac{\boldsymbol{\breve{B}}}{\breve{B}} \boldsymbol{\nabla}_{\varGamma}\boldsymbol{\cdot}(v_\mathrm{QS} \boldsymbol{\breve{B}})\right.\right.\nonumber\\ & \quad + \left(\iota-N/M\right) \left( {\left| \boldsymbol{\breve{g}}_\psi \right|}\; v_\mathrm{QS} \; {\boldsymbol{\hat{{n}}}}\times\boldsymbol{\nabla}_{\varGamma}\breve{B} - \frac{\boldsymbol{\breve{B}}}{\breve{B}} \boldsymbol{\nabla}_{\varGamma}\boldsymbol{\cdot}\left({\left| \boldsymbol{\breve{g}}_\psi \right|}\;v_\mathrm{QS} \boldsymbol{\breve{B}}\times{\boldsymbol{\hat{{n}}}}\right)\right.\nonumber\\ & \quad\left.\left. +\, v_\mathrm{QS}{\left| \boldsymbol{\breve{g}}_\psi \right|} \frac{\boldsymbol{\breve{B}}}{\widetilde{B^2}} \boldsymbol{\breve{B}}\times{\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}\breve{B} \right) \right] \!-\! \delta\iota \; v_\mathrm{QS}{\left| \boldsymbol{\breve{g}}_\psi \right|} \boldsymbol{\breve{B}}\times{\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}\breve{B} \left[ \left(\iota-N/M\right) \frac{\boldsymbol{\nabla}_{\varGamma}\alpha\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}\phi}{{\left| \boldsymbol{\nabla}_{\varGamma}\alpha \right|}^2} \!+\! 1\right] \nonumber\\ & \quad - \delta\lambda \left(\iota-N/M\right)\;\boldsymbol{\nabla}_{\varGamma}\boldsymbol{\cdot}\left[ v_\mathrm{QS} {\left| \boldsymbol{\breve{g}}_\psi \right|} \frac{\boldsymbol{\nabla}_{\varGamma}\alpha}{{\left| \boldsymbol{\nabla}_{\varGamma}\alpha \right|}^2} \; \boldsymbol{\breve{B}}\times{\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}\breve{B} \right] \nonumber\\ & \quad\left. -\, ({\delta\boldsymbol{{x}}\boldsymbol{\cdot} {\boldsymbol{\hat{{n}}}}})\left[ \boldsymbol{\breve{B}}\boldsymbol{\cdot} \boldsymbol{\nabla}_{\varGamma}\left( v_\mathrm{QS}\;{\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\breve{B} \right) \!-\! \left(\iota\!-\!N/M\right)\; \boldsymbol{\nabla}_{\varGamma}\boldsymbol{\cdot}\left( v_\mathrm{QS} {\left| \boldsymbol{\breve{g}}_\psi \right|} \boldsymbol{\breve{B}}\times(\boldsymbol{\nabla}\breve{B} \!-\!\boldsymbol{\nabla}_{\varGamma}\breve{B} ) \right) \right] \frac{\boldsymbol{\breve{B}}}{\breve{B}}\right\}, \end{align}

with repeated use of the surface divergence theorem (A 3), and using $\boldsymbol {\nabla }_{\varGamma }\boldsymbol {\cdot }\boldsymbol {\breve {B}} = - {\boldsymbol {\hat {{n}}}}\boldsymbol {\cdot }\boldsymbol {\nabla }\boldsymbol {\breve {B}}\boldsymbol {\cdot } {\boldsymbol {\hat {{n}}}}$ from the magnetic field being divergence-less and (A 2). The terms in the last line can be simplified, first using

(B 15)\begin{equation} \boldsymbol{\breve{B}}\boldsymbol{\cdot} \boldsymbol{\nabla}_{\varGamma}\left( v_\mathrm{QS}\;{\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\breve{B} \right) = ({\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\breve{B}) \boldsymbol{\breve{B}}\boldsymbol{\cdot}\boldsymbol{\nabla} v_\mathrm{QS} + v_\mathrm{QS}\left( \boldsymbol{\breve{B}}\boldsymbol{\cdot}\boldsymbol{\nabla}{\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\breve{B} + \boldsymbol{\breve{B}}\boldsymbol{\cdot}\boldsymbol{\nabla}\boldsymbol{\nabla}\breve{B}\boldsymbol{\cdot}{\boldsymbol{\hat{{n}}}} \right) . \end{equation}

Furthermore, note that

(B 16)\begin{equation} \boldsymbol{\nabla}_{\varGamma}\boldsymbol{\cdot}(\boldsymbol{\breve{B}}\times\boldsymbol{\nabla}\breve{B}) ={-} {\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}(\boldsymbol{\breve{B}}\times\boldsymbol{\nabla}\breve{B})\boldsymbol{\cdot}{\boldsymbol{\hat{{n}}}}, \end{equation}

where we used (A 2), $\boldsymbol {\nabla }\times \boldsymbol {\breve {B}} = 0$ and $\boldsymbol {\nabla }\times \boldsymbol {\nabla }\breve {B}=0$; and

(B 17)\begin{equation} \boldsymbol{\breve{B}}\times\boldsymbol{\nabla}\breve{B}\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma} {\left| \boldsymbol{\breve{g}}_\psi \right|} ={-}{\left| \boldsymbol{\breve{g}}_\psi \right|}\boldsymbol{\breve{B}}\times\boldsymbol{\nabla}\breve{B}\boldsymbol{\cdot}\left( \frac{1}{\breve{B}} {\boldsymbol{\hat{{n}}}}({\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\breve{B}) + \frac{1}{{\left| \boldsymbol{\nabla}_{\varGamma}\alpha \right|}} \boldsymbol{\nabla}_{\varGamma}{\left| \boldsymbol{\nabla}_{\varGamma}\alpha \right|} \right), \end{equation}

using (A 1). The terms of the last parenthesis in (B 14) now simplify to

(B 18)\begin{align} & \boldsymbol{\nabla}_{\varGamma}\boldsymbol{\cdot}\left( v_\mathrm{QS}\; {\left| \boldsymbol{\breve{g}}_\psi \right|}\; \boldsymbol{\breve{B}}\times\boldsymbol{\nabla}\breve{B} \right)\nonumber\\ & \quad = {\left| \boldsymbol{\breve{g}}_\psi \right|} \left[ \boldsymbol{\breve{B}}\times\boldsymbol{\nabla}\breve{B}\boldsymbol{\cdot}\left( {\left| \boldsymbol{\nabla}_{\varGamma}\alpha \right|} \boldsymbol{\nabla}_{\varGamma} \left( \frac{v_\mathrm{QS}}{{\left| \boldsymbol{\nabla}_{\varGamma}\alpha \right|}}\right) \!-\! v_\mathrm{QS}\;{\boldsymbol{\hat{{n}}}} \frac{{\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\breve{B}}{\breve{B}} \right) \!-\! v_\mathrm{QS}\; {\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}(\boldsymbol{\breve{B}}\times\boldsymbol{\nabla}\breve{B})\boldsymbol{\cdot}{\boldsymbol{\hat{{n}}}} \right], \end{align}

and

(B 19)\begin{equation} \boldsymbol{\nabla}_{\varGamma} \boldsymbol{\cdot} \left( v_\mathrm{QS}\; {\left| \boldsymbol{\breve{g}}_\psi \right|}\; \boldsymbol{\breve{B}}\times \boldsymbol{\nabla}_{\varGamma}\breve{B} \right) = h\; v_\mathrm{QS}\; {\left| \boldsymbol{\breve{g}}_\psi \right|}\; {\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot} \boldsymbol{\breve{B}}\times \boldsymbol{\nabla}_{\varGamma}\breve{B}, \end{equation}

where we used the fact that $\boldsymbol {\breve {B}}\times \boldsymbol {\nabla }_{\varGamma }\breve {B}$ is normal to the surface, and $\boldsymbol {\nabla }_{\varGamma }\boldsymbol {\cdot } {\boldsymbol {\hat {{n}}}} = h$.

We now turn to the normal derivative of $v_\mathrm {QS}$, the second term in (B 10). Using the fact that $ {\boldsymbol {\hat {{n}}}}$ and $\alpha$ are normally extended, we can write

(B 20)\begin{equation} {\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}(\boldsymbol{\breve{B}}\times{\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\breve{B}) ={-}{\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}(\boldsymbol{\breve{B}}\times\boldsymbol{\nabla}\breve{B})\boldsymbol{\cdot}{\boldsymbol{\hat{{n}}}} \end{equation}

and

(B 21)\begin{equation} {\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}{\left| \boldsymbol{\nabla}_{\varGamma}\alpha \right|} = \frac{{\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\boldsymbol{\nabla}_{\varGamma}\alpha\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}\alpha}{{\left| \boldsymbol{\nabla}_{\varGamma}\alpha \right|}} =\frac{{\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\boldsymbol{\nabla}\alpha\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}\alpha}{{\left| \boldsymbol{\nabla}_{\varGamma}\alpha \right|}} ={-}\frac{\boldsymbol{\nabla}_{\varGamma}\alpha\boldsymbol{\cdot}\boldsymbol{\nabla}{\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}{\boldsymbol{\hat{{n}}}}}{{\left| \boldsymbol{\nabla}_{\varGamma}\alpha \right|}}, \end{equation}

such that

(B 22)\begin{equation} {\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\left( {\left| \boldsymbol{\breve{g}}_\psi \right|} \right) = {\left| \boldsymbol{\breve{g}}_\psi \right|} \left[ \frac{{\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\breve{B}}{\breve{B}} + \frac{ \boldsymbol{\nabla}_{\varGamma}\alpha\boldsymbol{\cdot}\boldsymbol{\nabla}{\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}\alpha}{{\left| \boldsymbol{\nabla}_{\varGamma}\alpha \right|}^2} \right]. \end{equation}

This allows us to express the normal derivative of $v_\mathrm {QS}$ as

(B 23)\begin{align} & {\boldsymbol{\hat{{n}}}} \boldsymbol{\cdot} \boldsymbol{\nabla} v_\mathrm{QS} = {\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\boldsymbol{\breve{B}}\boldsymbol{\cdot}\boldsymbol{\nabla}\breve{B} + {\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\boldsymbol{\nabla}\breve{B}\boldsymbol{\cdot}\boldsymbol{\breve{B}}\nonumber\\ & \quad - (\iota\!-\!N/M) {\left| \boldsymbol{\breve{g}}_\psi \right|} \left[ \!-{\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}(\boldsymbol{\breve{B}}\times\boldsymbol{\nabla}\breve{B})\boldsymbol{\cdot}{\boldsymbol{\hat{{n}}}} \!+\! \left( \frac{{\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\breve{B}}{\breve{B}} \!+\! \frac{ \boldsymbol{\nabla}_{\varGamma}\alpha\boldsymbol{\cdot}\boldsymbol{\nabla}{\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}\alpha}{{\left| \boldsymbol{\nabla}_{\varGamma}\alpha \right|}^2} \right) \boldsymbol{\breve{B}}\!\times\!{\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\breve{B} \right]\!. \end{align}

Combining (B 10), (B 14) (and simplifications thereafter) and (B 23), the shape derivative of $f_\mathrm {QS}$ can finally be expressed as

(B 24)\begin{align} \delta f_\mathrm{QS} & = \int_{\mathcal{S}} \,\mathrm{d} S\; \left\{ \delta\omega \;\boldsymbol{\nabla}_{\varGamma}\boldsymbol{\cdot} \left[{-}v_\mathrm{QS} \boldsymbol{\nabla}_{\varGamma} \breve{B} + \frac{\boldsymbol{\breve{B}}}{\breve{B}} \boldsymbol{\nabla}_{\varGamma}\boldsymbol{\cdot}(v_\mathrm{QS} \boldsymbol{\breve{B}})\right.\right.\nonumber\\ & \left.\quad + \left(\iota-N/M\right) \left( v_\mathrm{QS} \; \boldsymbol{\breve{g}}_\psi\times\boldsymbol{\nabla}_{\varGamma}\breve{B} - \boldsymbol{\breve{B}}\; \boldsymbol{\nabla}_{\varGamma}\boldsymbol{\cdot}\left(\frac{1}{\breve{B}} v_\mathrm{QS} \boldsymbol{\breve{B}}\times\boldsymbol{\breve{g}}_\psi\right) \right) \vphantom{\left\{ \delta\omega \;\boldsymbol{\nabla}_{\varGamma}\boldsymbol{\cdot} \left[{-}v_\mathrm{QS} \boldsymbol{\nabla}_{\varGamma} \breve{B} + \frac{\boldsymbol{\breve{B}}}{\breve{B}} \boldsymbol{\nabla}_{\varGamma}\boldsymbol{\cdot}(v_\mathrm{QS} \boldsymbol{\breve{B}})\right.\right.}\right] \nonumber\\ & \quad - \delta\iota \; v_\mathrm{QS} \boldsymbol{\breve{B}}\times\boldsymbol{\breve{g}}_\psi\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}\breve{B} \left[ \left(\iota-N/M\right) \frac{\boldsymbol{\nabla}_{\varGamma}\alpha\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}\phi}{{\left| \boldsymbol{\nabla}_{\varGamma}\alpha \right|}^2} + 1\right] \nonumber\\ & \quad - \delta\lambda \;\left(\iota-N/M\right)\;\boldsymbol{\nabla}_{\varGamma}\boldsymbol{\cdot}\left[ v_\mathrm{QS} \frac{\boldsymbol{\nabla}_{\varGamma}\alpha}{{\left| \boldsymbol{\nabla}_{\varGamma}\alpha \right|}^2} \; \boldsymbol{\breve{B}}\times\boldsymbol{\breve{g}}_\psi\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}\breve{B} \right] \nonumber\\ & \quad + ({\delta\boldsymbol{{x}}\boldsymbol{\cdot} {\boldsymbol{\hat{{n}}}}}) \left[ \left(\iota-N/M\right)\; {\left| \boldsymbol{\breve{g}}_\psi \right|} \; \boldsymbol{\breve{B}}\times\boldsymbol{\nabla}\breve{B}\boldsymbol{\cdot} \left( \boldsymbol{\nabla}_{\varGamma} v_\mathrm{QS} - v_\mathrm{QS} \frac{\boldsymbol{\nabla}_{\varGamma} {\left| \boldsymbol{\nabla}_{\varGamma}\alpha \right|}}{{\left| \boldsymbol{\nabla}_{\varGamma}\alpha \right|}} \right)\right.\nonumber\\ & \quad + \frac{h}{2} v_\mathrm{QS}^2 - ({\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\breve{B}) \boldsymbol{\nabla}_{\varGamma}\boldsymbol{\cdot}\left( v_\mathrm{QS} \boldsymbol{\breve{B}} \right) - v_\mathrm{QS}\left(\boldsymbol{\breve{B}}\boldsymbol{\cdot}\boldsymbol{\nabla}{\boldsymbol{\hat{{n}}}} - {\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\boldsymbol{\breve{B}} \right)\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}\breve{B} \nonumber\\ & \left.\left.\quad -\, v_\mathrm{QS} \; \boldsymbol{\breve{B}}\times\boldsymbol{\breve{g}}_\psi\boldsymbol{\cdot}\boldsymbol{\nabla} \breve{B} \; \left( \iota - N/M\right) \left( \frac{\boldsymbol{\nabla}_{\varGamma}\alpha\boldsymbol{\cdot}\boldsymbol{\nabla}{\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}\alpha}{{\left| \boldsymbol{\nabla}_{\varGamma} \alpha \right|}^2} -h \right) \vphantom{\left\{ \delta\omega \;\boldsymbol{\nabla}_{\varGamma}\boldsymbol{\cdot} \left[{-}v_\mathrm{QS} \boldsymbol{\nabla}_{\varGamma} \breve{B} + \frac{\boldsymbol{\breve{B}}}{\breve{B}} \boldsymbol{\nabla}_{\varGamma}\boldsymbol{\cdot}(v_\mathrm{QS} \boldsymbol{\breve{B}})\right.\right.}\right] \vphantom{\left\{ \delta\omega \;\boldsymbol{\nabla}_{\varGamma}\boldsymbol{\cdot} \left[{-}v_\mathrm{QS} \boldsymbol{\nabla}_{\varGamma} \breve{B} + \frac{\boldsymbol{\breve{B}}}{\breve{B}} \boldsymbol{\nabla}_{\varGamma}\boldsymbol{\cdot}(v_\mathrm{QS} \boldsymbol{\breve{B}})\right.\right.}\right\}, \end{align}

where we used

(B 25)\begin{equation} \boldsymbol{\breve{B}}\boldsymbol{\cdot}\boldsymbol{\nabla}{\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\breve{B} - {\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\boldsymbol{\breve{B}}\boldsymbol{\cdot}\boldsymbol{\nabla}\breve{B} = \left(\boldsymbol{\breve{B}}\boldsymbol{\cdot}\boldsymbol{\nabla}{\boldsymbol{\hat{{n}}}} - {\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\boldsymbol{\breve{B}} \right)\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}\breve{B} +\boldsymbol{\nabla}_{\varGamma} \boldsymbol{\cdot} \boldsymbol{\breve{B}}\;({\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\breve{B}). \end{equation}

Combining (B 4), (B 9) and (B 24), and rearranging, the shape derivative of the Lagrangian for the quasi-symmetric figure of merit can be written as

(B 26)\begin{align} & \delta \mathcal{L}_\mathrm{QS} ={-}\int_{\mathcal{S}} \,\mathrm{d} S\; \delta\lambda \; \boldsymbol{\nabla}_{\varGamma}\boldsymbol{\cdot}\left[ q_\alpha\boldsymbol{\breve{B}} + \left(\iota-N/M\right) v_\mathrm{QS} \frac{\boldsymbol{\nabla}_{\varGamma}\alpha}{{\left| \boldsymbol{\nabla}_{\varGamma}\alpha \right|}^2} \; \boldsymbol{\breve{B}}\times\boldsymbol{\breve{g}}_\psi\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}\breve{B} \right] \nonumber\\ & \quad -\delta\iota\; \int_{\mathcal{S}} \,\mathrm{d} S \left\{ q_\alpha \boldsymbol{\breve{B}} \boldsymbol{\cdot} \boldsymbol{\nabla}\phi + v_\mathrm{QS} \boldsymbol{\breve{B}}\times\boldsymbol{\breve{g}}_\psi\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}\breve{B} \left[ \left(\iota-N/M\right) \frac{\boldsymbol{\nabla}_{\varGamma}\alpha\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}\phi}{{\left| \boldsymbol{\nabla}_{\varGamma}\alpha \right|}^2} + 1\right] \right\} \nonumber\\ & \quad + \int_{\mathcal{V}} \,\mathrm{d} V \; \delta\omega \; \Delta q_\omega - \int_{\mathcal{S}} \,\mathrm{d} S\; \delta\omega \left\{ {\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla} q_\omega + \boldsymbol{\nabla}_{\varGamma}\boldsymbol{\cdot} \left[{-}v_\mathrm{QS} \boldsymbol{\nabla}_{\varGamma} \breve{B} + \frac{\boldsymbol{\breve{B}}}{\breve{B}} \boldsymbol{\nabla}_{\varGamma}\boldsymbol{\cdot}(v_\mathrm{QS} \boldsymbol{\breve{B}})\right.\right. \nonumber\\ & \left.\left.\quad + \left(\iota-N/M\right) \left( v_\mathrm{QS} \; \boldsymbol{\breve{g}}_\psi\times\boldsymbol{\nabla}_{\varGamma}\breve{B} - \boldsymbol{\breve{B}}\; \boldsymbol{\nabla}_{\varGamma}\boldsymbol{\cdot}\left(\frac{1}{\breve{B}} v_\mathrm{QS} \boldsymbol{\breve{B}}\times\boldsymbol{\breve{g}}_\psi\right) \right) \vphantom{\left\{ \delta\omega \;\boldsymbol{\nabla}_{\varGamma}\boldsymbol{\cdot} \left[{-}v_\mathrm{QS} \boldsymbol{\nabla}_{\varGamma} \breve{B} + \frac{\boldsymbol{\breve{B}}}{\breve{B}} \boldsymbol{\nabla}_{\varGamma}\boldsymbol{\cdot}(v_\mathrm{QS} \boldsymbol{\breve{B}})\right.\right.}\right] \vphantom{\left\{ \delta\omega \;\boldsymbol{\nabla}_{\varGamma}\boldsymbol{\cdot} \left[{-}v_\mathrm{QS} \boldsymbol{\nabla}_{\varGamma} \breve{B} + \frac{\boldsymbol{\breve{B}}}{\breve{B}} \boldsymbol{\nabla}_{\varGamma}\boldsymbol{\cdot}(v_\mathrm{QS} \boldsymbol{\breve{B}})\right.\right.}\right\} \nonumber\\ & \quad + \int_{\mathcal{S}} \,\mathrm{d} S ({\delta\boldsymbol{{x}}\boldsymbol{\cdot} {\boldsymbol{\hat{{n}}}}}) \left\{\!\!\vphantom{\frac{h}{2}} - ({\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\breve{B}) \boldsymbol{\nabla}_{\varGamma}\boldsymbol{\cdot}\left( v_\mathrm{QS} \boldsymbol{\breve{B}} \right) - v_\mathrm{QS}\;\left(\boldsymbol{\breve{B}}\boldsymbol{\cdot}\boldsymbol{\nabla}{\boldsymbol{\hat{{n}}}} - {\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\boldsymbol{\breve{B}} \right)\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}\breve{B} \right.\nonumber\\ & \quad + \left(\iota-N/M\right) {\left| \boldsymbol{\breve{g}}_\psi \right|} \boldsymbol{\breve{B}}\times\boldsymbol{\nabla}\breve{B}\boldsymbol{\cdot} \left[ {\left| \boldsymbol{\nabla}_{\varGamma}\alpha \right|} \boldsymbol{\nabla}_{\varGamma}\left( \frac{v_\mathrm{QS}}{{\left| \boldsymbol{\nabla}_{\varGamma}\alpha \right|}} \right) + {\boldsymbol{\hat{{n}}}}\; v_\mathrm{QS} \left( \frac{\boldsymbol{\nabla}_{\varGamma}\alpha\boldsymbol{\cdot}\boldsymbol{\nabla}{\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}\alpha}{{\left| \boldsymbol{\nabla}_{\varGamma} \alpha \right|}^2} -h \right) \right] \nonumber\\ & \left.\quad +\, \boldsymbol{\breve{B}}\boldsymbol{\cdot}\boldsymbol{\nabla} q_\omega + q_\alpha \left( {\boldsymbol{\hat{{n}}}}\boldsymbol{\cdot}\boldsymbol{\nabla}\boldsymbol{\breve{B}} - \boldsymbol{\breve{B}}\boldsymbol{\cdot}\boldsymbol{\nabla}{\boldsymbol{\hat{{n}}}} \right)\boldsymbol{\cdot}\boldsymbol{\nabla}_{\varGamma}\alpha + \frac{h}{2} v_\mathrm{QS}^2, \right\}. \end{align}

The shape derivative of the Lagrangian directly provides the adjoint equations for $q_\omega$ and $q_\alpha$, as well as the shape gradient, as shown in § 4.2.

References

REFERENCES

Anderson, F.S.B., Almagri, A.F., Anderson, D.T., Matthews, P.G., Talmadge, J.N. & Shohet, J.L. 1995 The helically symmetric experiment, (HSX) goals, design and status. Fusion Technol. 27 (3 T), 273277.CrossRefGoogle Scholar
Antonsen, T., Paul, E.J. & Landreman, M. 2019 Adjoint approach to calculating shape gradients for three-dimensional magnetic confinement equilibria. J. Plasma Phys. 85 (2), 905850207.CrossRefGoogle Scholar
Bader, A., Drevlak, M., Anderson, D.T., Faber, B.J., Hegna, C.C., Likin, K.M., Schmitt, J.C. & Talmadge, J.N. 2019 Stellarator equilibria with reactor relevant energetic particle losses. J. Plasma Phys. 85 (5), 905850508.CrossRefGoogle Scholar
Beidler, C., Grieger, G., Herrnegger, F., Harmeyer, E., Kisslinger, J., Lotz, W., Maassberg, H., Merkel, P., Nührenberg, J., Rau, F., et al. 1990 Physics and engineering design for wendelstein VII-X. Fusion Technol. 17 (1), 148168.CrossRefGoogle Scholar
Boozer, A.H. 2019 Curl-free magnetic fields for stellarator optimization. Phys. Plasmas 26 (10), 102504.CrossRefGoogle Scholar
Burby, J.W., Kallinikos, N. & MacKay, R.S. 2020 Some mathematics for quasi-symmetry. J. Math. Phys. 61 (9), 093503.CrossRefGoogle Scholar
Delfour, M.C. & Zolésio, J.P. 2011 Shapes and Geometries. Advances in Design and Control. PUBNAMESociety for Industrial and Applied Mathematics.CrossRefGoogle Scholar
Dewar, R., Hole, M., McGann, M., Mills, R. & Hudson, S. 2008 Relaxed plasma equilibria and entropy-related plasma self-organization principles. Entropy 10 (4), 621634.CrossRefGoogle Scholar
Drevlak, M., Brochard, F., Helander, P., Kisslinger, J., Mikhailov, M., Nührenberg, C., Nührenberg, J. & Turkin, Y. 2013 ESTELL: a quasi-toroidally symmetric stellarator. Contrib. Plasma Phys. 53 (6), 459468.CrossRefGoogle Scholar
Garren, D.A. & Boozer, A.H. 1991 Existence of quasihelically symmetric stellarators. Phys. Fluids B 3 (10), 28222834.CrossRefGoogle Scholar
Geraldini, A., Landreman, M. & Paul, E. 2021 An adjoint method for determining the sensitivity of island size to magnetic field variations. J. Plasma Phys. 87 (3), 905870302.CrossRefGoogle Scholar
Giuliani, A., Wechsung, F., Cerfon, A., Stadler, G. & Landreman, M. 2020 Single-stage gradient-based stellarator coil design: Optimization for near-axis quasi-symmetry. arXiv:2010.02033.CrossRefGoogle Scholar
Greene, J.M., Mackay, R.S. & Stark, J. 1986 Boundary circles for area-preserving maps. Physica D 21 (2–3), 267295.CrossRefGoogle Scholar
Hall, L.S. & McNamara, B. 1975 Three-dimensional equilibrium of the anisotropic, finite-pressure guiding-center plasma: theory of the magnetic plasma. Phys. Fluids 18 (5), 552.CrossRefGoogle Scholar
Helander, P. 2014 Theory of plasma confinement in non-axisymmetric magnetic fields. Rep. Prog. Phys. 77 (8), 087001.CrossRefGoogle ScholarPubMed
Henneberg, S.A., Drevlak, M. & Helander, P. 2020 Improving fast-particle confinement in quasi-axisymmetric stellarator optimization. Plasma Phys. Control. Fusion 62 (1), 014023.CrossRefGoogle Scholar
Henneberg, S.A., Drevlak, M., Nührenberg, C., Beidler, C.D., Turkin, Y., Loizu, J. & Helander, P. 2019 Properties of a new quasi-axisymmetric configuration. Nucl. Fusion 59 (2), 026014.CrossRefGoogle Scholar
Hirshman, S.P., van RIJ, W.I. & Merkel, P. 1986 Three-dimensional free boundary calculations using a spectral Green's function method. Comput. Phys. Commun. 43 (1), 143155.CrossRefGoogle Scholar
Hudson, S.R., Dewar, R.L., Dennis, G., Hole, M.J., McGann, M., von Nessi, G. & Lazerson, S. 2012 Computation of multi-region relaxed magnetohydrodynamic equilibria. Phys. Plasmas 19 (11), 112502.CrossRefGoogle Scholar
Hudson, S.R., Zhu, C., Pfefferlé, D. & Gunderson, L. 2018 Differentiating the shape of stellarator coils with respect to the plasma boundary. Phys. Lett. A 382 (38), 27322737.CrossRefGoogle Scholar
Ku, L.P. & Boozer, A.H. 2011 New classes of quasi-helically symmetric stellarators. Nucl. Fusion 51 (1), 013004.CrossRefGoogle Scholar
Landreman, M., Medasani, B. & Zhu, C. 2021 Stellarator optimization for good magnetic surfaces at the same time as quasisymmetry. Phys. Plasmas 28 (9), 092505.CrossRefGoogle Scholar
Landreman, M. & Paul, E. 2018 Computing local sensitivity and tolerances for stellarator physics properties using shape gradients. Nucl. Fusion 58 (7), 076023.CrossRefGoogle Scholar
Landreman, M. & Paul, E. 2021 Magnetic fields with precise quasisymmetry. arXiv:2108.03711.CrossRefGoogle Scholar
Malhotra, D., Cerfon, A., Imbert-Gérard, L.-M. & O'Neil, M. 2019 Taylor states in stellarators: a fast high-order boundary integral solver. J. Comput. Phys. 397, 108791.CrossRefGoogle Scholar
McGrath, P. 2016 On the Smooth Jordan Brouwer separation theorem. Am. Math. Mon. 123 (3), 292.CrossRefGoogle Scholar
Meiss, J.D. 1992 Symplectic maps, variational principles, and transport. Rev. Mod. Phys. 64 (3), 795848.CrossRefGoogle Scholar
Mercier, C. 1964 Equilibrium and stability of a toroidal magnetohydrodynamic system in the neighbourhood of a magnetic axis. Nucl. Fusion 4 (3), 213226.CrossRefGoogle Scholar
Nies, R. 2021 Dataset from: “Adjoint methods for quasisymmetry of vacuum fields on a surface”. Available at: doi:10.5281/zenodo.5248498.CrossRefGoogle Scholar
Nührenberg, J. & Zille, R. 1988 Quasi-helically symmetric toroidal stellarators. Phys. Lett. A 129 (2), 113117.CrossRefGoogle Scholar
Paul, E. 2020 Adjoint methods for stellarator shape optimization and sensitivity analysis. arXiv:2005.07633.Google Scholar
Paul, E.J., Abel, I.G., Landreman, M. & Dorland, W. 2019 An adjoint method for neoclassical stellarator optimization. J. Plasma Phys. 85 (5), 795850501.CrossRefGoogle Scholar
Paul, E.J., Antonsen, T., Landreman, M. & Cooper, W.A. 2020 Adjoint approach to calculating shape gradients for three-dimensional magnetic confinement equilibria. Part 2. Applications. J. Plasma Phys. 86 (1), 905860103.CrossRefGoogle Scholar
Paul, E.J., Landreman, M. & Antonsen, T. 2021 Gradient-based optimization of 3D MHD equilibria. J. Plasma Phys. 87 (2), 905870214.CrossRefGoogle Scholar
Paul, E.J., Landreman, M., Bader, A. & Dorland, W. 2018 An adjoint method for gradient-based optimization of stellarator coil shapes. Nucl. Fusion 58 (7), 076015.CrossRefGoogle Scholar
Plunk, G.G. & Helander, P. 2018 Quasi-axisymmetric magnetic fields: weakly non-axisymmetric case in a vacuum. J. Plasma Phys. 84 (2), 905840205.CrossRefGoogle Scholar
Qu, Z.S., Pfefferlé, D., Hudson, S.R., Baillod, A., Kumar, A., Dewar, R.L. & Hole, M.J. 2020 Coordinate parameterisation and spectral method optimisation for Beltrami field solver in stellarator geometry. Plasma Phys. Control. Fusion 62 (12), 124004.CrossRefGoogle Scholar
Rodríguez, E. & Bhattacharjee, A. 2021 a Solving the problem of overdetermination of quasisymmetric equilibrium solutions by near-axis expansions. I. Generalized force balance. Phys. Plasmas 28 (1), 012508.CrossRefGoogle Scholar
Rodríguez, E. & Bhattacharjee, A. 2021 b Solving the problem of overdetermination of quasisymmetric equilibrium solutions by near-axis expansions. II. Circular axis stellarator solutions. Phys. Plasmas 28 (1), 012509.CrossRefGoogle Scholar
Rodríguez, E., Helander, P. & Bhattacharjee, A. 2020 Necessary and sufficient conditions for quasisymmetry. Phys. Plasmas 27 (6), 062501.CrossRefGoogle Scholar
Rodriguez, E., Paul, E. & Bhattacharjee, A. 2021 Measures of quasisymmetry for stellarators. arXiv:2109.13080.Google Scholar
Sengupta, W., Paul, E.J., Weitzner, H. & Bhattacharjee, A. 2021 Vacuum magnetic fields with exact quasisymmetry near a flux surface. Part 1. Solutions near an axisymmetric surface. J. Plasma Phys. 87 (2), 905870205.CrossRefGoogle Scholar
Sokołowski, J. & Zolésio, J.P. 1992 Introduction to shape optimization: shape sensitivity analysis. Springer Series in Computational Mathematics, vol. 16. Springer.CrossRefGoogle Scholar
Spitzer, L. 1958 The stellarator concept. Phys. Fluids 1 (4), 253.CrossRefGoogle Scholar
Walker, S.W. 2015 The shapes of things: a practical guide to differential geometry and the shape derivative. Advances in Design and Control. Society for Industrial and Applied Mathematics.CrossRefGoogle Scholar
Zarnstorff, M.C., Berry, L.A., Brooks, A., Fredrickson, E., Fu, G.-Y., Hirschman, S., Hudson, S., Ku., L.-P., Lazarus, E., Mikkelsen, D., et al. 2001 Physics of the compact advanced stellarator NCSX. Plasma Phys. Control. Fusion 43 (12A), A237A249.CrossRefGoogle Scholar
Zhu, C., Hudson, S.R., Song, Y. & Wan, Y. 2018 New method to design stellarator coils without the winding surface. Nucl. Fusion 58 (1), 016008.CrossRefGoogle Scholar
Figure 0

Figure 1. Comparison of (a) the toroidal flux gradient ${\left | \boldsymbol {\nabla }\psi \right |}$ evaluated using VMEC with (b) the generalised toroidal flux gradient $|\boldsymbol {g}_{\psi }|$ (3.1) obtained in SPEC, for a $5$-period rotating ellipse case with half a rotation per field period, major radius at the ellipse centre $R_0 = 5$ m and ellipse major and minor axes values of $2$ and $1$ m, respectively. The relative difference between the two quantities is below $1\,\%$, as shown in (c). A small difference is to be expected in this case, where integrability is well satisfied, as attested in (d) by the Poincaré plot at toroidal angle $\phi =0$ from the SPEC calculation, which agrees well with the flux surfaces computed by VMEC. All data generated in this paper can be obtained from Nies (2021).

Figure 1

Figure 2. Shape gradient for the rotational transform objective function with $\iota _T = 1$, evaluated through (a) adjoint methods and (b) a forward finite-difference scheme with step size $\epsilon _\mathrm {FD}=10^{-7}$, for the example rotating ellipse case introduced in figure 1, with Fourier resolution $(N_\mathrm {tor}, M_\mathrm {pol}) = (16,16)$. The relative error, defined as the absolute error normalised by the maximal absolute value of the adjoint shape gradient, is shown in (c). The convergence of the relative error in the parameter derivative (2.4) for a random direction in $\varOmega$ is shown in (d) as a function of the step size $\epsilon _\mathrm {FD}$ and Fourier resolution $(N_\mathrm {tor}, M_\mathrm {pol})$. The black dashed line indicates the linear scaling in $\epsilon _\mathrm {FD}$ expected from the employed forward finite-difference scheme.

Figure 2

Figure 3. Shape gradient for the quasi-symmetry objective function with helicity $N/M=5$, evaluated through (a) adjoint methods and (b) a forward finite-difference scheme with step size $\epsilon _\mathrm {FD}=10^{-9}$, for the example rotating ellipse case introduced in figure 1, with Fourier resolution $(N_\mathrm {tor}, M_\mathrm {pol}) = (16,16)$. The relative error, defined as the absolute error normalised by the maximal absolute value of the adjoint shape gradient, is shown in (c). The convergence of the relative error in the parameter derivative (2.4) for a random direction in $\varOmega$ is shown in (d) as a function of the step size $\epsilon _\mathrm {FD}$ and Fourier resolution $(N_\mathrm {tor}, M_\mathrm {pol})$. The black dashed line indicates the linear scaling in $\epsilon _\mathrm {FD}$ expected from the employed forward finite-difference scheme.