# An Optimal Power Control Strategy for Grid-Following Inverters in a Synchronous Frame
## 2 Mathematical Model  
The mathematical model is based on the circuit shown in Figure 2. The output of a three-phase inverter E is connected through an inductor-capacitor-inductor (_LCL_) output filter to a stiff voltage source V\({}_{g}\) that represents the main grid. Input inductor current, capacitor voltage, and output current are denoted by I\({}_{l}\), V\({}_{c}\), and I\({}_{o}\), respectively.  
Figure 2: Three-phase inverter connected to the main grid.  
The state-space model of this circuit for each phase in the \(ABC\) frame is given by  
\[\left[\begin{array}{c}\dot{\mathrm{V}}_{\mathrm{c}}\\ \dot{\mathrm{I}}_{\mathrm{I}}\\ \dot{\mathrm{I}}_{\mathrm{o}}\end{array}\right]=\left[\begin{array}{ccc}0&{}^{ 1}/\mathrm{C}&-{}^{1}/\mathrm{C}\\ -{}^{1}/\mathrm{I}_{\mathrm{a}}&0&0\\ {}^{1}/\mathrm{I}_{\mathrm{o}}&0&0\end{array}\right]\left[\begin{array}{c} \mathrm{V}_{\mathrm{c}}\\ \mathrm{I}_{\mathrm{I}}\\ \mathrm{I}_{\mathrm{o}}\end{array}\right]+\left[\begin{array}{c}0\\ {}^{1}/\mathrm{I}_{\mathrm{a}}\\ 0\end{array}\right]\mathrm{E}+\left[\begin{array}{c}0\\ {}^{0}\\ {}^{-1}/\mathrm{I}_{\mathrm{o}}\end{array}\right]\mathrm{V}_{\mathrm{g}} \tag{3}\]  
The main grid voltage \(\mathrm{V}_{\mathrm{g}}\) is assumed as a balanced three-phase signal with an amplitude of \(120\mathrm{V}_{\mathrm{RMS}}\) and an angular frequency \(\omega_{\mathrm{c}}=2\pi 60\mathrm{Hz}\). The state-space model (3) is transformed to a synchronous frame using the well-known \(dq\) transformation as follows [30]:  
\[\mathrm{w}_{\mathrm{dq}}=\mathrm{T}_{\mathrm{dq}}\mathrm{w}_{\mathrm{abc}} \tag{4}\]  
where \(\mathrm{W}_{\mathrm{abc}}=\left[\begin{array}{cc}\mathrm{W}_{\mathrm{a}}& \mathrm{W}_{\mathrm{b}}&\mathrm{W}_{\mathrm{c}}\end{array}\right]^{\mathrm{T}}\) is some vector in the \(ABC\) frame representing each state variable and  
\[\mathrm{T}_{\mathrm{dq}}=\sqrt{\frac{2}{3}}\left[\begin{array}{cc}\cos( \omega_{\mathrm{c}}\,\mathrm{t})&\cos(\omega_{\mathrm{c}}\mathrm{t}-\frac{2\pi }{3})&\cos(\omega_{\mathrm{c}}\mathrm{t}+\frac{2\pi}{3})\\ -\sin(\omega_{\mathrm{c}}\mathrm{t})&-\sin(\omega_{\mathrm{c}}\mathrm{t}-\frac{ 2\pi}{3})&-\sin(\omega_{\mathrm{c}}\mathrm{t}+\frac{2\pi}{3})\\ \frac{1}{\sqrt{2}}&\frac{1}{\sqrt{2}}&\frac{1}{\sqrt{2}}\end{array}\right]. \tag{5}\]  
The state-space model of the inverter in the \(dq\) frame is shown in (6). When \(\mathrm{T}_{\mathrm{dq}}\) is synchronized with the main grid, \(\mathrm{V}_{\mathrm{g}}\) becomes static with a constant value \(\mathrm{V}_{\mathrm{g}dq}=\left[\begin{array}{cc}\mathrm{\widetilde{V}}_{ \mathrm{g}d}&0\end{array}\right]^{\mathrm{T}}\), where \(\mathrm{\widetilde{V}}_{\mathrm{d}}\) represents the peak amplitude of the main grid voltage.  
\[\left[\begin{array}{c}\dot{\mathrm{V}}_{\mathrm{od}}\\ \dot{\mathrm{V}}_{\mathrm{eq}}\\ \dot{\mathrm{I}}_{\mathrm{id}}\\ \dot{\mathrm{I}}_{\mathrm{a}}\\ \dot{\mathrm{I}}_{\mathrm{ol}}\\ \dot{\mathrm{I}}_{\mathrm{eq}}\end{array}\right]=\left[\begin{array}{cccc}0& \omega_{\mathrm{c}}&1/\mathrm{C}&0&-1/\mathrm{C}&0\\ -\omega_{\mathrm{c}}&0&0&1/\mathrm{C}&0&-1/\mathrm{C}&\mathrm{V}_{\mathrm{eq}}\\ -1/\mathrm{I}_{\mathrm{a}}&0&0&\omega_{\mathrm{c}}&0&0\\ 0&-1/\mathrm{I}_{\mathrm{a}}&-\omega_{\mathrm{c}}&0&0&0\\ 1/\mathrm{I}_{\mathrm{o}}&0&0&0&0&\omega_{\mathrm{c}}\\ 0&1/\mathrm{I}_{\mathrm{o}}&0&0&-\omega_{\mathrm{c}}&0\where \(X=\left[\begin{array}{cc}x_{\rm dq}&E_{\rm i}\end{array}\right]^{T}\), \(T_{\rm s}\) is the sampling period, and the upper bar \(\blacksquare\) represents the discrete-time transformation. The auxiliary integral of the input is represented by \(E_{\rm i}\). The discrete-time state-space system can be rewritten as follows:  
\[X[k+1]=\overline{A}_{\rm T}X[k]+\overline{B}_{\rm 1T}E_{\rm dq}[k]+ \overline{B}_{\rm 2T}V_{\rm gdq}[k]\] \[Y=CX[k]. \tag{9}\]  
The output matrix \(C\) is given by  
\[C=\frac{3}{2}\left[\begin{array}{cccccccc}0&0&0&0&\overline{V}_{\rm gd}&0&0 &0\\ 0&0&0&0&0&-\overline{V}_{\rm gd}&0&0\end{array}\right]. \tag{10}\]