**4. Result Analysis**

The proposed LSTM–GA model has been designed using MATLAB Simulink as per the architecture shown in Figure 6.

**Figure 6.** Simulink model for STATCOM microgrid coordinated control action using LSTM and GA.

Here, the LSTM module will process the *id*, *iq*, and *v*<sup>∗</sup> values to determine the required amount of reactive power for the grid, which the STATCOM needs to produce. LSTM will share the hyperplane with the GA-optimized module to evaluate the agent position and initialize the chromosome parameter with four different variables.

Table 1 shows the STATCOM model's parameters, which have been used in the Simulink model to perform the analysis. All the set points, especially the AC voltage reference magnitude and DC voltage set point, are assumed to be per unit. All the AC and DC regulator gains have been evaluated based on a genetic algorithm ensemble with the classical Ziegler–Nicholas method.


**Table 1.** STATCOM module parameters for Simulink model used in microgrid architecture.

As observed, the regulator gain for the AC voltage is [0.52 0.39], which was evaluated through the Ziegler–Nicholas method (ZNM), and the corresponding DC voltage gain was evaluated through ZNM and GA. Moreover, the current regulator gain, which is a function of both the AC voltage and DC voltage regulation gains, has been evaluated through the ZNM–LSTM ensemble with GA. Thus, a single hyperplane can be maintained throughout the analysis.

Figures 7 and 8 present the LSTM–GA performance analysis for two different values of *μ*, i.e., 0.11 and 0.18, respectively. As observed, the objective of LSTM–GA is to forecast the required reactive power support for the microgrid, which is 15.58% and 12.10%, respectively, in this case. With the increase in the chromosome size, the system is able to accurately predict the amount of required reactive power support for the grid. In the subsequent discussion, the performance analysis has been carried out with *μ* of 0.18.

**Figure 7.** GA performance with *μ* = 0.11. (**a**) FACTS location initialization, (**b**) reactive power support range, (**c**) percentage of reactive power support, (**d**) best solution history.

Figure 9 presents the STATCOM DC link voltage for three different models (a) the Fuzzy–PI STATCOM, (b) PSO–PI STATCOM, and (c) proposed LSTM–GA–PI STATCOM (LGPS). As observed, the "LGPS" model produces a standard optimized DC link voltage of 700.24 V (Figure 9c), which is 0.32% less compared to the fuzzy model (Figure 9a) and 0.23% less compared to the PSO STATCOM (Figure 9b) model. This reduction in the voltage percentage will also reduce the voltage stress on the switch.

**Figure 8.** GA performance with *μ* = 0.18. (**a**) FACTS location initialization, (**b**) reactive power support range, (**c**) percentage of reactive power support, (**d**) best solution history.

**Figure 9.** STATCOM DC link voltage obtained from microgrid side. (**a**) Fuzzy PI Controller (**b**) PSO-PI Controller (**c**) LSTM-GA-PI controller.

Figure 10 presents the STATCOM DC link current for all the models. Here, it is observed that with the Fuzzy STATCOM model, the system exhibits sub-synchronous resonance (SSR) between 0.002 and 0.005 s, and a similar SSR was also noticed with the PSO STATCOM, from 0.006 to 0.008 s. However, an SSR limit of 2.8% was noticed with the hyperplane concept using LSTM and GA. As compared to the Fuzzy and PSO STATCOM models, the SSR has been reduced by 7.2% and 9.43% with the proposed "LGPS" model. The SSR also reduces the voltage swell at the point of common coupling and thereby indirectly supplies the reactive power compensation in the line.

**Figure 10.** STATCOM DC link current obtained from microgrid side. (**a**) Fuzzy–PI STATCOM, (**b**) PSO–PI STATCOM, and (**c**) LGPS.

Figure 11 presents the STATCOM injected current and Figure 12 presents the STAT-COM injected voltage at the point of common coupling. As observed, the injected current using the proposed model is 11.23 Amp. Similarly, a voltage level of 188 V has been maintained at the PCC, against 200 V and 197 V in the case of the fuzzy and PSO-enabled PI controllers. The THD levels of all three models for the injected current are shown in Figure 13. With the proposed model, the THD has been reduced to 11.44%, against 15.04% in Fuzzy–PI STATCOM and 12.39% in PSO–PI STATCOM.

**Figure 11.** STATCOM injected current at PCC into microgrid. (**a**) Fuzzy–PI STATCOM, (**b**) PSO–PI STATCOM, and (**c**) LGPS.

**Figure 12.** STATCOM injected voltage at PCC into microgrid. (**a**) Fuzzy–PI STATCOM, (**b**) PSO–PI STATCOM, and (**c**) LGPS.

**Figure 13.** Total harmonic distortion of current waveform at the terminal of PCC.

Figure 14 presents the voltage waveform of the r-phase of the microgrid. In Figure 14a, it is observed that the voltage is 252 V with harmonic content of 12.3% and that of for Figure 14b, PSO-PI controller, the voltage becomes 238 V with harmonic content of 10.78%. However, with proposed controller Figure 14c the voltage is maintained at 231.7 V. The percentage of harmonics injected by the STATCOM becomes 18% and that in the proposed model becomes 12.03%.

