**1. Introduction**

An artificial neural network is a powerful and universal algorithm of identification and approximation. It can be used to predict parameters of a complex dynamical plants under control. The advantages of neural network models include low computational complexity and wide possibilies of hardware implementation. From this perspective, it is especially beneficial to employ neural networks with a small number of neurons.

In tokamak experiments, plasma parameters cannot be directly measured because of the high temperature plasma that is able to disable diagnostics. The simplest and most widely used method to detect the boundary and integral parameters of the plasma is the use of magnetic sensors which measure the changes in magnetic field and flux outside the plasma, but within the region of the magnetic field produced by the plasma. The plasma shape is to be identified from the signals of the tokamak diagnostic system. This inverse problem is known as the plasma equilibrium reconstruction problem [1,2]. The FCDI algorithm was developed for plasma equilibrium reconstruction in the Globus-M2 tokamak and uses the Picard iteration approach [3]. The FCDI code is able to obtain the plasma shape offline after cessation of experiment and cannot be used online because of high computational complexity and high task execution time. For real-time use, it is necessary to achieve identification of the FCDI code via a fast model.

There are different approximation methods of a plasma reconstruction algorithm [4]. Neural networks were used for plasma reconstruction in COMPASS tokamak (UK) [5], ASDEX-Upgrade (Germany) [6], D-IIID (USA) [7], and models of ITER [8]. The EFIT reconstruction code was approximated through neural networks by researchers in [9]. In these works, fully connected neural networks with different layer numbers, activation functions, layers sizes were employed.

**Citation:** Kruzhkov, V.I.; Mitrishkin, Y.V.; Pavlova, E.A. Real-Time Hardware Identification of Complex Dynamical Plant by Artificial Neural Network Based on Experimentally Processed Data by Smart Technologies. *Eng. Proc.* **2023**, *33*, 17. https://doi.org/10.3390/ engproc2023033017

Academic Editors: Askhat Diveev, Ivan Zelinka, Arutun Avetisyan and Alexander Ilin

Published: 13 June 2023

**Copyright:** © 2023 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https:// creativecommons.org/licenses/by/ 4.0/).

An artificial neural network was used for identification of a reconstruction algorithm for Globus-M2 in [4,10]. In [10], a neural network was used for identification of moving filaments of the plasma reconstruction approach. In [4], several methods of FCDI algorithm identification were considered including artificial neural networks. The present work offers further development in the use of artificial neural networks for plasma shape prediction in the Globus-M2 tokamak. Neural network structure, optimization of hyperparameters and real-time hardware implementation are considered.

A real-time imitation platform was constructed for working out algorithms of tokamaks plasma control [11]. It is composed of two Speedgoat Performance computers including digital-to-analog and analog-to-digital converters connected by analog feedback. The first computer models the controller with a plasma reconstruction algorithm; the second computer models the tokamak with plasma and actuators. Such an approach provides several opportunities for digital control systems development. In particular, the imitation platform allows us to measure the working time required of the plasma reconstruction algorithm for plasma shape calculation. Calculation of TET of the Globus-M2 plasma shape control system with a plasma reconstruction algorithm on a Speedgaot computer gives less than 100 μs. Consequently, the time for plasma shape calculation should be about 10 μs.

#### **2. Experimental Signals**

This paper deals with the spherical Globus-M2 tokamak (Ioffe Institute, Saint-Petersburg, Russia) [12]. The basic parameters of this device are as follows: major radius R = 0.36 m, minor radius a = 0.24 m, aspect ratio R/a = 1.5, toroidal magnetic field, B t max = 1 T, plasma current 0.5 MA, impulse duration less than 0.7 s. Plasma confinement and control are provided by 8 poloidal field coils: horizontal field coil, vertical field coil, central solenoid, 4 poloidal field coils and a correcting coil. Plasma diagnostics consists of measurements of plasma current and 24 magnetic fluxes loops.

A plasma discharge consists of several phases. The phase when plasma is present inside the vacuum vessel and is not in contact with the inner walls is known as the diverter phase. In the Globus-M2 tokamak, a duration of the diverter phase is about 30 ms. For improving plasma confinement and control, it is necessary to use feedback control of the plasma shape. The plasma shape is determined at 6 points on a separatrix. The separatrix is the largest closed equal line of magnetic flux in Figure 1. In this paper, time series from 51 Globus-M2 discharges were processed. The FCDI algorithm was used to obtain the plasma shape in these discharges on the diverter phase. An example from the experimental data can be seen in Figure 2. The time step of the experimental data is 1 ms.

**Figure 1.** (**a**) Globus-M2 tokamak (**b**) Vertical cross-section with poloidal system, diagnostic probes (red dots) and points on separatrix (g1–g6).

