Accelerated Bayesian inference of plasma profiles with self-consistent
  MHD equilibria at W7-X via neural networks
High-$\langle \beta \rangle$ operations require a fast and robust inference
of plasma parameters with a self-consistent MHD equilibrium. Precalculated MHD
equilibria are usually employed at W7-X due to the high computational cost. To
address this, we couple a physics-regularized NN model that approximates the
ideal-MHD equilibrium with the Bayesian modeling framework Minerva. We show the
fast and robust inference of plasma profiles (electron temperature and density)
with a self-consistent MHD equilibrium approximated by the NN model. We
investigate the robustness of the inference across diverse synthetic W7-X
plasma scenarios. The inferred plasma parameters and their uncertainties are
compatible with the parameters inferred using the VMEC, and the inference time
is reduced by more than two orders of magnitude. This work suggests that MHD
self-consistent inferences of plasma parameters can be performed between shots.
Andrea Merlo, Andrea Pavone, Daniel Böckenhoff, Ekkehard Pasch, Golo Fuchert, Kai Jakob Brunner, Kian Rahbarnia, Jonathan Schilling, Udo Höfel, Sehyun Kwak, Jakob Svensson, Thomas Sunn Pedersen, the W7-X team
Accelerated Bayesian inference of plasma profiles with self-consistent MHD equilibria at W7-X via neural networks

###### Abstract

High-\(\beta\) operations require a fast and robust inference of plasma parameters with a self-consistent magnetohydrodynamic (MHD) equilibrium. Precalculated MHD equilibria are usually employed at Wendelstein 7-X (W7-X) due to the high computational cost. To address this, we couple a physics-regularized artificial neural network (NN) model that approximates the ideal-MHD equilibrium with the Bayesian modeling framework Minerva. We show the fast and robust inference of plasma profiles (electron temperature and density) with a self-consistent MHD equilibrium approximated by the NN model. We investigate the robustness of the inference across diverse synthetic W7-X plasma scenarios. The inferred plasma parameters and their uncertainties are compatible with the parameters inferred using the variational moments equilibrium code (VMEC), and the inference time is reduced by more than two orders of magnitude. This work suggests that MHD self-consistent inferences of plasma parameters can be performed between shots.

## 1 Introduction

Bayesian inference is the statistical identification of model parameters that are consistent with given observed data using Bayes theorem. In a magnetic confinement experiment, the model parameters describe the plasma state, which often includes, but is not limited to the plasma profiles (e. g., temperature and density) and an ideal-magnetohydrodynamic (MHD) equilibrium. Diagnostics raw measurements provide the observed data.

In case of a high \(\beta\) (the ratio between the plasma kinetic to the magnetic pressure) scenario or a large internal plasma current, the equilibrium may differ from the vacuum equilibrium. To correctly infer the plasma state, a self-consistent, finite-beta ideal-MHD equilibrium is required. Wendelstein 7-X (W7-X) is an optimized stellarator that features a stiff equilibrium and a low bootstrap current [1, 2] (the expected bootstrap current at high-\(\beta\) in the standard configuration is \(\simeq 80\,\)kA [3]), therefore, equilibrium changes caused by the plasma internal current are predicted to be small with respects to an equivalent tokamak. Finite-beta effects, however, have been experimentally observed, and they can still modify the vacuum equilibrium [4].

In tokamaks, data analysis workflows regularly include the reconstruction of a self-consistent ideal-MHD equilibrium [5, 6, 7]. However, this is not the case with stellarators. The inference of 3D ideal-MHD equilibria have been already demonstrated in several non-axisymmetric experiments, namely the Compact
Toroidal Hybrid (CTH) [8; 9], the National Compact Stellarator Experiment (NCSX) [10], the Helically Symmetric Experiment (HSX) [11; 12; 13], Wendelstein 7-AS (W7-AS) [14], and W7-X [4; 15; 16]. Moreover, multiple frameworks exist that allow the reconstruction of 3D ideal-MHD equilibria: V3FIT [17; 18], STELLOPT [19], and Minerva [20; 52]. However, because of the computational cost of calculating 3D ideal-MHD equilibria, equilibrium reconstruction is not routinely used in Bayesian inference procedures and data analysis pipelines. Vacuum fields, or precalculated finite-beta approximations are used instead [16].

Data-driven approaches have been proposed to reduce the computational cost of constructing stellarator equilibria. Function parametrization was used at W7-AS [14; 21] and at W7-X [22; 23; 24]. More recently, [25] proposed a physics-regularized artificial neural network (NN) to approximate the ideal-MHD solution operator in W7-X configurations. Adopting machine learning (ML) models to approximate experimental equilibria can drastically accelerate sample-intensive applications (e. g., Bayesian inference) that require the computation of a MHD equilibrium.

However, how does the adoption of MHD equilibria approximated by NN models affect the inferred plasma parameters? In this paper, we show the fast (\(\mathcal{O}(10^{2}\,\mathrm{s})\)) and robust inference of plasma profiles (electron temperature and density) based on the Thomson scattering (TS) [26; 27] and single channel dispersion interferometer (DI) [28] diagnostics with a self-consistent MHD equilibrium. The self-consistent MHD equilibrium is approximated by the physics-regularized NN model proposed in [25]. The NN model allows the efficient exploration of the full posterior distribution of plasma profiles with self-consistent MHD equilibria, yielding an estimation of the profile uncertainties. Specifically, we:

