GS-DeepNet: mastering tokamak plasma equilibria with deep neural networks and the Grad–Shafranov equation

The force-balanced state of magnetically confined plasmas heated up to 100 million degrees Celsius must be sustained long enough to achieve a burning-plasma state, such as in the case of ITER, a fusion reactor that promises a net energy gain. This force balance between the Lorentz force and the pressure gradient force, known as a plasma equilibrium, can be theoretically portrayed together with Maxwell’s equations as plasmas are collections of charged particles. Nevertheless, identifying the plasma equilibrium in real time is challenging owing to its free-boundary and ill-posed conditions, which conventionally involves iterative numerical approach with a certain degree of subjective human decisions such as including or excluding certain magnetic measurements to achieve numerical convergence on the solution as well as to avoid unphysical solutions. Here, we introduce GS-DeepNet, which learns plasma equilibria through solely unsupervised learning, without using traditional numerical algorithms. GS-DeepNet includes two neural networks and teaches itself. One neural network generates a possible candidate of an equilibrium following Maxwell’s equations and is taught by the other network satisfying the force balance under the equilibrium. Measurements constrain both networks. Our GS-DeepNet achieves reliable equilibria with uncertainties in contrast with existing methods, leading to possible better control of fusion-grade plasmas.


GS
The force-balanced state of magnetically confined plasmas heated up to 100 million degrees Celsius must be sustained long enough to achieve a burning-plasma state, such as in the case of ITER, a fusion reactor that promises a net energy gain.This force balance between the Lorentz force and the pressure gradient force, known as a plasma equilibrium, can be theoretically portrayed together with Maxwell's equations as plasmas are collections of charged particles.Nevertheless, identifying the plasma equilibrium in real time is challenging owing to its free-boundary and ill-posed conditions, which conventionally involves iterative numerical approach with a certain degree of subjective human decisions such as including or excluding certain magnetic measurements to achieve numerical convergence on the solution as well as to avoid unphysical solutions.Here, we introduce GS-DeepNet, which learns plasma equilibria through solely unsupervised learning, without using traditional numerical algorithms.GS-DeepNet includes two neural networks and teaches itself.One neural network generates a possible candidate of an equilibrium following Maxwell's equations and is taught by the other network satisfying the force balance under the equilibrium.Measurements constrain both networks.Our GS-DeepNet achieves reliable equilibria with uncertainties in contrast with existing methods, leading to possible better control of fusion-grade plasmas.
The ultimate goal of scientific and engineering research in the field of nuclear fusion is to build a power plant producing sustainable and clean electricity through fusion reactions from a confined plasma heated up to ~ 100 million degrees Celsius 1,2 .A tokamak is a torus-shape vacuum vessel within which the plasma is confined by magnetic fields directed along the long (toroidal) and short (poloidal) ways around the torus.Maintaining such a high-temperature plasma for a long period of time (e.g., longer than 400 s 3 ) requires the plasma pressure gradient and the Lorentz force to be balanced throughout the plasma volume 4 during operation of a tokamak.This means that knowing internal spatial structures of the plasma pressure and the magnetic fields in real-time is beneficial for operating tokamak plasmas.
Direct in situ measurements of the plasma structures are often difficult to make owing to the harsh environment; e.g., environments with high temperature and radiation.Although optics systems that directly measure internal information such as the electron temperature and density 5 and magnetic pitch angle 6 exist, these measurements are spatially localized and require a magnetic field structure to be mapped onto the whole plasma volume.Hence, a suite of magnetic diagnostics 7 , fundamental measurement devices installed behind the plasmafacing components far from the plasma, is used to obtain the magnetic field structures indirectly by solving the Grad-Shafranov (GS) equation 8,9 .The GS equation constrained with the measured magnetic fields describes a force balanced plasma state conforming to Maxwell's equations with a toroidal axisymmetry assumption, and finding a solution to the GS equation under such constraints is thus regarded as reconstructing the magnetohydrodynamic (MHD) equilibrium of a toroidal plasma.
The GS equation, resembling the Hicks equation 10 that describes an axisymmetric inviscid fluid, is a twodimensional (poloidal cross-section), nonlinear, elliptic partial differential equation.Owing to the nonlinearity of the GS equation, reconstructing the MHD equilibrium consistent with the GS equation traditionally requires an iterative numerical approach as it is both an inverse and a free-boundary problem.Only external measurements of the magnetic fields are typically available, and we do not have a priori knowledge of where the boundary separates the vacuum region from the plasma region.These difficulties hinder the real-time application of the GS equation.Of course, a simple solution for real-time application is to sacrifice the accuracy of the solution as in Ref. 11 .However, even if accuracy is eschewed, human expert choices are made in reaching numerical convergence.Traditional numerical algorithms of the reconstruction, chiefly EFIT 12 , often require subjective decisions in the manual selection of magnetic measurements.The neglected data do not participate in reconstructing a plasma equilibrium because they tend to obstruct the search for a converging numerical solution.
Attempts have been made to parallelize the traditional numerical algorithms using graphical processing units (GPUs) 13,14 or a supervised deep neural network 15 , which fulfill the real-time demand but still require human intervention because they are based on the EFIT algorithm.In contrast, reconstruction methods using Bayesian inference [16][17][18] have been introduced to eliminate (or at least explicitly articulate) manual selections, but they are unlikely to be used for real-time purposes owing to their heavy computations.We note that reconstructing more detailed plasma equilibria in real time using internal information is an active research area 19,20 .
Recent scientific computing has been supported by deep learning 21 , and therefore various approaches have been proposed for neural networks to learn physics-based differential equations, such as in solving the many-electron Schrödinger equation 22,23 , the Navier-Stokes equation 24 and an atmospheric model for climate modeling 25 .Other examples include interpolating partial differential equations [26][27][28] and regularizing neural networks with the Kohn − Sham equations 29 .These previous works require actual solutions 27,28 , prior knowledge on some of the unknown parameters [24][25][26] , or approximated solution states 22,23,29 of the target governing equations.Similarly, attempts have been made to find a solution to the GS equation using neural networks 26,30 , and they work with given internal profiles since they are GS equation solvers, i.e., not an equilibrium reconstruction algorithm.Additionally, there is a method 31 of using neural networks to solve a Stefan problem 32 , which is a free-boundary problem and describes a phase-change between liquid and solid states.However, the method assumes that the boundary of the phase-change between the states is already known.
We propose an algorithm, Grad-Shafranov Deep Neural Networks (GS-DeepNet), which learns plasma equilibria without using existing traditional numerical algorithms that reconstruct the equilibria (i.e., find the solution to the GS equation).First and foremost, GS-DeepNet is trained through self-teaching unsupervised learning, without any guess of the solutions.The only known information is the GS equation and the externally measured magnetic fields, acting as the boundary condition of the differential equation, with no manual selections.Second, GS-DeepNet uses typical fully-connected neural networks known to be capable of retaining real-time application.Finally, GS-DeepNet uses an auxiliary module that detects plasma boundary information solely from network outputs.To reach these outcomes, we develop neural networks that are capable of solving a nonlinear elliptic partial differential equation under free-boundary and inverse conditions, namely the GS equation.GS-DeepNet is trained, validated and tested in the Korea Superconducting Tokamak Advanced Research (KSTAR) environment 33 .

