Microgrid Stability Improvement Using a Deep Neural Network Controller Based VSG

In order to support the inertia of a microgrid, virtual synchronous generator control is a suitable control method. However, the use of the virtual synchronous generator control leads to unacceptable transient active power sharing, active power oscillations, and the inverter output power oscillation in the event of a disturbance. )is study aims to propose a deep neural network controller which combines the features of a restricted Boltzmann machine and a multilayer neural network. To initialize a multilayer neural network in the unsupervised pretraining method, the restricted Boltzmann machine is applied as a very important part of the deep learning controller. )e Lyapunov stability method is used to update the weight of the deep neural network controller.)e proposed method performs power oscillation damping and frequency stabilization.)e experimental and simulation results are presented to assess the usefulness of the suggested method in damping oscillations and frequency stabilization.


Introduction
Renewable energy-based microgrids have drawn increasing interest in recent years. e primary distributed generating units in the microgrid include wind power, solar power, batteries, fuel cells, etc. e majority of them use inverters, also known as DC/AC converters, to connect to the grid. Grid-connected mode and islanded mode are the two operational modes for DGs [1]. e goal of grid-connected DGs is to inject predetermined active and reactive powers. According to their power capacity, DG units in an islanded microgrid must distribute the whole microgrid power demand [2]. Voltage Source Converters (VSCs) are often used to inject energy generated by these RESs into the power network. As a result, the influence of inverters is growing quickly. Direct power/current control can be mentioned as one of the most common methods for controlling inverters [1][2][3]. Due to the absence of rotating parts, the inertia of the inverter-based DGs is significantly lower than that of traditional synchronous generators. As a result, the grid's frequency fluctuation cannot be properly controlled, endangering the stability of the power system's operation.
Despite the popularity of direct control of power and its easy implementation, studies have been conducted so it can be replaced with new control methods to resolve its problems. e main disadvantage of the direct power controllers is lack of frequency and inertial irresponsiveness. e presence of a rotary rotor/turbine causes a large amount of angular momentum to dampen unexpected disturbances or changes in power systems. erefore, traditional power systems are robust to instability due to the presence of kinetic inertia. Inverter-based distributed generations (DGs) that do not have a rotating part make the system vulnerable to disturbances [4][5][6][7][8][9][10][11][12]. e virtual synchronous generator (VSG) technology has been proposed to surmount the drawbacks of direct power controls [13][14][15]. In the VSG, the dynamic behavior of a synchronous generator is mimicked by the inverter. Using power reference commands as input, a VSG operates similar to a synchronous generator. So, the robustness of the power system is improved [16][17][18][19].
Numerous studies have examined various features of VSG controllers. e swing equation of the generator is a fundamental component in the control scheme of a VSG. In this regard, the efforts of researchers have been limited to the determination of the optimal swing parameters such as the damping factor and the virtual inertia. In [20], to remove the deviation in the frequency and the voltage, the particle swarm optimization (PSO) algorithm is employed to obtain the moment of inertia parameter and the damping parameter. In [21], the virtual inertia constant is calculated by the fuzzy logic technique. e main disadvantage of the fuzzy logic technique is its dependence on the designer's knowledge. In [22], the oscillation damping is improved by a virtual synchronous generator using a neural network. Several methods have been suggested for the improvement of the main equations of the VSG. Most of the suggested VSGs have examined the decoupled control methods employed for reactive and active power [23].
In [24], a VSG control strategy with adaptive inertia has been proposed. If the deviation of the frequency is greater than the specified value, the inertia increases in proportion to the frequency deviation rate. In [25], a VSG is controlled by a bangbang control strategy. e amount of the virtual inertia is set to the maximum or minimum value according to the frequency deviation rate.
In conclusion, since the synchronverter does not have the physical limitations of a real synchronous generator (SG), its embedded parameters can be adjusted freely and online [26]. Although the synchronverter helps to support inertia in weak grid conditions [27], its main disadvantage is the inability to adjust the dynamic response speed of the active power loop (APL) without affecting the characteristics of the steady-state frequency droop. For example, the coefficient of the frequency droop has to be modified [28], which is undesirable because local network standards determine this coefficient [29]. If the response speed of the APL cannot be adjusted, following a single-phase-to-ground fault in the network, the synchronverter cannot control the frequency droop in time to suppress the frequency deviations. Other VSG control schemes also have this disadvantage [30]. In the literature, several approaches have been suggested to improve the dynamic response speed of the APL. A number of methods have been suggested for frequency droop control [31][32][33]. If the frequency droop control is used directly in synchronverters, it induces the adverse coupling effect between the reactive power loop (RPL) and the APL. In studies on VSGs, the virtual impedance method [34] and the inertia control [29] try to mitigate oscillations of power and frequency and also modify the response speed of the APL. Instead, the response speed of the APL is directly modified by the configurable natural droop controller [21], the distributed frequency control [35], and the differential algorithm [36]. e method proposed in [37] needs a PLL to measure grid frequency, which deteriorates the effectiveness of this method. e method proposed in [38] uses a differential term to increase the APL response speed. As we know, derivation leads to an amplification of noise in measured signals. In [36], the proposed method creates a zero in the transfer function from the active-power reference value to the active power output.
is new zero may be positive if the APL reacts rapidly and as a result, may lead to adverse nonminimum phase behavior.
Droop control is widely used in microgrid control. Loads can be shared between DGs using the P-f droop (frequency versus active power) and the Q-V droop (voltage versus reactive power), which is similar to the power sharing between parallel synchronous generators [38,39]. e conventional droop control is not able to increase the inertia of microgrids; consequently droop-based microgrids usually have low inertia and are fault sensitive. e oscillatory nature of VSG also causes oscillations during improper transient active power sharing [40]. e main problem of the conventional Q-V and P-V droops is the inaccurate power sharing, which leads to an inequality in the output voltage of DGs caused by unequal line voltage drop. In the literature, many researchers have focused on this issue and suggested various control strategies to solve it [41][42][43][44][45][46][47][48][49][50][51][52][53][54][55]. An inclusive solution is that the DG output impedance mismatch is removed [41,42]. However, if the active power sharing is not based on the power rating ratio, this solution will not be able to attain exact reactive power sharing. In [43], an approach based on the compensation of line voltage drop is presented. Also, other methods such as Q-dV/dt droop control [44], adaptive voltage droop [45], and virtual capacitor control [46] are suggested. However, these methods cannot completely eliminate errors of reactive power sharing as shown in the experimental results. Several methods have used communication to improve reactive power sharing [47][48][49][50][51][52][53][54][55].
e key drawbacks of this method are communication time delay and possible communication fault. erefore, considering these problems, it is preferable to resolve the issue of reactive power sharing in a less costly and simpler way and without telecommunication. In [56], VSG control incorporates an extra power loop and an auxiliary inertia unit. In [57], a hybrid adaptive strategy is proposed to control the virtual inertia of VSGs. e suggested method can enhance primary frequency control (PFC) performance metrics while providing low frequency oscillation (LFO) damping. In [58], to determine appropriate virtual inertia values for VSGs and to reduce the real power output and frequency oscillations of the DG during load fluctuation, an approach for virtual inertia estimation is provided. In [19], a cost function based on frequency deviation and frequency change rate is used to increase the inertia in microgrids. e problem with traditional synchronous generators is also evident in the case of VSG. In the event of a disturbance, the inverter output power begins to oscillate, and even the uncontrolled overshoot will injure the power electronic devices.

