Optimized proportional-integral controller for a photovoltaic- virtual synchronous generator system

Received Aug 17, 2021 Revised Jan 31, 2022 Accepted Feb 7, 2022 Due to the lack of a physical rotating rotor, the photovoltaic generators (PVG) have no inertia. Therefore, replacing traditional synchronous generators (SG), (source of inertia), with PVG will reduce the inertia of overall power systems. A reduced inertia and damping feature will frequently cause instability issues due to high rate of change of frequency (RoCoF), and less stringent voltage at the nearby point of common coupling (PCC). In this paper, the concept of virtual synchronous generators (VSG) is adopted in to couple the source with the grid frequency in order to provide virtual inertia. This is created by using energy storage for short time, direct current (DC) to alternating current (AC) converter, and a suitable control mechanism. In implementing VSG, the important aspects to focus on are reducing the fluctuation of DC-link voltage, stabilize the frequency and voltage, and power flow. So, the particle swarm optimization (PSO) algorithm was used to adjust the parameters of proportional integral (PI) controller by reducing the error of the current controller and voltage regulator in the VSG controller. The simulation results illustrate the advantages of the PI tuning using PSO, where the overshoot is decreased by 68.9% and the settling time is decreased by 34% due to load fluctuations.

Due to the lack of a physical rotating rotor, the photovoltaic generators (PVG) have no inertia. Therefore, replacing traditional synchronous generators (SG), (source of inertia), with PVG will reduce the inertia of overall power systems. A reduced inertia and damping feature will frequently cause instability issues due to high rate of change of frequency (RoCoF), and less stringent voltage at the nearby point of common coupling (PCC). In this paper, the concept of virtual synchronous generators (VSG) is adopted in to couple the source with the grid frequency in order to provide virtual inertia. This is created by using energy storage for short time, direct current (DC) to alternating current (AC) converter, and a suitable control mechanism. In implementing VSG, the important aspects to focus on are reducing the fluctuation of DC-link voltage, stabilize the frequency and voltage, and power flow. So, the particle swarm optimization (PSO) algorithm was used to adjust the parameters of proportional integral (PI) controller by reducing the error of the current controller and voltage regulator in the VSG controller. The simulation results illustrate the advantages of the PI tuning using PSO, where the overshoot is decreased by 68.9% and the settling time is decreased by 34% due to load fluctuations.

Battery energy storage Particle swarm optimization Photovoltaic generator Virtual inertia Virtual synchronous generator
This is an open access article under the CC BY-SA license.

INTRODUCTION
The frequency of a power system is an essential criterion for evaluating its power surplus and deficit [1]. In the case of a disturbance, traditional synchronous generators (SGs) will use the kinetic energy stored in their rotational inertia to balance the power grid's potential energy variation. Therefore, the system will return to stability after disturbances [2]. The photovoltaic (PV) system is a static source, which does not have any rotating parts. In addition, PV systems do not have the same dynamic features as traditional SG, due to a lack of inverter inertia and damping [3]. So, a large-scale PV power plant will decrease the inertia of all power systems and weaken the system's primary frequency response ability [4]. Most renewable energy sources (RESs) are connected to the grid using power inverters as grid following units [5]. The converter injects the active power into the grid after synchronization with the grid voltage. Therefore, the renewable energy supply stops feeding power into the grid after any disturbance. As a result, concerns about stability arise due to increased renewable energy penetration [6].
Due to the above reasons, virtual synchronous generator (VSG) technology was implemented into the PV market to enable PV grid-connected inverters to work similarly to SGs [7]. This control method helps control the inverters in a weak grid since it blends the fast response of the inverter with its SG's static and  [6]. Furthermore, the proposed VSG control uses a battery energy storage system (BESS) with inverter to provide the grid with virtual inertia [8]. Moreover, droop control is widely used in microgrids with various hybrid PV and BESS to achieve power-sharing and energy management [9]. The VSG structures discussed in [8] are designed to connect an energy storage element to the main grid, and the VSGs synchronize with the grid using the swing equation rather than the conventional phase-locked loop (PLL). In [10]− [12], several control strategies have been offered to improve power systems' voltage, frequency, transient stability, and damping characteristic with penetration renewable power. In [13], [14], the control systems are designed to mimic the behavior of SGs with energy storage systems (ESS) by controlling PVs and wind power. Wu et al. [15], proposed the alternating current (AC) frequency represents the state of charge (SOC) of the battery, while the PV generation controls its output power depending on the frequency calculated to maintain its stability. Rahman et al. [16] used particle swarm optimization (PSO) to determine the best location for the active power of VSG to maintain the frequency within the allowable limits in the microgrid.
An essential factor to consider when implementing virtual inertial control of an ESS in renewable energy sources (RES) is the fast response of the system to provide active power to the load when a disturbance occurs. When sudden load change occurs, the system frequency can exceed the allowed limitations if the active power is not rapidly provided. This paper offers a method to improve power quality and system response for VSG by using the PSO algorithm. PSO is used to tune the VSG's PI controller, thus improving the power quality, so that when any disturbance occurs, the system can restore its frequency to the permissible limitations.
The main goal of this research is to design VSG to emulate the damping and inertia characteristics of SG by using a BESS to improve a PV system's inertial response. In addition, the PSO technique is used to tune the gain values of the PI controller of VSG for damping the voltage and frequency deviation under sudden change conditions. And then using PSO to estimate the time delay under various disturbances to used it in the implementation of suggested online optimization.

