Reactive Power Injection to Mitigate Frequency Transients Using Grid Connected PV Systems

The increasing integration of renewable energies reduces the inertia of power systems and thus adds stiffness to grid dynamics. For this reason, methods to obtain virtual inertia have been proposed to imitate mechanical behavior of rotating generators, but, usually, these methods rely on extra power reserves. In this paper, a novel ancillary service is proposed to alleviate frequency transients by smoothing the electromagnetic torque of synchronous generators due to change of active power consumed by loads. Being implemented by grid-tied inverters of renewables, the ancillary service regulates the reactive power flow in response to frequency transients, thereby demanding no additional power reserves and having little impact on renewables’ active power generation. Differently from the active power compensation by virtual inertia methods, it aims to low-pass filter the transients of the active power required to synchronous generators. The proposed ancillary service is firstly verified in simulation in comparison with the virtual inertia method, and afterwards tested on processor by controller-hardware-in-the-loop simulation, analysing practical issues and providing indications for making the algorithm suitable in real implementation. The ancillary service proves effective in damping frequency transients and appropriate to be used in grid with distributed power generators.


Introduction
Renewable energy sources (RESs) are of strategic importance and crucial to the sustainability of energy production from an environmental point of view. They are playing an important role in distribution networks [1,2] transforming them from passive to active [3], and representing a challenge for power planning and operation [4,5]. The increasing penetration of RESs, which are usually interfaced with static power converters, reduces the inertia of the electric network, so issues related to stiff frequency transients and oscillations arise and the immunity against faults and disturbances is weakened [6,7]. Nevertheless, RESs themselves are foreseen to play a major and decisive role in maintaining the reliability and stability of the grid in the future [8]. Moreover, the idea to divide the distribution networks in several small zones capable of self-regulating can help to overcome those issues. These kinds of partitioned networks, which are called microgrids, are well reviewed and classified in [9]. The photovoltaic (PV) system is one of the most representative RESs, which takes an active part in the construction of these modern grids. Therefore, the grid codes of many countries have requested for PV systems' cooperation in case of faults and transients [10,11]. Another important aspect is related to the management of both active and reactive power among different sources and loads. This aspect is crucial for microgrids that can operate both in grid connected mode and in islanded mode [12]. In any case, among the most popular control strategies, which also help for the stability of the network, there are the well-known droop-based controls. These kinds of control are very powerful because they can deal with different sources; they are flexible and can be used both in high voltage (HV) lines and low voltage (LV) distribution lines. In HV lines, it is well-know the assumption for which it is possible to decouple the frequency and voltage controls by acting on the active power (P/f) and reactive power (Q/V), respectively. This assumption is valid because in HV lines the inductive effect is predominant on the resistive one. On the contrary, in LV lines, where the resistive effect is the predominant one, the two droop controls can be exchanged each other having the P/V control and Q/f control [13][14][15][16]. In general, both effects are coupled. In particular, in the medium voltage lines the inductive and resistive effects are comparable, therefore, it is not possible none of the two assumptions. In this case, to decouple the problem it is possible to use the orthogonal linear rotational transformation matrix from the active and reactive actual powers to the modified ones as reported in [17]. Another way to decouple the two droop-controls, also considering the harmonic current in case of non linear loads, is through the usage of the virtual impedance [18][19][20].
Focusing, in particular, on the frequency stability of networks in which it is valid the assumption of predominant inductive effect, several approaches and control techniques have been studied and proposed. They can be categorized into two main groups: active power based frequency controls and reactive power based frequency controls. The active power based frequency controls are the most common used because they are related to the assumption itself of P/f and Q/V decoupling controls [21]. In this case, static reserves such as battery storage units can be dispatched to provide fast response when the system is under serious or peak load conditions [22,23]. Frequency-oriented advanced converter control algorithms, such as the virtual synchronous generator (VSG), are also viable methods tackling those problems [4,24,25]. They can be either provided by specific equipment or integrated into RES systems. In the former case, the energy reserve is utilized as a backup so it does not contribute to the nominal capacity. In the latter case, the availability of the VSG service could be restricted by ambient conditions; therefore, in order to ensure the service in any condition, auxiliary battery energy storage systems can be added to the RES [26]. The presence of additional equipment implies increased budget and complexity. In [27], the frequency-active power curve is studied and integrated into PV systems focusing on the curtailment, dead band and droop. Again, the droop-like control is limited by solar radiation and the efficiency of the PV systems is reduced. Ochoa [28] proposes an innovative control for wind system by shifting the maximum power point tracking (MPPT) to an optimized power point tracking, so that the power generation curve versus the ambient condition is smoothed. In this way, the wind farm contributes to the power grid capacity. Moreover, due to its self-regulating feature, it is not sensitive to grid conditions. All these methods present a common drawback related to the necessity to have an energy reserve to be implemented. For this reason, even if the active power based frequency controls are the most studied for the above-mentioned reasons, also the reactive power based frequency controls have been analyzed as well. It is worth nothing that, even if we are in the case in which it is valid the P/f and Q/V controls for the steady state power management, it is possible to use the reactive power during the transients to dump and help the frequency stability [29][30][31][32][33][34][35]. The first developed tools were the so-called power system stabilizers (PSSs) that act directly on the exciters of the synchronous generators (SGs) damping both the local and inter-area frequency oscillations [29,35]. Recently, thanks to the wide spread of the well-kwon flexible alternating current transmission systems (FACTSs) the supplementary damping controllers (SDCs) have also been developed [30][31][32][33][34][35]. Both the PSSs and SDCs provide an additional voltage signal to the voltage reference of the exciters of SGs or FACTSs. This signal is related to the frequency deviation. In order to avoid the influence of the voltage reference signal at the steady state regulation a washout filter is usually employed [34]. These methods, acting on the exciters of synchronous generators or on voltage references of FACTS are usually not really fast and, mainly, can be implemented only in few points of the grid.
Unlike the aforementioned previous researches, in this paper it is proposed a method based on a simple reactive power based frequency control carried out by RESs without introducing any additional reserve or reducing the active power efficiency. Moreover, no additional voltage reference is employed.
For this reason, the proposed method can be applied in any RES converter, spreading the service in the grid and improving, in this way, its effectiveness. Taking the PV system as an example, its excessive capacity design makes it possible to generate or absorb a considerable amount of reactive power also at the peak hours. The capacity of the PV inverter is defined according to the maximum evaluated solar irradiance of the day. However, the inverter is not used at its maximum power during the whole day. Indeed, it stands partially idling in most of the daytime and completely idling after the sunset. Therefore, the active power produced by the PV can be controlled according to MPPT while exchanging reactive power. For this reason, the proposed control, based on exchanging reactive power to smooth frequency transients can be implemented without affecting the main PV control (i.e., MPPT). In the following, the proposed ancillary service will be shortly indicated as Q/f control.
In order to evaluate the effectiveness of the proposed ancillary service, it is firstly tested by means of numerical simulations. Frequency transients and the consumed power for this service are illustrated. For proving the hypothesis based on which the ancillary service is proposed, significant internal variables of the synchronous generator (SG) are shown as well. Moreover, a comparison between the proposed method and the VSG method is carried out focusing on the working principles, performance, cost effectiveness and practicability. Then a controller-hardware-in-the-loop (CHIL) platform is set up based on which, the ancillary service is tested in real time.
The paper is organized as follows: Section 2 reports the theoretical aspects of the proposed ancillary service; Section 3 demonstrates the effectiveness of the ancillary service in simulation and the comparison with the VSG method; Section 4 describes the performance of the algorithm in CHIL highlighting the related issues and suggesting appropriate solutions; finally Section 5 draws the conclusions.