**Figure 2.** Experimental signals from shot #37255 and Gaps reconstructed by the FCDI algorithm at a divertor phase of the plasma discharge.

#### **3. Artificial Neural Networks**

The simplest type of artificial neural network is a single layer perceptron [13]. The signal from inputs multiplied by weights, summarized with bias, and converted by a nonlinear activation function is written as follows:

$$output = activation(\mathcal{W} \cdot input + b),\tag{1}$$

#### *3.1. Fully Connected Feedforward Neural Networks*

An artificial neural network consisting of a set of fully connected layers is called a fully connected feedforward neural network [14]. In these neural networks, the layers are connected consequentially without loops (Figure 3). Values of *xi* are referred to as hidden layers.

$$\begin{aligned} \mathbf{x}\_1 &= activation\_1(W\_1 \cdot input + b\_1), \\ \mathbf{x}\_2 &= activation\_2(W\_2 \cdot \mathbf{x}\_1 + b\_2), \\ \vdots \\ \mathbf{x}\_{n-1} &= activation\_{n-1}(W\_{n-1} \cdot \mathbf{x}\_{n-2} + b\_{n-1}), \\ output\_{NN} &= \mathcal{W}\_n \cdot \mathbf{x}\_{n-1} + b\_n; \end{aligned} \tag{2}$$

Regarding the identification of the FCDI algorithm, the neural network has 33 input signals (8 coil currents, plasma current and 24 magnetic fluxes) and 6 output signals (2 strike point coordinates and 4 gaps between the plasma separatrix and the vacuum vessel). In general cases, the sizes the of hidden layers differ, and in the case of the FCDI code identification neural networks with hidden layers of the same size *s* were considered

$$\mathcal{W}\_1 \in \mathbb{R}^{33 \times s}, \mathcal{W}\_2, \dots, \mathcal{W}\_{n-1} \in \mathbb{R}^{s \times s}, \mathcal{W}\_n \in \mathbb{R}^{s \times 6}, \tag{3}$$

$$b\_1, \ldots, b\_{n-1} \in \mathbb{R}^s, b\_n \in \mathbb{R}^6. \tag{4}$$

An activation function is a nonlinear function that is needed for separating different hidden layers. In general, activation functions in various layers can differ. In the case of FCDI identification, a neural network with different activation functions but the same in all layers was considered. These are ReLU, LeakyReLU, ELU, Sigmoid, LogSigmoid, Tanh. Values of *n* and *s* and type of the activation function are called hyperparameters of the neural network (Figure 4). It is necessary to obtain optimal values of hyperparameters.

$$ReLU(\mathbf{x}) = \begin{cases} 0 & , \mathbf{x} < 0 \\ \mathbf{x} & , \mathbf{x} \ge 0 \end{cases} \quad LeakyReLU(\mathbf{x}) = \begin{cases} 0.01 \mathbf{x} & , \mathbf{x} < 0 \\ \mathbf{x} & , \mathbf{x} \ge 0 \end{cases}$$

$$ELI(\mathbf{x}) = \begin{cases} e^{\mathbf{x}} - 1 & , \mathbf{x} < 0 \\ \mathbf{x} & , \mathbf{x} \ge 0 \end{cases} \quad Signoid(\mathbf{x}) = \frac{1}{1 + e^{-\mathbf{x}}} \text{,} \tag{5}$$

$$LogSigmoid(\mathbf{x}) = \log \frac{1}{1 + e^{-\mathbf{x}}}, \quad tanh(\mathbf{x}) = tanh(\mathbf{x}) = \frac{e^{\mathbf{x}} - e^{-\mathbf{x}}}{e^{\mathbf{x}} + e^{-\mathbf{x}}}.$$

**Figure 3.** Structure of the fully connected feedforward neural network containing two hidden layers at a size of *s*. Input size is *k*, output size is *m*.

**Figure 4.** Dependency of accuracy on hyperparameter values of the fully connected feedforward neural network. Accuracy is measured on test data.

Training of the neural network involves finding values of weights *Wi* and biases *bi* to obtain minimum of the loss-function between a real output signal and a signal predicted by the neural network. In case of FCDI identification, the MSE (Mean Square Error) loss is used. This is a multi-parameter non-linear optimization problem. The most widely used algorithm for training artificial neural networks is backpropagation with a gradient method [15]. The main idea rests in calculation of the gradient of the loss function with respect to weights from output to input. A gradient descent with backpropagation does not guarantee finding the global minimum of the loss function, but only a local minimum. For minimizing this problem, a stochastic gradient method with momentum is used. Furthermore, normalization of signals was made to improve performance of the backpropagation algorithm. Training of the neural network for the FCDI identification was achieved using the Adam [16] algorithm in PyTorch. The experimental data were divided into two parts: 46 training shots and 5 testing shots. Thus, the size of training data is 1795 points and the size of the test data is 145 points. Results are shown in Figure 5.