Architecture of GS-DeepNet
Our novel unsupervised learning algorithm GS-DeepNet, comprising two deep neural networks NN 1 and NN 2 θ (Fig. 1c) with parameters and θ , respectively, finds a solution of the GS equation, which is where ∂Z 2 is defined as a two-dimensional, elliptic partial differential operator in the tokamak machine coordinates (R, φ, Z) with the toroidal axisymmetry assumption 8,9 ; i.e., ∂ ∂φ = 0 .The first line of Eq. ( 1) is a consequence of ∇ • � B = 0 and ∇ × � B = µ 0 � J in an axisymmetric toroidal geometry, where B and J are respec- tively the magnetic field and current density from Maxwell's equations.It states that the elliptic differential operator acting on the poloidal flux function ψ is proportional to the product of the major radius R and the toroidal plasma current density J φ with the permeability µ 0 as the constant of proportionality.The second line of Eq. (1) can be derived using the force-balanced MHD momentum equation, � J × � B = ∇p , where p is the plasma pres- sure.The poloidal current function f = RB φ with toroidal magnetic field B φ is a quantity related to the poloidal plasma current.Formally, p and f are functions of only ψ .Thus, the task of GS-DeepNet is to find ψ(R, Z) in the two-dimensional poloidal plane (Fig. 1b) with two free functions p(ψ) and f (ψ) while satisfying the boundary conditions set by a given magnetic measurement state that we call a feature.Note that finding ψ(R, Z) together with p(ψ) and f (ψ) is what is known as the reconstruction of the MHD equilibrium of a toroidal plasma.
With a single spatial point (R, Z) and a set of magnetic measurements FL ) means a collection of measurements made at different spatial locations in a single time slice (i.e., a feature), namely 31 measurements of B MD R , 31 of B MD Z and 45 of ψ MD FL , resulting in a total of 107 magnetic measurements.Here, B MD R and B MD Z are respectively the R -and Z-components of the poloidal magnetic field, measured using a magnetic pick-up probe (blue dots in Fig. 1a,b).ψ MD FL is the poloidal magnetic flux measured using a magnetic flux loop (red open circles in Fig. 1a or red dots in Fig. 1b).These magnetic pick-up probes and flux loops installed at the tokamak boundary constitute a suite of magnetic diagnostics and impose the boundary conditions in real time on GS-DeepNet.The magnetic pick-up probes measure the normal ( B MD n ) and tangential ( B MD t ) components of the poloidal magnetic fields with respect to the vacuum vessel wall where the probes are installed, and B MD R and B MD Z are thus calculated using a simple coordinate conversion (see Fig. S1).We specified 41 × 41 (1) grid points (black dots in Fig. 1b) on the (R, Z) plane (i.e., on a poloidal plane), where NN 1 is trained to output the values of ψ .The GS equation constrains only the derivative of ψ , and we must therefore supply proper bound- ary conditions as discussed in Supplementary Note S1.For this reason, we let NN 1 also accept the (R, Z) positions The network NN 1 (Maxwell Net) takes a spatial position and a feature of the magnetic data as its input and outputs a poloidal flux function that is used to calculate B R , B Z and � * ψ with the automatic differential operator Diff A .After determining a plasma boundary using the auxiliary module with the output of the Maxwell Net, the network NN 2 (Force-Balance Net) takes a poloidal flux function as its input and outputs a pair p ′ , ff ′ . (d,e) Example of the three-dimensional configurations of the reconstructed � * ψ (d) and ψ (e) from GS-DeepNet.KSTAR poloidal field coils (gray), the vacuum vessel wall (light orange) and the plasma facing components (light blue) are also shown as well as the magnetic diagnostics (blue and red dots).
of the magnetic diagnostics as an input and be trained to provide values of ψ at the tokamak boundary.Thus, the solution space is the 41 × 41 grid points and the positions of the magnetic diagnostics.Using the automatic differential operator 34 ( Diff A in Fig. 1c) and the flux function ψ , B R (= −1/R • ∂ψ/∂Z) , B Z (= 1/R • ∂ψ/∂R) and � * ψ are calculated and used to train the network with the measured boundary conditions.We refer to NN 1 together with Diff A as the Maxwell Net.
The output of NN 1 , ψ , is fed into NN 2 θ , which outputs two free functions: dp/dψ, fdf /dψ ≡ p ′ , ff ′ = NN 2 θ (ψ) .The input of NN 2 θ is ψ , and the two free functions are thus guaranteed to be functions of only ψ .Tokamak plasmas have a well-defined plasma boundary known as the last closed flux surface (LCFS, thick black line in Fig. 1b); consequently, outside the LCFS, the toroidal plasma current density J φ is set to be zero based on a common assumption, resulting in � * ψ out = 0 from Eq. (1), where ψ out(in) is the flux function ψ outside (inside) the LCFS.Thus, finding p ′ , ff ′ consistent with Eq. ( 1) is relevant only inside the LCFS.Unfortunately, the LCFS cannot be identified until ψ 's in the solution space are known, which is the reason why solving the GS equation is a free-boundary problem.We note that there is a recent work to predict the future LCFSs in real-time with deep learning 35 , and it requires a free-boundary problem solver, e.g., EFIT, to identify where the boundary locations are.GS-DeepNet first infers the LCFS on the basis of (B R , B Z , ψ) in the solution space from NN 1 using an auxiliary module for the boundary detection (Fig. 1c) (see "Methods").NN 2 θ then outputs p ′ , ff ′ using the normalized input ψ if it is inside the LCFS.Note that ψ is normalized to be zero at the magnetic axis and 1 at the LCFS according to the boundary detection module.The output p ′ , ff ′ is used to calculate −µ 0 R 2 p ′ − ff ′ , which must be equal to � * ψ in according to the second line of Eq. (1), which is the reason why we refer to NN 2 θ as the Force-Balance Net.As mentioned earlier, p(ψ) and f (ψ) are free functions, and they thus have large numbers of degrees of freedom.To constrain these free functions (i.e., to train the NN 2 θ network) such that they convey physical meanings, as they should, we use the fact that µ 0 R 2 p ′ + ff ′ = µ 0 RJ φ from Eq. (1).More specifically, −µ 0 R 2 p ′ − ff ′ , which dictates what the current source J φ has to be inside the LCFS, must be constrained with the given magnetic data −→ MD , (i.e., a feature) via a response matrix R calculated using the Biot-Savart law (see "Methods") and the measured total plasma current I plasma m , which is a quantity routinely measured using a Rogowski coil in real time 7 .
In summarizing how the unsupervised GS-DeepNet works, the Maxwell Net NN 1 with the input of (R, Z, −→ MD) generates ψ , whose normalized value is the input to the Force-Balance Net NN 2 θ generating p ′ , ff ′ .Because � * ψ (from the Maxwell Net) must be equal to −µ 0 R 2 • p ′ − ff ′ (from the Force-Balance Net), GS-DeepNet trains itself until the Maxwell Net and Force-Balance Net are consistent with each other while matching the measured magnetic signals −→ MD at the tokamak boundary using the automatic differential operator for the Maxwell Net and the response matrix R for the Force-Balance Net.Of course, we impose that there is no plasma current outside the LCFS, where the LCFS is determined by the plasma boundary detection module; thus, the Maxwell Net is also trained to give ψ out such that � * ψ out = 0 .This constraint brings an ill-posed condition in our problem, which is explained in detail in Methods.To resolve such an issue, we train the Force-Balance Net using the concept of transfer learning 36 and the singular value decomposition (SVD) technique (see "Methods") in addition to a usual gradient descent algorithm which makes our algorithm novel.
Both the Maxwell Net and Force-Balance Net have multiple fully-connected layers 21 with dropout 37 and swish nonlinear activation functions 38 .The Maxwell Net has three hidden layers with 100 neurons and a bias for each layer, whereas the Force-Balance Net has two hidden layers with 60 and 6 nodes for the first and second layers, respectively, without any bias nodes.We used a dropout scheme with a rate of 0.05 and 0.10 for the Maxwell Net and Force-Balance Net, respectively, during the training process.The same dropout rates are also used for both networks during the test (prediction) phase to obtain the model uncertainty 39 .A detailed description on how we train GS-DeepNet such as collecting dataset and defining loss functions is provided in "Methods".
As an example, two-dimensional configurations of � * ψ and ψ from GS-DeepNet are shown in Fig. 1d and e, respectively, with some relevant tokamak structures of KSTAR 33 for this work.Tokamak plasmas are toroidally axisymmetric as assumed in the GS equation, and � * ψ and ψ on a two-dimensional poloidal (R, Z) plane thus suffice for us to reconstruct an axisymmetry two-dimensional structure of the MHD equilibrium of a tokamak plasma.