PROPOSED CONFIGURATION
Distributed generators (DGs) sources are mostly connected to the grid through power-electronic inverters. Traditional control strategies have been unable to meet their grid connection requirements. Figure 1 depicted an overview of the proposed VSG control with PSO for PV of single-stage grid-connected mode. PV is the primary source of energy in this microgrid. The PV source is connected to an inverter that converts power from direct current (DC) to alternating current (AC). A VSG controller is implemented to control the inverter for the desired active and reactive power to make the PV system operate similarly to the SG. The load is connected to the inverter output through an inductors and capacitors (L.C.) filter to reduce the harmonic distortion to allowable limits. In the above system, a BESS is connected to a solar power plant's DC-link, and its function is to inject (discharging mode) or absorb (charging mode) the power to the system for a short time during the disturbance. The charging and discharging method use a bi-directional buck-boost converter connected to BESS that adjusts the input current of BESS. Thus, a BESS can be constructed to compensate for the power intermittence of a PV system during normal conditions such as solar irradiance variability produced by passing clouds. In contrast, the solar plant still operates at its maximal power point tracking (MPPT) mode to achieve the highest power efficiency possible.
Measured three-phase voltages and currents from the three-phase (abc) system's load bus are converted to dq0 rotating reference frame using Park's transformation. In addition, the active and reactive power is measured, and the results are used as input signals to the active power-frequency control (P-f) and reactive power-voltage control (Q-V) blocks. Droop controllers have been used to provide frequency and voltage stability. The P-f droop controller calculates the phase angle and the frequency of the VSG, and the Q-V droop controller calculates the reference voltage. The synthesis algorithm will then use the phase angle and frequency to determine the reference current for current control blocks. The current controller calculates the three-phase reference voltage for the pulls width modulation (PWM).

SYSTEM MODELING 3.1. Modeling of photovoltaic array
The main constituents of PV arrays are photovoltaic cells. Its function is to transform solar energy into electricity when exposed to light [17]. PV includes short circuit current ( ), open-circuit voltage ( ), maximum voltage ( ), and maximum current ( ). The I-V and P-V curves are shaped by these parameters. A single diode and a two-diode model are used to simulate a PV two diodes are more accurate, but more variables are required to make the model more complex [17]. A simplified single diode PV module current is represented by (1) [18].
Where and are the PV output current and voltage, respectively, ℎ is the current produced from photon bombardment on the solar cell surface, is dark current of saturation, usually about 10 −12 A/cm², is the number of modules connected in series, q is the electron charge, K is the Boltzmann constant, T is the module temperature, and A is the diode ideality constant.

Battery energy storage system (BESS)
Characteristics of the battery charging and discharging method for short or long periods are described in [19], [20]. There are many models for BESS design, and some of these types are not used in electrical design because the time constant is higher than the electrical time constant. Figure 2 shows the use of the voltage source resistance model to simplify the electrochemical calculations. is the battery's electromotive force (E.M.F), represents the battery's internal resistance in the charging state ( ℎ ) and discharging states ( ), which both contribute to the energy loss inside the battery during charging and discharging, is the charging and discharging current where the positive value of represents the charging current and the negative value the discharging current and represents the terminal voltage of the battery. In this model, and electric parameters ℎ and , all dependent on SOC and the operating temperature ( ) of the battery as shown in (2) [21].  Figure 3 (a) shows the structure of a bi-directional DC/DC converter, which controls the charging and discharging of BESS. The design of the DC/DC bi-directional converter depends on boosting topology, this meaning that the voltage of BESS is always lower than the DC-link voltage. To achieve the two-way power conversion [22]. Both of the DC/DC converter switches, 1 and 2 , must be coordinated by a control system, where the BESS current is regulated by the inner current loop to track the given command * , Figure 3 (b) shows this control system. The outer voltage loop controls the DC-link voltage and generates a reference signal for the inner loop * [23].

