Model for Frequency Dynamics in an Islanded Microgrid and Primary Frequency Control Based on Disturbance Compensation

Islanded microgrids have low inertia due to a large penetration of non-inertial inverter based power sources. In such systems, the primary frequency controller (PFC) faces the issue of a higher rate of change of frequency (RoCoF) and large peak frequency deviation in case of a sudden change in load or generation loss. The frequency control becomes more challenging as the variation in the frequency of different sources is not synchronized. This paper proposes a model for frequency dynamics in an islanded microgrid comprised of both inverter based distributed generators (DGs) and synchronous generators (SGs). The model is developed considering the asynchronous variation of frequency among the SGs. Based on the developed model, a novel disturbance compensation-based PFC is proposed. The PFC controls the reference power of a battery energy storage system (BESS) which is operated in grid-following mode and compensates for the power imbalance in the microgrid. The performance of the proposed model and the PFC is verified using Typhoon real-time hardware-in-the-loop simulation.


I. INTRODUCTION
During recent years, electric utilities and large power consumers have been showing increasing interest in microgrids for a variety of reasons such as control flexibility, energy security, cost, enhanced reliability, etc. [1]. A microgrid, when connected to the main grid, operates in power control mode, and its control benefits from frequency and voltage stabilization by the grid. However, for powering a remote area or in the event of a fault in the main grid, the microgrid has to operate autonomously and is known as an islanded microgrid. Islanded microgrids are responsible for their voltage and frequency stability. These microgrids usually consist of both SGs and DGs which are operated in parallel [2]. In comparison to the conventional power grid, isolated microgrids have a much higher penetration of DGs which are either inertia less or possess very low inertia [3]. As a result, a higher RoCoF is observed during sudden and large power imbalance between generation and demand [4]. If the microgrid operates The associate editor coordinating the review of this manuscript and approving it for publication was Zhilei Yao .
with RoCoF having exceeded a certain value, the SGs can potentially trip off, and the DGs can be disconnected due to the operation of the RoCoF relay. The limit on RoCoF for the operation of RoCoF relay varies for different countries which can be found in [5], [6]. A sudden imbalance in power also imposes a threat to the stable operation of SGs and DGs. Oscillation in frequency and power is a common issue that has been reported in the literature [7], [8].
From the system architecture point of view, the frequency control issue is addressed in two ways 1) reduced power operation of DGs powered by renewable energy source (RES) [9], [10], and 2) support from energy storage system [11], [12]. A trade-off lies between the cost of additional RES units and the cost of the energy storage unit [13]. However, the option of energy storage, particularly the BESS has been gaining more attention because of its fast response, small size, and ongoing improvement in the maximum continuous current rating [14].
The control of the inverter, interfacing DG/BESS with the microgrid, also plays an important role in frequency control. There are two commonly known methods for controlling the grid-connected inverter: grid forming mode and grid following mode. In the grid forming mode, the inverter is operated in voltage-controlled mode. The frequency and the magnitude of the voltage are controlled based on the active and reactive power supplied by the inverter respectively. Droop control [15] is a popular method to control the frequency of a DG in grid forming mode. Using droop control, power can be shared among the generating sources according to their capacity without requiring communication among them. However, this method suffers from sudden frequency change in inertia-less DGs. Ref. [16] implements a modified droop control method, where the power output of DGs is controlled based on frequency deviation as well as the RoCoF. This method provides virtual inertia to the DGs and hence improves the RoCoF. A more effective method to provide virtual inertia is virtual synchronous generator (VSG) control introduced in [17]. This method emulates the characteristic of an SG by introducing virtual inertia and damping in the power control loop of the DGs. Further, the emulated virtual inertia and damping can be controlled to improve the frequency and power oscillation among the DGs. However, the VSG control is mostly implemented for DG-based microgrids. [18]- [20] are among the few works in literature that implemented the VSG concept for frequency control in microgrids comprised of both SGs and DGs. Also, the effectiveness of this method is limited in terms of peak frequency deviation and/or speed of frequency control in an SG-DG-based microgrid. The reason is the fixed inertia of the SGs. A better frequency response using VSG control requires each source to be able to control their inertia. In this sense, the fixed inertia of the SG limits the flexibility and speed of the VSG control.
In the grid following mode, the inverter is always operated at the grid frequency and its output power is controlled independently. In the literature, this mode of operation is mostly considered for non-dispatchable sources. However, there are some works including [21] and [22] that discuss the application of grid-following mode for frequency control. In [21], the performance of the frequency controller is analyzed by operating energy storage in the grid-following mode as well as in grid-forming mode. As per [21], as the energy storage is operated at a fixed power in grid-following mode, a higher frequency deviation is observed in the event of a transient. However, the performance of the grid-following mode of operation for frequency control can be improved if the output power of DG/BESS is controlled based on the power imbalance/disturbance during the transient. This method requires a model of the microgrid that can estimate the disturbance immediately after its occurrence by observing the deviation in frequency. The model for the frequency dynamics of the microgrid depends on various factors such as mechanical parameters of SGs, speed governor characteristics, droop constants, the impedance of both SGs and the network. Although models for frequency/power dynamics for an SG-DG-based microgrid are presented in [20], [21], [23]- [26], the effect of the synchronous reactance of the SG on the variation of frequency has not been considered.
In this paper, a detailed model of frequency dynamics is presented for an islanded microgrid comprised of both SGs and DGs. The derived model can be used to estimate the disturbance anywhere in the microgrid by observing the deviation in frequency caused by the disturbance. Based on the estimated disturbance, a disturbance compensation-based PFC is implemented to derive the reference power of a BESS which is controlled in grid-following mode to compensate for the disturbance. The major contributions of the paper are as follows: • A model for frequency dynamics is proposed for an islanded microgrid comprised of both SGs and DGs. The proposed model is based on the asynchronous variation of frequency among SGs during the transient.
• The proposed model can be used to estimate the power imbalance anywhere in the microgrid by observing the variation in frequency during the transient.
• Using the developed model, a disturbance compensationbased fast PFC is proposed. The disturbance is compensated by controlling a fast responding BESS in the grid-following mode.
• The proposed PFC does not require a secondary frequency controller since there is no steady state error. Fig. 1 shows the schematic of a BESS interfaced to an ac microgrid. The BESS primarily consists of battery energy storage and a grid side converter that interfaces the battery energy storage with the microgrid. The control of the grid side converter plays an important role in the frequency control of the microgrid. There are two commonly known modes of operation of the grid-side converters: grid-following mode and grid-forming mode [27]. In the grid-following mode, the grid-side converter is controlled to operate the BESS/DG as a current source. On the other hand, in the grid-forming mode, the grid-side converter is controlled in such a way that the BESS/DG acts as a voltage source. Fig. 1 shows the control of the grid-side converter in the grid-forming mode where the voltage controller block is responsible for the FIGURE 1. Control structure of DG/BESS using droop and VSG control. VOLUME 9, 2021 regulation of the magnitude of the voltage. The magnitude of the voltage is regulated primarily by controlling the reactive power supplied by the BESS. The other block in Fig. 1 is the frequency controller which controls the phase/frequency of the voltage. The control of the frequency of the voltage is primarily governed by the active power shared by the BESS/DG. Most of the PFC methods explored in literature operate the grid-side converter in grid-forming mode. Among them, the droop and the VSG controllers are the most popular methods which are discussed in the following subsections.