Statistical analysis of GS-DeepNet training: how well GS-DeepNet teaches itself to solve the GS equation
GS-DeepNet is constrained only by the GS equation given as Eq.(1), which is formulated as the loss functions l 1 and l 2 (see "Methods") as in Eqs. ( 6) and ( 7) for the Maxwell Net NN 1 and Force-Balance Net NN 2 θ , respectively, and by the measured magnetic signals as the boundary conditions.Therefore, we first evaluate the training performance; i.e., we evaluate how well GS-DeepNet has learned to solve the GS equation with the boundary conditions.This is important because GS-DeepNet does not rely on existing traditional numerical algorithms that solve the GS equation.Figure 2 summarizes the statistical results of the training performance.
Figure 2a-c shows the performance of the Maxwell Net in outputting values of ψ and their corresponding (B R , B Z , ψ)| MD calculated by the automatic differential operator 34 according to the boundary conditions, which are magnetic measurements Taking a single feature as an example, the left panels in Fig. 2a-c compare the GS-DeepNet results (cyan line: average; cyan dashed line: 1 − σ uncertainty) and magnetic measurements (red dots) for B R (Fig. 2a), B Z (Fig. 2b) and ψ FL (Fig. 2c).Note that the 1 − σ uncertainty of the network is obtained using the Monte Carlo (MC) dropout method 39 .The right panels in Fig. 2a-c show histograms (color coded), generated using all training data sets, comparing GS-DeepNet results (abscissa) and measurements (ordinate) with the y = x red dashed line.We also provide values of the coefficient of determination R 2 for B R , B Z and ψ FL , all of which are close to unity, indicating that the Maxwell Net has been trained well to be consistent with the measured boundary conditions.
We mention that KSTAR has 42 magnetic pick-up probes for measuring both B R and B Z at the toroidal loca- tion that we are considering and 45 flux loops for measuring ψ FL , as shown by the probe and loop indices on the horizontal axes of Fig. 2a-c.Among them, we used 31 magnetic pick-up probes because the others were impaired and simply output null values; thus, there are 31 red dots, instead of 42, in Fig. 2a and b.For the signals from the 45 flux loops, we devised an algorithm using a separate neural network that examines whether the measurements of ψ MD FL are consistent with the measurements made by the magnetic pick-up probes and, if necessary, corrects the flux-loop measurements in real time 40 ; thus, we are able to use 45 measurements for ψ FL as in Fig. 2c.Note that such real-time corrections are necessary because a number of the magnetic measurements are sometimes impaired as the pick-up probes and flux loops are susceptible to damage 41,42 .One advantage of our GS-DeepNet over traditional numerical algorithms solving the GS equation is that GS-DeepNet allows us to use every magnetic measurement except those that are fully out of order.On the other hand, traditional ones require human selection of the measurements, which introduces human subjectivity, even among seemingly good measurements to guarantee numerical convergence, i.e., minimizing a chi-square estimation 12 , and to avoid obtaining unphysical plasma equilibria.Moreover, if there are flawed magnetic pick-up probes among the 31 selected probes, GS-DeepNet can incorporate an existing real-time imputation scheme 41 based on Bayesian inference 43 and a Gaussian process 44 .
To examine the training performance of the Force-Balance Net, we first compare an algebraic combination of the output, namely −µ 0 R 2 p ′ − ff ′ , with � * ψ obtained from the Maxwell Net.As dictated by the GS equation given in Eq. (1), GS-DeepNet must satisfy 2d is a histogram (color coded) generated using whole training data sets, which compares results from the Force-Balance Net www.nature.com/scientificreports/(ordinate) and the Maxwell Net (abscissa) with the y = x red dashed line.We see that the coefficient of deter- mination R 2 is close to unity, indicating that GS-DeepNet has taught itself well to solve the GS equation.Being free functions, p ′ (ψ) and ff ′ (ψ) must not only obey the GS equation as demonstrated in Fig. 2d but also comply with the magnetic measurements.Otherwise, these two free functions would have too much freedom to be applicable for tokamak operations.Figure 2e-f shows how these free functions are consistent with the magnetic measurements by comparing the Force-Balance Net results R J with the given magnetic data −→ MD , with the background colors of yellow, white and gray indicating B R , B Z and ψ , respectively.Here, R is the response matrix, and J is the current source containing toroidal current densities of plasma, and currents flowing through the external coils and the vacuum vessel (see "Methods").