* couple the physics-regularized NN model from [25] in the Bayesian framework Minerva (section 2);
* investigate the robustness of the inferred plasma parameters across diverse W7-X synthetic plasma scenarios (sections 3.1 and 3.2);
* compare the reconstructed experimental plasma parameters and their uncertainties (estimated with Markov chain Monte Carlo (MCMC)) with three different MHD equilibrium models (section 3.3): a fixed, finite-beta variational moments equilibrium code (VMEC) equilibrium; a self-consistent VMEC equilibrium; and a self-consistent NN equilibrium;

## 2 Methods

### Bayesian Analysis

In a model-based simulation, a mechanistic model, the model parameters \(H\), and observed data \(D\) characterize the phenomenon under study. In Bayesian analysis, the model parameters and observations are fully captured by their joint probability distribution:

\[P(H,D)=P(D|H)P(H)\, \tag{1}\]

where the _prior_ distribution \(P(H)\) describes the prior knowledge on the model parameters before taking any observations into account (e. g., plasma density should be positive), and the conditional distribution \(P(D|H)\) denotes the probability of the observed data \(D\) given the model parameters \(H\) (when seen as a function of \(H\) for given \(D\), \(P(D|H)\) is it also known as the _likelihood_ function).

A parametric distribution function (e. g., Gaussian) usually represents \(P(D|H)\). The likelihood function is a function that captures the physical model under consideration, and it is often referred to as the _forward_ model. Experimentally derived uncertainties inform the distribution variance.

Bayesian _inference_ updates the model parameters prior distribution to their posterior distribution given the observed data using Bayes formula:

\[P(H|D)=\frac{P(H,D)}{P(D)}=\frac{P(D|H)P(H)}{P(D)}\, \tag{2}\]

where the _posterior_ distribution \(P(H|D)\) describes the probability of the model parameters given the observed data, and \(P(D)\) is the _evidence_, a normalization constant that describes the probability of the observed data given all possible values of the model parameters:
\[P(D)=\int P(D|H)P(H)dH. \tag{3}\]

The posterior distribution of the model parameters describes the degree of belief we have in the parameter values, which is based on prior knowledge and updated by the observed data. It encapsulates all the information and uncertainties we have on the model parameters.

### Model Graph

The Bayesian modeling framework Minerva [20, 52] is used in this work. In Minerva, a graph describes the relationship between model parameters and observed data, which are both represented as the graph's nodes. The graph's edges represent the probabilistic relationships between the modeled quantities. At W7-X, several diagnostics are already implemented in Minerva, making it the obvious choice to validate the accelerated inference of plasma profiles with the NN model.

Figure 1 shows a simplified picture of the Minerva graph used in this work. Blue denotes the model free parameters, and orange denotes the observed quantities. A MHD equilibrium maps the 1D electron temperature and density profiles to a 3D position of magnetic flux surfaces in space. The TS [26, 27] and the single channel DI [28] diagnostics are used to constrain the plasma state: the TS provides information on the electron density and temperature, while the DI measures the line-integrated electron density along a single line of sight (LOS).

#### 2.2.1 Prior distributions and forward models

Modified _two power_ profiles parametrize the electron density and temperature:

\[n_{e}(\rho) =h_{n_{e},0}(1-(\rho/h_{n_{e},3})^{h_{n_{e},1}+2})^{h_{n_{e},2}}, \tag{4}\] \[T_{e}(\rho) =h_{T_{e},0}(1-(\rho/h_{T_{e},3})^{h_{T_{e},1}+2})^{h_{T_{e},2}}, \tag{5}\]

where \(\rho=\sqrt{\Phi/\Phi_{\rm edge}}\) is the square root of the normalized toroidal flux. The additional (with respect the standard two power parametrization) parameters \(h_{T_{e},3}\) and \(h_{n_{e},3}\) allow modeling not-null temperatures

Figure 1: A simplified sketch of the Minerva graph. Blue ellipses represent free parameters, orange ellipses represent observed quantities, white ellipses represent model fixed parameters or model internal quantities, and white boxes represent physical forward models.
and densities beyond the last closed flux surface (LCFS), which are usually observed at W7-X [29]. Uniform distributions represent the prior on the plasma profile parameters (see section 7.1).

Flux surfaces \(\rho(x,y,z)\) computed from a free-boundary ideal-MHD equilibrium map the 1D profiles (e. g., \(n_{e}(\rho)\)) to the 3D real space geometry (\(n_{e}(x,y,z)\)). The set of W7-X coil currents fixed to their setpoint values, the net toroidal magnetic flux \(\Phi_{\rm edge}\) represented by a uniform prior distribution, and the 1D pressure and toroidal current profiles parametrize the free-boundary ideal-MHD equilibrium.