2
International Transactions on Electrical Energy Systems e main contributions of this study are (1) To surmount the problem of VSGs, a deep neural network controller (DNNC) is suggested to increase damping value in microgrids. (2) e Lyapunov stability theory is used to update the parameter of the DNNC so the stability of closedloop system can be ensured. e output of the proposed controller is applied to the inverter for power oscillation damping and frequency stabilization. e organization of the paper is as follows: in the second section, the fundamentals of virtual synchronous generator are stated; the third section explains the design of the suggested controller; in the fourth section, the simulation and experimental results are presented.

The Fundamental of VSG
VSGs imitate the dynamic behavior of synchronous generators to provide "synthetic inertia" for ancillary services in power grids. Inertia is a property of standard synchronous generators associated with the rotating physical mass of the system spinning at a frequency proportional to the electricity being generated. Inertia has implications for grid stability as work is required to alter the kinetic energy of the spinning physical mass and therefore opposes changes in grid frequency. Inverter-based generation inherently lacks this property as the waveform is being created artificially via power electronics. In the following, VSG modeling is presented, and the effect of virtual inertia on microgrid stability is studied. e swing equation of a synchronous generator simulated by the active power loop of VSG can be written as [59]: e damping and inertia factors of a synchronous generator are not changeable, while they are virtual and changeable in a VSG. Hence, the damping and inertia factors can be used to achieve a quicker and more stable operation. Damping factor D is designed and fixed based on grid operating requirements. Hence, this section focuses on the impact of virtual inertia J on the VSG output. Figure 1 shows a VSG operated in grid-connected mode [59,60].
It is supposed that the line impedance is inductive (i.e., Xg/Rg >>1). en the active power and reactive power of the VSG are represented by [61]: (3) Figure 2 shows the APL structure of VSG using (1) and (3). e closed-loop transfer function of the output active power is as follows [59]: Comparing a typical second-order system with the transfer function given in (4), one can write [59]: From (5) and (6), it is concluded that the virtual inertia is inversely proportional to the damping coefficient and natural frequency.