II. CONVENTIONAL PRIMARY FREQUENCY CONTROL METHODS
Since the focus of this paper is frequency control, only active power control is discussed in the rest of this paper.

A. DROOP CONTROL
The block diagram of PFC using the droop-based control is shown in Fig. 2. The frequency at which the grid-side converter is operated, is given as where ω act is the frequency at which the grid-side converter is operated, P act is active power supplied by the by BESS, ω nom is the nominal frequency, P nom is the active power supplied by the BESS at the nominal frequency, and R is the droop constant. As ω nom and P nom are constants, the change in frequency ( ω), as a function of the change in active power ( P) supplied by the BESS, can be expressed as where ω is the difference between nominal and actual frequency. In the event of a disturbance in the microgrid, the output power from the BESS changes instantly. Consequently, following (2), the frequency of the BESS also changes as soon as the disturbance occurs in the microgrid. Therefore, the droop controller is known to provide negligible inertia to the system. To improve the frequency response of the grid-connected converter, VSG control is proposed in [17] which is discussed in the next subsection.

B. VIRTUAL SYNCHRONOUS GENERATOR CONTROL
The VSG controller provides virtual inertia to the BESS/DG by emulating the characteristics of an SG. The block diagram for PFC using VSG controller is shown in Fig. 3. The dynamics of frequency can be represented by following two equations Equation (3) represents the dynamics of the virtual speed governor where, k SG is the proportional gain of virtual speed governor and P m is the virtual mechanical power. The virtual rotor dynamic is represented by (4) where J and D are controller parameters, known as virtual inertia and damping constant respectively. From (4), at the steady state, the RoCoF is 0 and P m − P act = D ω. In the event of a disturbance, P act changes almost instantly while the change in P m and ω is relatively slow. Therefore, at the instant of disturbance, the RoCoF can be approximated, in terms of change in active power from BESS, as It can be observed from (5) that the initial RoCoF is inversely proportional to the virtual inertia which prevents the sudden change in frequency of the grid side converter. Therefore, the VSG controller is known to provide inertia to the system.