In this work, we assume \(T_{i}\simeq T_{e}\), \(Z_{\rm eff}\simeq 1\), and \(n_{i}\simeq n_{e}=n\). As a result, the pressure is simply given by \(p\simeq 2n_{e}T_{e}\). The purpose of this paper is to investigate the use of NN equilibria in a Bayesian inference framework, rather than providing a highly accurate description of W7-X (e. g., by including a X-ray imaging crystal spectroscopy (XICS) to infer the ion temperature, or spectrometers to infer the plasma effective ion charge \(Z_{\rm eff}\)). Therefore, the relaxation of these assumptions is not in the scope of this paper.

The NN model sees only the total pressure \(p\) and not \(T_{e}\) or \(T_{i}\). As a result, for the scope of this work, it is not critical how the pressure profile is constructed. The assumptions only limit the set of experimental scenarios that can be used to test the inference procedure. Indeed, the experimental scenarios considered in section 3.3 feature \(T_{i}\simeq T_{e}\) within experimental uncertainties. However, in section 3.2, we use synthetic data to investigate the robustness of the inference procedure across diverse, randomly sampled (within the model parameter prior distributions) W7-X scenarios.

The toroidal current profile is parametrized as:

\[I_{\rm tor}(s)=\frac{2}{\pi}h_{I_{\rm tor},1}{\rm atan}(\frac{h_{I_{\rm tor}, 2}s^{h_{I_{\rm tor},3}}}{(1-s)^{h_{I_{\rm tor},4}}}), \tag{6}\]

where \(s=\rho^{2}\). However, given the lack of diagnostics to constrain its profile [24], the profile shape is fixed: \(h_{I_{\rm tor},2}=h_{I_{\rm tor},3}=h_{I_{\rm tor},4}=1\). Moreover, given that \(I_{\rm tor}(s=1)=h_{I_{\rm tor},1}\), \(h_{I_{\rm tor},1}\) is held fixed to the net toroidal current as measured by the Rogowski coil [30].

This work considers two MHD equilibrium models: VMEC [31] and a physics-regularized NN [25]. The NN model has been integrated into Minerva with the ONNX Runtime framework [32]. In the proposed Minerva graph, the equilibrium model is employed only to provide the self-consistent flux surface mapping. In this regard, [25] reports that the NN model achieves an average flux surface error of \(\simeq 0.6\,\)mm. The NN model was trained on a large set of W7-X magnetic configurations, including the reference W7-X configurations [33], pressure profiles with \(\langle\beta\rangle\) up to \(5\,\%\), and toroidal current profiles with \(I_{\rm tor}\) up to \(20\,\)kA. W7-X experimental conditions in previous operational campaigns are well within the training data set [**Rolf2019**, 34]. For further information on the model architecture, training, and evaluation, please refer to [25].

The TS observations constrain the electron density and temperature. The TS system's forward model maps \(n_{e}(x,y,z)\) and \(T_{e}(x,y,z)\) to the number of scattered photons on a set of _volumes_ along the TS laser beam path. Polychromator filters are used to measure the scattered spectrum by selecting distinct spectral intervals. The time integral of the signal of each channel over the length of the scattered laser pulse corresponds to the number of the scattered photons [27]. Thomson scattering scatters laser photons off of electrons, and the Doppler effect broadens the Thomson scattered spectra due to the thermal motions of the electrons. The electron temperature determines the width of the Thomson scattered spectrum, and electron density determines its amplitude. The predicted TS signal of the \(i\)-th channel is [27]:

\[D^{i}_{\rm TS}=C_{\rm TS}g_{0}E_{\rm laser}r_{e}^{2}n_{e}\int\frac{\lambda}{ \lambda_{\rm laser}}\frac{g_{i}(\lambda)}{g_{0}}S(\lambda,\theta,T_{\rm e})d \lambda\, \tag{7}\]

where the integration is over the scattered spectrum wavelength \(\lambda\). \(g_{0}\) is the absolute sensitivity of a reference channel, \(E_{\rm laser}\) is the laser pulse energy, \(r_{e}\) is the electron radius, \(\lambda_{\rm laser}\) is the laser wavelength, \(g_{i}(\lambda)\) is the absolute sensitivity of the \(i\)-th channel, \(\theta\) is the scattering angle, and \(S(\lambda,\theta,T_{\rm e})\) is the spectral density function. The \(\frac{g_{i}(\lambda)}{g_{0}}\) factor represents the relative calibration of each channel, and the \(C_{\rm TS}\) is the global calibration factor. For a more detailed description of the TS system, please refer to [26, 27].

The forward model of the DI system maps the 3D electron density to the line-integrated value along the DI LOS. The predicted DI signal is:

\[D_{\rm DI}=\int n_{e}(x,y,z)dl, \tag{8}\]
where the integration path \(\int dl\) is along the DI LOS. For a more detailed description of the DI system, please refer to [28].

The misalignment of the laser system is a common issue that affects TS systems. In a TS system, observation optics with LOSs that cross the laser beam path capture the scattered light. A misaligned laser system can cause the laser beam path to be outside the nominal scattering volumes; in such a case, the inferred density will be lower than the actual plasma density.