Physical parameters learned by GS-DeepNet
We confirm that with high degrees of precision GS-DeepNet learns the GS equation by itself with the measurement constraints as the boundary conditions, and therefore we present the physical parameters that GS-DeepNet obtains-the poloidal flux function ψ , plasma pressure p and poloidal current function f -to demonstrate the real-time applicability of GS-DeepNet to tokamak operations.
Tokamak plasmas are generally categorized as limited and diverted plasmas 45 .These two types of plasma have fundamentally different magnetic topologies in that a limited plasma has its boundary touching a solid wall (Fig. 3a,b, top row), whereas a diverted plasma has one (or more) magnetic X-point(s) (i.e., null point(s) of poloidal magnetic fields) and only the legs extend to the divertors (Fig. 3a,b, bottom row).As shown in Fig. 3a,b, these two types of tokamak plasma are well reconstructed by GS-DeepNet in accordance with the measurements.Here, with example features randomly selected from KSTAR discharges, Fig. 3a shows the poloidal flux function ψ , which is the most important quantity with which to control the plasmas, and their corresponding � * ψ , which dictates the toroidal current density, is shown in Fig. 3b.Because there are absolutely no means by which to determine an equilibrium in tokamaks directly, Fig. 3a compares the contours of constant ψ from an existing numerical algorithm EFIT (gray dashed lines) with those from GS-DeepNet (colored lines).Not only do the contours match well but also the plasma boundary (red dashed line) coincides with that from EFIT (black dashed line).We cannot argue whether or not the contours of ψ from EFIT is true representation of the plasma equilibrium because EFIT solves the ill-posed GS equation.Nevertheless, EFIT is a reasonable target for comparison because it has been widely used in the field of nuclear fusion.Figure 3a,b also shows the model uncertainties obtained using the MC dropout method 39 .
For a complete statistical comparison, we estimated and compared histograms of several plasma parameters widely used in plasma control, namely the major radius R 0 ( R at the magnetic axis of an equilibrium), elongation κ (the ratio of vertical to horizontal sizes of a plasma), minor radius a (the half distance between the innermost and outermost R positions of a plasma) and triangularity δ (a shaping parameter) (see Fig. S5g in Supplementary Note S2).Histograms for EFIT and GS-DeepNet are shown in Fig. 3c together with the differences between them calculated as ǫ rel,x = 100 × x EFIT − x NN /x EFIT , where x EFIT and x NN take one of the plasma parameters from EFIT and GS-DeepNet, respectively.Although the estimations are similar between the two, noticeable differences can be seen in that the only EFIT results have the bimodal histograms for R 0 and κ .Whether such results are real phenomena or not cannot be identified at this point since we find that there exist at least 5 to 10 mm uncertainties in EFIT for R 0 and the boundary estimations, which are associated with selecting slightly (about 10%) different combinations of working magnetic pick-up coils (similar to the human subjectivity discussed earlier) as well as a finite spatial resolution the EFIT has, i.e., radial resolution of approximately 10 mm.We note that GS-DeepNet gets a position of ( R, Z ) as its input, meaning that GS-DeepNet can have a higher spatial resolution around the magnetic axis, X-point(s) and the boundary.
While one may argue that the availability of a real-time map of ψ(R, Z) from the Maxwell Net of GS-DeepNet suffices for the purpose of tokamak operation, we further examine a radial profile of the plasma pressure because it is a part of the Force-Balance Net that is essential for training GS-DeepNet.Comparing the plasma pressure from GS-DeepNet with a measurement is not trivial as tokamak plasmas consist of electrons, main ions (usually isotopes of hydrogen), fast ions and trace amounts of impurity ions, such as carbon and nitrogen ions.In most cases, we can ignore the pressure contributions from the impurity ions because their densities are much lower than the density of the main ions.Thus, denoting the density and temperature by n and T with a subscript e, i and F for the electron, main ion and fast ion, respectively, we have the total pressure p = n e k B T e + n i k B T i + n F k B T F with the Boltzmann constant k B .During tokamak operation, plasmas can be heated by their own currents with finite electrical resistivity 46 and by injecting external electromagnetic waves 47 resonating with either electrons or ions.There is also a neutral beam injection 48 that heats the plasmas, which is a main source of fast ions in present tokamaks.Unfortunately, there is no method of measuring a radial pressure profile of fast ions in KSTAR; therefore, we need to select plasmas that have no fast ions (i.e., no neutral beam injections) to make the pressure comparisons with the measurements.This means that we cannot measure the pressure of main ions either because the temperature of main ions is inferred by the Charge Exchange Spectroscopy system 49 , which requires a neutral beam injection.Thus, the only available pressure measurement is that for the electrons using the Thomson scattering system 5,50 , which provides n e and T e , separately.Therefore, as has been done for other tokamaks [51][52][53] , we simply set the measured total plasma pressure to be p = 2n e k B T e for ohmic discharges.
Figure 3d shows a radial profile of the measured pressure as p = 2n e k B T e (black dots) from the KSTAR Thomson scattering system 50 for an ohmic discharge, The red line denoted as p GP is obtained by performing a non-parametric Gaussian process regression 44 on the measurements.The pressure profile from GS-DeepNet, denoted as p NN , is shown as the blue line.A comparison reveals that the pressure profile from GS-DeepNet agrees well with the measurements within their uncertainties.Note that uncertainties in p GP are obtained through the Gaussian process regression with the measurement uncertainties whereas those in p NN are estimated via the MC dropout method 39 without relying on the measurement uncertainties.Thus, the uncertainties in p NN such as smaller uncertainties in the core compared to those in the edge require careful interpretations.This will be addressed as a future work with the extended GS-DeepNet proposed in Supplementary Note S3.Another output of the Force-Balance Net is ff ′ , where f = RB φ is the poloidal current function with the toroidal magnetic field B φ .We examine this quantity with measured local magnetic pitch angles via the motional Stark effect (MSE) diagnostic system 6 .The MSE system in KSTAR 54 measures the pitch angle γ at 25 different radial positions as tanγ , where the coefficients A 1 , A 2 and A 3 are fixed by the Histograms of the various plasma parameters ( R 0 , κ , a and δ ) from GS-DeepNet (blue) and the EFIT (red) and their relative errors ǫ rel . (d) Comparisons of the profile of plasma pressure from the Force-Balance Net (blue) and the measurements (black) based on p = 2n e k B T e .The red line is obtained vis the Gaussian process from the measurements.Blue and red highlighted regions indicate the 1 − σ uncertainty from the Force-Balance Net and Gaussian process, respectively.(e) Left: comparison of the profile of the calculated magnetic pitch angle, tanγ , from the Force-Balance Net (blue) and the measurements (red).Right: histogram of the root-mean-square difference in tanγ between the Force-Balance Net and measurements.
Vol:.( 1234567890 www.nature.com/scientificreports/geometrical configuration of the system.Note that the MSE system requires a neutral beam injection, and because the pitch angle is a field quantity rather than a species quantity, we do not have to restrict ourselves only to ohmic discharges, which was the case for the pressure comparisons.Together with the output of the Maxwell Net, ψ , where we obtain B R (= −1/R • ∂ψ/∂Z) and B Z (= 1/R • ∂ψ/∂R) , tanγ can be calculated with the output of the Force-Balance Net. Figure 3e compares a radial profile of tanγ , where the red dots indicate the measurements and the blue line is the result from GS-DeepNet.The agreement is excellent, and we calculated the histogram of the root-mean-square error (RMSE) of tanγ as using 50 KSTAR discharges.Here, the subscript i denotes a channel index for 25 channels (i.e., n = 25 ), and the superscripts NN and m indicate values from GS-DeepNet and the measurements, respectively.As a guide for the RMSE magnitude, we note that the RMSE is 0.024 in Fig. 3e.

Discussion
We showed that solving a two-dimensional, second-order, nonlinear, elliptic partial differential equation from scratch (i.e., tabula rasa) is possible with the proposed structure of an unsupervised neural network scheme.The differential equation that we solved, the GS equation, provides the most fundamental information with which to control tokamak plasmas in harnessing electricity via nuclear fusion reactions.The developed network, GS-DeepNet, comprises the Maxwell Net and Force-Balance Net and outputs the poloidal flux function ψ , pressure gradient dp dψ , and a quantity related to the poloidal current f df dψ in the two-dimensional poloidal plane (R, Z) consistent with the GS equation and the magnetic boundary conditions measured far from the solution space.The problem that we have solved is an ill-posed and free-boundary problem that is solved by invoking the concept of transfer learning and the singular value decomposition technique for the ill-posedness aspect and by introducing the auxiliary boundary detection module for the free-boundary aspect.Because many (if not all) physical phenomena are expressed in a form of differential equations, our work can shed light on constructing a neural network in other engineering and science fields to solve their problems starting from scratch.For instance, previous work on solving complex physical systems such as those of quantum mechanics 22,23,29 , fluid dynamics 24 and high-energy physics 55 may be advanced using our proposed methodologies.
Being specific to the field of nuclear fusion, GS-DeepNet is also confirmed to be capable of generating reliable magnetic equilibria when its results are compared with the results obtained from a traditional numerical algorithm, specifically EFIT.This means that GS-DeepNet can be used together with a conventional real-time EFIT algorithm to support or sometimes to rebuke real-time EFIT results because one of the advantages that GS-DeepNet has is its flexible and adjustable spatial resolution.For instance, higher spatial resolution around the magnetic axis or near the magnetic X-point(s) can be achieved with GS-DeepNet since an ( R, Z ) position is a part of its input.Therefore, using GS-DeepNet together with a real-time EFIT, we anticipate that tokamak performance will be enhanced, supporting the realization of economical nuclear fusion reactors.Note that GS-DeepNet takes less than 1 ms to estimate full two-dimensional flux surface on 41 × 41 grids using a single GPU (RTX A4000).
As a final remark, we briefly mention how GS-DeepNet can be further extended.If we know the two free functions p(ψ) and f (ψ) , then Eq. ( 1) is a closed system for ψ(R, Z) .There thus exist advanced numerical algorithms, such as a kinetic-EFIT 56 , that consider the inferred p(ψ) and f (ψ) based on measurements in reconstructing the MHD equilibrium.Radial profiles of the pressure are typically measured using a Thomson scattering system 5 for electron density and temperature, whereas the ion temperature is inferred using a charge exchange system 49 .The poloidal current function f (ψ) is inferred from a profile of the local magnetic pitch angle, which can be measured using an MSE system 6 .Although there have been attempts to obtain p(ψ) and f (ψ) in real time 57 , these profiles are not typically available during tokamak operation.Furthermore, many of the mid-to large-scale tokamak operations contain another type of ion, namely fast ions.In some tokamak scenarios, the contribution of fast ions to the pressure is not negligible 58 , and profiles of the fast ions are not available in real time nowadays.Therefore, we do not have p(ψ) and f (ψ) in real time at the moment.Note that the kinetic-EFIT does not work in real time.Nevertheless, because we foresee that these profiles may become available in real time in the future, we propose an extended GS-DeepNet to accommodate such profiles.In training the Force-Balance Net with the measured p(ψ) and f (ψ) available in real time to output dp dψ and f df dψ , we can add an auto-encoder as further elaborated in Supplementary Note S3.

Response matrix R
Let us discuss the response matrix R in more detail because it may not be trivial.The Biot-Savart law allows us to calculate at an arbitrary spatial position the magnetic field generated using a constant electric current at a fixed location.Owing to its linearity, the magnetic field generated at a certain position by plasmas can be calculated by modeling the total toroidal plasma current as the sum of many toroidal current filaments with small rectangular cross-sections 18,59 in a tokamak.For instance, a toroidal plasma current J φ at a single R − Z grid position (a black dot in Fig. 1b) has a well-defined rectangular cross-section set by the distance between neighboring grid points with a toroidal length of 2πR (see Fig. S2) and a fixed position.We thus pre-calculate the contribution of a single toroidal current filament J φ generating a magnetic field at a measurement position as R ij , where the subscripts i and j indicate a magnetic sensor and a toroidal current filament dictating the measurement and source positions, respectively.We calculate a component of the magnetic field at the location of the i th magnetic sensor due to the total toroidal plasma current as j R ij J φ,j , where j runs from 1 to 1681 for the 41 × 41 grid points.
We have a total of 107 magnetic measurements, and the contribution due to plasmas can thus be formulated as a 107 (rows) by 1681 (columns) matrix R p .Because we do not know where the LCFS is in advance, we prepare the matrix to cover all 41 × 41 grid points.Once the LCFS is inferred through the plasma boundary detection www.nature.com/scientificreports/module, we reduce the size of R p to 107 (rows) by N in (columns), where N in is the number of the grid points inside the LCFS, and we denote the reduced matrix as R p,in .Therefore, with � J φ ≡ {J φ } , (i.e., a column vector of N in by 1 containing the filaments of toroidal plasma current densities), R p,in J φ provides a column vector with the magnitudes of magnetic fields at the 107 magnetic measurement positions due to the total plasma current.
Because a tokamak has external current-carrying coils generating magnetic fields that confine hot plasmas (see Fig. 1d,e), we must also include such current sources that affect the magnetic fields at the measurement positions.At KSTAR 33 , a tokamak at which GS-DeepNet is trained, which is validated and tested for this work, 14 poloidal field coils and 16 bundles of two conductors are in four segments for the in-vessel coils where toroidal currents flow.The response matrix for these external coils, denoted as R ext , is prepared with dimensions of 107 (rows) by 14 + 16 (columns), and the corresponding magnitudes of the currents J ext are known because they are set using the controls of the tokamak.The other current source is the induced toroidal eddy currents flowing through the vacuum vessel that may not be negligible 60 , and this source is modeled with 18 current-carrying segments, following a previous approach used for KSTAR 61 .We thus have a 107 (rows) by 18 (columns) matrix R VV that contains the contribution of the eddy currents J VV flowing through the vacuum vessel.Obviously, J VV is a column vector with dimensions of 18 by 1, and the vector is inferred 62 in the unsupervised training procedure.The network NN 2 θ must then comply with the condition −→ MD = R � J , where the response matrix R is defined as with dimensions of 107 (rows) by N in + (14 + 16) + 18 (columns) and the column vector current source J is defined as J φ , J ext , J VV with dimensions of N in + (14 + 16) + 18 by 1. Figure S2 shows the three-dimensional structure of a toroidal current filament with a rectangular cross section for modeling the plasma current density, external coil currents and vessel currents.Using this model, we estimate a matrix component of the response matrix R ij with the equations 63 and Here, R denote the components for B R , B Z and ψ FL , respectively.The subscript j identi- fies a current source (point P in Fig. S2), whereas i indicates a magnetic sensor (point Q in Fig. S2).Thus, R j,1 , R j,2 , Z j,1 , Z j,2 denotes the four vertices of the rectangular cross-section for the j th current source, whereas (R i , Z i ) is the spatial position of the i th magnetic sensor; i.e., a magnetic pick-up probe or flux loop.Note that we designate 1 ≤ i ≤ 31 , 32 ≤ i ≤ 62 and 63 ≤ i ≤ 107 for 31 values of B R , 31 values of B Z and 45 values of ψ FL , respectively, resulting in a total of 107 values to be compared with the measured magnetic fields.We have 1 ≤ j ≤ 41 2 (= 1681) values for R p , 1 ≤ j ≤ 30(= 14 + 16) values for R ext and 1 ≤ j ≤ 18 values for R VV .K(k) and E(k) are the complete elliptic integrals of the first and the second kinds, respectively, with the elliptic modulus k

How to train GS-DeepNet
To demonstrate the performance of the proposed architecture of GS-DeepNet, we randomly collected 50 experimental plasma discharges of KSTAR from 2019 campaign including a limited number of the ohmic phase and reasonable number of the L-mode and H-mode phases, where each discharge lasted a few tens of seconds.Supplementary Note S2 describes a typical KSTAR plasma discharge.From these discharges, we have obtained magnetic data at every 0.1 s starting approximately from 0.8 s of the discharge time from each discharge, resulting in ∼ 10 4 time slices (features) including ramp-up and flat-top phases but no ramp-down phases.With approximately 2 × 10 3 spatial positions ( 41 × 41 + 107 positions exactly) we gathered approximately 2 × 10 7 = 2 × 10 3 × 10 4 datasets, of which 80%, 5% and 15% were used as training, validation and test datasets, respectively.The training of GS-DeepNet via TensorFlow 64 continued until it was terminated using the early stopping method (a regularization method that preserves generalization for unseen features) 65 , which took approximately 1 day with one GPU worker and 20 CPU cores using a mini-batch scheme.The total mini-batch size was approximately 8000 , which is 80% of ∼ 10 4 features.We note that measurement noise and signals drifts in the magnetic signals −→ MD were compensated adopting a boxcar average scheme and the Bayesian-based drift mitigation method 15 , respectively.The boxcar average uses a time window of 1 ms as the sampling frequency of the measurements is 10 kHz, and the equilibrium to control the plasmas is typically updated every ~ 10 ms in KSTAR.
Training GS-DeepNet starts by initializing both NN 1 (Maxwell Net) and NN 2 θ (Force-Balance Net) with random parameters of 0 and θ 0 , respectively, adopting the Glorot (or Xavier) initialization 66 scheme.At each iteration k ≥ 1 , we select a random and unseen feature t from the total of ∼ 8000 features, resulting in a batch size of 41 2 + 107 = 1788 corresponding to the 41 × 41 grid points and the 107 different locations of the magnetic measurements.The solution is then generated at all 1788 spatial positions, and with the automatic differential operator Diff A , 1788 sets of ψ, B R , B Z , � * ψ t are prepared.After an LCFS is inferred using the plasma boundary detection module, p ′ , ff ′ t = NN 2 θ k−1 ψ t in is generated at all the positions inside the LCFS, giving us N in sets of p ′ , ff ′ , −µ 0 R 2 p ′ − ff ′ , � J φ t .As a reminder, N in is the number of the grid points inside the LCFS.To train GS-DeepNet, we need J , which is J φ , J ext , J VV ; thus, we also prepare J ext , which can be simply read from the tokamak controls, and J VV , which is determined through singular value decomposition (SVD) during the training of the Force-Balance Net.At every iteration with a randomly selected feature t , we update the networks' parameters and θ using the two loss functions l 1 and l 2 , respectively.Following a mini- batch training scheme, one epoch is completed when GS-DeepNet sees a total of ∼ 8000 features, corresponding to ∼ 8000 iterations for one epoch.
We use a stochastic gradient descent algorithm to train the parameters and θ by means of loss functions and the SVD technique for θ as well as J .The Maxwell Net, NN 1 together with Diff A , is trained to output an absolute value (i.e., unnormalized value) of ψ such that it satisfies the boundary conditions as well as the force-balanced equilibrium.This is formulated as the loss function l 1 : where the angle brackets N denote an averaging operator with the subscript N denoting the number of elements for the average.(B R , B Z , ψ)| MD denotes the calculated B R , B Z from Diff A and ψ (output of NN 1 ) at the locations of the magnetic diagnostics with N MD = 107 ; thus, the first term forces the Maxwell Net to comply with the measured boundary conditions −→ MD .The second term ensures consistency between the Maxwell Net and Force- Balance Net inside the LCFS, where � * ψ in is the estimate from the Maxwell Net and µ 0 R 2 p ′ + ff ′ that from the Force-Balance Net.The third term ensures that there is no toroidal plasma current outside the LCFS; i.e., � * ψ out = 0 .The last term, c 1 2 , is the L2 regularization (sum of squares) on the weights with the coefficient c 1 = 10 −3 , and it avoids overfitting together with the early stopping method 65 .
The Force-Balance Net, NN 2 θ , is trained to output p ′ , ff ′ with an input ψ from the Maxwell Net after normal- izing ψ such that its value becomes 0 and 1 at the magnetic axis and boundary, respectively.The loss function l 2 for the Force-Balance Net is constructed as The first term specifies the network to be consistent with the measured boundary conditions −→ MD because the response matrix R associates the current source J , which is a function of the network's output p ′ , ff ′ , with −→ MD .The second term dictates that the sum of filaments of the toroidal current density inside the LCFS calculated by the network, which is α * � N in i=1 R i p i ′ + ff i ′ /R i µ 0 with the area of the rectangular cross-section α divided by 10 6 ( α * ≡ α/10 6 ), must be equal to the measured total plasma current I plasma m in units of megaamperes, which is the reason why we have a factor of 10 6 for α * .To regularize the weights connecting the last hidden layer and the output layer, we have the L1 regularization (sum of absolute values), c 2 θ 1 , with the coefficient c 2 = 10 −2 for p ′ and 10 −3 for ff ′ .In resolving the ill-posedness of our system, training the Force-Balance Net becomes complex as we use the concept of transfer learning 36 and the SVD technique in addition to a usual gradient descent algorithm, which makes our algorithm novel; thus, we provide a detailed explanation of our algorithm in 'Optimizing the Force-Balance Net' in Methods.

Optimizing the Force-Balance Net
As mentioned in the main text, the Force-Balance Net accepts a value of ψ as the input from the Maxwell Net and outputs ( p ′ , ff ′ ).The Force-Balance Net has two fully connected hidden layers, with the first and second layers having 60 and 6 nodes, respectively, without any bias nodes.A neural network can sensibly reproduce any form of a profile, similar to the case for Gaussian processes, as long as the network has a sufficient number of degrees of freedom 67 .We find empirically that our choice of the numbers of hidden layers and nodes has enough degrees of freedom to describe the experimentally measured profiles of p ′ and ff ′ .
Optimizing the Force-Balance Net comes down to a problem of minimizing the loss function l 2 (Eq. ( 7)) whose role is to reveal the most probable representations of � J = � J φ , � J ext , � J VV that explain the given magnetic data −→ MD and the measured total plasma current I plasma m with consideration of the L1 regularization, where J φ is determined by an algebraic combination of � p ′ and � ff ′ .As a reminder, J φ is the collection of filaments of the toroidal plasma currents, whereas J ext and J VV are the currents flowing through the external magnetic field coils and the eddy currents flowing through the vacuum vessel, respectively.This optimization process is generally subject to an ill-posed condition because the number of unknown quantities to be determined (i.e., � p ′ , � ff ′ and J VV ) is considerably larger than the number of the given measurements (i.e., −→ MD and I plasma m ).Note that we have reasonably good information on J ext because it is a control parameter.Consequently, optimizing the Force- Balance Net using only a gradient descent algorithm often leads the to-be-determined current density J to be stuck in extremely unphysical solution spaces where very small plasma currents of the order of a few amperes throughout the plasma region are predicted while a small number of segments of eddy current on the vacuum vessel attempt to explain the entire set of measurements.This is likely to have at least two reasons.First, there are many nuisance local minima owing to the ill-posed condition.Second, constraints on the eddy current J VV are ( 6) Vol.:(0123456789) www.nature.com/scientificreports/very weak.Therefore, we relax the ill-posed condition by recasting the loss function l 2 into a matrix multiplica- tion form and then optimize the source current � J = � J φ , � J ext , � J VV by updating the weights of direct connections to the output nodes using the SVD technique, while all other weights up to the last hidden layer are determined using a gradient descent algorithm through transfer learning 36 .Figure S3a shows the matrix form of the loss function l 2 .We introduce a clever representation for the plasma current density J φ and its associated response matrix R p,in to loosen the ill-posed condition, while J ext and J VV and their associated response matrices R ext and R VV are expressed as they are (the red part in Fig. S3a).Note that we borrow the idea of the matrix representation from the EFIT algorithm 12 .These quantities regulate the first term of the loss function l 2 as we wish to minimize R � J − −→ MD

2
. Basically, we reform the plasma contributions, namely R p,in J φ and α * � N in i=1 R i p i ′ + ff i ′ /R i µ 0 , in terms of the network's weight-wise form as R p,in h⋆ � v � J φ and � α * h⋆ � v � J φ (see the red part in Fig. S3a), respectively, with h⋆ � v � J φ = � J φ (see Fig. S3b), where h⋆ and v J φ are explained below.Let us suppose that we want to estimate a plasma current density J φ,i at the i th grid position inside the LCFS with an output of the Force-Balance Net (p i ′ , ff i ′ ) .We know that J φ,i = R i p i ′ + ff i ′ /R i µ 0 from Eq. (1), and the network's structure with the node values at the last hidden layer h i (dimensions of 1 × 6 ) and the weights assigned to the output from the last hidden layer � v p ′ (dimensions of 6 × 1 ) and � v ff ′ (dimensions of 6 × 1 ) for the output nodes p ′ and ff ′ , respectively.We thus rewrite J φ,i in the weight-wise form as This weight-wise representation can be extended to all grid positions inside the LCFS as � p ′ = h� v p ′ and � ff ′ = h� v ff ′ with the matrix form of the hidden node values h (dimen- sions of N in × 6 ).Let us define two constant matrices containing R i and 1  S3b).We can thus change R p,in J φ into R p,in h⋆ � v � J φ , which is what we have in Fig. S3a.Similarly, a predicted total plasma current α * � N in i=1 R i p i ′ + ff i ′ /R i µ 0 can be represented as � α * h⋆ � v � J φ using a row vector � α * = [α * , • • • , α * ] with dimensions of 1 × N in , and it plays a role as the second term in the loss function l 2 ; i.e., minimizing α * � N in i=1 R i p i ′ + ff i ′ /R i µ 0 − I plasma m

