LSTM Recurrent Neural Network-Based Frequency Control Enhancement of the Power System with Electric Vehicles and Demand Management

Due to the unpredictable and stochastic nature of renewables, current power networks confront operational issues as renewable energy sources are more widely used. Frequency stability of modern power systems has been considerably harmed by fast and unpredictable power variations generated by intermittent power generation sources and fexible loads. Te main objective of the power system frequency control is to ensure the generation demand balance at all times. In reality, obtaining precise estimates of the imbalance of power in both transmission and distribution systems is challenging, especially when renewable energy penetration is high. Electric vehicles have become a viable tool to reduce the occasional impact of renewable energy sources engaged in frequency regulation mainly because of vehicle-to-grid technologies and the quick output power management of EV batteries. Te rapid response of EVs enhances the efectiveness of the LFC system signifcantly. Tis research work investigates a deep learning strategy based on a long short-term memory recurrent neural network to identify active power fuctuations in real-time. Te new approach assesses power fuctuations from a real-time observed frequency signal precisely and quickly. Te observed power fuctuations can be used as a control reference, allowing automatic generation control to maintain better system frequency and ensure optimum generation cost with the use of demand management techniques. To validate the suggested method and compare it with several classical methods, a realistic model of the Indian power system integrated with distributed generation technology is used. Te simulation results clearly indicate the importance of power fuctuation identifcation as well as the benefts of the proposed strategy. Te results clearly show a considerable improvement in response performance indices, as the maximum peak overshoot was decreased by 21.25% to 51.2%, and settling time was lowered by about 23.34% to 65.40% for the suggested control technique compared to other controllers.