At W7-X, the TS system is believed to be affected by a systematic shift of the laser beam [35, 36]. Laser misalignment is expected to be the dominant source of error in the electron density profiles, affecting both the overall scale and shape of the profile.

In this work, we introduce two additional parameters to account for laser misalignment errors: the global TS calibration factor \(C_{\mathrm{TS}}\), and a systematic uncertainty \(\sigma_{\mathrm{laser}}\) that is added to the nominal TS uncertainty. \(C_{\mathrm{TS}}\) is a model free parameter, and it is constrained during inference by the line-integrated density of the DI (i. e., the TS is cross-calibrated during inference). The systematic uncertainty due to laser misalignment is held fixed, and the standard deviation of the \(i\)-th TS channel is modeled as:

\[(\sigma_{\mathrm{TS}}^{i})^{2}=(\hat{\sigma}_{\mathrm{TS}}^{i})^ {2}+(\sigma_{\mathrm{laser}}^{i})^{2}, \tag{9}\] \[\sigma_{\mathrm{laser}}^{i}=\max(\sigma_{0},\alpha D_{\mathrm{ TS}}^{i})\, \tag{10}\]

where \(\hat{\sigma}_{\mathrm{TS}}^{i}\) is the nominal TS uncertainty. \(\alpha\) and \(\sigma_{0}\) are experimentally estimated (see section 7.2). Ongoing efforts at W7-X are in place to account for the TS laser misalignment. A comprehensive modeling and exhaustive analysis of this error is beyond the scope of this paper.

### Inference

The inference procedure is divided in two stages. Firstly, in the so called maximum a posteriori (MAP) optimization, the model free parameters that maximizes the left-hand side of equation (2), i. e., the mode of the posterior distribution, are derived:

\[H_{\mathrm{MAP}}=\operatorname*{arg\,max}_{H}P(H|D). \tag{11}\]

The Hooke and Jeeves optimizer [37] drives the optimization. Secondly, the MCMC Metropolis-Hastings algorithm (MHA) [38, 39] numerically approximates the full posterior distribution. The model parameter uncertainties can be derived from the MCMC samples. The inference is carried out on a single core of an Intel(R) Xeon(R) Gold 6136 CPU @ 3 GHz.

We are interested in generating samples from the posterior distribution of the model parameters because they allow propagating their uncertainties into any subsequent quantities. The computation of the samples is not straightforward: either a closed form of the posterior is derived (either analytically, possible only in very seldom cases, or by approximating it with a parametric form as it is done in variational inference), or a sampling algorithm, such as an MCMC method, is used. MCMC methods have desirable mathematical convergence properties, and they do not require assumptions on the parametric form of the posterior distribution. However, they do not scale well to problems where the computation of the likelihood is inefficient because they require several thousands of evaluations of the likelihood function. Replacing the VMEC code with the NN model results in orders of magnitude faster likelihood evaluations, therefore, it brings the Bayesian inference approach to a scale that was not possible before.

## 3 Results

This section investigates the inference of plasma profiles for both synthetic and experimental W7-X data: section 3.1 visualizes the simple reconstruction of two parameters on simulated diagnostic data; section 3.2 investigates the robustness of the inference procedure across diverse W7-X plasma scenarios; section 3.3 compares the reconstruction of plasma profiles and their uncertainties with three different MHD equilibrium models: a fixed, finite-beta VMEC equilibrium; a self-consistent VMEC equilibrium; and a self-consistent NN equilibrium.
### \(2\)D inference on synthetic data

To introduce the inference procedure, and to visualize the free parameter values during inference, a simplified 2D inference on synthetic data is reported. Apart for the electron density scale factor \(h_{n_{e},0}\) and the total toroidal flux enclosed by the plasma \(\Phi_{\rm edge}\), all other model parameters are fixed.

In this section, diagnostic data are simulated with this Minerva graph rather than taken from the experiment. Observations are modeled using normal or truncated normal distributions. The predicted data from the forward model determine the distribution means, and the experimentally informed uncertainties determine the distribution standard deviations. The synthetic diagnostic data are then generated by setting the free parameter values to their target one (see paragraph below), running the forward model with VMEC as the equilibrium solver, setting the observation means to the predicted diagnostic data, and finally drawing samples from the observation distributions. We would like to make two important remarks: the generated synthetic data are obtained using an accurate equilibrium provided by VMEC, while the inference process uses equilibria obtained from the NN model; the synthetic data are sampled from distributions whose sigma is informed by experimental uncertainties, ensuring that they are not noise-free.

A W7-X plasma scenario resembling the post-pellet phase with an enhanced confinement [4] is considered (_W7X20181016.037_ at \(t=1.7\,\)s): central density \(n_{e}(\rho=0)=8.0\times 10^{19}\,\)m\({}^{-3}\), density peaking factor \(n_{e}(\rho=0)/n_{e}(\rho=0.8)\simeq 2.77\), central temperature \(T_{e}(\rho=0)=3.0\,\)keV, flat temperature profile till \(\rho\simeq 0.2\), net toroidal current \(I_{\rm tor}=1.3\,\)kA, and \(\Phi_{\rm edge}=1.945\,\)V s as from the vacuum equilibrium. For simplicity, \(h_{n_{e},3}=h_{T_{e},3}=1.0\). The resulting volume average plasma beta is \(\langle\beta\rangle=1.31\,\)%.