$$\text{loss}(output\_{NN}, output\_{FCDI}) \xrightarrow[W\_i, b\_i]{} \text{min}\_{\prime} \tag{6}$$

$$loss(x, y) = MSE(x, y) = \sum\_{i=1}^{N} (x\_i - y\_i)^2 / N. \tag{7}$$

**Figure 5.** Results of the FCDI identification by the fully connected feedforward neural network with one hidden layer of the size of 100 neurons and the LeakyReLU activation function. In total, 5 test signals from Globus-M2 shots #37336, #37338, #37702, #37712 and #37320 are shown.

#### *3.2. Recurrent Neural Networks*

The feedforward neural network only uses a current input signal for calculation of the output signal. In the case of dynamic system identification, it could be useful to apply values from previous time moments. Recurrent neural networks use an additional hidden layer *h*. The values of the hidden layer *ht*−<sup>1</sup> on the time step *t* − 1 uses for calculation next step *ht*. Accuracy of RNN in dependence of hyperparameters is shown in Figure 6.

$$\begin{aligned} h\_t &= \operatorname{activation}(\mathcal{W}\_1 \cdot \operatorname{input} + \mathcal{W}\_h \cdot h\_{t-1} + b\_1), \\ output &= \mathcal{W}\_2 \cdot h\_t + b\_2; \\ \mathcal{W}\_1 &\in \mathbb{R}^{3 \times s}, \mathcal{W}\_2 \in \mathbb{R}^{s \times 6}, \mathcal{W}\_h \in \mathbb{R}^{s \times s}, \\ b\_1 &\in \mathbb{R}^s, b\_2 \in \mathbb{R}^6. \end{aligned} \tag{8}$$

**Figure 6.** Dependency of accuracy on hyperparameter values of the recurrent neural network. Accuracy is measured on test data.

#### *3.3. Implementation of Neural Network Models in Real-Time Hardware*

The imitation platform with Speedgoat computers is based on a SimulinkRT operation system. Real-time test bed for plasma control in tokamaks consists of two Speedgoat performance real-time target machines that are connected in feedback: one computer plays the role of the controlled plant model and the other one acts as the MIMO controller. PyTorch models were transferred to Matlab with the help of SciPy library. The neural networks with different structures were testified in real-time regime (Figure 7). Each neuron is connected with all neurons of adjacent layers. Because of this, the computation complexity of one layer of the neural network is proportional to the square of the layer size.

**Figure 7.** Dependency of Task Execution Time (TET) on number of neurons.

$$ETT(n, \mathbf{s}) = a \cdot n \cdot \mathbf{s}^2 + b, \; a = 7.33 \times 10^{-10} \,\text{s}, \; b = 1.79 \times 10^{-6} \,\text{s} \tag{9}$$

Plasma shape control in Globus-M2 requires plasma-reconstruction works in about 10 μs. Consequently, for real-time usage neural networks containing 100–150 neurons are applicable.

#### **4. Conclusions**

The artificial neural network model of the FCDI plasma reconstruction code was obtained along with an optimal structure and hyperparameters. The optimal model for FCDI algorithm identification is a fully connected feedforward neural network with one hidden layer and LeakyReLU activation function. Modeling on the imitation platform showed the possibility of using the neural network model for real-time high-performance control systems, with results demonstrating a Task Execution Time of 4.4 μs and a Mean Square Error of 3.4 <sup>×</sup> <sup>10</sup><sup>5</sup> m2.

**Author Contributions:** Conceptualization, Y.V.M.; methodology, Y.V.M.; funding acquisition, Y.V.M.; software, V.I.K.; supervision, Y.V.M.; validation, V.I.K.; visualization, V.I.K. and E.A.P.; writing—original draft preparation, V.I.K., Y.V.M. and E.A.P.; writing—review and editing, Y.V.M. and E.A.P. All authors have read and agreed to the published version of the manuscript.

**Funding:** This research was sponsored by the Russian Science Foundation (RSF), Grant No. 21-79-20180.

**Institutional Review Board Statement:** Not applicable.

**Informed Consent Statement:** Not applicable.

**Data Availability Statement:** The data used in this paper are not currently publicly accessible.

**Conflicts of Interest:** The authors declare no conflict of interest.

#### **References**


**Disclaimer/Publisher's Note:** The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.