III. FREQUENCY VARIATION IN THE CONSIDERED SYSTEM DURING A DISTURBANCE A. SYSTEM DESCRIPTION
An example of the microgrid configuration considered for this paper is shown in Fig. 4. It is comprised of multiple SGs, DGs, a BESS, and loads which are connected at nodes N 1 -N 6 . The SGs act as the grid forming units and are operated in parallel with droop control. ω 1 and ω 2 represent the frequency of SG 1 and SG 2 respectively, behind their synchronous reactance. ω 1 and ω 2 are termed as rotor frequency in this paper. The inverters powered by small-scale RES are represented as DGs. These DGs are operated in grid-following mode and controlled to extract the maximum power from the corresponding RES. Therefore, they are not considered to participate in frequency control. A large and sudden change in load and/or output power from these DGs is considered a disturbance in the microgrid. The BESS serves to provide frequency support in the event of a disturbance. The BESS is operated in grid-following mode. The reference power of the BESS is determined to restore the frequency by compensating for the disturbance.

B. FREQUENCY VARIATION
In the event of a disturbance, the variation in frequency at different points in the microgrid is different. According to the frequency division rule [28], the difference in the frequency between two points is proportional to the impedance between them. In view of this, the difference between the rotor frequency and the frequency of the terminal voltage of an SG is expected to be much higher than the difference in frequency between any two nodes in the microgrid. This is because of the high synchronous reactance of SG as compared to the impedance of the microgrid network.
To observe the asynchronous variation of the frequency, a simulation is performed on the system shown in Fig. 4. The system is modeled in Typhoon real-time simulator where the model for SG is available. The inductance between the nodes is selected as 10uH while the equivalent inductance of the SG 1 and SG 2 are taken as 400 µH and 200 µH respectively. The resistance between the nodes is neglected as they are too small to create a significant difference in frequency. The simulation result is shown in Fig. 5 which shows the variation in the rotor frequency of the SGs and the frequency at the nodes, N 1 and N 6 , following a sudden increment in the load. The rotor frequency is determined by measuring the rotor speed of the SG while the frequency of the nodes N 1 and N 6 are measured using a phase-locked loop (PLL).
As observed from Fig. 5, the variation in the frequency of the nodes N 1 and N 6 are almost identical while the variation in the rotor frequency of the SGs is not identical. A relatively higher difference between the frequency of a node (N 1 or N 6 ) and the rotor frequency of an SG can also be observed. The frequency difference among other nodes will be less than what is observed between N 1 and N 6 as the impedance among other nodes is less than the impedance between N 1 and N 6 . Therefore, in the view of the frequency division rule and the observation from the simulation result in Fig. 5, it can be seen that the frequency in the microgrid will vary synchronously except for the rotor frequency of the SGs. The frequency dynamics model derived in the following section is based on the asynchronous variation of rotor frequency among the SGs which has not been taken into consideration in models presented in literature so far.

