**1. Introduction**

A microgrid is a type of electrical system that can operate independently or in coordination with the main grid. It consists of one or more distributed energy resources (DERs), such as solar panels, wind turbines, batteries, or generators, which are used to generate or store electricity [1]. Microgrids are designed to provide reliable, efficient, and eco-friendly power to local communities, businesses, and institutions, particularly in remote or off-grid areas where access to the main grid is limited or unreliable. Additionally, they can function as a backup source of power during emergencies, such as grid outages or natural disasters.

Voltage fluctuations are a common power quality issue in microgrids, especially those that incorporate renewable energy sources such as solar and wind. These sources have variable outputs, causing voltage fluctuations that can negatively impact the stability

**Citation:** Swain, D.; Viswavandya, M.; Dash, R.; Reddy, K.J.; Chittathuru, D.; Gopal, A.; Khan, R.; Ravindra, M. P2P Coordinated Control between SPV and STATCOM in a Microgrid for Power Quality Compensation Using LSTM–Genetic Algorithm. *Sustainability* **2023**, *15*, 10913. https://doi.org/10.3390/ su151410913

Academic Editor: Noradin Ghadimi

Received: 13 May 2023 Revised: 3 July 2023 Accepted: 8 July 2023 Published: 12 July 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/).

and performance of the microgrid [2]. Voltage fluctuation can be addressed based on voltage regulation. Voltage regulation is the process of keeping the voltage level in an electrical system stable and constant. This process is particularly important in microgrids, where voltage regulation is critical to ensuring dependable and efficient system operation, especially when intermittent renewable energy sources are present. To ensure voltage regulation in a microgrid, voltage regulators such as automatic voltage regulators (AVRs) or static VAR compensators (SVCs) can be used. These devices can regulate voltage levels in real time by increasing or decreasing the reactive power output of the system.

A static synchronous compensator (STATCOM) is a power electronics device that is frequently used for voltage regulation and reactive power compensation in electrical power systems. It is a type of flexible AC transmission system (FACTS) device that can introduce reactive power into the system to enhance the power quality and voltage stability. With the capacity to supply both capacitive and inductive reactive power, the STATCOM can react quickly to changes in system conditions, making it a versatile device that is appropriate for various applications, including microgrids [3].

Ping He et al. [4], in their paper, present a coordinated control strategy for a PSS and STATCOM, two critical power system devices. The goal of this approach is to enhance power system stability and damping, particularly in the presence of disturbances such as faults or sudden load changes. The study employs a multi-machine power system model and simulation techniques to evaluate the effectiveness of the proposed coordinated control strategy in various scenarios. According to the simulation outcomes, the strategy significantly improves the power system stability and damping and outperforms other control methods that disregard the coordination between the PSS and STATCOM.

Kaliaperumal Rukmani et al. [5] introduce a new approach to optimize the allocation of distribution static compensators (D-STATCOMs) in distribution systems where there is uncertainty. D-STATCOMs are crucial in enhancing the power quality and stability of distribution systems by injecting reactive power. The proposed method involves a combination of fuzzy logic and particle swarm optimization (PSO) algorithms to determine the optimal locations and sizes of D-STATCOMs. Fuzzy logic is utilized to manage uncertainties in the system parameters, while the PSO algorithm is utilized to locate the optimal solution.

Tariq, M. et al. [6], in their article, describe a new approach to voltage regulation and power quality improvement using static synchronous compensators. The proposed method involves adjusting the phase angle between the current and voltage using a simple PI controller to control the output voltage of the STATCOM. The effectiveness of the proposed method is evaluated through simulation studies, which show that it can successfully regulate the voltage and improve the power quality.

Anil Bharadwaj et al. [7] propose a novel approach to tuning PI and PID controllers in power systems equipped with various types of flexible AC transmission system devices, including a STATCOM, SSSC, and UPFC. The proposed method aims to minimize the damping of oscillations in the power system by adjusting the parameters of the controllers. To evaluate the performance of the proposed tuning method, the authors use a multimachine power system model and conduct simulation studies. The results indicate that the proposed method can effectively improve the damping of oscillations in the power system and outperform other tuning methods that do not consider the presence of FACTS devices.

Sarath Perera et al. [8] present a framework for the reduction of power network oscillations with the use of static synchronous compensators and the synthesis of H2/H∞ controllers. The framework employs an H2/H∞ synthesis technique to design the controller and improve the stability of the power system. The paper evaluates the effectiveness of the proposed framework through simulations using a power system model with a STATCOM, and the results indicate that the framework can effectively reduce oscillations in the power system and enhance its stability.

Claudia Battistelli et al. [9] suggest using the whale optimization algorithm (WOA) to develop power system stabilizers for multi-machine power systems. The goal of this method is to enhance the stability of the system by designing power system stabilizers that

minimize oscillations. The authors evaluate the proposed method by simulating it using a multi-machine power system model, and the findings show that the WOA-based stabilizers can effectively damp oscillations in the power system and enhance its stability [7].