Introduction
For many decades, load frequency control (LFC) in electrical power systems was extensively used to ensure a balance between load consumption and power production in each control area, thereby eliminating system frequency variations. Due to increased renewable energy penetration, deployment of innovative solutions such as smart grid, and modernization of the electric power system with insecure communication technologies, electric power systems increased their complexity which in turn directly afected the electric power system's operation, stability, and safety [1,2]. Te inclusion of electric vehicles (EVs) into LFC systems through an aggregator has received a lot of interest in recent years [3][4][5][6][7][8]. EVs have become a viable tool to reduce the occasional impact of renewable energy sources engaged in frequency regulation because of vehicle-to-grid technologies and the quick output power management of EV batteries. Te rapid response of EVs enhances the efectiveness of the LFC system signifcantly. Although EVs can be used as generators or loads, unwanted frequency changes can be reduced and thus the frequency response can be improved.
To practically manage the involvement of EVs in the frequency control market, an aggregator is used. Te aggregator's role is to gather and manage a group of EVs to meet frequency regulation criteria [9,10].
Hundreds of thousands of EVs can also be connected to the grid as a massive battery energy storage system (BESS). Tis is possible as EVs plug into the grid when parked at a station or at home. Due to the short response time of EV batteries, a feet of EVs working as a massive BESS is specifcally successful in regulating load demand and wind power oscillations [11]. EVs aggregation into the interconnected power system can engage in both primary and secondary frequency control to help conventional power plants promptly decrease system frequency fuctuations caused by load disruptions and unpredictable renewable energy sources. In terms of primary frequency control (PFC), EVs' PFC can emulate the behavior of a turbine governor by adopting a droop control [12][13][14][15][16][17][18][19]. Te author [12] presented a basic control strategy for EVs with a load estimator, in which all EVs are abruptly unplugged from the grids due to increased demand in the system. When the power of the disconnected EVs is greater than the system's power imbalance, this control strategy, however, can have negative efects on system frequency.
In secondary frequency control (SFC), an aggregation of EVs serves as a generating power source to assist an existing power generation system meet the LFC need quickly [20,21]. EVs use bidirectional power electronic devices to communicate with the power grid, allowing them to respond to new load set-points faster than traditional generators [22]. For LFC analysis, EV-based battery storage was proposed in [20]. Te usefulness of SFC with EVs in lowering the area control errors (ACEs) in a Western Danish power system is demonstrated in this simulation. Furthermore, the authors studied LFC power system topologies with EV integration in [23,24]. LFC methods efectively control frequency fuctuation by using the SFC signal to manage EV power output.
Moreover, EV aggregators send information to the controller about EVs energy capabilities, electrical power availability, and charging status. As a result, the aggregators restructure control instructions regarding the engagement of EVs for automatic generation control to control their output power [22,[25][26][27][28].
Under unexpected and worsening changes in load conditions, it is not possible to keep the system frequency within a prescribed limit. Ten, the demand management technique can be implemented using a nature-inspired algorithm to optimise system operation cost to fnd the fexible demand of EVs engaged by the system to maintain the supply-demand balance, which in turn is refected in the frequency control.
Over the last few decades, algorithms inspired by the natural behavior of species that rely on benefcial properties of biological systems have evolved rapidly. Swarm intelligence systems imitate the social behavior of birds, bees, and ants. Teir prominence stems from their capacity to successfully tackle real-world global optimization problems [29]. Diferent swarm intelligence algorithms such as Ant Colony Optimization (ACO) [30], Ant Lion Optimizer (ALO) [31], Particle Swarm Optimization (PSO) [32], Firefy Algorithm (FA) [33], and Chimp Optimization (CO) [34] are based on simple notions related to physical phenomena and evolutionary psychology. Tese algorithms have drawn a lot of interest since they are derivative-free, robust, and can be used to solve a variety of optimization problems. Tese algorithms employ the randomization idea, which shifts the efciency of local search to global search.
However, due to their sluggish convergence speed, such single approaches are inefective in solving optimization problems as these approaches take a long time to compute and are usually confned to the local search space. As a result, numerous optimization techniques have been merged to calculate better outputs to improve the benefts of such optimization algorithms. Te efciency of these optimization techniques, which combine the best aspects of two or three methods, has been demonstrated in terms of computing time and convergence rate. Tese algorithms are capable of fnding optimal results more quickly than traditional algorithms. Te suggested Firefy Algorithm hybridized with Flower Pollination Algorithm (FA/FPA) efectively utilizes two specifc terms from the Firefy Algorithm (FA) and Flower Pollination Algorithm (FPA): exploration and exploitation. Te proposed hybrid will be compared with the Firefy Algorithm (FA) and Flower Pollination Algorithm (FPA) based on their performance.
To enhance the performance of the controller, the author [35] suggested a novel resilient LFC design for multiarea power systems based on the second-order sliding mode control and an extended disturbance observer. For a hybrid isolated microgrid, the author [36] devised a new frequency control mechanism based on a disturbance observer and double sliding mode controllers. Numerous methods such as distributed control, robust control, and model predictive control were proposed to enhance the LFC's performance, though their efciency and response time were largely dependent on the estimated imbalance of power [37][38][39].
Deep learning has shown promise in solving complicated nonlinear engineering issues in current history. To handle short-term load forecasting problems in individual residential families, Kong [40] suggested a prediction framework based on the long short-term memory (LSTM) recurrent neural network (RNN). Te short-term load demand prediction was performed using a radial basis function neural network (RBFNN) [41]. Most existing research on power fuctuations estimate of LFC relies on disturbance observers [35,36,42,43].
(i) To the best of the authors' knowledge, online power fuctuation detection using a data-driven strategy has not been resorted to in solving frequency deviation problems accompanying the application of demand management techniques.
Because of the greater penetration of renewable power generation and controllable demands in power system, rapid 2 International Transactions on Electrical Energy Systems and unpredictable power surges can dramatically degrade the power system's frequency performance. Te goal of this research is to apply a recurrent neural network to accurately assess real-time power fuctuations from frequency measurements along with the application of demand management techniques. Tis paper's key contribution and novelty can be summarised as follows: (i) An LSTM RNN is intended to provide an accurate control signal to the LFC to control the frequency of the power system. (ii) Te online application of the well-trained LSTM is used to recognize real-time power fuctuations from the recorded frequency. Control devices, such as synchronous generators and energy storage integrated EV systems, can keep the frequency in a steady condition by using identifed power fuctuations. (iii) Under unexpected and worsening changes in load conditions, it is not possible to keep system frequency within a prescribed limit. Tus, the demand management technique can be implemented using FA/FPA algorithm to optimise system operation cost to fnd the fexible demand of EVs engaged in the system to maintain the supplydemand balance, which is refected in the frequency control. (iv) With actual data on power and frequency changes, a model of the Indian power system that includes combined heat and power generation, solar photovoltaic generation, wind energy generation, and loads (including electric vehicles) is developed. Te proposed algorithm is tested on this platform and compared to several conventional algorithms.
Te remainder of this work is structured as follows: Section 2 describes the transfer function model of the multiarea system. Section 3 proposes the LSTM RNN method that is applied to optimise the ftness function. Section 4 narrates the FA/FPA algorithm and its application to fnd the optimal fexible load demand. Section 5 verifes the proposed logic using simulation results. Finally, Section 6 concludes the considered work.

System Model
Building an appropriate hybrid power system model for the LFC analysis is quite important. In the proposed approach, the four-area model included a renewable energy source such as a wind turbine and a photovoltaic module in addition to an electric vehicle. Controlling output power from intermittent power generation systems is difcult due to uneven variations. It is also completely diferent compared to nonintermittent power generation systems. Tere have always been difculties with stability when power demand was greater than power generation.
Te major goal of this study is to build an improved LFC for a four-area power system network using a superior controller. To achieve excellent performance in dynamic stability, various types of controllers, as reported earlier, were used. Te conventional controller was created to tackle these challenges due to the nonlinearity of the power system component utilized in modeling the power system network. Te controller in four-area modeling was mostly based on a proportional-integral controller, as the integral gain has the characteristics of both fast-transient recovery and minimal overshoot. Te detailed transfer function modeling of intermittent and nonintermittent energy sources of the interconnected hybrid power system is presented in [16,35].
EVs' demand management technique (DMT) gained popularity in recent years. Te development and extensive use of electric vehicles could have a substantial infuence on power grids. In this work, a system to model an electric vehicle feet was devised, and the impact on the load demand of a power system network was investigated. However, it was considered that distinct EV classes' features were not considered. An aggregate model of EV feets is shown in Figure 1. A deadband function with droop features was included in this model to prevent undesirable frequency fuctuation. ΔF UL and ΔF LL describe the dead band upper and lower limit values, respectively; ΔP max AG and ΔP min AG indicate the maximum and minimum power outputs of the EV feet, respectively; R AG represents the model droop coefcient (same as conventional units), K EV represents the EV gain, N EV represents the number of connected EVs, T EV represents the battery time constant, and ΔP EV represents the incremental generation change of EV feet. Te transfer function model that describes the efect of the EV feet is given as follows: Te state equations for all areas for the above interconnected hybrid power system as seen in Figure 2 can be stated as follows: International Transactions on Electrical Energy Systems

International Transactions on Electrical Energy Systems
Te state-space equation for the considered system can be expressed as follows: where U is the input variable vector, Y is the output variable vector, X is the state variable vector, and W is the disturbance vector. Tey are expressed as follows: 6 International Transactions on Electrical Energy Systems International Transactions on Electrical Energy Systems

LSTM Network.
An RNN is a type of artifcial neural network that takes advantage of time information in input data, as opposed to a regular neural network that merely has interactions between layers. As a result, RNN performs better when dealing with time-series learning problems. Te structure of the LSTM cell includes the input gate, forget gate, and output gate. Te LSTM defnes and maintains the cell state to manage information fow, which is an essential factor in the LSTM architecture, to acquire long-term temporal functional relationships [44]. Relying on the results of prior stages and inputs of the current time step, the memory cell state C t−1 interacts with the intermediate output h t−1 and the succeeding input x t to determine which parts of the internal state vector should be modifed, retained, or discarded. Te following are the compact expression of an LSTM network with a forget gate: where i denotes the input gate; f denotes the forget gate; o denotes the output gate; σ denotes the sigmoid activation function; the operator * denotes element-wise   International Transactions on Electrical Energy Systems multiplication; W i , W f , W o , and W g denote the weight matrices that need to be learned during training; U i , U f , U o , and U g are coefcient matrixes; C t is a "candidate" hidden state, which is calculated based on the current input and the previous hidden state; C t is the internal memory of the unit, and h t represents the fnal output of the memory unit. LSTM memory units can record sophisticated correlation patterns inside time-series data in both short and long term through the function of diferent gates, which is a signifcant advance over other RNNs.

LSTM Network for Power Identifcation.
Te LSTM RNN is used in this work to present an active identifcation approach for real power perturbations. Tis provides a new realistic reference for automatic generation control (AGC) to preserve system frequency. Te proposed technique is divided into two parts: ofine training and online application of the LSTM, with the entire procedure being depicted in Figure 3.

Ofine Training Progress.
Te statistical data of frequency variations, which provides the input for the LSTM training, can be considered the preceding information. Te target (i.e., the output) is the real power fuctuation. Te training processes are as follows: (i) Step 1: data on the frequency and active power fuctuations should be collected.     (iii) Step 3: by updating the weight coefcients and bias vectors, the neural network is trained using the backward propagation approach with the gradientbased optimizer to minimize the cost function. (iv) Step 4: invert the recognized power fuctuations from the normalized to real values, then output the results of the identifcation.

Online Application.
Te proposed LSTM network is trained using previous data in the ofine environment and created using power and frequency changes. Once the LSTM network is properly trained, it may be used online to calculate power fuctuations based on the frequency observed online. It is worth noting that varied system running conditions can be considered for training database development when in the ofine training mode. In addition, the model can be updated on a regular basis if fresh online measurement and generated data becomes available, or if the system's conditions change unexpectedly. Frequency control resources, such as synchronous generators and ESSs, clear out all the recognized real-time power perturbations and form a control signal for AGC.  gains due to lesser overshoots/undershoots and fuctuations [10]. Equations (14)-(17) describe the ftness function of ITAE and the PID controller gain limits, respectively. By optimizing the ftness function of ITAE, the PID controller gains are well-tuned. For area-n,

Performance Evaluation
Subjected to PID gain limits, where n denotes the number of areas; j � 1, 2, . . . n(j ≠ n); ΔF n denotes the frequency deviations in the n th area; ΔP tie,n−j denotes the tie line power fuctuation.

Demand Management Technique.
Te primary goal of the DMT is to reduce system peak demand and its operational cost. In this considered work, the clipping of system peak demand can be achieved with the help of the working behavior of EVs while the system operational cost can be managed with the help of nonintermittent power generation units such as thermal units and combined heat and power generation units. Te formulation of the objective function with their constraints is listed as follows: (18) where ΔV min ,i is the variation in minimum voltage, P d is the variation in electrical power demand, N p and N c represent the number of conventional thermal and cogeneration units, respectively, C i (P p i ) represents the fuel cost of the conventional thermal units, and C j (P j c , H j c ) represents the fuel cost of the cogeneration units and they are expressed as follows: Subject to the following constraints, Te operation of the suggested DMT is to determine the best timings for charging electric vehicles and turning on various heating loads while adhering to the aforementioned restrictions [45,46]. To keep frequency oscillation to the minimum, the considered system fully relies on the nonintermittent power generation units. However, it is also        International Transactions on Electrical Energy Systems   limited by their upper and lower bounds. Terefore, in such a scenario, the FA/FPA algorithm can be used to fnd the optimal fexible demand, which will reduce the system operation cost and ensure standard system frequency. Te implementation logic of the DMT coordinated LFC is described in Figure 4.
Te system frequency rises due to an unexpected drop in load. Nonintermittent power generation must be altered to achieve zero frequency variation. In some unconditional situations, this cannot be performed beyond a certain limit as it will further increase the system's operational cost due to the temporary shutdown and startup. Ten, given a time constraint, the FA/FPA algorithm is run to determine optimum fexible demand, which can then be introduced to the system to satisfy zero frequency deviation and to calculate the optimal cost function.

FA/FPA Algorithm
Te proposed technique is based on two metaheuristic algorithms, Firefy Algorithm and Flower Pollination Algorithm, which were thoroughly examined in this research work. Tese proposed algorithms combine the concepts of exploration (diversifcation) and exploitation (intensifcation) to create a hybrid algorithm. Exploration is a global search term, while exploitation is a local search term. Te Firefy Algorithm (FA) is based on the blinking characteristic of frefies, which are infuenced by their natural behavior and bioluminescence phenomena. Tese frefies move toward an attractive frefy that serves as the present global best. Optimization is used to determine the fashing brightness of frefies.
Te Flower Pollination Algorithm (FPA) is based on the properties of the fowers of various plants. Te main goal is to reproduce by transferring pollen and pollinators such as insects, birds, bees, and fies assist in this process. Abiotic (self-pollination) and biotic (cross-pollination) pollination are the diferent sorts of pollination. As pollinators travel a great distance, global pollination (biotic) happens over vast distances. Cross-pollination occurs within fowers of the same plant. To reach speedier optimums, both processes are regulated by a switch probability p.
Both FA and FPA algorithms employ biological notions. Te fundamental goal of hybridization is to solve the drawbacks of existing separate optimization algorithm components and generate a better form. Second, to establish the robustness of this suggested algorithm in terms of achieving global optima in very little time while maximizing the utilization of the exploration and exploitation concepts. Both these concepts are used to investigate new potential outcomes as well as improve the current solution. Te fowchart that describes the considered work using FA/FPA is shown in Figure 5.
Te suggested algorithm introduces both concepts. Te movement of particles in this method is based on moving less brighter particles toward brighter ones by completing local and global walks in two phases, identical to the Firefy Algorithm and Flower Pollination Algorithm. Te FA/FPA algorithm incorporates the Firefy Algorithm concept by frst opting for a local search as all particles are divided into numerous subgroups and then selecting the best value from each group. By preventing from being trapped within local optima and reducing the randomness efect, they were able to fnd a global best one value from all these values, allowing particles to explore a better optima solution. As a result, the entire process includes the global step, which is efciently completed by the particles. Te suggested algorithm (FA/ FPA) then uses the Flower Pollination Algorithm paradigm to create an interaction between local and global search. Tis results in a switch probability having a magnitude bigger than the random number generation of particles, as the particles can move in any direction in a local walk and hence the efect of randomization is greater.
Te exploitation impact is included in the local search of the Flower Pollination Algorithm because fowers of the same species are selected using the fower consistency process, and pollen transfer occurs in the same plant. Similarly, the proposed algorithm's local search exploits particles belonging to the same species. As a result, the convergence rate is quicker as particles will do a more effcient local search. In the considered work, the minimum system operational cost can be taken as the objective function, which can be achieved with the application of FA/ FPA. Te implementation logic of the FA/FPA can be described as a pseudocode in Figure 6.

Simulation Results and Discussion
Due to the signifcant penetration of intermittent power generation and variable fexible loads, the frequency stability of an Indian power system is challenged. Te one-line diagram of the typical 62-bus Indian utility system is shown in Figure 7 and their corresponding generator data is shown in Table 1. Te area-wise number of both intermittent and nonintermittent power generation units is provided in [47]. Te four-area power system is modeled using MATLAB/ Simulink tools, which includes the efects of renewable energy sources and electric vehicles. Tis four-area power system is linked to the proposed controller, which has been put through its paces under various operating situations to test the efciency of the controller's response. Te test system is simulated in four diferent scenarios, and the suggested controller response is compared to that of a standard PID controller and a fuzzy controller.

Case 01 (System Response with All Energy Resources).
Case 01 deals with intermittent and nonintermittent power generation in all four areas. Figures 8-11 show the simulation of the system's reaction with a load variation of 0.01 p.u and the accompanying responses associated with the suggested controller, which delivers a superior and faster response when compared to traditional PID and fuzzy controllers. Moreover, better frequency response is required to reduce associated power generation cost. Nonintermittent power generation units in each of the four zones are responsible for this.

Case 02 (System Response with Change of ∆P w ).
For frequency regulation with the efects of wind power, Case 02 considers both intermittent and nonintermittent power generation in the four areas under study. Variations in solar power and load are retained as constant, whereas only variations in wind power are implemented with rising and falling ∆P w values. As wind power is an intermittent power source, it is frequently encountered in the power system. Figures 12-15 present the fndings of the system response using the proposed controller to handle these variations in ∆P w values. Compared to PID and fuzzy controllers, frequency deviation provides a better and faster reaction while minimizing power generation costs with good frequency response, meeting the frequency deviation within ±0.5 when using the FA/FPA algorithm.

Case 03 (System Response with Change of ∆P S ).
For frequency regulation with the efects of solar power, Case 03 considers both intermittent and nonintermittent power generation in the four areas under study. Only variations in solar power are implemented with a rise in the value of ∆P S , while variations in wind power and load remain constant. As solar power is an intermittent power source, it is frequently encountered in the power system. Figures 16-19 present the fndings of the system response using the proposed controller to handle variations in ∆P S values. To maintain better frequency response, control inputs to nonintermittent power generation units such as thermal, and CHP are modifed in a decreasing manner when solar power increases. Simultaneously, the suggested FA/FPA algorithm reduces power-generating costs by improving frequency response and achieving a frequency deviation of less than ±0.5.

Case 04 (System Response with
Change of ∆P L, ∆P W, and ∆P S ). Case 04 considers both intermittent and nonintermittent power generation in all four areas for load frequency regulation with all conceivable system disturbances. Tis case connects the problems discussed in the three earlier cases at the same time. If changes in solar and wind power are accompanied by increases in the values of ∆P S and ∆P W , and changes in load value are accompanied by decreases in the value of ∆P L , then the nonintermittent power generation units must be modifed to suit the power demand while still being within their constraints to keep the frequency deviation (+0.5) within a limit. If the nonintermittent power generation units fail to match the above criteria, the FA/FPA algorithm-based DMT can be used to determine the best fexible demand (such as electric vehicle charging) with a time constraint, which can then be incorporated to achieve zero frequency deviation. Figures 20-23 present the fndings of the system response using the suggested controller to handle these changes in ∆P L , ∆P W , and ∆P S . Te frequency deviation of the system for the proposed controller is superior in maintaining almost  Table 2 shows the MATLAB/Simulink's numerical results for the prescribed four-area power system network for frequency deviation using diferent types of controllers and power generation cost using diferent optimization techniques. In addition to this, the ANFIS controller [48] was also tested for the considered network to mitigate frequency deviation problems. However, the performance was almost the same as that of the fuzzy controller. It was found that the  LFC with LSTM provided the best performance with minimum overshoot and settling time compared to the other two considered controllers in all four areas. As discussed in Section 3, the accuracy of the proposed LSTM RNN methodology can be assessed with the help of ITAE and the corresponding numerical fgures for all the 4 considered scenarios that are given in Table 3. It is clear from the results that the ITAE of the proposed methodology was well minimized by about 6.54% to 69.65% compared to other controllers. Power generation cost was also calculated for all the four distinct situations and depicted in Figure 24. It is clear that the application of the hybrid algorithm performs well in optimizing the fexible load demand so that the optimum generation cost can be obtained with the consideration of bounds in system frequency.

Conclusion
Tis work discussed the efect of fast and unpredictable power variations generated by intermittent power generation sources and electric vehicles on the frequency stability of modern power systems. Active power fuctuations in realtime were investigated using a deep learning strategy based on a long short-term memory recurrent neural network. Te observed power fuctuations could be used as a control reference for automatic generation control to maintain better system frequency and obtain optimum generation cost with the use of FA/FPA based demand management techniques. Te suggested method was applied to the realistic model of an Indian power system integrated with distributed generation technology and validated and compared to the classical methods. Simulation results revealed decent improvements in frequency response performance indices, as the maximum peak overshoot was decreased by 21.25% to 51.2%, settling time was lowered by about 23.34% to 65.40% and ITAE was minimized about 6.54% to 69.65% for the suggested control technique compared to other controllers. Te simulation results clearly indicate the importance of power fuctuation identifcation as well as the benefts of the proposed strategy. Te fndings show that the proposed technique was successful in improving controller performance by minimizing performance characteristics such as peak overshoot, settling time, and ITAE.
C j (P j c , H j c ) : Fuel cost of the cogeneration units P i p : Power generation of the i th conventional thermal unit P j c : Power generation of the j th cogeneration thermal unit α i , β i , c i : Cost coefcients of the conventional thermal units a j , b j , c j : Cost coefcients of the cogeneration units.