IV. PROPOSED SYSTEM MODELING
This section derives the small-signal frequency to load transfer function (FLTF) of the considered microgrid. The small-signal FLTF (G MG (s)) of the microgrid is given as where ω is the deviation in frequency and P D represents the disturbance in the microgrid caused by a sudden change in load or power from DGs. As the SGs are the only grid-forming units in the considered microgrid, the frequency varies based on the distribution of the disturbance among the SGs. Therefore, the small-signal FLTF model of the microgrid depends on the FLTF of the participating SGs as well as the dynamics of power transfer among them. The following subsection derives the small-signal FLTF of an SG. The FLTF of the microgrid will be derived in the later subsection considering the effects of the power transfer among the SGs.

A. SMALL-SIGNAL FREQUENCY TO LOAD TRANSFER FUNCTION OF AN SG
The small-signal FLTF for the i th SG in the considered microgrid is expressed as where ω i is the change in rotor frequency and P D i is the disturbance power shared by the i th SG. The block diagram for the small-signal frequency response of an i th SG is shown in Fig. 6. As shown in the block diagram, the small-signal FLTF of an SG depends on the frequency control algorithm, characteristic of speed governor, the dynamics of the rotor, and the engine delay. The frequency control algorithm modifies the reference frequency of the speed governor. The change in the reference frequency ( ω refi ) of the i th SG is given as where R i is the droop constant of the i th SG. The first term on the right-hand side in (8) represents the drop in the reference frequency due to the droop control which is applied to share the transient power among SGs as per their rating. ω b i in (8) is the change in the biased frequency which is controlled by a secondary frequency controller (SFC). The focus of this paper is the PFC. Therefore, ω b i is omitted from the small-signal FLTF of the SG. Hence, (8) can be modified as Based on the change in reference frequency, the speed governor of an SG controls the mechanical output power such that the actual frequency follows the reference frequency. The block diagram of the speed governor model [29] is shown in Fig. 7. The model of the speed governor is represented as K i F(s) in Fig. 6 where F(s) combines the characteristics of the master controller and the actuator, and K i is their combined gain. The output of the speed governor is the torque command (T c i ) which is input to the diesel engine. The diesel engine outputs the mechanical torque (T m i ) which is equal to the torque command with a delay t d . The effect of the engine delay is linearized as its first order approximation as From the block diagram in Fig. 6 and (10), the change in mechanical torque can be expressed as, The dynamics of the rotor of the i th SG is given as where J i is the moment of inertia, D i is the damping constant, ω i is the change in angular speed and T e i is the change in electromagnetic torque of the i th SG. T e i can be approximated in terms of the change in the power and the change in the angular speed as As observed from (13), T e i due to ω i is insignificant as compared to T e i due to P D i . Therefore, T e i can further be approximated as Using (9), (11), (12), and (14), the small-signal FLTF for the i th SG is obtained as

