# Optimal Design and Real Time Implementation of Autonomous Microgrid Including Active Load
## 2 System Description
### Autonomous Microgrid Model  
Three inverter-based DGs are feeding two loads (CPL and CIL) through two transmission lines filters and coupling inductances as illustrated in Figure 1. In the autonomous mode, feeding the load with the predefined frequency and voltage values is the main objective of the inverter controller. Therefore, three controllers have been used to achieve this goal. Three controllers are presented to control the three inverters of the DG units. Firstly, emulating the synchronous generator, droop control is used to share the powers between DGs as given in Figure 2. Secondly, two PI controllers are employed to control the DGs' output voltage and current as shown in Figure 3. It is worth mentioning that each DG inverter is assumed to be connected to a constant dc power source, so there no need to regulate the dc-link voltage otherwise, a controller should be introduced to regulate the dc-link voltage [40]. Meanwhile, our objective in this paper is to study the dynamic performance of the ac side of the inverter-based DG. The instantaneous real (\(P_{m}\)) and reactive powers (\(Q_{m}\)) are calculated using measured output current (\(i_{o}\)) and output voltage (\(v_{o}\)) is used to obtain the as given  
\[P_{m}=v_{od}i_{od}+v_{od}i_{od} \tag{1}\]  
\[Q_{m}=v_{od}i_{od}-v_{od}i_{od} \tag{2}\]  
The average real \(P_{c}\) and reactive powers \(Q_{c}\) are obtained using a low pass filter as given in Figure 2.  
\[P_{c}=\frac{\omega_{c}}{\omega_{c}+s}P_{m},Q_{c}=\frac{\omega_{c}}{\omega_{c} +s}Q_{m} \tag{3}\]  
where \(\omega_{c}\) is the cut-off frequency of the low-pass filter. As shown in Figure 2, the frequency \(\omega\) is obtained from the active power while the d-axis reference voltage \(v_{od}^{*}\) is obtained from the reactive power as  
\[\omega=\omega_{n}-m_{p}P_{c}\,\quad\overset{\bullet}{\theta}=\omega \tag{4}\]  
\[v_{od}^{*}=V_{n}-n_{q}Q_{c}\,\quad v_{od}^{*}=0 \tag{5}\]  
where \(\omega_{n}\) is the nominal angular frequency of DG, \(V_{n}\) is the nominal magnitude of the DG voltage and \(m_{p}\) and \(n_{q}\) are the droop controller gains. Voltage and current controllers' state equations are shown  
\[ \begin{array}{l}i_{ld}^{*}=Fi_{od}-\omega_{n}C_{f}v_{od}+K_{pv}(v_{od}^{*}-v _{od})+K_{iv}\int{(v_{od}^{*}-v_{od})dt}\\ i_{lq}^{*}=Fi_{qq}+u_{n}C_{f}v_{od}+K_{pv}(v_{od}^{*}-v_{od})+K_{iv}\int{(v_{od}^ {*}-v_{od})dt}\end{array}  \tag{6}\]  
\[ \begin{array}{l}v_{it}^{*}=-\omega_{n}L_{f}i_{ld}+K_{pc}(i_{ld}^{*}-i_{ld})+ K_{ic}\int{(i_{ld}^{*}-i_{ld})dt}\\ v_{iq}^{*}=\omega_{n}L_{f}i_{ld}+K_{pc}(i_{lq}^{*}-i_{ld})+K_{ic}\int{(i_{lq}^{* }-i_{ld})dt}\end{array}  \tag{7}\]  
where \(L_{c}\) and \(r_{c}\) are the inductance and resistance of the coupling inductor respectively, \(F\) is feed-forward gain, \(C_{f}\) is the filter capacitance, and \(K_{pc}\), \(K_{ic}\), \(K_{pv}\), and \(K_{iv}\) are the PI controller parameters. Figure 1: Microgrid with active load. Figure 2: Power droop controller. The \(LC\) filter and coupling inductance state equations are written as  
\[\frac{di_{ld}}{dt} =-\frac{r_{f}}{L_{f}}i_{ld}+\omega i_{lq}+\frac{1}{L_{f}}(v_{id}-v_ {od}) \tag{8}\] \[\frac{di_{lq}}{dt} =-\frac{r_{f}}{L_{f}}i_{lq}-\omega i_{ld}+\frac{1}{L_{f}}(v_{iq}-v _{qq})\] (9) \[\frac{dv_{od}}{dt} =\omega v_{qq}+\frac{1}{C_{f}}(i_{ld}-i_{od})\] (10) \[\frac{dv_{qq}}{dt} =-\omega v_{od}+\frac{1}{C_{f}}(i_{lq}-i_{qq})\] (11) \[\frac{di_{od}}{dt} =-\frac{r_{c}}{L_{c}}i_{od}+\omega i_{qq}+\frac{1}{L_{c}}(v_{od}- v_{bd})\] (12) \[\frac{di_{qq}}{dt} =-\frac{r_{c}}{L_{c}}i_{qq}-\omega i_{od}+\frac{1}{L_{c}}(v_{qq}- v_{qq}) \tag{13}\]  
Actually, this model uses different frequency variables: \(\omega\), \(\omega_{0}\), \(\omega_{n}\), and \(\omega_{COM}\). The variable \(\omega\) denotes an arbitrary time varying frequency which used in Equations (8)-(13) to obtain the drop voltage in the coupling inductances. While nominal system frequency denoted by \(\omega_{n}\) is used to obtain the reference values (Equations (6) and (7)).