In this simplified 2D inference, the MAP optimization quickly converges to the true values (figure 2): after five iterations, the inferred values (black dots) are already close to the target ones (red star). The inference initial guess (black star) is sampled from the parameter prior distributions. The relative difference between the inferred and true values is less than \(1\,\)% (table 1).

Figure 2 also shows the contours of the full posterior distribution normalized to the posterior distribution of the MAP values in the \((h_{n_{e},0},\Phi_{\rm edge})\) space: a dark color indicates that a region of parameter space is less likely than the MAP values, on the other hand, a light color indicates that a region of parameter space is equally likely as the MAP values. \(10\,000\) random samples are used to interpolate the posterior distribution. Figure 2 does also highlight the advantage of a fast MHD equilibrium model: sampling \(10\,000\) parameter values, which requires computing \(10\,000\) self-consistent MHD equilibria, took only about \(20\,\)min (in a serial fashion on a single core). Hence, it is now possible to quickly explore the entire posterior distribution.

### Inference robustness on synthetic data

Is the NN model's approximation of the ideal-MHD equilibrium robust across diverse plasma scenarios? The NN model was trained on a large set of W7-X equilibria for various vacuum magnetic configurations, plasma pressure and toroidal current profiles. In this section, we investigate if the inference procedure is robust across plasma scenarios (e. g., high- and low-\(\beta\), flat or peaked pressure profiles).

Using synthetic data provides the advantage of being able to conveniently scan the parameter space in different trials: for each inference trial, the _true_ state and the _initial guess_ are sampled from the model parameter prior distributions. The plasma state is represented by the vector \(\vec{h}=(h_{T_{e},0},h_{T_{e},1},h_{T_{e},2},h_{n_{e},0},h_{n_{e},1},h_{n_{e},2})^{T}\), while \(h_{T_{e},3}=h_{n_{e},3}=1\) are fixed. Similarly to section 3.1, synthetic data are generated by injecting the true plasma state into the graph, and by setting the observed data to samples drawn from the observation distributions, using VMEC as equilibrium model. The free parameters are then initialized to their initial guesses, and the posterior distribution is maximized for \(100\) iterations. The NN model approximates the MHD equilibrium during inference.

The inference procedure is robust across plasma state and initial guess (figures 2(a) to 2(f)). Figures 2(a) to 2(f) show the trajectory of the free parameters (normalized to their true values) as a function of the

\begin{table}
\begin{tabular}{l c c c c} \hline \hline Parameter & true & initial & inferred & difference [\%] \\ \hline \(h_{n_{e},0}\) & 8.00 & 10.30 & 7.98 & 0.19 \\ \(\Phi_{\rm edge}\) & -1.95 & -1.88 & -1.94 & 0.04 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Reconstructed free parameter values for the 2D inference on synthetic data. See section 2.2.1 for the description of each parameter.
MAP iterations. Because the free parameters are normalized to their true values, a final value of 1 (red dashed line) represents a successfully converged inference. The trajectory means (solid line) and \(5\,\%-95\,\%\) quantiles (dashed lines) are estimated with 25 independent inference trials. The profile scale factors (\(h_{n_{e},0}\) and \(h_{T_{e},0}\)) are accurately inferred, whereas the distributions of the profile shape parameters show a non-finite spread in their estimated values. Yet, the inferred values are on average close to the target values. As a representative case, table 2 shows the true, initial, and inferred parameter values in case of the median trial (i. e., the trial that has the median average percentage inference error across all trials).

### Inference of improved confinement scenarios at W7-X

In this section, we replace the synthetic diagnostic data with experimental data. We address two questions: how does the approximation of the equilibria by the NN model affect the inferred plasma parameters? What are the implications of a self-consistent MHD equilibrium for plasma parameter estimation?

\begin{table}
\begin{tabular}{l c c c c} \hline \hline Parameter & true & initial & inferred & difference [\%] \\ \hline \(h_{T_{e},0}\) & 3.87 & 4.37 & 3.87 & 0.20 \\ \(h_{T_{e},1}\) & 2.70 & 2.17 & 2.87 & 6.44 \\ \(h_{T_{e},2}\) & 3.19 & 0.20 & 3.38 & 5.93 \\ \(h_{n_{e},0}\) & 13.92 & 12.20 & 13.92 & 0.03 \\ \(h_{n_{e},1}\) & 4.93 & 2.95 & 4.96 & 0.62 \\ \(h_{n_{e},2}\) & 6.73 & 2.90 & 6.72 & 0.22 \\ \hline \hline \end{tabular}
\end{table}
Table 2: Target, initial guess, and inferred parameter values for the median trial. See section 2.2.1 for the description of each parameter.