Liangce He et al. [10] propose a method to optimize the economic and environmental performance of an integrated regional energy system by incorporating an integrated demand response into the environmental economic dispatch process. The proposed method optimizes the dispatch of different energy sources to minimize the total cost and emissions of the system while considering the impact of DR on the load demand. The effectiveness of the proposed method is evaluated through simulations, which show that it can effectively reduce the total cost and emissions of the system while considering the impact of DR.

D. Ranamuka et al. [11,12] propose a strategy for the control of the power flow in distribution systems using the coordinated control of distributed solar–PV and battery energy storage units. The objective is to enhance the stability and efficiency of the distribution systems through real-time power flow control via distributed energy resources. The proposed method is evaluated using a distribution system model with solar–PV and battery energy storage units, and the simulation results demonstrate its effectiveness in improving the stability and efficiency of the distribution system [13,14].

The paper [15,16] proposes a power system stabilizer (PSS) design for the damping of low-frequency oscillations in a multi-machine power system with the integration of renewable power generation. The proposed PSS design is based on eigenvalue analysis and aims to optimize the damping of low-frequency oscillations in the system. To evaluate the effectiveness of the proposed PSS design, simulations are conducted using a multimachine power system model with renewable power generation. The simulation results indicate that the proposed PSS design can effectively dampen low-frequency oscillations and enhance the stability of the power system [17,18]. As observed in the literature review, GA searches for a solution in the space based on probabilistic principles. Therefore, there is no sufficient guarantee that the system will always be optimized to the global optimal solution. Depending on the complexity of the STATCOM control problem and the specific fitness function used, there is a risk that GA may become trapped in local optima and fail to discover the best possible controller settings.

The performance of particle swarm optimization (PSO) in controlling STATCOMs in power systems may be limited by multiple factors [19,20]. One of these factors is the high sensitivity of the PSO algorithm to the initial conditions, which may lead to suboptimal solutions or becoming stuck in local optima. A solution to this problem can be achieved by starting with a good initial population and modifying the parameters of the PSO algorithm [21,22]. Another limitation is the inability of the PSO STATCOM to handle uncertainties in the power system, such as variations in renewable energy sources or changes in load demand. This may result in suboptimal STATCOM operation and reduced performance in controlling the power system [23,24].

Hyperparameter selection in the case of optimization is a critical challenge as it is the hyperparameters that will determine the area of optimization. Overfitting is a common problem in the case of data fitting, which is primarily due to the involvement of long-term dependencies. To avoid such conditions, it is necessary to store past data in the system's memory for the easy analysis and prediction of situations under abnormal conditions.

PSO, inspired by swarm behavior, is a population-based optimization algorithm that seeks optimal solutions in a problem space. In contrast, long short-term memory (LSTM) is a type of recurrent neural network (RNN) renowned for capturing and learning temporal dependencies in sequential data. The integration of PSO with LSTM involves utilizing PSO as a training algorithm to optimize LSTM's weights and biases. PSO achieves this by iteratively updating the particle positions and velocities based on personal and global best solutions, enabling LSTM to discover optimal parameter values for enhanced predictive accuracy. However, empirical studies consistently demonstrate LSTM's superiority over PSO-based LSTM models. LSTM's inherent capability to capture long-term dependencies and handle sequential data empowers it in time series prediction tasks. LSTM exhibits stronger learning capabilities and generalization power compared to PSO, which primarily focuses on optimization.

The combination of LSTM and genetic algorithm (GA) can have diverse applications, including time-series prediction, anomaly detection, and optimization problems [25,26]. For time-series prediction, LSTM can be utilized to forecast future values based on historical data, while GA can be used to optimize the hyperparameters of the LSTM model, such as the learning rate and the number of LSTM cells. In anomaly detection, LSTM can learn the regular patterns in data and identify any deviations from them, and GA can optimize the threshold for the detection of anomalies [27,28]. In optimization problems, LSTM can serve as a surrogate model for the evaluation of the objective function, and GA can search for the optimal solution.

In this paper, an attempt has been made to design a STATCOM, particularly in a microgrid, to provide voltage and reactive power support under variations in environmental parameters. We have analyzed various grid disturbances related to the injected current, voltage, and harmonics when utilizing a STATCOM. These disturbances include voltage sags and swells, which are temporary voltage decreases or increases caused by faults or abrupt changes in load demand. The current injected by the STATCOM is carefully examined to address and stabilize the voltage levels during such disturbances. Furthermore, we investigate the impact of harmonics on the grid, which refer to additional frequencies that can distort the sinusoidal waveform of the power supply. Through an evaluation of the harmonic content within the injected voltage, the effectiveness of the STATCOM in mitigating harmonic distortion and enhancing the power quality is assessed. By considering these grid disturbances, the study provides valuable insights into the STATCOM's performance and capabilities in effectively managing voltage fluctuations and harmonics, thus ensuring a reliable and efficient power supply. LSTM has been used to store the previous memory and historical data of the power quality issues and the amount of reactive power support, whereas genetic algorithm provides support for hyperparameter optimization. The objectives of the research can be summarized as follows.

