## 2 Mathematical Modeling of DER System
### State Space Modelling of DER System  
The representation of the system in the state space describes the dynamic behavior of all the energy storage elements in the distributed energy system, which in this case are the inductor \(L_{f}\) and capacitor \(C_{f}\) belonging to the inverter filter. To better understand the physical relationships between the components of the inverter, Figure 2 shows the block diagram representation of the inverter that shows the relationship between the capacitor voltage and the inductor current. The block diagram facilitates understanding and later description by state variables. As the load connected to the DER system can be linear or non-linear, this paper considers a representation of the load current in terms of two distinct components. The first current, derived from the admittance \(Y_{load}\), which represents a linear load that consumes a current \(i_{load}\). The second added to \(i_{load}\) is an \(i_{d}\) current, which in this paper represents disturbances or disturbances to the value of the load applied to the distributed energy system. This current represents in a simplified way the model of non-linear loads connected to a DER system [19; 20]. The initial methodology to compose the state matrices requires the determination of the differential equations that govern the behavior of the voltages and currents involved in the filter, according to the polarity defined in Figure 1. Basically, two equations are used, one referring to the mesh equation and the other one to the node equation as shown in (2). \[ \begin{array}{c}V_{DER}=v_{\text{load}}+v_{Lf}+i_{Lf}R_{Lf}\\ i_{Lf}=i_{Cf}+i_{\text{load}}+i_{d}\end{array}  \tag{2}\]  
Knowing that the relationship between voltage and current in the inductor and capacitor are given by:  
\[ \begin{array}{c}i_{Cf}=C_{f}\frac{dv_{Cf}}{dt}\\ v_{Lf}=L_{f}\frac{dt_{Lf}}{dt}\end{array}  \tag{3}\]  
The voltage drop in the internal resistance of the inductor is proportional to the current flowing through it, as well as the voltage drop in the internal resistance of the capacitor. In this way, Equation (4) is defined. \[ \begin{array}{c}v_{R_{Lf}}=R_{Lf}i_{Lf}\\ v_{R_{Cf}}=R_{Cf}i_{Cf}\end{array}  \tag{4}\]  
and taking into account the voltage drop in the resistance referring to the losses in the capacitor, we obtain:  
\[ \begin{array}{c}v_{\text{load}}=v_{Cf}+v_{R_{cf}}\\ v_{\text{load}}=v_{Cf}+i_{Cf}R_{Cf}\end{array}  \tag{5}\]From (3), the current is obtained at the series impedance of the capacitor, reaching the equation for voltage at the load:  
\[v_{load}=v_{Cf}+C_{f}\frac{dv_{Cf}}{dt}R_{Cf} \tag{6}\]  
By replacing the two equations defined in (3), we obtain the relationship defined in (7). \[i_{Lf}=C_{f}\frac{dv_{Cf}}{dt}+v_{load}\cdot Y_{load}+i_{d} \tag{7}\]  
And replacing the variable \(V_{load}\) of Equation (7) in Equation (6) we obtain Equation (8)  
\[i_{Lf}=C_{f}\frac{dv_{Cf}}{dt}+Y_{\text{load}}\left(v_{Cf+}C_{f}\frac{dv_{Cf}}{ dt}R_{Cf}\right)+i_{d} \tag{8}\]  
We then arrive at an equation where there are only the measured variables related to each other as presented in (9). \[\frac{dv_{Cf}}{dt}\left(C_{f}+Y_{\text{load}}\cdot C_{f}R_{Cf}\right)=i_{Lf}-Y _{\text{load}}\cdot v_{Cf}-i_{d} \tag{9}\]  
As there is the presence of the capacitor voltage and its derivative, the following manipulation can be done to arrive at the first state Equation (10), related to the capacitor voltage. \[\frac{dv_{Cf}}{dt}=\frac{\frac{1}{Y_{\text{load}}}}{C_{f}\left(\frac{1}{Y_{ \text{load}}}+R_{Cf}\right)}i_{Lf}-\frac{1}{C_{f}\left(\frac{1}{Y_{\text{ load}}}+R_{Cf}\right)}v_{Cf}-\frac{\frac{1}{Y_{\text{load}}}}{C_{f}\left(\frac{1}{Y_{ \text{load}}}+R_{Cf}\right)}i_{d} \tag{10}\]  
Having obtained the first equation of state from the law of nodes applied to the system, the process for obtaining the second equation of state will now be started based on the law of meshes, given by Equation (11).