Figure 2: Trajectory of the free parameters during inference. In this case, the free parameters are the electron density scale factor \(h_{n_{e},0}\) and the net toroidal flux enclosed by the plasma \(\Phi_{\rm edge}\). The reconstruction process starts from the black star, which represents the initial guess, and converges to the red star, which represents the true state. The dashed black line indicates the order of parameter values encountered during inference. The synthetic observations are generated using the Minerva graph and VMEC as equilibrium model, while the inference is performed using the NN as equilibrium model. The logarithm of the ratio of the sample posterior probability to the MAP posterior probability is also shown. The light dark dots represent \(10\,000\) random samples used to interpolate the posterior distribution.
To address both questions, two plasma scenarios with \(T_{\rm i}\simeq T_{\rm e}\) at different \(\langle\beta\rangle\) and magnetic configurations are considered:

_W7X20181016.37_**, \(t=1.7\)s:**: a \(\langle\beta\rangle>1\,\%\), improved confinement scenario following pellet injections in the _standard_ configuration [4].
**W7X20180080.5**: \(t=20.0\)s:**: a low-power, improved confinement scenario in the _high-iota_ configuration [40].

In this section, we compare three different ideal-MHD equilibrium models: a reference, fixed, finite-beta VMEC equilibrium (see description below); a self-consistent VMEC equilibrium; and a self-consistent NN equilibrium. Comparing the two self-consistent equilibrium models allows the investigation of the approximations provided by the NN model, while comparing the fixed and self-consistent equilibrium models enables the analysis of the implications of a self-consistent equilibrium on the inferred plasma profiles.

Figure 3: Convergence of the model parameters during inference for 25 independent trials. Each trial yields a randomly sampled set of true and initial guess values. Each figure shows the mean (solid line) and \(5\,\%-95\,\%\) quantiles (dashed lines) of the normalized (to their true value) free parameters as a function of the MAP optimization iterations. A red dashed line guides the eye to indicate the normalized target value (i. e., 1). See section 2.2.1 for the description of each parameter.
The reference VMEC equilibrium is taken from the set of precalculated finite-beta equilibria commonly used at W7-X [16]. The pressure profile is assumed to be \(p_{0}(1-s)^{a_{2}}\), where \(p_{0}\) is the pressure scale, and \(a_{2}\) determines the pressure peaking factor. Estimating \(a_{2}\) from the experimental profiles, and assuming \(p_{0}\) so that \(W_{\rm kin}\) matches the measured \(W_{\rm dia}\) value (with a plasma volume of \(V_{p}=30\,\)m\({}^{3}\)), the closest precalculated equilibrium in terms of Euclidean distance in the \((p_{0},a_{2})\) space is selected. The net toroidal current is less than 2 kA in these experiments and can be neglected. \(\Phi_{\rm edge}\) is set to the toroidal flux enclosed by the LCFS of the vacuum field obtained from field line tracing.

In case of the self-consistent MHD equilibria, the equilibrium is not fixed, but evaluated consistently with the proposed density and temperature profiles. Nine free parameters represent the plasma state: four profile parameters each for \(n_{e}\) and \(T_{\rm e}\), and a global calibration factor for the TS (see section 2.2.1). \(\Phi_{\rm edge}\) is held fixed. As in section 3.2, the toroidal current profile shape is fixed, but the net toroidal current is set to the value measured by the Rogowski coil.

To improve the inference's convergence, diagnostics raw data inform the initial guess: \(h_{n_{e},0}\) is set to be consistent with the line average integrated density from the DI (assuming a flat density profile and a LOS length of 1.1 m), and \(h_{T_{e},0}\) is chosen so that the plasma's kinetic energy matches the measured diamagnetic energy from the diamagnetic loop (assuming a plasma volume of \(V_{p}=30\,\)m\({}^{3}\), and a linear pressure profile in normalized toroidal flux).

For both considered experiments, the inferred profile parameters with the three MHD equilibrium models are compatible (tables 3 and 4): after 100 MAP iterations, the parameter values are within one standard deviation away from each other. The standard deviations are estimated using 30 000 MCMC samples, of which the first 10 000 are discarded, and only 1 in every 50 are kept to reduce the sample autocorrelation.

It is worth highlighting the time needed to perform each inference (100 MAP iterations on a single core, given here in case of the _W7X20181016.37_ shot): using the self-consistent VMEC equilibrium took 1108 min and 45 s, using the fixed VMEC equilibrium took 9 min and 35 s, and using the NN model took only 3 min and 31 s. The inference time is reduced by more than two orders of magnitude.

As depicted in tables 3 and 4, the three ideal-MHD models yield compatible plasma profiles. This is true not only in terms of MAP profiles, but also for their posterior distributions estimated with MCMC (figures 4a to 4d).

The inferred profiles are also consistent with a independently inferred electron temperatures and densities per TS volume (figures 4a to 4d). For the reference Minerva inference, the density and temperature values at each TS volume are independently reconstructed using the fixed, finite-beta VMEC equilibrium as MHD model, and the density is further scaled to match the line-integrated value from the DI. See [27, Section 5] for a description of the inference procedure.

Tables 5 and 6 show selected quantities of interest of the resulting equilibria. In case of the inference performed with the NN model, the mean and standard deviation (in brackets) of the MCMC samples are reported.