Scope and Comparison with VSG
Advanced control strategies, such as virtual inertia generation, are studied and implemented on grid-tied inverters to mitigate the stiffness caused by lack of inertia technologies. Virtual synchronous generators usually are implemented using a reference for the active power dependent on the virtual inertia, the virtual friction factor, the frequency and the rate of the frequency change (ROCOF) while the set point of the reactive power is obtained by the voltage regulator. This method partially compensates the fast active power variations of the loads during transients and thus gives less pressure to SG's governor to recover the frequency. The differential component ROCOF makes the active power loop respond to the frequency change earlier; however, as a consequence, it can bring instability concerns. VSG can be carried out by the highly integrated RESs. RESs are expected to work at the MPPs which are determined by ambient conditions and therefore, the MPPs can be taken as the output active power of VSG at steady state. When frequency goes below the setpoint, VSG is required to provide fast active power response greater than the MPP and the amount over MPP must be supported by other reserves. These reserves serve the transients but do not contribute to the capacity of the network.
The purpose of the proposed ancillary service is to alleviate frequency transients without either introducing additional power reserves or sacrificing the maximum active power generation. This is achieved, in this paper, by relating the grid frequency to the reactive power Q exchanged by the RES inverter with the grid itself.
The main idea is to change the voltage across the terminals of the SG with a consequent variation of the electromagnetic torque developed by the machine. In order to achieve this objective, the reactive power can be utilized. Indeed, while the excitation system fixes the rotor flux, controlling the reactive power it is possible to change the stator flux and, consequently, the machine torque. Acting on the torque, it is possible to modify the speed transient of the SG and, as a consequence, the grid frequency transient. Therefore, a relationship between grid frequency and reactive power can be implemented in the inverter control for a transient assisting purpose. Frequency transients are due to unbalance between prime motor torque and electromagnetic torque. When electrical load increases, the electromagnetic torque increases and, while the prime motor adjust its torque, the machine speed decreases and so does the frequency. For this reason, when, for example, the grid frequency drops below its set point, the proposed ancillary service makes the inverter to absorb reactive power reducing the stator flux and limiting the increasing of the electromagnetic torque mitigating the speed transient. Finally, the proposed service is implemented by means of a linear relationship between the reactive power absorbed by the inverter and the frequency deviation from the rated value. Table 1 summarizes and compares the features of the VSG method and the proposed Q/f method. J is the virtual moment of inertia; F is the virtual friction factor; ω is the electrical angular frequency; v is the voltage; p is the number of pole pairs. P * and Q * are the active and reactive power set points of the ancillary service control loops. In the VSG method, the fast change of the load power is compensated by a third entity, i.e., the VSG.  In order to achieve a low-pass filtering effect on the change of the electromagnetic torque, the proposed method must be faster than the governing and excitation systems of the SG. Mostly, both systems are much slower than the power electronic devices.
It is worth noting that, in low voltage distribution grids with low X/R ratio it is not possible to decouple the frequency and voltage regulation using active and reactive power respectively. In those cases, a cross-coupled regulation of active and reactive power is used to regulate frequency and voltage [36]. Nevertheless, for grid connected PV plants, active power is usually injected to support microgrids during frequency transients [37]. Moreover, it has to be highlighted that, the proposed service is a fast-transient service. Indeed, the regulation proposed has its positive effect in the fast transient when, usually, excitation systems of synchronous generators are not yet capable of working. A sort of secondary regulation leading the reactive power to zero after the frequency transient can be designed. In this paper, for sake of simplicity, this possibility has not been investigated.