2
. The key rationale behind reformulating J φ in the weight-wise form is that instead of letting the measured −→ MD and I plasma m be explained by J φ itself, which is the main cause of the ill-posed condition because J φ occupies the majority of J , we design the given measurements to be described by v J φ , which drastically reduces the number of unknown parameters and thus relaxes the ill-posed condition.
The third term in the loss function l 2 is the L1 regularization, and its purpose is to prevent the network's output from being unnecessarily complex; i.e., preventing the overfitting problem.This regularization can be embedded in the matrix form; i.e., forcing c 2 I v J φ to be as small as possible (see the blue part in Fig. S3a), where the identity matrix I has dimensions of 12 × 12 .c 2 is constant, and we set it at 10 −2 for � v p ′ and 10 −3 for � v ff ′ .Indeed, c 2 plays a crucial role in determining how flexible and complex the profiles of p ′ and ff ′ can be, and we determined its value using numerous profiles of p ′ and ff ′ obtained from KSTAR over the past few years such that the Force- Balance Net has just enough, and not too much, flexibility to satisfy the given measurements.
We must also consider that some of the externally generated magnetic fields have finite degrees of distortion owing to the Incoloy effect 68 .KSTAR has 14 poloidal field coils, with 10 of them being subject to the Incoloy effect as they are made of Nb 3 Sn superconductors with the Incoloy 908 conduit, whereas the other four are made of NbTi superconductors and STS316LN conduit 69 .Let us introduce J m ext to denote the actual currents flowing through the external magnetic field coils, which are always available in real time during tokamak operation.If we use R ext J m ext as a part of the calculated R J and compare it with −→ MD , (i.e., we let � J ext = � J m ext ), we will generate bias errors because our R ext does not model the Incoloy effect.Instead of rectifying R ext to include such an effect, which is a demanding and challenging task, we relax the condition of � J ext = � J m ext and let the network determine J ext that is consistent with −→ MD .In other words, we allow J ext to be the effective external currents including the consequence of the Incoloy effect.This is done by introducing a diagonal matrix β , whose dimensions are 30 × 30 , to relate J ext to J m ext (see the green part in Fig. S3a).Among the diagonal components β n,n , where the subscript n indicates one of the 30 external magnetic field coils, we set β n,n = 0.9 for the external coils susceptible to the Incoloy effect (i.e., the 10 poloidal field coils), whereas the others are set to be unity.J m ext is also multiplied by either 0.9 or 1, accordingly.Setting β n,n less than unity essentially means that a smaller contribution to the χ 2 minimization in solving the matrix using the SVD technique is allowed as we have recast the problem to be overdetermined.Note that the value of 0.9 is also used in the KSTAR EFIT algorithm.
Our matrix form of the loss function l 2 can also include other constraints such as the Dirichlet and/or Neu- mann boundary conditions.As an example, the Dirichlet boundary condition can be included such that the Force-Balance Net's output (p ′ , ff ′ ) must equal zero outside the plasma-facing component (see the black part in Fig. S3a); i.e., � h pfc � v p ′ = 0 and � h pfc � v ff ′ = 0 , where h pfc (dimensions of 1 × 6 ) contains the node values at the last hidden layer outside the plasma-facing component.
We now have a complete matrix form of the loss function l 2 in Eq. ( 7), which resolves the ill-posed problem by expressing the unknown J φ in terms of the network's weight-wise form v J φ and modifying the response matrix R to contain the node values of the last hidden layer.All the necessary constraints associated with the loss func- tion l 2 are modeled in the matrix M (see Fig. S3a).The unknown current sources � J = � J φ , � J ext , � J VV have become � J * = � v � J φ , � J ext , � J VV , and with the real-time available measurements g , we have � g = M − → J * (see Fig. S3a).This -DeepNet: mastering tokamak plasma equilibria with deep neural networks and the Grad-Shafranov equation Semin Joung 1,5* , Y.-C.Ghim 1* , Jaewook Kim 2 , Sehyun Kwak 3 , Daeho Kwon 4 , C. Sung 1 , D. Kim 1 , Hyun-Seok Kim 2 , J. G. Bak 2 & S. W. Yoon 2