The Design of the Suggested Controller
As mentioned earlier, due to the absence of rotating parts, the inertia of the inverter-based DGs is significantly lower than that of traditional synchronous generators. As a result, the grid's frequency fluctuation cannot be properly controlled, endangering the stability of the power system's operation. Also, the use of the VSG control leads to unacceptable transient active power sharing, active power oscillations, and inverter output power oscillations in the event of a disturbance. Hence, to surmount the difficulties of the VSG, a deep neural controller is used to enhance the damping value of microgrids. In this section, the design of the suggested method is presented in detail. Figure 3 shows the block diagram of the suggested method for increasing the damping value and mitigating the power oscillations. As can be seen in this figure, the error between the desired frequency ω d and the network frequency ω is used in the proposed DNNC to generate the required inertia. e generated inertia (control effort u) is then converted to a PWM signal and applied to the inverter. It should be noted that the conventional virtual synchronous generator shown in Figure 2 has been completely replaced by the proposed method. In this case, thẽ Figure 1: A VSG connected to the grid.

e Control Strategy.
- Js θ Figure 2: Active power loop of the VSG.
International Transactions on Electrical Energy Systems limitations of a conventional virtual synchronous generator can be overcome by the proposed method.

Deep Neural Network
Controller. Deep learning, as a relatively new development in artificial intelligence, offers a way to train deep neural networks. e purpose of this method is to learn the hierarchy of features with features from higher levels of the hierarchy formed by combining low-level features. Deep learning-based learning methods can be used for a wide array of deep architectures. Here, the combination of the restricted Boltzmann machine (RBM) features and a multilayer neural network is suggested.

3.2.1.
e RBM. Geoffrey Hinton introduced the RBM technique, which uses sample training data inputs to learn probability distribution. It has applications in numerous supervised and unsupervised machine learning applications, including feature learning, dimensionality reduction, classification, collaborative filtering, and topic modeling. e restricted Boltzmann machine, which is an energybased model, has two layers: a hidden layer including the hidden nodes H and a visible layer including the visible nodes V. e conventional method introduced for RBM training has the drawback of the linear nature of the neural units. Figure 4 shows a three-layer RBM where V(q-1) is the input data. e following equation represents the output of the hidden layer: In the inverse layer, the data are reconstructed from the hidden layer. As a result, the output of this layer can be written as: Figure 5 shows a four-layer neural network with one input layer, two hidden layers, and one output layer. e input layer accepts the inputs x 1 , x 2 ,. . .,x n . e output of each node in the first hidden layer can be written as:

e Deep Neural Network.
where f (.) is a sigmoid function. e output of each node in the second hidden layer can be written as: where f (.) is a sigmoid function. In the output layer, the output can be computed by: To minimize the error in Figure 3, the deep neural network should be trained. e objective function can be defined as (see Figure 3): To guarantee the stability of the closed-loop system, the following two conditions must be satisfied: e general form of the weight updating law can be expressed as follows: Proof. Consider the following Lyapunov function where where α, β, and δ are constants. We can define: (e(n + 1)) 2 − (e(n)) 2 , (21) By using Taylor series, we can write: It should be noted that higher order terms of equation (24) is ignored. en, equation (24) can be written as: (e(n + 1)) 2 − α 2 (e(n)) 2 ≃αe(n) z(e(n)) zθ(n) Δθ(n).
Since it is assumed that b 2 − 4ac � 0, the roots of equation (32) are as follows: International Transactions on Electrical Energy Systems By replacing equation (39) into equation (15), equation (16) can be achieved. e suggested DNNC structure is shown in Figure 6. e purpose of using the DNNC is to learn the hierarchy of features with features from higher levels of the hierarchy formed by combining low-level features. Deep learning-based learning methods can be used for a wide array of deep architectures. A restricted Boltzmann machine is a generative stochastic neural network that can learn a probability distribution over its set of inputs.
Here, the combination of the RBM features and a multilayer neural network is suggested. ree nodes in the first layer are: x 1 � e(n), x 2 � e(n)-e(n-1), and x 3 � e(n)-2e(n-1)+e(n-2). e suggested DNNC has two parts: a neural network and an RBM, which initializes the weights of the neural network as displayed in Figure 6.