B. SMALL SIGNAL FREQUENCY TO LOAD TRANSFER FUNCTION OF THE MICROGRID
During a disturbance in the microgrid, the power shared among the SGs during the transient is not in accordance with their ratings/droop setting. Instead, it is shared based on the network impedance [20] which momentarily causes the asynchronous variation of frequency and also the power oscillation among the SGs. The FLTF at an arbitrary point in the microgrid depends on the asynchronous variation of frequency among the SGs. To derive the FLTF of the microgrid, the considered microgrid is shown in Fig. 8 as its equivalent model. The node N represents the points where a disturbance occurs. The disturbance, shown as P D in Fig. 8, is an increase in power demand from the microgrid which occurs at the instant t 0 . The disturbance can be caused by the change in load and/or change in output power from DGs and/or BESS. ω represents the frequency at node N which is assumed to be the same throughout the microgrid network as per the assumption made in Section III B. ω 1 and ω 2 are the rotor frequency of SG 1 and SG 2 respectively. E 1 and E 2 are the magnitude of the internal voltage of the SGs behind their synchronous reactance, V is the voltage at node N. δ 1 , δ 2 , δ are the small change in power angle of SG 1 , SG 2 and node N respectively. X l 1 and X l 2 are the reactance of the lines joining SG 1 and SG 2 respectively with the point N. The change in power supplied by SG 1 and SG 2 , after the switch is closed, is given as where X 1 = X s 1 + X l 1 , X 2 = X s 2 + X l 2 . Assuming that the change in power angle is small, the change in power supplied by SG 1 and SG 2 can be approximated and expressed in Laplace form as, The change in the frequency at node N is a function of the change in the rotor frequency of SG 1 and SG 2 and is given by the frequency division rule [28] which is expressed as where x 1 and x 2 are given as Integrating (20) to derive relation among the power angle of SG 1 , SG 2, and the point N, where t + o is the instant immediately after the instant of transient, t o . δ t + o , δ 1 t + o and δ 2 t + o are the change in power angle of SG 1 , SG 2 , and the point N respectively, between t o and t + o . The duration between t o and t + o is the time required for the SGs to change their electrical power output to match the change in power demand. This duration is typically in milliseconds and is too small to observe any significant change in the rotor frequency of the SGs due to their mechanical inertia. Hence, the change in power angle of SG 1 and SG 2 ( δ 1 t + o and δ 2 t + o ) can be neglected. As a result, (21) can be expressed in Laplace form as where δ 0 (s) is the Laplace transform of δ t + o . Using (22) to replace δ (s) from (18) and (19), the change in power supplied by SG 1 and SG 2 are obtained as where P D 10 and P D 20 are the power supplied at t + o by SG 1 and SG 2 respectively, and expressed as Applying active power balance, From (25) and (26) P D 10 (s) = x 2 P D (s) , P D 20 (s) = x 1 P D (s) (27) Using (27) in (23) and (24), and applying (7) for SG 1 and SG 2 , the frequency variation of SG 1 and SG 2 is expressed as Substituting δ 1 (s) = ω 1 (s) /s, δ 2 (s) = ω 2 (s) /s in (28) and (29) respectively and using (20), the small-signal FLTF of the microgrid is obtained as It can be observed from (30) that the FLTF of the microgrid requires the instantaneous value of the internal voltage of the SGs which varies during the disturbance. The excitation system of the SGs controls the internal voltage to maintain a constant voltage at the generator bus. The change in the internal voltage depends on the change in current supplied by the SG and its synchronous reactance. Hence, the FLTF in (30) represents a dynamic model. As explained in the VOLUME 9, 2021 next section, the proposed PFC is implemented on the BESS and requires the FLTF to estimate the disturbance. If the FLTF of (30) is used for the estimation of disturbance, communication will be required between the BESS and the SGs to communicate the instantaneous value of the internal voltage of the SGs. To make the proposed PFC communication less, this paper approximates the internal voltage of the SGs as its rated value. The resulting approximated FLTF is given aŝ whereĜ MG (s) is the approximated FLTF and E r is the rated internal voltage of the SGs. Note that the voltage of node N will also be varying during the disturbance. However, this voltage can be measured at the BESS location without requiring communication.