\begin{table}
\begin{tabular}{l r r r} \hline Parameter & Fixed VMEC & Self-consistent VMEC & Self-consistent NN \\ \hline \(h_{T_{e},0}\) & 3.39 (0.16) & 3.403 & 3.40 (0.17) \\ \(h_{T_{e},1}\) & 1.04 (0.36) & 1.038 & 1.03 (0.38) \\ \(h_{T_{e},2}\) & 4.7 (1.9) & 4.834 & 4.7 (1.9) \\ \(h_{T_{e},3}\) & 1.129 (0.081) & 1.138 & 1.130 (0.080) \\ \(h_{n_{e},0}\) & 8.27 (0.51) & 8.341 & 8.35 (0.50) \\ \(h_{n_{e},1}\) & 0.16 (0.32) & 0.140 & 0.14 (0.33) \\ \(h_{n_{e},2}\) & 2.77 (0.74) & 2.726 & 2.71 (0.89) \\ \(h_{n_{e},3}\) & 1.330 (0.072) & 1.330 & 1.328 (0.079) \\ \hline \end{tabular}
\end{table}
Table 3: Comparison of the inferred free parameters in case of the _W7X20181016.37_ shot at \(t=1.7\) s with the three ideal-MHD models: a fixed, finite-beta precalculated VMEC equilibrium; a self-consistent VMEC equilibrium; and the NN model described in section 2.2.1. The free parameter values are obtained via a MAP optimization, and the standard deviation (in brackets) is estimated with MCMC. Because of the computational time required to run VMEC for each MCMC sample, the MCMC procedure has not been performed in case of the self-consistent VMEC equilibrium.
Figure 4: Comparison of the inferred electron density (figures 4a and 4c) and temperature (figures 4b and 4d) profiles with the following MHD models: a fixed, finite-beta precalculated VMEC equilibrium; a self-consistent VMEC equilibrium; and the self-consistent NN model described in section 2.2.1. The solid lines represent the mean profile across all MCMC samples (in case of the self-consistent VMEC equilibrium, the solid line is the MAP profile), and dashed lines represent the \(5\,\%-95\,\%\) quantiles. In addition, the values (as well as their standard deviation) of the electron density and temperature at each TS volume location, from a reference Minerva inference, are also shown (red stars). The shot id and time of each reconstructed slice are shown in each figure title.
The inferred MHD equilibria obtained using the self-consistent VMEC and NN models feature compatible properties (tables 5 and 6): the inferred values with the self-consistent NN model are within one standard deviation with respect to the values inferred with the self-consistent VMEC equilibrium. It is worth noting that, for the two experimental scenarios investigated, the assumed pressure profile in the precalculated fixed equilibrium (first column in the tables) differs from the inferred pressure profiles (second and third columns in the tables).

\begin{table}
\begin{tabular}{l c c c} \hline Quantity & Fixed VMEC & Self-consistent VMEC & Self-consistent NN \\ \hline \(\langle\beta\rangle\) [\%] & 0.253 & 0.273 & 0.268 (0.034) \\ \(\mathfrak{e}_{\rm axis}\) & 1.012 & 1.003 & 1.00253 (0.00026) \\ \(\mathfrak{e}_{\rm LCFS}\) & 1.193 & 1.172 & 1.17385 (0.00012) \\ \(W_{\rm kin}\) [kJ] & 218 & 236 & 228 (29) \\ \(R_{\rm axis}(\varphi=0)\) [m] & 5.976 & 5.977 & 5.97641 (0.00092) \\ \(p_{0}\) [kPa] & 20.0 & 26.3 & 25.3 (3.2) \\ pressure peaking factor & 3.47 & 4.22 & 4.13 (0.31) \\ \hline \end{tabular}
\end{table}
Table 6: Comparison of selected quantities of the inferred equilibria of experiment _W7X20180808.5_ at \(t=20.0\) s with the three MHD models, analogous to table 5. \(W_{\rm dia}=232.188\) kJ.

\begin{table}
\begin{tabular}{l c c c} \hline Parameter & Fixed VMEC & Self-consistent VMEC & Self-consistent NN \\ \hline \(h_{T_{e},0}\) & 1.930 (0.089) & 1.928 & 1.915 (0.088) \\ \(h_{T_{e},1}\) & 0.001 (0.323) & 0.001 & 0.002 (0.344) \\ \(h_{T_{e},2}\) & 4.1 (1.4) & 4.126 & 4.4 (1.4) \\ \(h_{T_{e},3}\) & 1.330 (0.087) & 1.330 & 1.330 (0.086) \\ \(h_{n_{e},0}\) & 4.32 (0.49) & 4.258 & 4.21 (0.50) \\ \(h_{n_{e},1}\) & 2.52 (0.65) & 2.524 & 2.35 (0.68) \\ \(h_{n_{e},2}\) & 8.2 (1.9) & 8.535 & 6.4 (1.9) \\ \(h_{n_{e},3}\) & 1.079 (0.075) & 1.090 & 1.051 (0.072) \\ \hline \end{tabular}
\end{table}
Table 4: Comparison of the inferred free parameters in case of the _W7X20180808.5_ shot at \(t=20.0\) s with the three ideal-MHD models. See table 3 for a description of each row.