Droop control of virtual synchronous generators (VSG)
The droop control is a control method that emulates the external characteristics of the SG output to control the inverter and distribute the inverter load power evenly [24]. The system voltage is determined by decoupling the droop characteristic curve between reactive power and voltage (Q-V), and active power and frequency (P-f). The droop controller will give the reference value of the voltage amplitude and frequency during the control process. In a DG system, P-f and Q-V droop controls are widely used to control active, and reactive power [11], [12], [24]. Frequency control must have a drooping characteristic with respect to the generator output for a power generator's stability, as shown in Figure 4 (a).
Where is reference grid frequency, is nominal frequency, and are a reference and nominal active power respectively, and is the P-f droop coefficient.
The terminal voltage of power generators is directly related to the reactive power supplied by the generator, and it has a drooping feature, as seen in Figure 4 (b). This Q-V droop characteristic is expressed by the following (4) [12].
Where is reactive droop coefficients, is the output voltage amplitude when the inverter output reactive power ( ) is zero.

MATHEMATICAL MODEL OF VIRTUAL SYNCHRONOUS GENERATORS
The VSG control contains two links, active and reactive power control. VSG's active power control regulates the frequency, matches the speed control system in SG, and adds inertia and damping to the active power control. The voltage amplitude is adjusted using reactive power control [25], like the excitation system in SG, making the inverter's external properties identical to those of a conventional SG, which will have rotational inertia to maintain grid smooth operation [13]. The second-order model of SG [14], [15] was used in this work, which includes the stator voltage equation and the rotor mechanical equation, respectively, as shown in (5) and (6).
Where E is excitation voltage, V is armature voltage, is armature current, is armature resistance, is synchronous reactance, is a moment of inertia, is the mechanical angular velocity, , and are mechanical and electrical torque. The rotor motion equation can be derived from (6) by using the synchronous rotation axis as the reference axis and using the relationship between electrical and mechanical angular velocity = and the number of pole pairs ( = 1).
Where is the electric angular velocity, is the synchronous electrical angular velocity, and are mechanical and electromagnetic power, respectively. The control algorithm model of the VSG is developed using (5) and (7).

PARTICLE SWARM OPTIMIZATION (PSO) TECHNIQUE
PSO is an ideal optimization approach that benefits from simplicity in design, robustness, and global convergence over the other optimization methods [26]. In this article, the fortunate and parameters were selected to search for the optimal values to make the error as small or zero as possible. This feature can control algorithm convergence and get the optimal value of the objective function [27]. The PI controller is generally a feedback control system based on a linear system equation for load conditions. The main reasons for selecting the PI controller to regulate an inverter system are good control performance, easy design, and high reliability.
Most voltage and current controllers in the AC system used PI controller to control in the DC-link voltage and the grid current. The injected power to the grid is properly controlled and the DC-link voltage of the invertor is stable [17], [28]. The PSO algorithm optimization technique is used to provide the best optimal value of and to reduce overshoot, transient response, and to obtain low steady-state error related to loading change. The inverter control model proposed with the PSO technique is illustrated in Figure 1. A PSO technique is implemented to design the PI controller parameters optimally to reduce the error for the current controller and voltage regulator. Moreover, compared to the other algorithms, which need to use a trial-and-error method, this required a long time through implementation. On the other hand, PSO required a short time to find the optimal values of PI parameters and simple implementation [27] .
The main PSO algorithms depend on two factors velocity and position. This factor is updated by applying (8), (9) [29].
Where is max. time, is the error, 1 and 2 are wight coefficients. In the beginning, the PSO algorithm randomly starts to calculate fitness and achieve the best value for each parameter in the entire swarm. MATLAB code was used to implement the proposed PSO algorithm. The optimization steps of the PSO algorithm are described in the flowchart shown in Figure 5.

RESULT
A 250 kW PV is connected to the grid during normal operation. The PV mainly provides the loads in the system. If the PV cannot provide all the loads, the power shortage is supplied by the grid. The parameters of the proposed VSG used for the simulation are given in Table 1. If a significant system disturbance occurs, the system frequency quickly deviates from its nominal value, and the rate of change of frequency (RoCoF) will be very high over the maximum limits, leads to instability and system collapse. Therefore, VSG is used to maintain system stability during disturbances. PSO is used to tuning the parameters of the PI controller for VSG to improves the power quality of VSG connected to the grid and compared the results with conventional VSG. The trial-and-error method by using MATLAB/Simulink was used to implement the initial value to the VSG system's PI controller. The PSO algorithm code was then simulated. The test results are presented for the following case:

Case 1: comparisons of different control methods
In this case, a PV system connected to the grid is considered. Then a VSG model is designed to study its characteristic in the modification of its output and moment of inertia according to load changes. Finally, a PSO technic is used to improve the parameters of VSG. The integrated system model connected to the load in the grid-connected mode is built-in MATLAB/Simulink. To analyze the voltage and frequency oscillations, a sudden load change is considered. A local load of 250 kW is connected to the PV initially. The solar radiation for the PV system is 1000 W/m² and the solar temperature is 25°. At t = 1sec, the load is suddenly increased by 50 kW (20%), and at t = 2 sec the load decreased by 50 kW. Figure 6 shows the DC link voltage, RMS value of PCC voltage, and system frequency of the PV without VSG, PV with VSG, and VSG-PSO. It can be seen from Figure 6 (a) that the system frequency for the PV without VSG changes rapidly with the sudden change of the load, and the fluctuation is very steep. also, the RoCoF is outside the permissible limits as shown in Figure 6 (b), and there is a drop in the PCC voltage when the load increase as shown Figure 6 (c). Also, the DC-link voltage is not constant and changes dramatically with a sudden change in the load, as shown in Figure 6 (d). So, the small oscillations in frequency and voltage may adversely affect the system stability.
When VSG connected the fluctuation in the system's frequency and RoCoF becomes very small within the permissible limits, and the change in the frequency and RoCoF will be slowly and more gradually as shown in Figures 6 (a) and 6 (b) respectively. This is due to the energy injected by BES when the load increases. And when the load decreases, the BES will absorb power by charging itself for a short time until the grid provides the power to the load or receives the excess power from the PV. The battery balances the generated power with the load power which makes the frequency always stable as shown in Figure 7. And the presence of the battery will make the DC-link voltage constant as shown in Figure 6 (d), so the drop in the load voltage will be very small as shown in Figure 6  that the existence of VSG with and without PSO has helped to decrease the amplitude of the frequency deviation and the RoCoF to the permissible limits, also the frequency returns to the study state in a short time. The maximum overshoot, settling time, RoCoF, and drop voltage with a step-change in load is given in Table 2.

Case 2: transient analysis of grid-connected photovoltaic system with step change in irradiance
In this case, PV model irradiance was changed from a constant of 1000 W/m² to 500 W/m² at t = 1.5 s. The system load was kept constant at 250 kW. The frequency variations of the system are shown in Figure 8 (a). While using VSG control, the system performance is tested for irradiance changes from 1000 W/m² to 500 W/m² at t =1.5 s. The minimum frequency deviation in the grid-connected PV system was reduced from 49.132 Hz to 49.82 Hz. Using PSO, the frequency variation decreased to 49.923 Hz, which was within the normal operating range of 0.2 Hz, as shown in Figure 8 (a). And the RoCoF also decrease to allowable limits when using VSG with and without PSO as shown in Figure 8 (b). RoCoF, peck overshoot, and settling time of the frequency response with change in the irradiance are listed in Table 3. And as the inertia increases, the reduction in the frequency will increase. This reduction should prevent frequency relays from being tripped unnecessarily. Figure 9 depicts the power injected and the power absorbed by BESS to reduce frequency deviation caused by a change in irradiance.   Figure 9. The output power of BESS due to a change in irradiance In this paper, the PSO algorithm is implemented under various disturbances for the optimum tuning of PI factors used in the VSG. The optimization process requires a period to retune the PI controllers. The values of estimated time delay for each scenario are listed in Tables 4 and 5 for different irradiances. This delay time used then to implementation the suggested online PSO algorithm to improve power system quality.

CONCLUSION
This paper proposes using VSG control for a PV system to emulate the behavior of a real SG This study uses PV-VSG control and B.E. to enable virtual inertia for the power systems. In addition, the PSO technique is used to obtain optimal tuning of PI controller parameters ( , ) of the VSG controller. In this manner, grid frequency ancillary services are provided by the PVG as the grid codes require. In other words, when the power system's frequency falls under allowable limits during the sudden load change and reduction in irradiance, the proposed system counters the situation by supplying available energy. Simulation tests showed that VSG with PSO technique could reduce the frequency overshoot and reduce the time (Ts) required for the frequency to return to its steady state. In the case of VSG without PSO, the frequency is still acceptable when a disturbance occurs. The results also showed that VSG with and without PSO technique maintains DC-link voltage at nominal value and significantly reduces the drop in the load voltage. The proposed future work is to use online optimization using the delay time which was found in this work with different types of disturbance.