V. PRIMARY FREQUENCY CONTROL
The proposed PFC is based on observing the change in load/disturbance and compensating for it using a BESS. The block diagram for the proposed PFC is shown in Fig. 9 which comprises two closed-loop systems: disturbance observer and disturbance controller. As shown in Fig. 9, the closed-loop disturbance ( P DCL ) is given as where P BESS is the change in power supplied by the BESS. The disturbance observer estimates the closed-loop disturbance which is represented as P D CL in Fig. 9. Based on the estimated disturbance, an estimate of the change in frequency ( ω) is evaluated using the approximated FLTF expressed in (31). The estimated change in frequency is then compared with the actual change in frequency. Based on the difference between the estimated and actual frequency, a PI controller modifies the estimate of the closed-loop disturbance. The PI controller ensures that the estimated change in frequency equalizes the actual change in frequency in the steady state. Ideally, in the steady, P D CL should also converge towards P D CL . However, due to the variation in microgrid parameters, P D CL is considered to have steady state error. Also, the disturbance observer is approximated as a first-order FIGURE 9. Disturbance observer-based primary frequency controller. system with a time constant of τ DO . Therefore, the dynamics of P D CL can be expressed as where ξ represents per unit error with respect to the disturbance due to the variation in microgrid parameters. Based on the estimated closed-loop disturbance, the disturbance controller determines reference power for BESS which can be expressed as where k p and k i are the proportional and integral gain of the PI controller that determines reference power for the BESS. The BESS is operated in grid-following mode and controlled to supply/absorb the power as determined by the disturbance controller. This paper implements the conventional current control technique [27] for BESS power control. The BESS power controller is also approximated as first order system with time constant of τ PC . The dynamics of the BESS power controller can be expressed as where, P ref is the change in reference power determined by the disturbance controller. Assuming the disturbance observer is decoupled from the disturbance controller and using (32), (33), (34) and (35), the closed loop disturbance is given as From (36), the closed loop transfer function of the disturbance controller is obtained as It is observed from (37) that the design of the disturbance controller parameters (k p & k i ) depends on disturbance observer time constant, BESS power controller time constant and the per unit error in the estimation of disturbance. Applying the final value theorem in (37), it is observed that P D CL always converges to 0. However, the convergence of P D CL can be guaranteed only if the disturbance controller remains stable during the transient. Using the Routh-Hurwitz criterion in (37), the condition for stability is obtained as The selection of time constants (τ DO & τ PC ) depends on the design of the disturbance observer and BESS power  controller which can be determined by observing the corresponding step responses. In this paper, both τ DO and τ PC are designed as 50ms. As the error in disturbance estimation is uncertain, the controller parameters are designed for ξ = 0 and the stability of the designed controller is analyzed for different values of ξ . The disturbance controller parameters are designed as k p = 4 and k i = 100. Fig. 10 shows the dominant poles of the designed disturbance controller for ξ = {−0.5, 0, 0.5, 1} which guarantees the stability of the controller. The designed disturbance controller is simulated in MATLAB for an open-loop disturbance of 500kW. The resulting closed-loop disturbance is shown in Fig. 11. It can be observed that closed-loop disturbance decays to 20 kW in 200ms of the occurrence of the disturbance. The variation in frequency for the closed-loop disturbance is shown in Fig. 12. The frequency variation for the open-loop disturbance is also shown in Fig. 12 for comparison.

VI. SIMULATION MODEL DESCRIPTION
To validate the proposed frequency control method, Real-Time simulations were performed using Typhoon Hardware-in-the-loop simulator. The considered microgrid is designed in Typhoon while the proposed load observer-based PFC is implemented in DSP320F28335 which is interfaced with the Typhoon simulator.
The model for the case study consists of two SGs, one equivalent DG, one BESS, and three equivalent loads in Typhoon real-time simulator. The two SGs are termed SG 1 and SG 2 and their rating is 550KVA and 1.1MVA respectively. The total power share of DGs in the considered system is 400kW. Practically, the microgrids consist of multiple DGs with lower power ratings which are added to determine the total power share of the DGs. As the proposed method operates the DGs in grid-following mode, the effect of the change in output power from multiple DGs can be realized by a single DG of 400kW. Therefore, considering the limitation of the size of the model in the Typhoon simulator, the combined effect of multiple DGs is modeled as an equivalent DG for the case study. Further, the equivalent DG is modeled using an ideal DC voltage source with a three phase inverter that interfaces the DG with the microgrid. The output power of the DG can be controlled in real-time by changing the reference power to the three phase inverter.
Similar to DGs, the total active power demand in the microgrid is realized by three equivalent loads: Load-1 as 500kW, Load-2 as 500kW, and Load-3 as 400kW. The equivalent Load-1 represents the minimum amount of load which is always connected in the microgrid. The equivalent Load-2 represents the set of constant impedance loads while Load-3 represents the set of constant power loads. Both Load-2 and Load-3 are assumed to be variable depending on the load demand. The constant impedance load is realized by a resistive load which absorbs 500kW at the nominal voltage. The constant power load is available in the Typhoon model. The power demand of the constant power load can be varied in real-time.
The modeled BESS for the case study consists of a battery pack and a three phase inverter that interfaces the battery pack with the microgrid as shown in Fig. 4. The model of the battery pack is a variable voltage source in series with the internal resistance. The voltage of the battery pack varies with its SoC. Typically, a battery pack consists of several battery cells/modules connected in series and parallel to meet the required voltage and current rating. The nominal voltage VOLUME 9, 2021 and the capacity of the battery pack for the case study are selected as 240 V and 350 Ah respectively. The nominal continuous charge/discharge current is 1C while the peak charge/discharge current is 6C. The internal resistance of the battery pack is 17.1 m which is the equivalent resistance of all the cells connected in series and parallel. Despite the variation in the voltage of the battery with its SoC, the inverter of the BESS can be controlled to regulate its output voltage in grid forming mode or its output current in grid-following mode [27]. The other relevant simulation parameters are provided in Table 1.