Working Principle
Since the electrical frequency is set by the grid former which is usually a SG, the analysis is started from the mechanical behavior of the SG. Under the assumption of the friction absence the rotation motion of SG's rotor can be expressed by: where T m is the mechanical torque produced by the prime mover and T e is the electromagnetic torque applied to the rotor. From the Equation (1) it can be easily understood that the frequency transient depends on the ratio between the torque difference and the inertia. Given a SG, the inertia is fixed and the mechanical torque is provided by a governor with a slow response. Therefore, during a load change which induces an abrupt variation of the electromagnetic torque, the frequency experiences either an over-shooting or a drop in addition to a long recovery process usually accompanied by oscillations due to the low speed of the governor's response. The working principle of VSG is to compensate the slow response of the mechanical system by injecting or absorbing active power to the grid. The motion equation of SG's rotor is then changed into: where ∆P VSG is the compensating power injected by the VSG. This direct compensation is achieved by active power control and the compensated power is then transformed into compensated torque. Consequently, there are three origins of torques influencing the motion of the rotor: the prime mover torque, T m , the virtual mechanical torque ∆T m resulted from the active power of VSG and the electromagnetic torque T e given by electric loads. Differently from VSG, the proposed method aims at damping the frequency oscillations during the transients by means of regulating the reactive power. The motion equation of SG's rotor is thus changed into: where the function f LPF () stands for low-pass filtering behaviour. The high-frequency attenuation is achieved by additional reactive power absorption or injection which smooths the change of electromagnetic torque. Figure 1 shows the dynamic equivalent model of SG in the dq rotating frame. All the parameters have been transformed to the stator side. For clarity, the losses and the presence of dampers are ignored. Subscripts d and q respectively represent the variables or parameters on d-axis and q-axis; Superscript r refers to the dq-frame; V f and i f are the excitation voltage and current; v is the terminal voltage of SG; i is the armature current; φ is the stator flux; L l is the armature leakage inductance; L m is the magnetizing inductance and L f l is the field winding leakage inductance. As is known, the dq terminal voltages of SG are function of the stator flux, of its derivative and of the speed of the reference frame coinciding, at steady state, with the angular frequency. This is expressed, under lossless condition, as: Therefore, in symmetric situation, the instantaneous active electric power of SG can be derived as: which indicates that the output active power of SG is a result of the developed torque and of the rate of change of magnetic stored energy. Hence in the rotating reference frame, the electromagnetic torque can be expressed as: where p is the number of pole pairs. According to the equivalent circuit shown above, the flux is obtained as: Based on (6) and (7) the electromagnetic torque can be rewritten as: where ∆L mdq r = (L md r − L mq r ). The high frequency part of T e can thus be expressed as: where the over-line symbol represents the low frequency component of the variable while the hat symbol represents the high frequency component. The partial differentials ofT e respecting to the high frequency currents are: Since in (10) the currents are the main variables, vector diagrams are drawn so that the internal current of the SG can be associated to the current that is provided by the ancillary service actuator. Figure 2a shows the vector diagram of the SG variables under normal generative operation. Two sets of dq-frames: r-dq-frame and c-dq-frame have been drawn respectively according to the rotor position and the coupling point voltage. Therefore, in the following passage, r-d-axis, r-q-axis, c-d-axis and c-q-axis are used in short to refer to the d,q axes oriented on the rotor and on the grid voltage respectively. E 0 represents the no-load electromotive force lying on q-axis of rotor (r-q-axis). θ is the torque angle and ϕ is the power angle. c-dq-frame leads r-dq-frame by (π/2 − θ) and, θ should be an acute angle under stable condition. In case of ohmic-inductive loads, ϕ should be an acute angle with the armature current i lagging the terminal voltage v.
Back to the discussion ofT e , as the magnetizing inductance is proportional to the reciprocal of the magnetic reluctance, the term ∆L mdq r in a salient pole machine is positive while in a round rotor machine it is close to zero. In normal generative operation, both i q r and (L md are positive. Referring to Equation (10), the partial differential ofT e respecting toî d r is negative for a salient pole rotor and zero for round rotor while the partial differential ofT e respecting toî q r is positive for both salient pole and round rotors. So if we are able to increaseî d r and decreaseî q r , we can attenuateT e as long as the armature current is located in the first quadrant of r-dq-frame, i.e., r-I. In other words, the target variation of armature current ∆i should be located in quadrant r-IV when T e > 0 and in quadrant r-II whenT e < 0. Without decreasing the active power of the ancillary service actuator, the reactive power can be utilized to provide the low-pass filtering of the electromagnetic torque. As the c-dq-frame is set by the voltage at the coupling point, the current which induces reactive power flow should lie on the c-q-axis. As it is shown in Figure 2, the positive part of c-q-axis locates in quadrant r-II and the negative part in quadrant r-IV. So when a load is connected to the grid,T e > 0.
To attenuateT e , the ancillary service actuator injects a positive c-q-axis current ∆i inv to the grid and thus forces the SG to generate ∆i, which is 180 • shifted from ∆i inv , as shown in Figure 2b. Projecting ∆i to r-dq-frame, we obtain: The change of flux can be calculated as: indicating both fluxes in r-d-axis and r-q-axis having been weakened. The flux change depends on the amplitude and polarity of ∆i, and the torque angle θ. The removed high-frequency part of the electromagnetic torque can be obtained: where α is the attenuation coefficient of the electromagnetic torque; µ is the percentage of ∆i in high frequency domain. The faster is the ancillary service control loop, the higher becomes the value of µ .
In the case of a round rotor, it's only θ that determines the contribution of the ancillary service while in the case of salient pole rotor, the load current and the power angle matter as well. The way the ancillary service works under no-load condition is similar to changing the polarity of the controlled current ∆i inv . Based on the explanations above, the frequency regulation process is summarized by the block diagram shown in Figure 3. The grid former sets and regulates the frequency of the network. Since the electromagnetic torque is a result of the excitation current and the load current, changing a part of the load current will lead to changes in the electromagnetic torque. According to Figure 2, it is possible to refer the q-axis current of the PV inverter to the same reference system of the rotor. From the comparison of the two diagrams reported it can be said that even if this q-axis component of the PV inverter current calls for only reactive power from the PV plant, it still influences the electromagnetic torque seen by the SG. In order to obtain a good result, the response speed of this control loop must be faster than that of the SG exciter. Therefore, in the PV inverter a Q(f) control is implemented in order to smooth the electromagnetic torque transient without changing the active power injected in the grid. In particular, a linear relationship between reactive power and frequency deviation is implemented. It is: where f* is the reference frequency and k is tuned considering the maximum reactive power and the maximum allowed frequency variation. It is worth noting that, in a grid with distributed PV systems, the service can be performed by different devices, each one acting on the basis of its power rating.
To summarize, the VSG method temporarily compensates the blanking period of the mechanical power unlike the proposed method which works on the transient of the electromagnetic torque.

The Microgrid under Test
In this section, simulations are carried out to verify the proposed ancillary method. The system under analysis is represented in Figure 4, with power generators, loads, transmission lines and VSG equipment. The nominal frequency and line-to-line voltage of the system are respectively equal to 50 Hz and 400 Vrms. In order to have a better understanding of the analysis, most parameters are described using per unit (pu) values. Their base values are calculated and listed in Table 2.
The main power generator is a 250 kVA/400 V salient pole SG. Its detailed parameters are listed in Table 3. The SG is driven by a governor and excited by an excitation system, both of which have a much slower response compared to the power electronic devices in PV systems. The description and the parameters of the excitation and governing systems for the SG are listed in Tables 4 and 5    The second power generator unit is a PV plant. The nominal active power at standard test condition (STC) is 100 kW. The detailed parameters of the PV plant are listed in Table 6. The VSG is realized by a three-phase inverter whose nominal power is 25 kW. The detailed parameters are listed in Table 7. Finally, the parameters of the transmission lines are described in Table 8.

Control Methods
As previously discussed, the grid-tied inverter of the PV plant can be controlled to implement the proposed ancillary service as illustrated in Figure 3. The PV system is controlled to inject in the grid the active power given by the MPPT algorithm while the reactive power reference, Q, is set to zero when the frequency is at rated value. In the test of the proposed ancillary service, the reactive power is regulated by means of the current on c-q-axis related to the frequency transient rate. The VSG method is, instead, executed by adding a virtual inertia and friction factor to the active power control loop to emulate the mechanical behavior of the rotor.

Proposed Q/f Control
The control algorithm of grid-tied inverter of the PV plant is proposed as shown in Figure 5. It consists of active power control loop and reactive power control loop. In the active power control, perturb & observe MPPT is firstly performed to determine the right duty cycle of the boost converter. Then the output voltage of the boost converter is stabilized by a feedback control loop using a PI regulator with K p = 7 and K i = 800. The set point of this loop is 500 V and the output will be the set point of c-d-axis current in pu values limited between [−1.5, 1.5] pu. The reactive power control aims at stabilizing frequency. When frequency deviates from the set point 50 Hz, a c-q-axis current (in pu values) is set as a c-q-axis current reference by a positive coefficient D Q/ f = 0.5 : The set point of c-q-axis is kept between limits [−1.5, 1.5] pu. With the two set points of currents, the current loop is controlled by a PI regulator with K p = 0.3 and K i = 20. The output signals will be considered as the set points of c-d-axis and c-q-axis voltages in pu values and be limited between [−2, 2] pu. Feed-forward control concerning the output filter is added to speed up the control loop.
The regulators have been tuned by means of a trial and error procedure in order to obtain a fast and stable response by each control loop. The choice of the droop coefficient D Q/ f is done to have a pu quadrature current 0.5 when a 1Hz (i.e., 2%) deviation occurs on the grid frequency.

VSG Control
At the same time, a parallel comparison is made between the proposed method and VSG. The VSG is implemented by inserting an extra voltage source inverter (VSI) supplied by a DC voltage source. The control algorithm is depicted by the block diagram shown in Figure 6. Similar to the swing equation of the SG, the virtual inertia and the virtual friction factor amplify the ROCOF and the frequency deviation, respectively. A corresponding electric power is thus generated to emulate the change of mechanical power of the SG in order to dampen the frequency transient. Here in the test, a virtual inertia J = 15 kgm 2 and a friction factor F = 33 Nms are used to replicate the change of the mechanical torque. Therefore, the set point is the nominal mechanical angular frequency and the output is the set point of mechanical torque (both in SI values). Based on the mechanical angular frequency and the base values of the VSG shown in Table 2, the set point of the active power in pu value can be obtained which will be limited between [−1, 1] pu. Since the main focus is on frequency, the set point of the reactive power of VSG is set equal to zero. With set points of active and reactive power and the measured voltage, set points of c-d-axis and c-q-axis currents can be calculated.

Test Condition and Results
In Sections 3.2.4 and 3.2.2, the droop coefficient of the Q/f control is set to 0.5 pu/Hz and the virtual inertia and the friction factor are set to 15 kgm 2 and 33 Nms for VSG control. Under the condition of such parameters, the two ancillary services can achieve the same attenuation of the frequency overshooting during a transient. In this way, the two methods can be compared from the working principle aspect.
The simulation test starts from a steady state where load power is 175.8 kW-6.1 kvar. Referring to the base values of the SG, the load power is 0.704-0.024 j pu. The PV plant is generating 100 kW which means 1 pu referring to PV plant. Both ancillary services are not activated. In order to produce a frequency transient, an extra load of 27 kW-1.4 kvar (0.108-0.006 j pu referring to the SG) is connected to the micro grid at 0 s and disconnected at 10th s. The connection and disconnection is done by a circuit breaker. Therefore, under-frequency and over-frequency situations are provided.
The test is repeated three times. At the first time, neither of the ancillary services is activated. In the following plots, this case is named as No AS and it is taken as the reference. At the second time, just the proposed ancillary service, i.e., the Q/f control is activated. This case is named as Proposed AS. Finally, the VSG ancillary service is activated. This case is named as VSG AS.
The frequency transients are shown in Figure 7a. Even though the maximum deviations of frequency are comparable for VSG and the proposed ancillary service, the frequency transients are still different. According to the test results, both ancillary services are effective on reducing frequency over-shooting. However, the two methods are distinguished from each other by the transient curves. Figure 7b describes the power provided by the two ancillary services. In Q/f control, it is the reactive power that is responsible for the frequency transient mitigation where in VSG control, the active power is in charge. As shown in Figure 7b a 10% of additional reactive power is required to the inverter of the RES. In order to be able to exchange this reactive power also when the active power is maximum, the inverter has to be oversized. Anyway, an additional 10% of reactive power implies only a 0.5% increasing of the apparent power. Therefore, the additional cost to oversize the inverter (by 0.5%) can be considered negligible and it is possible to state that the service can be obtained with almost null costs. In the VSG test, ∆P performs the compensation process with the slow response of the governer. ∆Q in Q/f method controls the flux inside SG and thus smoothing the voltage recovery, which is shown in Figure 7c. Summarizing, the proposed ancillary service performances are comparable to those of a VSG in terms of limitation of minimum and maximum frequencies during the transients. Nevertheless, the recovery time of both frequency and voltage is slowed by the proposed ancillary service. Even if this seems a disadvantage, it is worth highlighting that this is obtained without needing any energy reserve and this makes the proposed service implementable in all the RES devices distributed in the grid. This is the main advantage of the proposed algorithm in comparison with the traditional VSG. Figure 8 shows the transients of the internal variables of the SG based on the c-dq-frame. The armature currents are regulated by the ancillary services. Relating to the reference current obtained in the reference test, the changing trends of i d and i q being regulated by Q/f method and VSG method are different. Therefore, the resultant electromagnetic torques T e of the two ancillary services have different shapes. However, both torques are smoother than that of the reference test, giving more time to the governor system to follow the change of load.    Table 2.
With quite close performances of alleviating frequency deviation, the proposed method is shown to be more efficient owing to the sole use of reactive power. In other words, the proposed method does not ask for an extra reserve to provide the requested active power. From the budget and simplicity point of view, the proposed ancillary service is a viable choice for the existing networks.
The main advantage of the method is that it can be implemented on every grid-connected inverter and works without affecting the functionalities of the MPPT. Requiring no additional power reserves, this methodology reduces costs of installation and can be flexibly integrated into the existing equipment.   Table 2.

Stability Analisys of the Proposed Q/f Control
In order to test the local stability of the proposed Q/f control we chose to use the indirect Lyapunov method for nonlinear systems. This method consists in linearizing the nonlinear system around an equilibrium point and assess its local stability for small perturbations. In our case, we want to assess the mechanical frequency stability of the SG at 50 Hz. The linearization was performed using the linear analysis tool of Matlab/Simulink software. Moreover, for the stability analysis all the saturations of the regulators were removed and the VSG is not connected. In the simulink model, we had to select one input perturbation point and one output measurement point in order to obtain the linearized closed loop transfer function between the mechanical frequency of the SG and the reference one. In fact, a perturbation in the reference frequency acts on both the governor of the SG and the proposed Q/f control. The poles placement of this closed loop transfer function is dependent on several parameters, among which, the value of the droop coefficient D Q / f that we want to assess for the stability analysis. Therefore, this was varied between 0 (proposed control not active) and 15 pu/Hz with a step of 0.5 pu/Hz. Since, the system was simulated using a discrete solver the poles are in the z-domain. As is well known, a nonlinear time invariant discrete system, trimmed at an equilibrium point and for small perturbations, is stable if and only if all the poles of the linearized system have an amplitude less than one, i.e., they are into the circumference of unitary radius. Figure 9 shows the zero-pole map of the closed loop transfer function for the different droop coefficient values. We can note that the region of the map in which some poles are out of the circumference is near to 1. Figure 10 show a zoom of such region. From this figure, we can see that for increasing values of the droop coefficient the poles are moving towards the boundary of the circumference up to pass it for values higher than 11 pu/Hz. This means that for droop coefficients greater than 11 pu/Hz the system becomes unstable; for droop coefficients less than 11 pu/Hz the system is locally stable, i.e., only for small perturbations. In order to assess the convergence domain, i.e., for which values of perturbation the system is stable, we should use other stability methods that for our system can be very difficult to apply. On the other hand, the transfer function for the chosen value of the droop coefficient (0.5 pu/Hz) has the poles far enough from the boundary of the circumference. Moreover, the actual system contains several saturations in the controllers helping in stabilizing the system response. Therefore, it is possible to state that the proposed service is stable if the droop coefficient is chosen much lower than the stability limit. In the paper a value 20 times lower than the limit was used obtaining a stable answer from the system.

CHIL Platform of Microgrid
In order to test the effectiveness of the proposed ancillary service on real processor, a CHIL platform is built on the basis of a real-time controller dSPACE [38] and a real-time simulator Typhoon HIL [39]. Figure 11 illustrates the general construction of the micro grid. The complete PV control is implemented by the real embedded system while the rest of the system including the model and other control units are simulated in real-time by the simulator.

Real-Time Microgrid
To reduce the total computation burden and to make a better usage of the hardware resources, the model is subdivided into two parts considering the PV system in one core and the rest in another using an ideal transformer model (ITM) as the interface algorithm [40]. The ITM is placed in the LCL output filter of the PV inverter ( Figure 12). The single-line diagram then is used to clarify the description. A voltage amplified ITM is placed within the PV inverter at the primary side and the grid at the secondary side. The stability of the system is affected by the value of the impedances on both sides of ITM as shown in [41]. Therefore, more attention needs to be paid while setting the ITM parameters. After circuit partition, the computation burden is greatly reduced from 145 % by one core to 25 % and 3 % respectively by two cores. The fundamental time step is defined as 1 µs, which is the reference clock to synchronize all parts of the system as well. In the micro grid, the SG is the only source of natural inertia; furthermore, since the proposed approach handles the reactive power flow from the PV plant to mitigate the frequency transients, the system's response has to be faster than the excitation system of the SG. The electrical part of the machine is modeled by a fifth-order state-space model in a synchronously rotating d-q coordinates; the mechanical part is modeled by a second-order state-space model [42]. The execution rate of the simulation of the synchronous generation system is defined as 5 kHz and the parameters are listed in Tables 3-5.
The PV plant is composed of DC side voltage source (PV panels), 3-phase inverter and LCL filter. The state-space variables are calculated at every fundamental step. The inverter gate driving signals are calculated at 1 MHz and therefore, they are generated with an oversampling frequency of 50 MHz, guaranteeing high fidelity of the pulsed signals even under fast switching and narrow duty cycle conditions. The features of the PV plant are listed in Table 6.
The loads and transmission lines are simulated at 1 MHz. The loads consist of a permanent 175.8 kW-6.1 kvar load and an optional 27 kW-1.4 kvar load which creates the frequency transients by connection and disconnection actions. For transmission the equivalent three phase RL modeled overhead lines are used. The related parameters are shown in Table 8. The synchronous generation system, PV system and the loads are joined at the PCC via transmission lines of 100 m, 100 m and 300 m respectively.

Interface and Real-Time Control
As previously mentioned, the PV control algorithm is executed by an embedded system in real-time out of the grid simulator, so an interface is required to join these two devices both physically and logically. The inputs of the control are voltages and currents measured at the PCC and the outputs of the control are the driving signals for the PV inverter. In real implementation, the voltages and currents are firstly measured and transformed by transducers. Before being sent to the controller, these analog signals are normally amplified or attenuated and filtered by conditioning circuits and finally converted into digital signals. On the other hand, the generated gate driving signals are sent to the driving circuit of the inverter where the non-ideal switching of the semiconductors takes place. Aiming at replicating the impact of the sampling devices, a software interface is created inside the real-time simulator, as it is illustrated in Figure 13. The PCC variables are firstly sampled by the maximum rate available in the model, i.e., 1 MHz to avoid aliasing issues. Then the samples go through a set of 1st-order low pass filters (LPFs) and absolute time delays which are executed at 50 kHz, to represent the limited bandwidth, anti-aliasing handling and response time of the measurement system. After the functional part, the physical connection is achieved by the analog-to-digital converters (ADCs), digital-to-analog converters (DACs) and digital inputs/outputs (DI/Os) of the two real-time devices. The conditioned PCC variables are amplified by DACs at 1 MHz. Compared with the receiver ADCs at controller side (10 kHz), the PCC variables are quasi-continuous. The modulation wave generated by the control algorithm at 10 kHz is then transformed into pulses by a slave dsp whose resolution is 100 ns. And finally the pulses are over-sampled by 50 MHz closely tracking the expected duty cycle.
The control algorithm follows the block diagram shown in Figure 5. The switching frequency is set at 20 kHz. With 100 ns resolution of the carrier signal, the output's duty cycle will have a resolution of 0.2 %. The reading commands of ADCs and the updating of the modulation wave are arranged at the beginning of the code. To a large extent, this fixes the time baseline when the variables are taken and sent within a control period, which avoids the unexpected high frequency harmonics caused by the embedded system, but introduces one-step delay to the actual control at the same time.

RT Control
RT Microgrid digital analog Figure 13. CHIL interfacing method.

Exposed Control Problem
Taking a brief look at the CHIL test results reveals a power offset (shown in Figure 14), posing unexpected power flow in the grid. This roots in the fact that theoretical ancillary service was proposed under ideal conditions where the variables had infinite bandwidth, unit gain and zero latency. However, this is not valid in CHIL and in practice. As it is explained in the previous subsection, there are measurement devices between PCC and control system featuring limited bandwidth, delay and filtering effect. The PLL introduces phase delay and time delay as well. These weak points influence the precision of the phase angles based on which the voltages and currents are transformed from rotating values to static ones. The consequence inspires control system designers to consider the effect of the measurement chain in practical control design. In this case, the shifted phase angle caused by the non-ideal signal transmission procedure and the PLL can be corrected by means of equivalent delay compensation. However, it is worth noting that the signal transmission chain is a mix of absolute time delays and frequency-dependent phase angle lags. Frequency dependent lags are estimated at rated frequency, i.e., 50 Hz. After integrating the measurement delay into the control algorithm, the reactive power seen by the controller is almost identical to the measured value in the micro grid, as plotted in Figure 15.

Final Test Results
The simulation initiates from the steady state where the 175.8 kW-6.1 kvar load is connected to the PCC. The transients to be observed are induced by the connection and disconnection of the 27 kW-1.4 kvar load at 0 s and 10th s respectively. Figure 16 reports the CHIL test results in comparison with the offline simulation. The reference test case does not include the activation of any ancillary service. The results are marked as No AS CHIL and plotted in blue. The CHIL test results of the proposed Q/f ancillary service are marked as Proposed AS CHIL and plotted in yellow. The offline simulation test results are shown as well in order to compare the test between the offline simulation and CHIL. It is marked as Proposed AS Sim and plotted in red.
The CHIL test results prove that the proposed method is able to attenuate the frequency over-shooting caused by either the load connection or disconnection. In particular, the frequency undershoot is reduced by 0.15 Hz corresponding to an improvement of 27.3% considering that in the base case the undershoot is 0.55 Hz. Moreover, the overshoot is reduced by 0.14 Hz corresponding to 23.3% of the base case variation equal to 0.6 Hz. The ancillary service has a negative effect on the voltage transient as it was expected by the theoretical analysis: the voltage recovery process is prolonged, but the over-shooting peak is not significantly increased.  Table 2.

Conclusions
This paper proposes a frequency-assisting ancillary service. It works in the context of modern micro grid with reduced inertia and it can be implemented in the distributed RESs. The proposed algorithm presents performances comparable to those of a traditional VSG in mitigating frequency transients due to load variations. Nevertheless, contrarily to VSG, the proposed service does not require energy reserve to be implemented since it does not affect the active power exchanged by the RES inverter with the grid. This represents an important added value of the proposed algorithm since it is implementable in all the RES devices distributed in the grid with almost null additional costs.
The ancillary service is explained theoretically by equations and verified in simulation. The performance is compared with that of the VSG method. Even though both of the ancillary services are able to achieve improvement on frequency transients, the working principles behind them are quite distinct and thereby, the requested types of power used for the ancillary services differ as well. Finally, a CHIL micro grid system is constructed to test the algorithm in an embedded system. However, it was noticed that without cautious consideration related to the non-ideal measurement and the delay caused by data processing, the control algorithm heads toward the performance deterioration and unexpected power loss. After modification, the ancillary service on processor proves to be effective on damping the over-shooting of frequency.