\begin{table}
\begin{tabular}{l c c c} \hline Quantity & Fixed VMEC & Self-consistent VMEC & Self-consistent NN \\ \hline \(\langle\beta\rangle\) [\%] & 1.176 & 1.067 & 1.083 (0.064) \\ \(\mathfrak{e}_{\rm axis}\) & 0.862 & 0.857 & 0.8597 (0.0012) \\ \(\mathfrak{e}_{\rm LCFS}\) & 0.971 & 0.974 & 0.97414 (0.00014) \\ \(W_{\rm kin}\) [kJ] & 1198 & 1089 & 1090 (64) \\ \(R_{\rm axis}(\varphi=0)\) [m] & 5.983 & 5.987 & 5.9876 (0.0028) \\ \(p_{0}\) [kPa] & 80.0 & 91.1 & 90.6 (6.7) \\ pressure peaking factor & 2.98 & 3.74 & 3.65 (0.19) \\ \hline \end{tabular}
\end{table}
Table 5: Comparison of selected quantities of the inferred equilibria of experiment _W7X20181016.37_ at \(t=1.7\) s with three MHD models: a fixed, finite-beta precalculated VMEC equilibrium; a self-consistent VMEC equilibrium; and the self-consistent NN model as described in section 2.2.1. In case of the inference performed with the self-consistent NN model, the mean and standard deviation (in brackets) of the MCMC samples are reported. In these experimental conditions, the measured diamagnetic energy is \(W_{\rm dia}=1137.661\) kJ.
## 4 Conclusions

In this work, we found that employing the NN model from [25] as ideal-MHD equilibrium model in the Minerva Bayesian framework yields inferred plasma parameters compatible with the parameters obtained using VMEC. We have also investigated the robustness of the NN accelerated inference using synthetic data, and we observed that it is robust across diverse W7-X plasma scenarios.

The inference time can be reduced by more than two orders of magnitude when using the NN model. Moreover, given the fast computational time, plasma parameter posterior distributions can be approximated using MCMC samples with self-consistent ideal-MHD equilibria.

This work has two major limitations: no magnetic diagnostics (except for the Rogowski coil) are included in the Minerva graph, owing to the lack of accuracy of the NN model in faithfully computing the plasma current density1, which is required to predict the magnetic diagnostics observations (the plasma contribution to the magnetic field at a location outside the plasma volume depends on a volume integral of the plasma current density [41]); \(T_{i}\sim T_{\mathrm{e}}\) and \(Z_{\mathrm{eff}}\simeq 1\) have been assumed, as a result, the approach can be tested only on a limited set of experimental conditions where these assumptions are close to being satisfied. To infer additional plasma parameters, more diagnostics can be included in the Minerva graph. A XICS can be used to constrain the ion temperature [42], and a spectrometer can be used to infer the effective charge \(Z_{\mathrm{eff}}\)[43].

Footnote 1: the plasma current density depends up to the second-order derivatives of the equilibrium solution, and the equilibrium solution provided by the NN model does not have smooth second-order radial derivatives [25]

Using NN ideal-MHD models, it is possible to quickly infer plasma parameters while taking into account finite-beta effects in the equilibrium. If diagnostic data are available, the MHD self-consistent inference of plasma parameters can theoretically be performed between shots, providing valuable insights for the conduction of operational campaigns.

## 5 Author Statement

The contributions to this paper are described using the CRediT taxonomy [44]:

**Andrea Merlo**: Conceptualization, Data Curation, Formal Analysis, Investigation, Methodology, Software, Visualization, Writing - original draft, Writing - review & editing.
**Andrea Pavone**: Conceptualization, Data Curation, Formal Analysis, Investigation, Methodology, Software, Writing - review & editing.
**Daniel Bockenhoff**: Methodology, Software, Supervision, Validation, Writing - review & editing.
**Ekkehard Pasch**: Data Curation.
**Kai Jakob Brunner**: Data Curation.
**Kian Rahbarnia**: Data Curation.
**Jonathan Schilling**: Software.
**Udo Hofel**: Software.
**Sehyun Kwak**: Software.
**Jakob Svensson**: Software.
**Thomas Sunn Pedersen**: Funding acquisition, Supervision.

## 6 Acknowledgement

We are indebted to the communities behind the multiple open-source software packages on which this work depends: hydra [45], matplotlib [46], numpy [47], pymc3 [48], pytorch [49], pytorch lightning [50], scipy [51].

Financial support by the European Social Fund (ID: ESF/14-BM-A55-0007/19) and the Ministry of Education, Science and Culture of Mecklenburg-Vorpommern, Germany via the project "NEISS" is gratefully acknowledged. This work has been carried out within the framework of the EUROfusion
Consortium, funded by the European Union via the Euratom Research and Training Programme (Grant Agreement No 101052200 -- EUROfusion). Views and opinions expressed are however those of the author(s) only and do not necessarily reflect those of the European Union or the European Commission. Neither the European Union nor the European Commission can be held responsible for them.