Results and Discussion
In this section, simulation and experimental results using the suggested DNNC are presented for different cases and events. Table 1 shows the structure of the DNNC.

Simulation Results.
Simulations are performed on the two microgrids shown in Figure 7 in MATLAB/SIMULINK to demonstrate the efficiency of the suggested DNNC. e results of the suggested DNNC are compared with the results obtained from VSG proposed in [62] and conventional VSG [56]. In Figure 7(b), the same characteristics and parameters are selected for both DGs. Table 2 provides DG generation and loading capacities.

Case 1:
e Microgrid with One DG: A Small Disturbance. For the first case, the system shown in Figure 7(a) is used to show the performance of the suggested DNNC. e DG1 is assumed to be a PV array operating at a point of 1000 W/m 2 and the output active power is 1 p.u. e irradiation radiated on the PV array is increased by 2% at t � 1s and returned to the pervious values at t � 1.02s. e active power of the DG1 and grid frequency using the suggested DNNC, the VSG, and the method proposed in [62] are shown in Figure 8. It is clear from these figures that the suggested DNNC provides much better damping than other methods. As can be seen in Figure 8(a), the DNNC significantly suppresses the output power fluctuations. As a result, the frequency fluctuation in the presence of DNNC, as shown in Figure 8(b), is smoother and its frequency stability is superior to that of the other two controllers. Although the maximum frequency deviation of the proposed method in [62] is comparable to the DNNC method, the active power output of DNNC is smoother because it is more sensitive. Figure 7(a), the DG1 is assumed to be operated at a point of 1000 W/m 2 and the output active power is 1p.u. e irradiation radiated on the PV array is increased by 5% at t � 1s and returned to the previous values at t � 5s. e active power of the DG1 and grid frequency using the suggested DNNC, the VSG, and the method proposed in [62] are shown in Figure 9. e increase in PV power leads to a power surplus, and as a result, the frequency of the network increases. On the other hand, when the active power decreases, a power shortage leads to a frequency drop. As seen in these figures, the PV array can switch to different operating points with a quicker speed and fewer oscillations. In addition, the proposed DNNC performance is better at frequency stabilization than other methods, since it returns the grid frequency to its nominal value faster.

Case 3: e Microgrid with One DG: A Severe Fault.
For the third simulation, it is assumed that a three-phase ground fault of 20 ms occurs at the PV bus at t � 1s. Figure 10 displays the dynamic responses of the microgrid to this fault. As seen from these figures, the suggested DNNC provides a better damping performance under this severe fault, since it damps out oscillations within 190ms. ese results confirm the robustness of the proposed method in any fault condition. e analysis presented above is primarily qualitative and based on time-domain data. Overshoot and settling time are typically used in control system analysis to objectively assess performance. In order to assess the dynamic performance quantitatively, the overshoot and settling time of power and frequency are used as indicators. Table 3 provides the numeric analysis of results obtained from different methods.

Case 4: Microgrid with Two DGS in Grid-Connected
Mode: Voltage Disturbance at Grid-Side. For this case, the system shown in Figure 6(b) is considered. To evaluate the performance of the suggested DNNC, it is assumed that a 50% grid-side voltage sag happens at the grid bus during 200 ms. Figure 11(a) shows the active power of each DG unit for this disturbance. Clearly, when the suggested DNNC is used for the microgrid, it is able to quickly damp the power oscillations and return grid powers to their nominal values. Also, the conventional VSG and the VSG control proposed in [62] lead to more power oscillations and longer settling time. Figure 11(b) draws the grid frequency. Table 4 compares the results obtained from different methods in terms of the integral-time-absolute-error (ITAE) index. e ITAE index's lowest value exhibits the best performance. It is obvious that the suggested DNNC has the ITAE index's minimal value.

Case 5: Renewable Energy Resources (RES) Variations.
e real island microgrids are thought to have essential characteristics such as RES intermittent power, generation/ demand power, and permanent system control adjustments. As a result, in this case, the performance of the microgrid's frequency is examined while taking RESs variations into account. Figure 12 shows output wind power. Figure 13 shows the grid frequency affected by the RES penetration. Table 5 compares the assessment metrics for the grid frequency deviation under various control strategies. It should be noted that the VSG can only control the grid frequency to within 0.05 Hz, while the method proposed in [62] can only control the grid frequency to within 0.05 Hz. e suggested DNNC, on the other hand, is able to adjust the grid frequency to within 0.01 Hz. In order to deal with RESs changes disturbance, it is evident that the DNNC in the virtual inertia control loop is the most effective. In addition, the closed-loop system is stable.

