#### Abstract

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. This 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. The Lyapunov stability method is used to update the weight of the deep neural network controller. The proposed method performs power oscillation damping and frequency stabilization. The experimental and simulation results are presented to assess the usefulness of the suggested method in damping oscillations and frequency stabilization.

#### 1. Introduction

Renewable energy-based microgrids have drawn increasing interest in recent years. The primary distributed generating units in the microgrid include wind power, solar power, batteries, fuel cells, etc. The 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]. The 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–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. The main disadvantage of the direct power controllers is lack of frequency and inertial irresponsiveness. The presence of a rotary rotor/turbine causes a large amount of angular momentum to dampen unexpected disturbances or changes in power systems. Therefore, 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–12]. The virtual synchronous generator (VSG) technology has been proposed to surmount the drawbacks of direct power controls [13–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–19].

Numerous studies have examined various features of VSG controllers. The 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. The 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 bang-bang control strategy. The 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–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]. The method proposed in [37] needs a PLL to measure grid frequency, which deteriorates the effectiveness of this method. The 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. This 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]. The conventional droop control is not able to increase the inertia of microgrids; consequently droop-based microgrids usually have low inertia and are fault sensitive. The oscillatory nature of VSG also causes oscillations during improper transient active power sharing [40]. The 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–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–55]. The key drawbacks of this method are communication time delay and possible communication fault. Therefore, 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. The 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.

The 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.

The 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)The Lyapunov stability theory is used to update the parameter of the DNNC so the stability of closed-loop system can be ensured. The output of the proposed controller is applied to the inverter for power oscillation damping and frequency stabilization.

The 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.

#### 2. 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.

The swing equation of a synchronous generator simulated by the active power loop of VSG can be written as [59]:

The 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). Then the active power and reactive power of the VSG are represented by [61]:

Figure 2 shows the APL structure of VSG using (1) and (3). The 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.

#### 3. 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.

##### 3.1. The Control Strategy

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. The 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, the limitations of a conventional virtual synchronous generator can be overcome by the proposed method.

##### 3.2. Deep Neural Network Controller

Deep learning, as a relatively new development in artificial intelligence, offers a way to train deep neural networks. The 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. The 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.

The restricted Boltzmann machine, which is an energy-based model, has two layers: a hidden layer including the hidden nodes *H* and a visible layer including the visible nodes *V*. The 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. The 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:

###### 3.2.2. The Deep Neural Network

Figure 5 shows a four-layer neural network with one input layer, two hidden layers, and one output layer. The input layer accepts the inputs *x*_{1}, *x*_{2},…,*x*_{n}. The output of each node in the first hidden layer can be written as:where *f* (.) is a sigmoid function. The 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. The 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:

The general form of the weight updating law can be expressed as follows:

Theorem 1. *To guarantee the stability of the system, the following equation is used to update parameters of the DNNC:*

*Proof. *Consider the following Lyapunov functionwherewhere *α*, *β,* and *δ* are constants. We can define:By using Taylor series, we can write:It should be noted that higher order terms of equation (24) is ignored. Then, equation (24) can be written as:Similarity, we can write:Equation (26) can be written as:By replacing equation (26) into (24), we have:SimilarityEquation (14) can be rewritten as:Thenwhere *Ω*≥0. Therefore, we can write:In this regard, consider the following general quadratic equation:The roots of equation (33) can be computed as:By matching equations (34) and (32), we can write:If , we have:And Ω is computed as:Since *Ω*≥0, thenSince it is assumed that , the roots of equation (32) are as follows:By replacing equation (39) into equation (15), equation (16) can be achieved.

###### 3.2.3. Structure of DNNC

The suggested DNNC structure is shown in Figure 6. The 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.

Three nodes in the first layer are: *x*_{1} = *e*(*n*), *x*_{2} = *e*(*n*)- *e*(*n*-1), and *x*_{3} = *e*(*n*)-2*e*(*n*-1)+*e*(*n*-2). The suggested DNNC has two parts: a neural network and an RBM, which initializes the weights of the neural network as displayed in Figure 6.

#### 4. 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.

##### 4.1. Simulation Results

Simulations are performed on the two microgrids shown in Figure 7 in MATLAB/SIMULINK to demonstrate the efficiency of the suggested DNNC. The 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.

**(a)**

**(b)**

###### 4.1.1. Case 1: The 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. The 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. The irradiation radiated on the PV array is increased by 2% at *t* = 1s and returned to the pervious values at *t* = 1.02s. The 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.

**(a)**

**(b)**

###### 4.1.2. Case 2: The Microgrid with One DG: Different Operating Conditions

For the second simulation performed on the microgrid shown in 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. The irradiation radiated on the PV array is increased by 5% at *t* = 1s and returned to the previous values at *t* = 5s. The 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. The 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.

**(a)**

**(b)**

###### 4.1.3. Case 3: The 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. These results confirm the robustness of the proposed method in any fault condition.

**(a)**

**(b)**

The 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.

###### 4.1.4. 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. The ITAE index’s lowest value exhibits the best performance. It is obvious that the suggested DNNC has the ITAE index’s minimal value.

**(a)**

**(b)**

###### 4.1.5. Case 5: Renewable Energy Resources (RES) Variations

The 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. The 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.

###### 4.1.6. 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. The 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.

**(a)**

**(b)**

**(c)**

##### 4.2. Experimental Results

Now, experimental tests are used to show the performance of the suggested enhanced VSG control. In these tests, the conventional VSG and the suggested VSG are evaluated and compared by using two cases: the load variation disturbance and the grid frequency disturbance. Figure 15 displays a laboratory set-up that includes a Texas Instrument’s TMS320F240 DSP board, controllable Load, a 5 kW PV panel, 10 kW converter, grid simulator, and signal conditioners. To implement the suggested VSG control, a TMS320F240 DSP is used. In this regard, using the Texas Instrument C2000 support package of MATLAB software, the VSG simulated in MATLAB can be easily built for DSP board programming.

###### 4.2.1. Case 7: Load Variation Disturbance

For the first experimental test, a 30% load increase is applied to the microgrid. 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.

**(a)**

**(b)**

###### 4.2.2. Case 8: Grid Frequency Disturbance

Figure 17(a) and 17(b) show the power system responses to a 0.2% decrease in the grid frequency. The 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.

**(a)**

**(b)**

#### 5. Conclusion

This study suggests a novel deep neural network for active power oscillation damping and for improving voltage and frequency support. The suggested deep neural network controller combines the features of a restricted Boltzmann machine and a neural network. The 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. The 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. The 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.

#### Appendix

Parameters of DNNC: *α* = 1.5, *β* = 2, *δ* = 1, *η* = 0.1.

#### 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}: | Threshold value of first hidden layer |

ψ_{mj}: | Connection weights between the first and second hidden layers |

T_{m}: | Threshold value of second hidden layer |

ψ_{m}: | Connection weights between the second hidden and output layers |

T: | Threshold value of output layer |

ω: | Grid frequency |

ω_{d}: | Desired frequency |

V(n): | Positive definite function Lyapunov function |

η: | Learning rate |

θ: | Generalized weight vector. |

#### Data Availability

No data were used to support this study.

#### Conflicts of Interest

The authors declare that there are no conflicts of interest regarding the publication of this article.