## 3 Frequency Deviation Suppression Based on VSG
### VSG Model and Control  
The VSG is formed by three important elements such as energy storage system, inverter, and a proper control algorithm. By taking the benefit of release/absorb characteristic of ESS, a proper designed control scheme could control the inverter to mimic the dynamic behavior of the synchronous generator. The VSG algorithm is implemented based on the swing equation of a synchronous generator and it is given in Equation (6). \[\int\frac{d\omega_{m}}{dt}=T_{m}-T_{e} \tag{6}\]  
where \(T_{m}\), \(T_{e}\) is the generator's mechanic torque and electromagnetic torque, respectively. \(J\) is a moment of inertia, and \(\omega_{m}\) is generator's angular frequency. By multiplying the Equation (6) with angular frequency (\(\omega_{m}\)), the swing equation in term of power (\(P=\omega_{m}\).\(T\)) is obtained as express in Equation (7). \[J\omega_{m}\frac{d\omega_{m}}{dt}=P_{m}-P_{e} \tag{7}\]  
The \(P-\omega\) and \(Q-v\) droop control are commonly used in the primary frequency and voltage regulation. The relation between \(P-\omega\) and \(Q-v\) are given in Equation (8). \[ \begin{split}\omega_{m}=\omega_{ref}-k_{f}(P_{m}-P_{ref})\\ V_{a}=V_{ref}-k_{v}(Q_{m}-Q_{ref})\end{split}  \tag{8}\]  
Moreover, in order to fully mimic the conventional synchronous generator, the damping term (\(D(\omega_{m}-\omega_{pcc})\)) due to damper winding, mechanical friction and electrical losses are commonly added to swing equation. By substituting the damping term and frequency governor model (Equation (8)) into Equation (7), the swing equation for the VSG in this research is obtained as expressed in Equation (9). \[J\omega_{m}\frac{d\omega_{m}}{dt}=P_{ref}-\frac{\omega_{m}-\omega_{ref}}{k_{f }}-P_{out}-D(\omega_{m}-\omega_{pcc}) \tag{9}\]  
In Formula (9), \(P_{out}\) is the measured power output of VSG which is equivalent to \(P_{e}\). \(\omega_{m}\) is the VSG's angular frequency and \(\omega_{pcc}\) is the angular frequency at the point of common coupling. \(J\) and \(D\) are the virtual inertia and damping factor, respectively. Designing the VSG parameters such as \(J\) and \(D\) are the challenging task. For the sake of simplicity, the parameter \(J\) and \(D\)[25] could be calculated based on Equation (10) which follows the synchronous generator. \[ \begin{split} J=\frac{2 HS_{n}}{\omega^{2}}\\ D=\frac{\Delta S}{\omega\Delta\omega}\end{split}  \tag{10}\]  
where \(H\) is the inertia constant, which is in range [2 s-10 s]. \(S_{n}\) is the base power of generator, \(\omega\) is the angular frequency which equals to \(2\pi f\) and \(\Delta\omega\) (\(\Delta\omega=\omega_{m}-\omega_{pcc}\)) is the allowable deviation frequency which equals to \(2\pi\). To understand the effect of virtual inertia and damping factor on the system's frequency, the Equation (9) is derived as. \[ \begin{split}\frac{d\omega_{m}}{dt}=\frac{\frac{P_{ref}}{\omega_ {m}}-\frac{\omega_{m}-\omega_{ref}}{k_{f}\omega_{m}}-\frac{P_{out}}{\omega_{m }}-\frac{D(\omega_{m}-\omega_{pcc})}{\omega_{m}}}{J}\\ \Delta\omega=\frac{P_{ref}-\frac{\omega_{m}-\omega_{ref}}{k_{f}} -P_{out}-J\omega_{m}\frac{d\omega_{m}}{dt}}{D}\end{split}  \tag{11}\]  
In Equation (11), assuming that \(\{\frac{P_{ref}}{\omega_{m}}-\frac{\omega_{m}-\omega_{ref}}{k_{f}\omega_{m}} -\frac{P_{out}}{\omega_{m}}-\frac{D(\omega_{m}-\omega_{pcc})}{\omega_{m}}\}\) is constant. If the value of J is increased, the \(\frac{d\omega_{m}}{dt}\) will be decreased. Similarly, in Equation (12), assuming that\(J\omega_{m}\frac{d\omega_{m}}{dt}\)) is constant. If the parameter \(D\) gets bigger, \(\Delta\omega\) will become smaller. Hence, the large value of \(J\) and \(D\) result in a small frequency deviation; at the same time, they maximize the power, generated or absorbed by the energy storage system. However, there is a side-effect for larger value selection of parameter \(J\) and \(D\) such as causing overload the inverter, increasing the settling time, requiring the high accuracy of \(PLL\).