**Figure 14.** Voltage waveform of r-phase of microgrid. (**a**) Fuzzy PI Controller (**b**) PSO-PI Controller (**c**) LSTM-GA-PI controller.

#### **5. Discussion**

The P2P coordinated control between the SPV and STATCOM in a microgrid for power quality compensation using LSTM–genetic algorithm has been analyzed experimentally (MATLAB simulation) with two benchmarking models, the Fuzzy–PI and PSO–PI models. On analyzing the model, the observations are as follows.

Table 2 shows the power quality analysis of the STATCOM microgrid. It is observed that maximum harmonics have been produced with the Fuzzy–PI STATCOM of the order of 15.43%, and the least harmonics produced amount to 11.22%, with the proposed model. In all three cases, the broad band has been maintained for the notch. As compared to all the other algorithms, with the LSTEM–GA–PI STATCOM, the lowest DC offset was observed. Similarly, Table 3 presents the time-domain analysis of the STATCOM–PI controller. By testing these different control algorithms against a step function input, the time-domain analysis allowed for a comparison of their performance in terms of how well they respond to sudden changes and achieve the desired system behavior. The proposed algorithm produces 8.84% of overshoot, which is also the lowest among all the benchmarking models.

**Table 2.** Power quality analysis of STATCOM microgrid.



**Table 3.** Time-domain analysis of STATCOM–PI controller.

Figure 15 presents the voltage and current performance of the STATCOM at the PCC. Figure 15a presents the voltage and current waveform for the Fuzzy–PI STATCOM. As observed, the current has undergone oscillations from 0.3 s to 0.4 s. This is due to the unavailability of internal memory and also the inability of the controller to dynamically assign the reference voltage for the grid-side converter of the DFIG. Similarly, for the PSO– PI controller, the oscillations are less as compared to the GA–PI controller, as presented in Figure 15b. However, with the proposed LSTM–GA–PI STATCOM (Figure 15c), the oscillations have been damped out completely. This is because of the presence of a memory unit in the feedback loop. The maximum peak overshoot in the current waveform is 0.58 pu, as compared to 0.98 pu and 0.77pu in the Fuzzy–PI and PSO–PI controllers, respectively.

Figure 16 shows the DC offset voltage analysis for the Fuzzy–PI, PSO–PI, and LSTM– GA–PI STATCOM controllers. As observed, the initial oscillation presents negative slope characteristics for LSTM–GA–PI as compared to the other controllers. Similarly, the second transition event from 0.2 s to 0.3 s shows fewer oscillations for the DC offset.

Figure 17 presents the power quality analysis of the STATCOM's injected real and reactive power for the Fuzzy–PI, PSO–PI, and LSTM–GA–PI STATCOMs. As observed in Figure 17a, the reactive power has been absorbed by the STATCOM for three cycles, whereas, for the PSO–PI controller in Figure 17b, it shows oscillations with a time-varying negative slope. However, with the LSTM–GA–PI controller, the reactive power has been injected at 25% so as to reduce the burden on the DFIG stator.

**Figure 15.** STATCOM performance. (**a**) Fuzzy–PI STATCOM, (**b**) PSO–PI STATCOM, (**c**) LSTM–GA– PI STATCOM.

**Figure 16.** DC offset voltage analysis for DFIG controller. (**a**) Fuzzy–PI, (**b**) PSO–PI, (**c**) LSTM–GA-PI.

**Figure 17.** Power quality analysis of STATCOM injected real and reactive power. (**a**) Fuzzy–PI, (**b**) PSO–PI, (**c**) LSTM–GA–PI.

The integration of solar photovoltaic systems in a microgrid represents the utilization of clean and renewable energy sources. This reduces the reliance on fossil fuels and conventional power generation, resulting in lower greenhouse gas emissions and promoting environmental sustainability. A microgrid is a localized and decentralized energy system that can operate independently or in conjunction with the main power grid. Coordinated control between the SPV and STATCOM enhances the microgrid's power quality by ensuring stable voltage and frequency levels. This improved power quality enables the efficient operation of connected devices, minimizes electrical disturbances, optimizes energy consumption, and reduces waste, contributing to sustainability.

The utilization of advanced control techniques, such as LSTM and genetic algorithm, underscores the intelligence of the control system. By leveraging machine learning and optimization algorithms, such as LSTM and genetic algorithm, respectively, the microgrid can adapt to changing conditions, optimize the energy flow, and minimize losses. This intelligent control approach enhances the overall performance and energy efficiency of the microgrid, maximizing the utilization of the available renewable energy resources and contributing to sustainability.

Microgrids are designed to operate autonomously during grid disruptions and enhance the resilience against natural disasters and other disturbances. By incorporating coordinated control between the SPV and STATCOM, the microgrid effectively compensates for power quality issues and maintains a stable energy supply. This increased energy independence improves the microgrid's resilience and reduces the reliance on the main power grid. Ultimately, it contributes to the overall sustainability of the energy system by ensuring a reliable and uninterrupted power supply, particularly during critical situations.