A. FREQUENCY RESPONSE WITH CONVENTIONAL FREQUENCY CONTROLLERS
First, the simulation is performed using the conventional droop and VSG-based control methods for the case of sudden addition of the constant power load. For the implementation of the droop and VSG control methods, the inverter of the BESS is operated in grid-forming mode. In this mode, the inverter of the BESS is controlled such that the BESS unit acts as a voltage source. The magnitude of the voltage is controlled to match with the voltage of the microgrid at the point of common coupling while the frequency/phase of the voltage is controlled based on the active power supplied by the BESS using droop/VSG control methods. The droop constant for the BESS is selected the same as that of the higher rating generator, SG 2, to observe minimum frequency deviation. To start the simulation, Load-1 of 500kW and Load-3 of 400kW are connected to the microgrid, and the output power of the DG is set to 400 kW. Therefore, before the addition of the Load-2, which is the constant impedance load of 500kW, the total power shared by the SGs and BESS is 500kW. Fig. 13(a) shows the variation in the frequency of SG 1 and BESS when the Load-2 is switched on. As the BESS is operated in the grid-forming mode, the frequency of SGs and the frequency at which the BESS is operated, are different during the transient. A sudden change of 0.18 Hz in the frequency of the BESS is observed as soon as the Load-2 is switched on. The reason is that the droop controller drops the frequency of the inverter as soon as the BESS increases its output power followed by the transition of Load-2. The sudden drop in the frequency of the BESS reduces the rate of power compensation from the BESS immediately after the addition of load-2 which can be observed in Fig. 13(b). As a result the SGs, which are the grid-forming units, supply more power immediately after the addition of Load-2. Consequently, a higher magnitude of peak frequency deviation (0.45 Hz) is observed. Also, the steady state power supplied by the BESS is approximately 200 kW. As the BESS does not fully compensate for the power demand of the Load-2 which is 500 kW, a steady state frequency deviation of 0.22 Hz is observed. Therefore, a secondary frequency controller is required to regulate the frequency to the nominal value. The performance of the VSG-based PFC is shown in Fig. 14. For the implementation of the VSG control, the virtual inertia of 124 kgm 2 , which is the same as that of SG 2 , is incorporated in the frequency control loop of the inverter of the BESS. As a result of the addition of virtual inertia, the frequency of the BESS does not suffer from a sudden change which can be observed from Fig. 14(a). The output power from the BESS for the case of droop and VSG control can also be compared from Fig. 13(b) and Fig. 14(b). In the case of VSG control, the peak power supplied by SG 2 reduces to 210kW as compared to 240kW for the case of droop control. Therefore, as compared to the droop control, a lower magnitude of peak frequency deviation (0.36 Hz) is observed. Note that the VSG controller improves only the transient frequency response of the BESS. The steady state performance of the VSG-based PFC is the same as the performance of the droop controller.