Figure 1 .
Figure 1.Self-teaching unsupervised learning scheme of GS-DeepNet.(a) Leftmost: locations and sensor numbers of the KSTAR magnetic diagnostics.There are 42 magnetic pick-up probes each measuring B R and B Z (blue) and 45 flux loops measuring ψ FL (red).The plots of the B MD R , B MD Z and ψ MD FL signals show examples of measurements made using 31 pick-up probes and 45 flux loops on the poloidal cross-section (R, Z) space as a function of time, which we refer to as the feature.Colors represent magnitude of the measurements.(b) Black dots: 41 × 41 grid points where GS-DeepNet finds a solution.Blue and red dots: positions of the pick-up probes and flux loops as in (a).Black line: example of the plasma boundary dividing the plasma region (inside the line) from a vacuum area.This boundary is known as the last closed flux surface.(c) Schematic representation of GS-DeepNet.The network NN 1 (Maxwell Net) takes a spatial position and a feature of the magnetic data as its input and outputs a poloidal flux function that is used to calculate B R , B Z and � * ψ with the automatic differential operator Diff A .After determining a plasma boundary using the auxiliary module with the output of the Maxwell Net, the network NN 2 (Force-Balance Net) takes a poloidal flux function as its input and outputs a pair p ′ , ff ′ . (d,e) Example of the three-dimensional configurations of the reconstructed � * ψ (d) and ψ (e) from GS-DeepNet.KSTAR poloidal field coils (gray), the vacuum vessel wall (light orange) and the plasma facing components (light blue) are also shown as well as the magnetic diagnostics (blue and red dots).