Case 6: Inertia Support During Low SOC of Storage
Unit. In this case, the performance of the proposed method is examined to support inertia during low SOC and load increasing. Initially, the microgrid frequency is 60 Hz with a 61% SOC. Figure 14(a)-14(c) show the active power of the energy storage unit, SOC, and system frequency. e load increases from 5 kW to 14 kW at t � 5 s, which is more than the DG capacity. As a result, because of an active power shortage, the frequency drops from 60 Hz to about 59.8 Hz. As shown in Figure 14(a), the storage unit is immediately activated. To maintain the power balance, the DG and storage unit begin looking for a load-sharing point. At 59.88 Hz, while the storage unit is supplying 6 kW, the power balance point is reached. As can be seen in Figure 14(b), not changing the load will cause a continuous decrease in SOC, so that the SOC will go out of its operating range and the battery will be discharged, in which case the frequency will drop again. It is clear from Figure 14(c) that the grid frequency has good dynamic behavior in the presence of the proposed method.

RBM Neural network inputs
Neural network output (Control signal) Weights Learning Based on Lyapunov Stability y m (2) Figure 6: e suggested DNNC structure.  Figure 16(a) and 16(b) shows the power system responses in the presence of the conventional VSG and the suggested VSG. As seen in these figures, when using the conventional VSG, the power oscillation peak is almost 896.63 W with an overshoot of 72.42% and the transient frequency peak is 50.06 Hz with a highest frequency deviation of 0.06 Hz. Compared with the conventional VSG, the power overshoot of the suggested enhanced VSG is decreased to 30%. Furthermore, the deviation of the frequency is lower than that of the conventional VSG. Figure 17(a) and 17(b) show the power system responses to a 0.2% decrease in the grid frequency. e transient power peak in the presence of the conventional VSG is 810.51 W, which is much larger than the steady-state power of 120.82 W. In the presence of the suggested VSG control, the transient power peak is 1.19 kW. As seen in Figure 17(b), the suggested enhanced VSG control provides a large amount of power to support the grid frequency in a short period.      Figure 11: e dynamic responses of microgrid with Two DGs to voltage disturbance at grid side; (a) active power; (b) grid frequency. Wind power (p.u.) Figure 12: Output wind power.

Conclusion
is study suggests a novel deep neural network for active power oscillation damping and for improving voltage and frequency support. e suggested deep neural network controller combines the features of a restricted Boltzmann machine and a neural network.
e Lyapunov stability theory is used to obtain the updating law of the deep neural network controller parameters. It is shown that the suggested deep neural network controller can efficiently damp out oscillations, support the frequency, and considerably improve the dynamic of the microgrid. e suggested DNNC can be implemented for microgrids having a higher number of DGs. In this article, a comparative study is performed between the conventional virtual synchronous generator and the proposed method in terms of power quality aspects that can facilitate a better understanding of the two favorable controller schemes for integrating renewable energy resources. e simulation and experimental results confirm the effectiveness of the suggested deep neural network controller control in damping active power oscillations and grid frequency support. Also, these results confirm that DNNC can adjust the grid frequency to within 0.01 Hz for high RES penetration. In future work, the frequency and voltage stability will be studied in a hybrid DC/ AC microgrid.
Nomenclature ω m : Virtual rotor angular speed ω n : Rotor rated angular speed P in : Virtual shaft power P out : Output active power D: Virtual damping factor J: Virtual inertia factor Xg: Reactance of transmission line Rg: Resistance of transmission line S: Output apparent power of the virtual synchronous machine Ug∠0: Grid voltage U∠δ: Virtual synchronous machine voltage W ij : Weight between the ith visible node and the jth hidden node b: biases vector in the hidden layer V i : binary state in the visible layer N: Number of the visible nodes P: Number of the hidden nodes Ψ: Activation function (sigmoid function) W ji : Weight between the jth hidden node and the ith visible node H j : Binary status in the hidden layer a i : Biases vector in the visible layer ψ ji : Connection weights between the input and first hidden layers T j : reshold value of first hidden layer ψ mj : Connection weights between the first and second hidden layers T m : reshold value of second hidden layer ψ m : Connection weights between the second hidden and output layers T: reshold value of output layer ω: Grid frequency ω d : Desired frequency V(n): Positive definite function Lyapunov function