# Optimal Design and Real Time Implementation of Autonomous Microgrid Including Active Load
## 2 System Description
### Active Load Model  
Active load model with its controllers is given in Figure 1. In the following model, the active load has its own \(dq\) reference frame as each inverter has. The active load should be synchronized with the microgrid to share its angles. A traditional \(PLL\) shown in Figure 5 is used for this purpose. The input variable of the active load model is the input voltage while the output variable is the current drawn from the DG units [12]. The active load input current (\(i_{IALDQ}\)) is converted from the common reference frame \"\(DQ\)\" to the active load reference frame \(dq_{AL}\) using \(PLL\).  
\[\begin{array}{l}\left[i_{IALDQ}\right]=\left[T_{R}\right]\left[i_{IALdq} \right]\\ \left[T_{R}\right]=\sqrt{\frac{2}{3}}\left[\begin{array}{cc}\cos(\delta_{i} )&-\sin(\delta_{i})\\ \sin(\delta_{i})&\cos(\delta_{i})\end{array}\right]\end{array} \tag{20}\]  
where \(\delta_{i}\) is the angle between the \(dq\) active load frame and common reference frame \(DQ\).  
To set the \(dq\) system frequency equal to the grid frequency, the regulator is arranged to maintain one component at zero by changing the frequency of \(dq\) system rotation [26]. The three-phase voltages are transformed into \(\alpha\beta\) stationary reference frame then the frequency and the inverter phase reference \(\theta\) will be estimated as given in (21) & (22). The angle \(\theta\) is controlled to transform from \(abc\) to \(dq\) and vice versa.  
\[\omega=k_{P}^{PLL}(v_{qq}-v_{qq}^{*})+k_{I}^{PLL}\int\left(v_{qq}-v_{qq}^{*} \right)dt \tag{21}\]  
\[\theta=\int\left(\omega-\omega_{ref}\right)dt+\theta(0) \tag{22}\]  
where \(k_{P}^{PLL}\) and \(k_{I}^{PLL}\) are the \(PLL\) controller parameters.  
As shown in Figure 6, to regulate the DC voltage and control the AC current of the active load, two PI controllers are proposed.  
\[i_{IALAL}^{*}=K_{pv\_AL}(v_{DC}^{*}-v_{DC})+K_{iv\_AL}\int\left(v_{DC}^{*}-v_{ DC}\right)dt \tag{23}\]  
Tuning these controller parameters is very important to get reasonable steady-state response. Firstly, the voltage controller can be used to get the AC reference current by minimizing the error between the measured DC voltage and the DC reference voltage. Similarly, the current controller can be used to get the AC reference voltage by minimizing the error between the measured AC current and the AC reference current. A negative sign to the inverter current should be added to the voltage controller state-space equations because the active load is receiving current from the DGs. For decoupling the inductor current in the \(DQ\) axes, feed-forward terms will be involved as shown in Figure 6. Meanwhile, the state-space equations of the DC capacitor circuit can be given.  
\[\begin{array}{l}v_{idAL}^{*}=\omega_{nAL}L_{fAL}i_{lqAL}-K_{pc\_AL}(i_{IMAL}^{*}-i_{ldAL})-K_{ic\_AL}\int\left(i_{ lIAL}^{*}-i_{ldAL}\right)dt\\ v_{iqAL}^{*}=-\omega_{nAL}L_{fAL}i_{ldAL}-K_{pc\_AL}(i_{lqAL}^{*}-i_{qAL})-K_{ ic\_AL}\int\left(i_{lqAL}^{*}-i_{lqAL}\right)dt\\ \frac{dv_{DC}}{dt}=\frac{1}{C_{dc}}i_{conv}-\frac{1}{R_{dc}C_{dc}}v_{DC}\end{array} \tag{24}\]  
where \(C_{dc}\) and \(R_{dc}\) are the dc load capacitance and resistance and \(i_{conv}\) is the DC current of the active load.  
Considering ideal power converter, the internal power losses can be neglected. Therefore, the state-space equations of the switching bridge can be written as  
\[v_{idAL}i_{idAL}+v_{iqAL}i_{iqAL}=i_{conv}v_{DC} \tag{26}\]