B. FREQUENCY RESPONSE WITH PROPOSED FREQUENCY CONTROLLER
For the implementation of the proposed PFC, the inverter of the BESS is operated in grid-following mode. In this mode, the grid side inverter is operated in power-control mode and the frequency of the BESS inverter is controlled to be the same as the frequency of the microgrid. The active power supplied by the BESS is controlled to compensate for the disturbance which is estimated by the model-based load observer. As the proposed work is focused on frequency control, the reactive power supplied by the BESS is regulated to be zero. The simulations implementing the proposed PFC are performed for a sudden change in constant impedance load, a sudden change in constant power load, and dynamic change in power output from DGs, which are discussed below: • Sudden change in constant impedance load The simulation implementing the proposed PFC for a sudden change in constant impedance load is performed under the same condition as for the droop and VSG controller. The performance of the PFC is shown in Fig. 15. It is noted from Fig. 15 (a) that the peak deviation in frequency is reduced to 0.07Hz which is 0.45 Hz and 0.36 Hz for droop and VSG controller respectively. Also, there is no steady error in the frequency. Therefore, the proposed controller does not require SFC.  The waveform of the active power supplied by the BESS is also shown in Fig. 15(a). It is noted that the BESS supplies 480kW power immediately after the addition of Load-2 which is rated as 500 kW at the nominal voltage. Due to the small amount of voltage drop in the line, the active power absorbed by the equivalent Load-2 is less than its rating. Irrespective of the voltage drop in the line, the disturbance observer always estimates the actual power absorbed by the Load-2 which is compensated by the BESS. Since the BESS is operated in grid-following mode, the frequency of the BESS does not drop as a result of the power compensation. In contrast, the droop and VSG control methods operate the BESS in grid forming mode and the frequency of the inverter of the BESS is a function of the power supplied by the BESS. The change in frequency of the BESS affects the difference in power angle between the BESS and other grid-forming units. As a result, the output power of the other grid forming units also changes and the frequency of the whole system is affected both in transient and steady state.
The closed-loop disturbance estimated by the disturbance observer due to the addition of Load-2 is shown in Fig. 15(b). The closed-loop disturbance decays to 0 in approximately 300ms which is in good agreement with what is observed in the MATLAB simulation shown in Fig. 11. Note that the disturbance observer is based on the approximated FLTF derived in (31) which is derived by neglecting the resistance of the SGs and transmission lines. However, these resistances are included in the Typhoon simulation model. Still, the closed-loop disturbance estimated by the load observer decays to zero due to the robustness of the disturbance controller as discussed in Section V.
Once the frequency is regulated, the power compensated by the BESS is gradually transferred to the SGs by implementing state of charge (SoC) control of the BESS. However, this paper focuses only on PFC and the simulation result, and discussion on the SoC control is out of the scope of this paper.
• Sudden change in constant power load To simulate the case of change in constant power load, Load-1 and Load-2 are remained connected to the microgrid, and the output power of the DG is set to 400kW. To create the disturbance, the constant power load (Load-3) of 400kW is suddenly connected to the microgrid. The corresponding waveform of frequency and active power supplied by the BESS is shown in Fig. 16. In this case, the peak frequency deviation is observed as 0.06 Hz. The performance of the proposed PFC for this case is similar to the case of the change in constant impedance load except the constant power load absorbs its rated power despite the voltage drop in the transmission line. Nevertheless, the BESS fully compensates for the disturbance caused by the addition of Load-3, resulting in zero steady state error in frequency.
• Dynamic change in DG output power To validate the proposed PFC for the case of dynamic disturbance, all the loads remained connected to the microgrid while the output power of the modeled DG is varied  by controlling its grid-side converter. The variation in output power from DG creates a power imbalance in the system similar to the disturbance caused by a dynamically changing constant power load. The resulting change in output power from the DG, compensating power from the BESS and the variation in frequency are shown in Fig. 17. It is observed that the proposed frequency controller is able to compensate for power imbalance caused by dynamically changing output power from the DGs with negligible deviation in frequency.

VIII. CONCLUSION
This paper presents an approximate model for frequency dynamics of an islanded microgrid comprised of both SGs and DGs. The model is developed considering the asynchronous variation of frequency among the SGs during the transient. Using the proposed FLTF, a disturbance compensation-based PFC is proposed which controls a BESS in grid-following mode to compensate for the disturbance in the microgrid. The proposed PFC provides the flexibility to integrate the BESS anywhere in the microgrid. The stability of the controller is analyzed in MATLAB. The performance of the proposed controller is compared with that of conventional droop and VSG-based PFC for a sudden change in constant impedance load which is rated as 500kW at nominal voltage. Using the proposed frequency controller, the peak frequency deviation is limited to 0.07 Hz which are observed as 0.45 Hz and 0.36 Hz using the conventional droop and VSG-based PFC respectively. Also, the proposed frequency controller does not require SFC which is needed in the case of droop and VSG control as they suffer from steady state frequency deviation following a transient in the microgrid. The proposed PFC is also successfully validated for cases of change in constant power load and variation in output power from DGs.