Abstract
A neural network solving the Grad–Shafranov equation constrained with measured magnetic signals to reconstruct magnetic equilibria in real time is developed. The database created to optimize the neural network's free parameters contains off-line EFIT results as the output of the network from 1118 KSTAR experimental discharges of two different campaigns. Input data to the network constitute magnetic signals measured by a Rogowski coil (plasma current), magnetic pick-up coils (normal and tangential components of magnetic fields) and flux loops (poloidal magnetic fluxes). The developed neural networks fully reconstruct not only the poloidal flux function but also the toroidal current density function with the off-line EFIT quality. To preserve the robustness of the networks against missing input data, an imputation scheme is utilized to eliminate the required additional training sets with a large number of possible combinations of the missing inputs.
Export citation and abstract BibTeX RIS
1. Introduction
Magnetic equilibrium is one of the most important factors in understanding the basic behavior of plasmas in magnetically confined plasmas, and the off-line EFIT [1] code has been extensively used to reconstruct such equilibria in tokamaks. Its fundamentals are basically finding a solution to an ideal magnetohydrodynamic equilibrium with toroidal axisymmetry, known as the Grad–Shafranov (GS) equation [2]:
where is the poloidal flux function, the toroidal current density function, and the plasma pressure. is related to the net poloidal current. Here, R, and Z denote the usual cylindrical coordinate system. As is a two-dimensional non-linear partial differential operator, the off-line EFIT [1] finds a solution with many numerical iterations and has been implemented in many tokamaks such as DIII-D [3], JET [4], NSTX [5], EAST [6] and KSTAR [7] to name a few examples.
With the aim of real-time control of tokamak plasmas, a real-time EFIT (rt-EFIT) [8] code is developed to provide a magnetic equilibrium fast enough, whose results are different from the off-line EFIT results. As pulse lengths of tokamak discharges become longer [9–15], the demand for more elaborate plasma control is ever increased. Furthermore, some of the ITER-relevant issues such as edge localized mode suppression with resonant magnetic perturbation coils [16] and the detached plasma scenarios [17, 18] require sophisticated plasma controls, meaning that the more accurate magnetic equilibria we have in real time, the better performance we can achieve.
There has been an attempt to satisfy such a requirement of acquiring a more accurate, i.e. closer to the off-line EFIT results compared to the rt-EFIT results, magnetic equilibrium in real time using graphics processing units (GPUs) [19] by parallelizing equilibrium reconstruction algorithms. The GPU-based EFIT (P-EFIT) [19] enabled the calculation of a well-converged equilibrium in much less time; however, the benchmark test showed similar results to the rt-EFIT rather than the off-line results [20].
Thus, we propose a reconstruction algorithm based on a neural network that satisfies the GS equation as well as the measured magnetic signals to obtain accurate magnetic equilibrium in real time. We note that usage of neural networks in the fusion community is increasing rapidly, and examples are radiated power estimation [21], identifying instabilities [22], estimating neutral beam effects [23], classifying confinement regimes [24], determination of scaling laws [25, 26], disruption prediction [27–29], turbulent transport modeling [30–33], plasma tomography with the bolometer system [34, 35], coil current prediction with the heat load pattern in W7-X [36], filament detection on MAST-U [37], electron temperature profile estimation via SXR with Thomson scattering [38] and equilibrium reconstruction [39–44] together with an equilibrium solver [45]. Most of the previous works on equilibrium reconstruction with neural networks have paid attention to finding the poloidal beta, the plasma elongation, positions of the X-points and plasma boundaries, i.e. last closed flux surface, and gaps between plasmas and plasma-facing components, rather than reconstructing the whole internal magnetic structures we present in this work.
The inputs to our developed neural networks consist of plasma current measured by a Rogowski coil, normal and tangential components of magnetic fields by magnetic pick-up coils, poloidal magnetic fluxes by flux loops and a position in the coordinate system, where R is the major radius and Z is the height as shown in figure 1. The output of the neural networks is a value of poloidal flux at the specified position. To train and validate the neural networks, we have collected a total of 1118 KSTAR discharges from two consecutive campaigns, i.e. the 2017 and 2018 campaigns. We, in fact, generate three separate neural networks which are NN2017, NN2018 and NN2017, 2018 where the subscripts indicate the year(s) of the KSTAR campaign(s) that the training data sets are obtained from. An additional 163 KSTAR discharges (from the same two campaigns) are collected to test the performance of the developed neural networks.
We train the neural networks with the KSTAR off-line EFIT results, and let them be accurate magnetic equilibria. Note that the dispute on whether the off-line EFIT results we use to train the networks are accurate or not is beyond the scope of this work. If we find more accurate EFIT results, e.g. motional Stark effect-constrained EFIT or more sophisticated equilibrium reconstruction algorithms that can cope with current-hole configurations (current reversal in the core) [46–48], then we can always re-train the networks with new sets of data as long as the networks follow the trained EFIT data with greater similarity than the rt-EFIT results do. This is because supervised neural networks are limited to follow the training data. Hence, as a part of the training sets we use the KSTAR off-line EFIT results as possible examples of accurate magnetic equilibria to corroborate our developed neural networks.
To calculate the output data a typical neural network requires the same set of input data as it has been trained with. Therefore, even a single missing input (out of the input data set) can result in a flawed output [49]. Such a case can be circumvented by training the network with possible combinations of missing inputs. As a part of the input data, we have 32 normal and 36 tangential magnetic fields measured by the magnetic pick-up coils. If we wish to cover a case with one missing item of input data, then we will need to repeat the whole training procedure with 68 (32 + 36) different cases. If we wish to cover a case with two or three missing items of input data, then we will need an additional 2278 and different cases to be trained, respectively. This number becomes large rapidly, and it becomes formidable, if not impossible, to train the networks with reasonable computational resources. Since the magnetic pick-up coils are susceptible to damage, we have developed our networks to be capable of inferring a few missing signals of the magnetic pick-up coils in real time by invoking an imputation scheme [50] based on Bayesian probability [51] and Gaussian processes [52].
In addition to reconstructing accurate magnetic equilibria in real time, the expected improvements with our neural networks compared to those of previous studies are at least fourfold: (1) the network is capable of providing the whole internal magnetic topology, and is not limited to boundaries and locations of X-points and/or magnetic axes; (2) the spatial resolution of the reconstructed equilibria is arbitrarily adjustable within the first wall of KSTAR since the position is a part of the input data; (3) the required training time and computational resources for the networks are reduced by generating coarse grid points also owing to the position being an input; and (4) the networks can handle a few missing signals of the magnetic pick-up coils using the imputation method.
First, we present how the data are collected to train the neural networks and briefly discuss real-time preprocessing of the measured magnetic signals in section 2. For the readers who are interested in a thorough description of the real-time preprocessing, appendix A provides the details. Then, we explain the structure of our neural networks and how we train them in section 3. In section 4, we present the results of the developed neural network EFIT (nn-EFIT) in four aspects. First, we discuss how well the NN2017, 2018 network reproduces the off-line EFIT results. Then, we make comparisons among the three networks, NN2017, NN2018 and NN2017, 2018, by examining in-campaign and cross-campaign performance. Once the absolute performance qualities of the networks are established, we compare relative performance qualities between nn-EFIT and rt-EFIT. Finally, we show how the imputation method supports the networks when there is missing input. Our conclusions are presented in section 5.
2. Collection and real-time preprocessing of data
Figure 1 shows locations where we obtain the input and the output data with the first wall (blue dotted line) on a poloidal cross-section of KSTAR. The green dotted line indicates a Rogowski coil measuring the plasma current (). The green open circles and crosses show locations of the magnetic pick-up coils measuring 32 normal () and 36 tangential () components of magnetic fields, respectively, whereas the green triangles show 22 flux loops measuring the poloidal magnetic fluxes (). These magnetic signals are selectively chosen out of all the magnetic sensors in KSTAR [53] whose performance has been demonstrated for many years, i.e. those which are less susceptible to damage.
Although KSTAR calibrates the magnetic sensors (magnetic pick-up coils and flux loops) regularly during a campaign to remove drifts in the magnetic signals, it does not guarantee to fully eliminate such drifts. Thus, we preprocess the signals to adjust the drifts. Figure 2 shows examples of before (blue) and after (red) the drift adjustment for (a) normal and (b) tangential components of magnetic fields measured by the magnetic pick-up coils and (c) poloidal magnetic flux measured by one of the flux loops. Here, a KSTAR discharge is sustained until about 20 s, and all the external magnetic coils (except the toroidal field coils) are turned off at about 30 s. Therefore, we expect all the magnetic signals to return to zeros at around 30 s. If not, we envisage that there has been residual drift. This means that we need to be able to preprocess the magnetic signals in real time so that the input signal characteristics for predictions are similar to the trained ones. Appendix A describes in detail how we preprocess the magnetic signals in real time.
Download figure:
Standard image High-resolution imageThe black asterisks in figure 1 show the grid points where we obtain the values of from the off-line EFIT results as outputs of the networks. We note that the original off-line EFIT provides the values of with grid points. The grid points are selected such that the distances between the neighboring channels in the R and Z directions are as similar as possible while covering the whole region within the first wall. By generating such coarse grid points we can decrease the number of samples to train the network, thus consuming less computational resources. Nevertheless, we do not lose the spatial resolution since the position is an input, i.e. the network can obtain the value of at any position within the first wall (see section 4).
With an additional input for the spatial positions R and Z, each data sample contains 93 inputs (and yet another input for bias) and one output which is a value of at the specified location. We randomly collect a total of 1118 KSTAR discharges from the 2017 and 2018 campaigns. Since each discharge can be further broken into many time slices, i.e. every 50 ms following the temporal resolution of the off-line EFIT, we obtain time slices. With a total value of 286 of from spatial points, we have a total of samples to train and validate the networks. 90% of the samples are used to train the networks, while the other 10% are used to validate the networks to avoid overfitting problems. Note that an overfitting problem can occur if a network is overly well trained to the training data, learning very detailed features of them such as noise features. This inhibits generalization of the trained network to predict unseen data, and such a problem can be minimized with the validation data set. All the inputs except R and Z are normalized such that the maximum and minimum values within the whole samples become 1 and −1, respectively. We use the actual values of R and Z in the unit of meters.
Table 1 summarizes the training and validation samples discussed in this section. Additionally, we also have randomly collected another 163 KSTAR discharges in the same way discussed here which are different from the 1118 KSTAR discharges to test the performance of the networks.
Table 1. Summary of the data samples to train and validate the networks.
Parameter | Definition | Data size | No. of samples |
---|---|---|---|
Plasma current | 1 | ||
(Rogowski coil) | |||
Normal magnetic field | 32 | ||
(Magnetic pick-up coils) | |||
217 820 | |||
Tangential magnetic field | 36 | (time slices) | |
(magnetic pick-up coils) | |||
Poloidal magnetic flux | 22 | ||
(flux loops) | |||
R | Position in major radius | 1 | 286 |
( grids) | |||
Z | Position in height | 1 | |
Network input size | 93 (+1 for bias) | ||
Total No. of samples | 62 296 520 |
3. Neural network model and training
3.1. Neural network model
We develop neural networks that not only output a value of but also satisfy equation (1), the GS equation. With a total of 94 input nodes (91 for the plasma current and magnetic signals, two for the R and Z position, and one for the bias) and one output node for a value of , each network has three fully connected hidden layers with an additional bias node at each hidden layer. Each layer contains 61 nodes including the bias node. The structure of our networks is selected by examining several different structures by trial and error.
Denoting the value of calculated by the networks as , we have
where xi is the ith input value with , i.e. 91 measured values with various magnetic diagnostics and two for the R and Z positions. wji is an element in a matrix, whereas and ulk are elements in matrices. sl connects the node of the third (last) hidden layer to the output node. and s are the weighting factors that need to be trained to achieve our goal of obtaining accurate . and s0 are the weighting factors connecting the biases, where values of all the biases are fixed to unity. We use a hyperbolic tangent function as the activation function f giving the network non-linearity [54]:
The weighting factors are initialized as described in [55] so that a good training can be achieved. They are randomly selected from a normal distribution whose mean is zero with the variance set to be an inverse of the total number of connecting nodes. For instance, our weighting factor w connects the input layer (94 nodes with bias) and the first hidden layer (61 nodes with bias), therefore the variance is set to be . Likewise, the variances for , u and s are , and , respectively.
3.2. Training
With the aforementioned network structure, training (or optimizing) the weighting factors to predict the correct value of highly depends on the choice of cost function. A typical choice of such cost function would be:
where is the target value, i.e. the value of from the off-line EFIT results in our case, and N the number of data sets.
As will be shown shortly, minimizing the cost function does not guarantee to satisfy the GS equation (equation (1)) even if and match well, i.e. the network is well trained with the given optimization rule. Since provides information on the toroidal current density directly, it is important that matches as well. We have an analytic form representing as in equation (2); therefore, we can analytically differentiate with respect to R and Z, meaning that we can calculate during the training stage. Thus, we introduce another cost function:
where we obtain the value of from the off-line EFIT results as well.
To acknowledge the difference between the two cost functions and , we first discuss the results. Figure 3 shows the outputs of the two trained networks with the cost function (a) and (b) . It is evident that in both cases the network output (red dashed line) reproduces the off-line EFIT (black line). However, only the network trained with the cost function reproduces the off-line EFIT . Both networks are trained well, but the network with the cost function does not achieve our goal of correctly predicting and .
Download figure:
Standard image High-resolution imageSince our goal is to develop a neural network that solves the GS equation, we choose the cost function to be to train the networks. We determine the weighting factors found by minimizing the cost function with Adam optimizer [56] which is one of the gradient-based optimization algorithms. With 90% and 10% of the total data samples for training and validation of the networks, respectively, we stop training the networks with a fixed number of iterations that is large enough but not too large such that the validation errors do not increase, i.e. to avoid overfitting problems. The whole workflow is carried out with Python and Tensorflow [57].
With the selected cost function we create three different networks that differ only by the training data sets. NN2017, NN2018 and NN2017, 2018 refer to the three networks trained with the data sets from only 2017 (744 discharges), from only 2018 (374 discharges) and from both 2017 and 2018 (744 + 374 discharges) campaigns, respectively.
The descending feature of the cost function as a function of the training iteration for the NN2017,2018 network is shown in figure 4. Both the training errors (blue line) and validation errors (red dashed line) decrease together with similar values which means that the network is well generalized. Furthermore, since the validation errors do not increase, the network does not have an overfitting problem. Note that fluctuations in the errors, i.e. standard deviation of the errors, are represented as shaded areas.
Download figure:
Standard image High-resolution imageSmall undulations repeated over the iterations in figure 4 are due to mini-batch learning. Contrary to batch learning, i.e. optimizing the network with the entire training set in one iteration, mini-batch learning divides the training set into a number of small subsets (1000 subsets in our case) to optimize the networks sequentially. One cycle that goes through all the subsets once is called an epoch. Mini-batch learning helps to escape from local minima in the weighting factor space [58] via the stochastic gradient descent scheme [59].
4. Performance of the developed neural networks: benchmark tests
In this section, we present how well the developed networks perform. The main figures of merit we use are the peak signal-to-noise ratio (PSNR) and mean structural similarity (MSSIM) as have been used previously [34] in addition to the usual statistical quantity R2, the coefficient of determination. We note that obtaining full-flux surface information on or spatial grids with our networks takes less than 1 msec on a typical personal computer.
First, we discuss the benchmark results of the NN2017,2018 network. Then, we compare the performance of the NN2017, NN2018 and NN2017,2018 networks. Here, we also investigate cross-year performance, for instance, applying the NN2017 network to predict the discharges obtained from the 2018 campaign and vice versa. Then, we evaluate the performance of the networks against the rt-EFIT results to examine the possibility of supplementing or even replacing the rt-EFIT with the networks. Finally, we show how the imputation scheme supports the networks' performance. Here, all the tests are performed with the unseen (to all three networks, i.e. NN2017, NN2018 and NN2017,2018) KSTAR discharges which are 88 and 75 KSTAR discharges from the 2017 and 2018 campaigns, respectively.
4.1. Benchmark results of the NN2017,2018 network
Figure 5 show the benchmark results of the NN2017,2018 network, i.e. network trained with the data sets from both 2017 and 2018 campaigns. (a) and (b) show the results with the test discharges from the 2017 campaign, while (c) and (d) present the results with the test discharges from the 2018 campaign. Histograms of (a)(c) versus and (b)(d) versus are shown with colors representing the number of counts. For instance, there is a yellow colored point in figure 5(a) around , where is a bin size for the histogram. Since yellow represents about counts, there are approximately data whose neural network values and EFIT values are simultaneously within our test data set. Note that each KSTAR discharge contains numerous time slices whose number depends on the actual pulse length of a discharge, and each time slice generates a total of data points. The values of and are obtained from the off-line EFIT results. It is clear that the network predicts the target values well.
Download figure:
Standard image High-resolution imageAs a figure of merit, we introduce the R2 metric (coefficient of determination) defined as
where y takes either or , and L is the number of test data sets. The calculated values are written in figure 5, and they are indeed close to unity, implying the existence of very strong linear correlations between the predicted (from the network) and target (from the off-line EFIT) values. Note that R2 = 1 means the perfect prediction. The red dashed lines in the figures are the y = x lines.
Figure 6 is an example of reconstructed magnetic equilibria using KSTAR shot #18057 from the 2017 campaign. (a) shows the evolution of the plasma current. The vertical dashed lines indicate the time points where we show and compare the equilibria obtained from the network (red) and the off-line EFIT (black) which is our target. (b) and (c) are taken during the ramp-up phase, (d) and (e) during the flat-top phase, and (f ) and (g) during the ramp-down phase. In each sub-figure from (b) to (g), the left panels compare , and the right panels are for . We mention that the equilibria in figure 6 are reconstructed with grid points even though the network is trained with grid points, demonstrating how the spatial resolution is flexible in our networks.
Download figure:
Standard image High-resolution imageFor a quantitative assessment of the network, we use an image-relevant figure of merit that is the PSNR [60] (see appendix B), originally developed to estimate the degree of artifacts due to image compression compared to an original image. The typical PSNR range for a JPEG image, which preserves the original quality with a reasonable degree, is generally 30–50 dB [34, 61]. For our case, the network errors relative to the off-line EFIT results can be treated as artifacts. As listed in figures 6(b)–(g), the PSNR for is very good, while we achieve acceptable values for .
4.2. The NN2017, NN2018 and NN2017,2018 networks
Similar to shown in figure 5, we show the benchmark results of NN2017 and NN2018 in figures 7 and 8, respectively. The R2 metric is also provided in the figures. Again, the overall performance of the networks is good.
Download figure:
Standard image High-resolution imageDownload figure:
Standard image High-resolution imageThe NN2017 and NN2018 networks are trained with only in-campaign data sets, e.g. NN2018 with data sets from only the 2018 campaign, and we find slightly poorer results, but still good, in predicting cross-campaign magnetic equilibria, e.g. NN2018 predicting equilibria for the 2017 campaign. Notice that NN2017 seems to predict cross-campaign equilibria better than the in-campaign ones by comparing figures 7(a) and (c), which contradicts our intuition. Although the histogram in figure 7(c) seems tightly aligned with the y = x line (red dashed line), close inspection reveals that the NN2017 network, in general, underestimates the off-line EFIT results from the 2018 campaign marginally. This will be evident when we compare image quality.
MSSIM [62] (see appendix B) is another image relevant figure of merit used to estimate perceptual similarity (or perceived differences) between the true and reproduced images based on the inter-dependence of adjacent spatial pixels in the images. The MSSIM ranges from zero to one, where the closer to unity the better the reproduced image is.
Together with the PSNR, figure 9 shows the MSSIM for (a) NN2017, (b) NN2018 and (c) NN2017,2018 where the off-line EFIT results are used as a reference. Notice that counts in all the histograms of MSSIM and PSNR in this work correspond to the number of reconstructed magnetic equilibria (or a number of time slices) since we obtain a single value of MSSIM and PSNR from one equilibrium, whereas counts in figures 5, 7 and 8 are much bigger since data points are generated from each time slice. The red (green) line indicates the test results for the data sets from the 2017 (2018) campaign. In general, whether the test data sets are in-campaign or cross-campaign, the image reproducibility of all three networks, i.e. predicting the off-line EFIT results, is good as attested by the fact that the MSSIM is quite close to unity and the PSNR for () ranges approximately from 40 to 60 (20 to 40). It is easily discernible that the in-campaign results are better for both NN2017 and NN2018 unlike what we noted in figures 7(a) and (c). Not necessarily guaranteed, we find that the NN2017,2018 network works equally well for both campaigns as shown in figure 9(c).
Download figure:
Standard image High-resolution image4.3. Comparisons among nn-EFIT, rt-EFIT and off-line EFIT
It is widely recognized that rt-EFIT results and off-line results are different from each other. If we allow the off-line EFIT results used to train the networks to be accurate ones, then the reconstruction of equilibria with the neural networks (nn-EFIT) must satisfy the following criterion: nn-EFIT results must be more similar to the off-line EFIT results than the rt-EFIT results are to the off-line EFIT, as mentioned in section 1. Once this criterion is satisfied, then we can always improve the nn-EFIT as genuinely more accurate EFIT results are collected. For this reason, we make comparisons among the nn-EFIT, rt-EFIT and off-line EFIT results.
Figure 10 shows an example of the reconstructed magnetic equilibria for (a) rt-EFIT versus off-line EFIT and (b) nn-EFIT (the NN2017,2018 network) versus the off-line EFIT for KSTAR shot #17975 at 0.7 s with (left panel) and (right panel). The green, red and black lines indicate rt-EFIT, nn-EFIT and off-line EFIT results, respectively. This simple example shows that the nn-EFIT is more similar to the off-line EFIT than the rt-EFIT is to the off-line EFIT, satisfying the aforementioned criterion.
Download figure:
Standard image High-resolution imageTo validate the criterion statistically, we generate histograms of the MSSIM and PSNR for the nn-EFIT and the rt-EFIT with reference to the off-line EFIT. This is shown in figure 11 as histograms, where the MSSIM (left panel) and PSNR (right panel) of (top) and (bottom) are compared between the nn-EFIT (black) and the rt-EFIT (green). Here, the nn-EFIT results are obtained with the NN2017,2018 network on the test data sets. We confirm that the criterion is satisfied with the NN2017,2018 network as the histograms in figure 11 are in favor of the nn-EFIT, i.e. larger MSSIM and PSNR are obtained by the nn-EFIT. This is more conspicuous for than .
Download figure:
Standard image High-resolution imageWe perform similar statistical analyses for the other two networks, NN2017 and NN2018, which are shown in figures 12 and 13. Since these two networks are trained with the data sets from only one campaign, we show the results where the test data sets are prepared from the (a) 2017 campaign and (b) 2018 campaign so that in-campaign and cross-campaign effects can be assessed separately. We find that the criterion is fulfilled for both and with both the in- or cross-campaign data.
Download figure:
Standard image High-resolution imageDownload figure:
Standard image High-resolution image4.4. The NN2017,2018 network with the imputation scheme
If one or more magnetic pick-up coils forming part of the input to the nn-EFIT are impaired, then we will have to re-train the network without the damaged ones, or hope that the network will reconstruct equilibria correctly by padding a fixed value, e.g. zero-padding, to the broken ones. Of course, one can anticipate training the network by considering possible combinations of impaired magnetic pick-up coils. With a total number of 68 signals from the magnetic pick-up coils being input to the network in our case, we immediately find that the number of possible combinations increases too quickly to consider it as a solution.
Since inferring the missing values is better than the null replacement [49], we resolve the issue by using the recently proposed imputation method [50] based on Gaussian processes [52] and Bayesian inference [51], where the likelihood is constructed based on Maxwell's equations. The imputation method infers the missing values fast enough, i.e. less than 1 msec to infer up to nine missing values on a typical personal computer; thus, we can apply the method during plasma discharge by replacing the missing values with the real-time inferred values.
We have applied the imputation method to KSTAR shot #20341 at 2.1 s for the normal () and tangential () components of the magnetic pick-up coils as an example. We have randomly chosen nine signals from the 32 measurements and another nine from the 36 measurements and pretended that all of them (9 + 9) are missing simultaneously. Figure 14 shows the measured (blue open circles) and the inferred (red crosses with their uncertainties) values for (a) and (b) . Probe # on the horizontal axis is used as an identification index of the magnetic pick-up coils. Table 2 provides the actual values of the measured and inferred ones for better comparisons. We find that the imputation method infers the correct (measured) values very well except probe #37 of . The inferred (missing) probes are probes #3, 4, 6, 14, 18, 24, 30, 35, 37 for and probes #4, 6, 8, 11, 17, 29, 30, 32, 35 for . Here, we provide all the probe #'s used for the neural network: probe #[2, ..., 6, 8, 9, 11, ..., 15, 17, ..., 20, 23, ..., 26, 28, ..., 32, 34, 35, 37, ..., 41] (a total of 32); and probe #[2, ..., 6, 8, 9, 11, ..., 32, 34, 35, 37, ..., 41] (a total of 36).
Download figure:
Standard image High-resolution imageTable 2. The imputation results shown in figure 14 with KSTAR shot #20341 at 2.1 s.
Bn (T) | Bt (T) | ||||
---|---|---|---|---|---|
No. | Measured | Inferred | No. | Measured | Inferred |
3 | −1.45 | −1.88 0.22 | 4 | −14.69 | −13.97 0.47 |
4 | −1.72 | −2.31 0.24 | 6 | −12.38 | −11.42 0.97 |
6 | 4.62 | 4.45 0.65 | 8 | −7.82 | −7.88 0.67 |
14 | 6.13 | 6.36 0.27 | 11 | −3.15 | −3.22 0.65 |
18 | −8.27 | −8.11 0.48 | 17 | 0.10 | 0.30 0.52 |
24 | 1.86 | 1.65 0.30 | 29 | 3.84 | 2.65 0.64 |
30 | −7.52 | −7.19 0.18 | 30 | 1.15 | 0.49 0.61 |
35 | −7.93 | −7.08 0.65 | 32 | −2.65 | −2.11 0.62 |
37 | −4.27 | −1.41 0.93 | 35 | −8.07 | −8.87 0.55 |
Comparisons between the nn-EFIT without any missing values, which we treat as reference values, and the nn-EFIT with the imputation method or with the zero-padding method are made. Here, the nn-EFIT results are obtained using the NN2017,2018 network. The top panel of figure 15 shows obtained from the nn-EFIT without any missing values (black line) and from the nn-EFIT with the two missing values replaced with the inferred values (green line), i.e. the imputation method, or with zeros (pink dashed line), i.e. the zero-padding method for (a) (left panel) and (b) (right panel) at 2.1 s of KSTAR shot #20341. Probes #14 and 30 for and probes #4 and 8 for are treated as the missing ones. The bottom panels compare histograms of MSSIM and PSNR using the imputation method (green) and the zero-padding method (pink) for all the equilibria obtained from KSTAR shot #20341.
Download figure:
Standard image High-resolution imageIt is clear that the nn-EFIT with the imputation method (green line) is not only much better than that with the zero-padding method (pink dashed line) but it also reconstructs the equilibrium close to the reference (black). In fact, the zero-padding method is too far off from the reference (black line) to be relied on for plasma controls.
Motivated by such a successful result of the nn-EFIT with the imputation method on the two missing values, we have increased the number of missing values as shown in figures 16 and 17 for the same KSTAR discharge, i.e. KSTAR shot #20341. Let us first discuss figure 16 which shows (a) the eight (without probe #6) and (b) nine (all) missing values of . The color codes are the same as in figure 15, i.e. the reference is black, and the nn-EFIT with the imputation method is green or with the zero-padding method is pink. It is evident that the nn-EFIT with the imputation method performs well at least up to nine missing values. Such a result is, in fact, expected since the imputation method has inferred the missing values well as shown in figure 14(b) in addition to the fact that a well-trained neural network typically has a reasonable degree of resistance on noise. Again, the nn-EFIT with the zero-padding method is not reliable.
Download figure:
Standard image High-resolution imageDownload figure:
Standard image High-resolution imageFigures 17(a) and (b) are the results with the eight (without probe #37) and nine (all) missing values of , respectively. The color codes are the same as in figure 15. We find that the nn-EFIT with the eight missing values reconstructs the equilibrium similar to the reference one, while the reconstruction quality becomes notably worse for the nine missing values. This is caused mostly due to poor inference of probe #37 by the imputation method (see figure 14(a)). Nevertheless, the result is still better than that with the zero-padding method. Figure 18 shows the reconstruction results with the same color codes as in figure 15 when we have (a) 4 + 4 and (b) 9 + 9 combinations of and missing values simultaneously.
Download figure:
Standard image High-resolution imageAll these results suggest that the nn-EFIT with the imputation method reconstructs equilibria reasonably well except when the imputation infers the true value poorly, e.g. probe #37 in figure 14(a) and table 2. In fact, the suggested imputation method [50] infers the missing values based on the neighboring intact values (using Gaussian processes) while satisfying Maxwell's equations (using Bayesian probability theory). Consequently, such a method becomes less accurate if (1) the neighboring channels are also missing AND (2) the true values change fast from the neighboring values. In fact, probe #37 happens to satisfy these two conditions, i.e. probe #35 is also missing, and the true values of probe #35, #37 and #38 are changing fast as one can discern from figure 14(a).
5. Conclusions
We have developed and presented a neural network-based GS solver constrained with measured magnetic signals. The networks take the plasma current from a Rogowski coil, 32 normal and 36 tangential components of the magnetic fields from the magnetic pick-up coils, 22 poloidal fluxes from the flux loops, and position of interest as inputs. With three fully connected hidden layers consisting of 61 nodes in each layer, the network outputs a value of poloidal flux . We set the cost function used to train the networks to be a function of not only the poloidal flux but also the GS equation itself. The networks are trained and validated with 1118 KSTAR discharges from the 2017 and 2018 campaigns.
Treating the off-line EFIT results as accurate magnetic equilibria to train the networks, our networks fully reconstruct magnetic equilibria, not limited to obtaining selected information such as positions of the magnetic axis, X-points or plasma boundaries, more similar to the off-line EFIT results than the rt-EFIT is to the off-line EFIT. Owing to the fact that the position is a part of the input, our networks have adjustable spatial resolution within the first wall. The imputation method supports the networks to obtain the nn-EFIT results even if there exist a few missing inputs.
As the necessary computation time is only approximately 1 ms, the networks have potential to be used for real-time plasma control. In addition, the networks can be used to provide a large number of automated EFIT results fast for many other data analyses requiring magnetic equilibria.
Acknowledgment
This research is supported by National R&D Program through the National Research Foundation of Korea (NRF) funded by the Ministry of Science and ICT (Grant Nos. NRF-2017M1A7A1A01015892 and NRF-2017R1C1B2006248) and the KAI-NEET, KAIST, Korea.
Appendix A. Real-time preprocess on magnetic signals
As shown in figure 2 and discussed in section 2, normal () and tangential () components of magnetic fields measured by the magnetic pick-up coils and poloidal magnetic fluxes () measured by the flux loops tend to have residual drifts after calibrating the magnetic diagnostics. We train the neural networks with preprocessed, i.e. drift-adjusted, magnetic signals. Therefore, we must be able to preprocess the signals in real time as well. Here, we introduce how we preprocess the magnetic signals in detail. The same preprocess is applied to all the training, validation and test data sets. Note that we do not claim that how we adjust the magnetic signals corrects the drifts completely.
A.1. Real-time drift adjustment with information obtained during the initial magnetization stage
To adjust the signal drifts, we deem a priori that the signals drift linearly in time [63–65]. Of course, non-linear drift may well exist in the signals. However, we need to come up with a very simple and fast solution to adjust the drifts in real time with the limited amount of information. One can consider such linearization in time as taking up to the first order of Taylor-expanded drifting signals. Therefore, we take the drifting components of the signals () from various types (the magnetic pick-up coils or the flux loops) of magnetic diagnostics to follow:
where t is the time. and are the slope and the offset, respectively, of a drift signal for the ith magnetic sensor of type m (magnetic pick-up coils or flux loops). Then, our goal simply becomes finding and for all i and m of interest before a plasma starts or the blip time (t = 0) so that can be subtracted from the measured magnetic signals in real time, i.e. preprocessing the magnetic signals for the neural networks.
We use two different time intervals during the initial magnetization stage, i.e. before the blip time, for every plasma discharge to find and , sequentially. Figure A1 shows an example of temporal evolutions of currents in the poloidal field (PF) coils, and and poloidal magnetic flux up to the blip time (t = 0) of a typical KSTAR discharge.
Download figure:
Standard image High-resolution imageDuring the time interval d1 in figure A1, all the magnetic signals must be constant in time because there are no changes in currents of any of the PF coils; in addition, there are no plasmas yet that can change the magnetic signals. Therefore, any temporal changes in a magnetic signal during d1 can be regarded as due to a non-zero . With the knowledge of from the d1 time interval, we obtain the value of using the fact that all the magnetic signals must be zeros during the time interval d2 because there are no sources of magnetic fields, i.e. all the currents in the PF coils are zeros.
Summarizing our procedure, (1) we first obtain the slopes based on the fact that all the magnetic signals must be constant in time during d1 time interval, and then (2) find the offsets based on the fact that all the magnetic signals, after the linear drifts in time are removed based on the knowledge of , must be zeros during d2 time interval.
A.2. Bayesian inference
Bayesian probability theory [51] has a general form of
where is a (set of) parameter(s) we wish to infer, i.e. and for our case, and is the measured data, i.e. measured magnetic signals during the time intervals of d1 and d2 in figure A1. The posterior provides us the probability of having a certain value for given the measured data which is proportional to a product of likelihood and prior . Then, we use the maximum a posterior (MAP) to select the value of . The evidence (or marginalized likelihood) is typically used for a model selection and is irrelevant here as we are only interested in estimating the parameter , i.e. and .
We estimate values of the slope and the offset based on equation (A.2) in two steps as described above:
where () are the time series data from the ith magnetic sensor of type m (magnetic pick-up coils or flux loops) during the time intervals of d1 (d2) as shown in figure A1. is the MAP, i.e. the value of maximizing the posterior . Since we have no prior knowledge of and , we take priors, and , to be uniform allowing all the real numbers. Note that a correct would be equal to [66], but we sacrifice rigor to obtain a fast solution. Furthermore, the posterior for should, rigorously speaking, be obtained by marginalizing over all possible , i.e. . Again, as we are interested in real-time application, such a step is simplified just to use .
With equation (A.1), we model likelihoods, and , as Gaussian:
which simply state that noises in the measured signals follow Gaussian distributions. Here, and are the experimentally obtained noise levels for the ith magnetic sensor of type m (magnetic pick-up coils and flux loops) during the time intervals of d1 and d2 in figure A1, respectively. tl and tk define the actual time intervals of d1 and d2, i.e. s and s with L and K being the numbers of the data points in each time interval, respectively. t0 can be any value within the d1 time interval, and we set t0 = −2 s in this work. , removing the offset effect to obtain only the slope, is the time-averaged value of for s. We use the time-averaged value to minimize the effect of the noise in at t = t0.
With our choice of uniform distributions for priors in equations (A.3) and (A.4), MAPs for and , which we denote as and , coincide with the maximum likelihoods which can be analytically obtained by maximizing equations (A.5) and (A.6) with respect to and , respectively:
Now, we have attained simple algebraic equations based on Bayesian probability theory which can provide us values of the slope and the offset before the blip time, i.e. before t = 0.
Since the required information ( and ) to adjust drifts in the magnetic signals is obtained before every discharge starts, we can preprocess the magnetic signals in real time. This is how we have adjusted the drift signals shown in figure 2.
Appendix B. Image-relevant figures of merit—PSNR and MSSIM
In section 4, we used two image-relevant figures of merit, namely PSNR [60, 61] and MSSIM [62], to examine the performance of the developed neural networks. Although these figures of merit are widely used and well known, we present short descriptions of the PSNR and MSSIM for the readers' convenience. Notice that we treat a reconstructed magnetic equilibrium as an image whose dimension (number of pixels) is set by the spatial grid points.
B.1. PSNR
PSNR is calculated as
where y i is the value of either or at the ith position of the spatial grid (analogous to a pixel value of an image), and M for the total number of grid points, i.e. either or depending on our choice for reconstructing equilibrium. operator selects the maximum value of an argument, and is an array containing 'pixel' values of a reference EFIT 'image', that is a reconstructed magnetic equilibrium. is also an array, and depending on whether we wish to compare the off-line EFIT result with either the rt-EFIT result or the nn-EFIT result, we select the corresponding values.
B.2. MSSIM
MSSIM is calculated as
where and are the mean values of and , respectively. Here, and mean the same as in section B.1. and are the variances of and , respectively, while is the covariance between and . C1 and C2 are used to prevent a possible numerical instability, i.e. the denominator being zero, and are set to be small numbers. Following [62], we have and .