Figure 2 .
Figure 2. Statistical evaluation of GS-DeepNet training.(a-c) Left: profiles of (a) B R , (b) B Z and (c) ψ from the Maxwell Net (cyan) and their corresponding measurements (red) as a function of the sensor number.Cyan dashed lines represent 1 − σ uncertainties of the network estimated from the MC dropout.Right: training statistics of the Maxwell Net, where the abscissa is the network's output and the ordinate is the measurement for (a) B R , (b) B Z and (c) ψ .The blue gradient indicates the number of occurrences and the red dashed lines are the y = x lines.The coefficients of determination R 2 are also given. (d) Training statistics of the Maxwell Net (abscissa) and the Force-Balance Net (ordinate).The blue gradient indicates the number of occurrences and the red dashed line is the y = x line.The coefficient of determination R 2 is also given. (e) Comparisons between B R , B Z and ψ (cyan crosses) calculated using the response matrix R together with the output of the Force-Balance Net and the measurements (red circles) and (f) their relative errors indicated by the blue bars.In (e,f), shadings indicate different types of measurement; i.e., B R (yellow), B Z (white) and ψ (gray). https://doi.org/10.1038/s41598-023-42991-5

Figure 3 .
Figure 3. Equilibrium prediction using the trained GS-DeepNet.(a) First column: example of limited (top) and diverted (bottom) plasma equilibria ψ(R, Z) produced by the Maxwell Net (colored lines) compared with the equilibria from EFIT (gray dashed lines).The red and black dashed lines represent the plasma boundaries from the Maxwell Net and EFIT, respectively.Second column: uncertainty maps of the Maxwell Net's ψ(R, Z) .The red dashed lines indicate the last closed flux surface.(b) Same as in (a) for � * ψ from the Maxwell Net. (c)Histograms of the various plasma parameters ( R 0 , κ , a and δ ) from GS-DeepNet (blue) and the EFIT (red) and their relative errors ǫ rel . (d) Comparisons of the profile of plasma pressure from the Force-Balance Net (blue) and the measurements (black) based on p = 2n e k B T e .The red line is obtained vis the Gaussian process from the measurements.Blue and red highlighted regions indicate the 1 − σ uncertainty from the Force-Balance Net and Gaussian process, respectively.(e) Left: comparison of the profile of the calculated magnetic pitch angle, tanγ , from the Force-Balance Net (blue) and the measurements (red).Right: histogram of the root-mean-square difference in tanγ between the Force-Balance Net and measurements. https://doi.org/10.1038/s41598-023-42991-5 https://doi.org/10.1038/s41598-023-42991-5 whose dimensions are N in × 6 each.We then have� J φ = h⋆ � v � J φ ,where h⋆ is a concatenated (or augmented) matrix C (dimensions of N in × 12 ) with the Hadamard product (⊙) , and � v � J φ = [� v p ′ , � v ff ′ ] (dimensions of 12 × 1 ) (see Fig.