A State-Space Model of an Inverter-Based Microgrid for Multivariable Feedback Control Analysis and Design

In this work, a synchronous model for grid-connected and islanded microgrids is presented. The grid-connected model is based on the premise that the reference frame is synchronized with the AC bus. The quadrature component of the AC bus voltage can be cancelled, which allows to express output power as a linear equation for nominal values in the AC bus amplitude voltage. The model for the islanded microgrid is developed by integrating all the inverter dynamics using a state-space model for the load currents. This model is presented in a comprehensive way such that it could be scalable to any number of inverter-based generators using inductor–capacitor–inductor (LCL) output filters. The use of these models allows designers to assess microgrid stability and robustness using modern control methods such as eigenvalue analysis and singular value diagrams. Both models were tested and validated in an experimental setup to demonstrate their accuracy in describing microgrid dynamics. In addition, three scenarios are presented: non-controlled model, Linear-Quadratic Integrator (LQI) power control, and Power-Voltage (PQ/Vdq) droop–boost controller. Experimental results demonstrate the effectiveness of the control strategies and the accuracy of the models to describe microgrid dynamics.


Introduction
With the increase in power generation using renewable energy sources, nowadays the concept of microgrids is becoming popular. The U.S. Department of Energy (DOE) defines a microgrid as "a group of interconnected loads and distributed energy resources within clearly defined electrical boundaries that acts as a single controllable entity with respect to the grid. A microgrid can connect and disconnect from the grid to enable it to operate in both grid-connected or island-mode" [1]. This concept gives a clear general view of the main characteristics of a microgrid. Moreover, it describes most of the technological challenges regarding microgrid integration. First, a microgrid must be composed of distributed generators that must be safely interconnected. Second, a microgrid should act as a single entity. This means that all generators must be synchronized to deliver active and reactive power according to microgrid requirements and operational mode. Finally, a microgrid may work directly connected to the main grid or work totally off grid. This implies that power quality must be guaranteed even if there is not a main grid with high inertia that indicates the reference voltage, frequency, and phase.
In a microgrid, multiple distributed generators (DG) and loads are connected to a point of common coupling (PCC) as shown in Figure 1. The loads connected to the microgrid may be supplied by the DGs or by a direct connection to the main grid. In addition, multiple energy storage units may be connected to the microgrid to increase the power availability and system reliability [2]. A microgrid requires the use of power electronics devices to perform the energy conversion from one voltage level to another. For example, for an AC microgrid, the energy storage system (ESS) requires the use of a bidirectional AC-DC converter that regulates the charge or discharge process depending on the available energy. Wind turbine generators require the use of AC-AC converters to transform the amplitude and frequency to standardized voltage levels in the microgrid. Solar photovoltaic (PV) generators require the use of a DC-AC converter to inject the maximum available energy to the microgrid. Loads such as residential homes and streetlights are connected to the microgrid's common bus. The common bus may be connected to the main grid or disconnected to be operating in islanded mode. Each of the interconnections mentioned above are managed by one or more controllers to optimize the energy generation, guarantee adequate power quality, and to improve stability and robustness in the microgrid.
Optimal controllers for microgrids are aimed to achieve the best performance and/or stability margins by applying numerical optimization methods to the open-loop model. Some relevant works related to the optimal control applied to Voltage-Current (V-I) control level may be found in [3][4][5][6][7][8][9][10][11][12]. Most of these works use proportional-integral (PI) or proportional-resonant (PR) controllers with linear quadratic (LQ) control to compute an optimal state-feedback matrix that minimizes certain cost functions. Optimal LQ strategies for primary control are more difficult to implement since this kind of controllers require an open-loop model to apply numerical optimization methods.
In [13], the authors presented a small signal stability analysis for a single-phase droop controlled inverter connected to a stiff AC source. In this analysis, a resistive-inductive load is connected between the inverter and the stiff AC source. The expressions to compute the active power P and reactive power Q expressions are presented as follows: P=-1 R 2 +X 2 RE 2 -REV cos δ +XEV sin δ Q=-1 R 2 +X 2 XE 2 -XEV cos δ -REV sin δ where R and X are the real and imaginary components of the line impedance. E and V are the voltage amplitude of the inverter and stiff AC source, respectively. Finally, the phase difference between both generators is defined by δ. For small disturbances, the above equations can be linearized as follows: The linearized expressions for P, Q, ω, and E are given by ΔP=k pe ΔE+k pd Δδ (5) A microgrid requires the use of power electronics devices to perform the energy conversion from one voltage level to another. For example, for an AC microgrid, the energy storage system (ESS) requires the use of a bidirectional AC-DC converter that regulates the charge or discharge process depending on the available energy. Wind turbine generators require the use of AC-AC converters to transform the amplitude and frequency to standardized voltage levels in the microgrid. Solar photovoltaic (PV) generators require the use of a DC-AC converter to inject the maximum available energy to the microgrid. Loads such as residential homes and streetlights are connected to the microgrid's common bus. The common bus may be connected to the main grid or disconnected to be operating in islanded mode. Each of the interconnections mentioned above are managed by one or more controllers to optimize the energy generation, guarantee adequate power quality, and to improve stability and robustness in the microgrid.
Optimal controllers for microgrids are aimed to achieve the best performance and/or stability margins by applying numerical optimization methods to the open-loop model. Some relevant works related to the optimal control applied to Voltage-Current (V-I) control level may be found in [3][4][5][6][7][8][9][10][11][12]. Most of these works use proportional-integral (PI) or proportional-resonant (PR) controllers with linear quadratic (LQ) control to compute an optimal state-feedback matrix that minimizes certain cost functions. Optimal LQ strategies for primary control are more difficult to implement since this kind of controllers require an open-loop model to apply numerical optimization methods.
In [13], the authors presented a small signal stability analysis for a single-phase droop controlled inverter connected to a stiff AC source. In this analysis, a resistive-inductive load is connected between the inverter and the stiff AC source. The expressions to compute the active power P and reactive power Q expressions are presented as follows: where R and X are the real and imaginary components of the line impedance. E and V are the voltage amplitude of the inverter and stiff AC source, respectively. Finally, the phase difference between both generators is defined by δ. For small disturbances, the above equations can be linearized as follows: Energies 2020, 13, 3279 3 of 29 The linearized expressions for P, Q, ω, and E are given by ∆P = k pe ∆E + k pd ∆δ (5) ∆Q = k qe ∆E + k qd ∆δ (6) ∆ω = −m∆P (7) where k pe , k pd , k qe , and k qd are the constants resulting from evaluating the linearization function on the operating point (δ e , E e , V e ) [13]. Equations (7) and (8) represent the droop control equations, where ∆ω(s)= sδ(s) is the frequency deviation around the operating point ω e . Using a low-pass filter with the cut-off frequency ω f and merging Equation (5) into (8), the following system is defined: ∆E(s)= − nω f s + ω f k qe ∆E(s)+k qd ∆δ(s) .
The analysis performed in [13] is used to determine the stability of a droop-controlled inverter connected to a stiff AC source. This is done by analyzing the resulting eigenvalues of the system generated by Equations (9) and (10). It can also be noticed that, for suitable values of m and n, the inverter frequency and voltage amplitude will converge to zero deviation from the operating point.
Following this work, Coelho et al. presented a similar small-signal stability analysis for the two parallel connected inverters sharing power between them [14]. In this work, a state-space representation of the entire linearized microgrid was developed in the dq frame. The entire system is described in (11): States ∆E di and ∆E qi are the in-phase and quadrature nominal voltage in the dq frame for the i-th inverter and ∆ω i is the frequency of each inverter. The state matrix A = M s +C s (I s +E s Y s )K s is composed of matrices that are dependent of the droop coefficients, the nominal voltages, and the nominal currents vector. Refer to [14] for a detailed definition of these matrices. Knowing the value of matrix A, the eigenvalues may be calculated to determine the stability and transient response of the entire system. The work by Coelho et al. provided an effective method for analyzing stability in microgrids using the droop method as a primary control strategy. However, this analysis does not consider the effects of the V-I control loop and does not allow to separate the droop controller and the system.
In [15], a complete microgrid was modeled using small-signal analysis. The V-I and power sharing control levels where integrated to analyze their influence on microgrid stability. The complete system was modeled in three different parts: inverter model, network model, and load model. In the inverter model, the V-I and primary droop control were considered together with the inductor-capacitorinductor (LCL) output filter dynamics. In the network model, a network with m nodes and n resistive-inductive lines was considered. In the load model, a resistive-inductive load was modeled. Each of these models was written in such a way that the complete microgrid model may integrate them depending on the number of generators, network interconnections, and loads.
The complete model was analyzed using the root locus method. It was discovered that there were three different relevant clusters in the microgrid's eigenvalues placement. This approach shows relevant information regarding microgrid stability using small signal analysis. However, the complete microgrid model relies entirely on the control topology and control constants. Generally, a dynamic system is modeled in such a way that the designer may easily couple it with a control strategy. However, in this approach, the control parameters are embedded into the microgrid model and changing them  , no formal stability analysis can be performed from an open-loop  perspective because the microgrid model can only be developed considering the closed loop system. Another important work regarding microgrid stability with droop controllers is presented in [16]. The author divides microgrid stability in three main categories: small signal stability, transient stability, and voltage stability. The small signal stability is mainly affected by the V-I and primary feedback controllers, where the control parameters affect system transient response and pole allocation. The use of feedback controllers with decentralized control methods such as droop control creates most of the small signal stability issues in islanded microgrids [16]. This stability can be improved by using robust and optimal control techniques, supplementary control loops, coordinated control, and stabilizers such as flywheels. Transient stability is mainly affected in islanded mode, were frequency and voltage amplitude may be affected without a connection to a stiff grid. Transient stability is analyzed by using Lyapunov function techniques and nonlinear system analysis [17]. In addition, transient stability can be addressed by using energy storage and load shedding methods which allow to sustain the entire system when a sudden power loss is detected. Finally, voltage stability may be caused by irregular behavior in reactive load sharing or the connection of induction motors. Voltage stability can be addressed by injecting reactive power into the microgrid and compensate the sudden voltage droop.
Another approach for stability analysis in droop controllers is performed in [18], where a dynamic phasor modeling (DPM) of the primary droop control of a microgrid was developed. The DPM allows to introduce additional terms on the imaginary axis to the mathematical model. This consideration makes the DPM of the inverter circuit more accurate than the conventional small signal analysis shown in [14]. A new active and reactive power model was developed, and its accuracy was compared to a complete order model and a small signal model. Results show adequate modeling in transient response and eigenvalue location. In addition, a virtual-frame droop control was tested with this model with more accurate results than in previous work. However, this model does not consider the V-I control loop and makes it difficult to analyze the coupling between the real and imaginary components of power, current, and impedances. This modeling could result more effective when analyzing transient responses in a complete microgrid.
In this document, a model for inverter-based grid-connected and islanded microgrids in a synchronous reference frame is presented. Both models were tested and validated in an experimental setup to demonstrate their accuracy in describing microgrid dynamics. Most of the approaches found in the literature developed the microgrid model based on the controller dynamics, which does not allow to perform an open-loop analysis such as singular value diagrams or obtaining stability margins. The aim of the proposed models is to allow designers to perform robustness and stability analysis techniques that require an open-loop model to be performed. In addition, the proposed models are able to be used to develop controllers that are based on numerical optimization methods such as linear quadratic controllers, Kalman filters, H ∞ -based controllers, model-predictive controllers, and others. The presented models are small-signal realizations that consider parameters such as frequency around the operating equilibrium point. Although the proposed models are developed for a microgrid based on inverter generators connected to a single point of common coupling (PCC), the methodology used to develop them may be used to expand the case study to more complex microgrids.
Three application scenarios are presented: non-controlled model, Linear-Quadratic Integrator (LQI) power control, and Power-Voltage (PQ/Vdq) droop-boost controller. Both controllers allow to perform stability and performance analysis methods which, unlike approaches found in the literature, can provide a wider perspective of the microgrid in islanded and grid-connected modes. Furthermore, the controlled open-loop model can be used to analyze the microgrid frequency response under disturbances in the process and noise in the sensors. The linear nature of the proposed controllers allows to compute modern controllers that rely on a precise model to obtain a controller that optimizes certain control objectives. The following sections are divided as follows: Section 2 presents the mathematical development of the proposed models; and Section 3 presents the validation of the proposed model under three different scenarios. Finally, the discussion of results is presented in Section 4.

Microgrid Model
The proposed model for this research is obtained in two stages. First, the model of each inverter connected to the main grid is used to describe dynamics in grid-connected mode. This model is also used to develop the proposed control strategy. Then, the models of all inverters are integrated in a single state-space model to describe the microgrid dynamics in islanded mode.

Model of a Single Inverter Connected to the Main Grid
The circuit used to develop the proposed model in grid-connected mode is shown in Figure 2. The output of a three-phase inverter E is driven by a Pulsed-Width Modulated (PWM) signal, which is filtered using an inductor-capacitor-inductor (LCL) output filter. The inverter is connected to a stiff voltage source V that represents the main grid. Input inductor current, capacitor voltage, and output current are denoted by I l , V c , and I o , respectively.

Microgrid Model
The proposed model for this research is obtained in two stages. First, the model of each inverter connected to the main grid is used to describe dynamics in grid-connected mode. This model is also used to develop the proposed control strategy. Then, the models of all inverters are integrated in a single state-space model to describe the microgrid dynamics in islanded mode.

Model of a Single Inverter Connected to the Main Grid
The circuit used to develop the proposed model in grid-connected mode is shown in Figure 2. The output of a three-phase inverter E is driven by a Pulsed-Width Modulated (PWM) signal, which is filtered using an inductor-capacitor-inductor (LCL) output filter. The inverter is connected to a stiff voltage source V that represents the main grid. Input inductor current, capacitor voltage, and output current are denoted by I l , V c , and I o , respectively.  The state-space model of this circuit for each phase in the ABC frame is given by It is important to note that, in order to simplify the mathematical procedure, this model does not consider non-linear phenomenon such as the switching behavior in the insulated-gate bipolar transistors (IGBT), the voltage saturation in the DC bus, nor the unbalances caused by the deviation in its components. In addition, no phenomenon related to AC-AC conversion using power transformers is considered. The state-space model (13) is obtained using the dq transformation. The state-space model transformation to the dq frame is based on the Clarke transformation and the complete mathematical development may be found in [19]. The dq transformation is performed by assuming a constant angular frequency ω c , which corresponds to the nominal angular frequency of the main grid: where E dq =[ E d E q ] T , V gdq =[ V gd V gq ] T , and: The active and reactive power injected to V gdq are defined by  The state-space model of this circuit for each phase in the ABC frame is given by It is important to note that, in order to simplify the mathematical procedure, this model does not consider non-linear phenomenon such as the switching behavior in the insulated-gate bipolar transistors (IGBT), the voltage saturation in the DC bus, nor the unbalances caused by the deviation in its components. In addition, no phenomenon related to AC-AC conversion using power transformers is considered. The state-space model (13) is obtained using the dq transformation. The state-space model transformation to the dq frame is based on the Clarke transformation and the complete mathematical development may be found in [19]. The dq transformation is performed by assuming a constant angular frequency ω c , which corresponds to the nominal angular frequency of the main grid: (13) where E dq = E d E q T , V gdq = V gd V gq T , and: Energies 2020, 13, 3279 The active and reactive power injected to V gdq are defined by The dq frame is synchronized with the main grid by using a Phase-Locked Loop (PLL). Thus, V gd represents the nominal voltage peak amplitude of the main grid, V gd and V gq = 0 [19]. This is because the PLL increases the angular frequency ω until the q component of the three-phase signal becomes zero. Thus, the output of the state-space model is used to represent the active and reactive power received by V gdq as follows: It is important to remark that the system in (13) must be discretized in order to implement it in a physical experiment using data acquisition devices and PWM control signals. To discretize it, the state must be augmented using a delay transfer function to account for the delay induced by the PWM output signal [20,21]. The resulting system is given by where A dq and B 1dq are the discrete-time state and input matrices. The auxiliary variable E −1 represents the delayed input and the discrete-time state vector in the dq frame is X[k] = V cd V cq I ld I lq I od I oq T .

Model of the Microgrid in Islanded Mode
The islanded microgrid model was used to assess the stability and robustness considering the interaction of multiple inverters connected in islanded mode to a single PCC. For the grid-connected mode, the state-space model (13) must be used for each generator individually. The circuit considered for the islanded microgrid model is shown in Figure 3. This circuit only considers interactions between inverter-based generators and the main grid from a single PCC. However, the methods proposed in this section may be used to integrate the proposed model into more complex microgrids. The integration of the proposed model with a microgrid with synchronous generators is out of the scope of this work.
Although, many types of loads may exist in microgrids, so the load is selected to be a resistiveinductive (RL) circuit because it allows to analyze the behavior of the active and reactive power. To obtain the complete microgrid model, the model for one phase of each inverter using (12) must be computed. Then, V g must be defined in terms of the output currents and load components as follows: I ot + RI ot (19) where I ot = n j=1 I oj with n representing the number of generators. Equation (19) can be reformulated to describe the resistive-capacitive behavior in order to analyze loads such as LED lighting or AC-DC converters. Nonlinear loads with harmonic currents can be modeled as a disturbance in the complete model with a known bandwidth and frequency behavior. A complete microgrid model is obtained by substituting V g from (19) into the model of each inverter (12) and combining all the models. For example, for two generators with a common RL load, the microgrid model in islanded mode for one phase is given by (20): where L dt = L(L o1 +L o2 )+L o1 L o2 , L t1 = L + L o1 , and L t2 = L + L o2 . For n inverters, replacing V g from (19) into each generator model (12) yields to a linear system with the differential equations for the output currents as shown in (21). Combining the solution of (21) with the model of each inverter (12), the complete microgrid model (22) for n inverters is obtained. The model in (22) is for each phase. However, it must be transformed to the dq frame using as in [19]: where: with 1 ≤ j ≤ n. Elements φ jk represent the coefficients of each state variable properly arranged from the solution of (21).  Although, many types of loads may exist in microgrids, so the load is selected to be a resistiveinductive (RL) circuit because it allows to analyze the behavior of the active and reactive power. To obtain the complete microgrid model, the model for one phase of each inverter using (12) must be computed. Then, V g must be defined in terms of the output currents and load components as follows: V g =LI ot +RI ot (19) where I ot = ∑ I oj n j=1 with n representing the number of generators. Equation (19) can be reformulated to describe the resistive-capacitive behavior in order to analyze loads such as LED lighting or AC-DC converters. Nonlinear loads with harmonic currents can be modeled as a disturbance in the complete model with a known bandwidth and frequency behavior. A complete microgrid model is obtained by substituting V g from (19) into the model of each inverter (12) and combining all the models. For example, for two generators with a common RL load, the microgrid model in islanded mode for one phase is given by (20): where L dt = L(L o1 + L o2 ) + L o1 L o2 , L t1 = L + L o1 , and L t2 = L + L o2 . For n inverters, replacing V g from (19) into each generator model (12) yields to a linear system with the differential equations for the output currents as shown in (21). Combining the solution of (21) with the model of each inverter (12), the complete microgrid model (22) for n inverters is obtained. The model in (22) is for each phase. However, it must be transformed to the dq frame using as in [19]:

Validation of the Proposed Models and Application Scenarios
The proposed models were validated in three scenarios: The open-loop model validation is used to assess the similarity between the mathematical model and the physical model. The grid connected LQI power controller is used to demonstrate the applicability of the model for a single inverter. Finally, the islanded PQ/Vdq LQI-based droop controller is used to assess the stability and performance of an entire microgrid in islanded mode.
For safety reasons, the open-loop model of the grid-connected and islanded microgrid were not validated in a real experiment. Instead, these models were validated using an OPAL-RT OP5700 Real-time simulator. The closed-loop models were validated using the setup shown in Figure 4. This setup uses four Danfoss 2.2 kVA inverters with LCL filters and four sensor boxes with voltage and current sensors from LEM International. These four inverters may be dynamically connected to the AC bus. The AC bus may also be dynamically connected or disconnected from the main grid using solid-state relays handled with a programmable logic controller (PLC). To implement the control algorithms, a dSPACE 1006 simulator was used to read the signals from the sensor boxes and send the 10 kHz PWM pulses via optical fiber.
For each scenario, the time responses of each inverter were compared with the mathematical model. In addition, the mathematical model and circuit responses were compared using the normalized root mean squared error (NRMSE) defined by [22]: where . indicates the Euclidian norm of a vector. Vectors y and y ref represent the time response of a measurement and its mathematical reference, respectively. The NRMSE varies between −∞ (bad fit) and 100% (perfect fit). The NRMSE is suitable for this validation because it considers the complete measurement during a specific interval of time. The NRMSE must be obtained for each state-variable and power measurement. It is expected to find certain discrepancies between both systems due to parasitic phenomenon and other neglectable nonlinear dynamics of the components that are not being considered in this work. However, parameters such as frequency response and transient response are expected to be similar in both systems [23]. To assess robustness and stability for the proposed model in each scenario, the Robust Control Toolbox from Matlab was used. The following robustness and stability analysis were performed: • Eigenvalue analysis: this analysis consists of plotting the eigenvalues of a multiple-input-multipleoutput (MIMO) transfer function G(z) in the complex z plane to check whether they remain inside the unit circle. If some of the eigenvalues are located outside the unit circle, it means that the system or its variations are unstable by nature. Eigenvalue location may also provide information about transient response. • Stability margin analysis: the disk margin method is used for estimating structured robustness under multiplicative uncertainties for MIMO systems using negative feedback [24]. The disk-based margins are calculated considering all loop interactions. Results from this analysis provide a more conservative information about structured gain and phase margins. • Singular value diagrams (SVD): the singular value plot is commonly used to analyze the frequency response of MIMO systems [25]. This plot shows the frequency response of the maximum and minimum singular values of a MIMO transfer function G(z). This way, some performance bounds may be established for the controlled closed-loop system.  For each scenario, the time responses of each inverter were compared with the mathematical model. In addition, the mathematical model and circuit responses were compared using the normalized root mean squared error (NRMSE) defined by [22]: where ‖.‖ indicates the Euclidian norm of a vector. Vectors y and y ref represent the time response of a measurement and its mathematical reference, respectively. The NRMSE varies between −∞ (bad fit) and 100% (perfect fit). The NRMSE is suitable for this validation because it considers the complete measurement during a specific interval of time. The NRMSE must be obtained for each state-variable and power measurement. It is expected to find certain discrepancies between both systems due to parasitic phenomenon and other neglectable nonlinear dynamics of the components that are not being considered in this work. However, parameters such as frequency response and transient response are expected to be similar in both systems [23]. To assess robustness and stability for the proposed model in each scenario, the Robust Control Toolbox from Matlab was used. The following robustness and stability analysis were performed:

Scenario 1: Open-Loop Models Validation
To demonstrate the effectiveness of the proposed models, a microgrid scenario with three inverter-based generators and an RL load was proposed. The parameter specifications for the microgrid are summarized in Table 1. To obtain the model of the microgrid in grid-connected mode, the component values were evaluated in (13) for each inverter. Sampling frequency was defined to be f s = 10 kHz according to the Shannon sampling theorem [26]. The three models were discretized and augmented with delay blocks using (18). This resulted in three independent models. The complete microgrid model in islanded mode was obtained by merging the grid-connected models and using (21) and (22). The resulting model for one phase of the islanded microgrid with three generators and a common RL load is shown in (26). This model was transformed to the dq frame as in [19]. Component values from Table 1 were evaluated and the model was discretized. Finally, the discretized model was augmented to account for the PWM delay (18). This resulted in a state-space system (26) with six inputs, six outputs, and a state vector with 24 variables given by where the subscript dq represents the direct and quadrature component and E −1jdq represents the delayed input of inverter j: where L dt = L(L o1 L o2 + L o1 L o3 + L o2 L o3 + L o1 L o2 L o3 ), L d1 = LL o2 + L o2 L o3 + LL o3 , L d2 = LL o1 +L o1 L o3 + LL o3 , and L d3 = LL o1 + L o1 L o2 + LL o2 .
Once an open-loop state-space model of the three-phase inverter-based generator was obtained, it was desired to analyze the performance, stability, and robustness characteristics such as phase margin, gain margin, eigenvalue structure, etc. Robustness and stability analyses were performed for the grid-connected and islanded models. To perform the robustness and stability analyses in grid-connected mode, the model of each inverter was analyzed separately. The discrete transfer function for the i-th inverter is given by where A dqi , B 1dqi , and C dqi are the discrete-time form of the i-th inverter state, input, and output matrices, respectively. The input is the control effort E dq and the output is the active and reactive power of the i-th inverter Y. Similarly, to perform a robustness and stability analysis in islanded mode, the following discrete-time transfer function of the microgrid is used: where A µG and B µG are the discrete-time state and input matrices from the transformed to the dq frame. The microgrid output matrix is given by C µG = diag(C dq1 , C dq2 , . . . , C dqn ). The input is the control efforts and the output is the power vector of all the inverters of the microgrid. To assess the robustness and stability under component variations, the Robust Control Toolbox from Matlab was used to generate instances of G µG (z) and G i (z) with randomized variations in the components [23]. For these analyses, the components in the LCL filters were defined as uncertain elements with a uniform variation of 30% around nominal parameter values shown in Table 1. Although circuit components are not expected to be more than 20% deviated from their nominal values before being considered defective, the variation was selected to be around 30% in order to test for a worst-case manufacturing scenario or worst-case component deterioration. The distribution of uncertain elements was selected to be uniform in order to have the same probability of obtaining a certain deviation from the nominal value. This was to analyze the interactions between the extreme deviations including positive and negative values around the nominal point. Stability analyses found in the literature for V-I or primary control are based on varying one parameter at a time and observing the variations in the eigenvalues location [9,14,[27][28][29][30]. Analyzing random variations in components gives a more conservative notion of stability and robustness because this method considers all the variations at the same time. Considering that a uniform deviation is used, 20 instances of each G µG (z) and G i (z) were created based on parameter variations. Considering positive and negative deviations, this number of deviations will provide a mean deviation of 3% between each set of components, which is adequate for analyzing the sensitivity to parameter variations.
As the open-loop models do not contain any controller to regulate the current spikes nor phase deviations, this could cause inverters to trip or even having a safety issue if the models are validated in a physical experiment. Thus, their validation can only be performed using real-time simulation tools. To validate the accuracy of the mathematical model of an inverter connected to the main grid, the simulation of the circuit shown in Figure 2 was computed in parallel with its mathematical model G i (z). Similarly, to validate the accuracy of the mathematical model of an islanded microgrid, the simulation of the microgrid scheme shown in Figure 3 was computed in parallel with its mathematical model G µG (z). For both validations (grid-connected and islanded mode), the same input signal was used on the mathematical model and the simulated circuit as shown in Figure 5. The three-phase reference generator produces step changes in amplitude in order to compare transient responses. Each inverter was simulated using an OPAL OP5700 real-time simulator with the ARTEMiS library for power electronics devices from Opal-RT Technologies™ [31]. The mathematical solver of this library runs accurate simulations of power electronics devices, such as the IGBT transistors used in three-phase inverters.

Grid-Connected Inverter Model
To validate the mathematical model (13), the LCL component values for Inverter 1 were used. Once the Inverter 1 model was validated, it was assumed that (13) was adequate in describing the dynamics of any grid-connected inverter such as Inverters 2 or 3.
For this experiment, the inverter output voltage E and main grid voltage V g started with the same nominal amplitude and phase. At t = 0.025s, the inverter output amplitude was duplicated to a peak value of 240√2 and returned to the original value at t = 0.035s. Figure 6 shows the active and

Grid-Connected Inverter Model
To validate the mathematical model (13), the LCL component values for Inverter 1 were used. Once the Inverter 1 model was validated, it was assumed that (13) was adequate in describing the dynamics of any grid-connected inverter such as Inverters 2 or 3.
For this experiment, the inverter output voltage E and main grid voltage V g started with the same nominal amplitude and phase. At t = 0.025 s, the inverter output amplitude was duplicated to a peak value of 240 √ 2 and returned to the original value at t = 0.035 s. Figure 6 shows the active and reactive power values for the mathematical model and circuit. Zoomed views in Figure 6 show that active and reactive power for the mathematical model and circuit have similar dynamics. However, there are small high-frequency oscillations in the power of the circuit. These oscillations are generated by IGBT transistor switching at a frequency of 10 kHz.

Calculator Generator
State-Space Model xss(k) Figure 5. Proposed validation of the integrated state-space model of the inverter-based generator.

Grid-Connected Inverter Model
To validate the mathematical model (13), the LCL component values for Inverter 1 were used. Once the Inverter 1 model was validated, it was assumed that (13) was adequate in describing the dynamics of any grid-connected inverter such as Inverters 2 or 3.
For this experiment, the inverter output voltage E and main grid voltage V g started with the same nominal amplitude and phase. At t = 0.025s, the inverter output amplitude was duplicated to a peak value of 240√2 and returned to the original value at t = 0.035s. Figure 6 shows the active and reactive power values for the mathematical model and circuit. Zoomed views in Figure 6 show that active and reactive power for the mathematical model and circuit have similar dynamics. However, there are small high-frequency oscillations in the power of the circuit. These oscillations are generated by IGBT transistor switching at a frequency of 10 kHz.    The NRMSE value was also analyzed for the shared power and the state vector in the dq frame. Figure 8 shows that the fitting values are above 95% in all the state variables except the input inductor current, which is about 78% on the q component of the input inductor current. This is produced by the 10 KHz switching noise of the PWM signal, which was not considered in the proposed model. These results validate the accuracy of the proposed model for the grid-connected inverter. The NRMSE value was also analyzed for the shared power and the state vector in the dq frame. Figure 8 shows that the fitting values are above 95% in all the state variables except the input inductor current, which is about 78% on the q component of the input inductor current. This is produced by the 10 KHz switching noise of the PWM signal, which was not considered in the proposed model. These results validate the accuracy of the proposed model for the grid-connected inverter. Open-loop eigenvalues of nominals G 1 (z), G 2 (z), and G 3 (z) and their variations are shown in Figure 9. As seen in the zoomed view, the eigenvalues remain inside the unit circle, which implies that all the inverters were stable in grid-connected mode without a controller. However, after analyzing the stability margins, none of the open-loop models were closed-loop stable using unit feedback.  The NRMSE value was also analyzed for the shared power and the state vector in the dq frame. Figure 8 shows that the fitting values are above 95% in all the state variables except the input inductor current, which is about 78% on the q component of the input inductor current. This is produced by the 10 KHz switching noise of the PWM signal, which was not considered in the proposed model. These results validate the accuracy of the proposed model for the grid-connected inverter. Open-loop eigenvalues of nominals G 1 (z), G 2 (z), and G 3 (z) and their variations are shown in Figure 9. As seen in the zoomed view, the eigenvalues remain inside the unit circle, which implies that all the inverters were stable in grid-connected mode without a controller. However, after analyzing the stability margins, none of the open-loop models were closed-loop stable using unit feedback. Open-loop eigenvalues of nominals G 1 (z), G 2 (z), and G 3 (z) and their variations are shown in Figure 9. As seen in the zoomed view, the eigenvalues remain inside the unit circle, which implies that all the inverters were stable in grid-connected mode without a controller. However, after analyzing the stability margins, none of the open-loop models were closed-loop stable using unit feedback.
Singular value diagrams of the nominal G 1 (z), G 2 (z), and G 3 (z) and their variations are shown in Figure 10. According to these diagrams, frequency responses of Inverters 2 and 3 are similar, with variations on their resonant and crossover frequencies. Moreover, Inverter 1 has the fastest dynamics followed by Inverters 2 and 3, respectively. Singular value diagrams of the nominal G 1 (z), G 2 (z), and G 3 (z) and their variations are shown in Figure 10. According to these diagrams, frequency responses of Inverters 2 and 3 are similar, with variations on their resonant and crossover frequencies. Moreover, Inverter 1 has the fastest dynamics followed by Inverters 2 and 3, respectively.

Islanded Microgrid Model
For the islanded mode, the scenario was simulated using an OPAL OP5700 real-time simulator with the ARTEMiS library for power electronics devices [31]. The ARTEMiS library was used to perform accurate simulations that considered the switching behavior of power electronic devices. To validate the mathematical model, the LCL component values from Table 1 were used. For this experiment, the output voltage of the three inverters and the main grid started with the same nominal amplitude and phase. At t = 0.025s, the inverters' output amplitude was duplicated to a peak value

Islanded Microgrid Model
For the islanded mode, the scenario was simulated using an OPAL OP5700 real-time simulator with the ARTEMiS library for power electronics devices [31]. The ARTEMiS library was used to perform accurate simulations that considered the switching behavior of power electronic devices. To validate the mathematical model, the LCL component values from Table 1 were used. For this experiment, the output voltage of the three inverters and the main grid started with the same nominal amplitude and phase. At t = 0.025s, the inverters' output amplitude was duplicated to a peak value Figure 10. Singular values diagram for G 1 (z), G 2 (z), and G 3 (z) and their variations.

Islanded Microgrid Model
For the islanded mode, the scenario was simulated using an OPAL OP5700 real-time simulator with the ARTEMiS library for power electronics devices [31]. The ARTEMiS library was used to perform accurate simulations that considered the switching behavior of power electronic devices.
To validate the mathematical model, the LCL component values from Table 1 were used. For this experiment, the output voltage of the three inverters and the main grid started with the same nominal amplitude and phase. At t = 0.025 s, the inverters' output amplitude was duplicated to a peak value of 240 √ 2 and returned to the original value at t = 0.035 s. Figure 11 shows the active and reactive power waveforms for the mathematical model and circuit. State vector waveforms in the dq frame are shown in Figure 12 and in the ABC frame in Figure 13. The active and reactive power for the mathematical model and circuit have similar dynamics. As detailed in zoomed views, input inductor currents showed switching oscillations. These oscillations were caused by the IGBT transistors switching at of 240√2 and returned to the original value at t = 0.035s. Figure 11 shows the active and reactive power waveforms for the mathematical model and circuit. State vector waveforms in the dq frame are shown in Figure 12 and in the ABC frame in Figure 13. The active and reactive power for the mathematical model and circuit have similar dynamics. As detailed in zoomed views, input inductor currents showed switching oscillations. These oscillations were caused by the IGBT transistors switching at a frequency of 10 kHz. However, state vector dynamics show similar behavior in steady state and during transient response. Figure 11. Power waveforms for the mathematical model and the circuit in islanded mode. Figure 11. Power waveforms for the mathematical model and the circuit in islanded mode.
The NRMSE value was also analyzed for the shared power and the state vector in the dq frame. Figure 14 shows that fitting values are above 98% in all the state variables except for the input inductor currents, which decrease due to the presence of the 10 kHz PWM switching. These results validate the accuracy of the proposed model for the islanded microgrid.
Open-loop eigenvalues of G µG (z) and its variations are shown in Figure 15. All the eigenvalues remain inside the unit circle, which implies that the open-loop microgrid is stable in grid-connected mode without a controller. However, after analyzing stability margins, none of the open-loop models were closed-loop stable using a unit feedback. Finally, the singular value diagrams of the nominal G µG (z) and its variations are shown in Figure 16. These diagrams show similar behavior compared to Figure 10. However, there is an additional response below 0 dB that is related to the RL load.

Scenario 2: Grid-Connected LQI Power Controller
The power controller for the grid-connected inverter was developed using (18) with the component values of Inverter 1 from Table 1. The control scheme is shown in Figure 17. To synchronize each inverter with the AC bus, a second order generalized integrator (SOGI-PLL) is implemented as shown in Figure 23.  The NRMSE value was also analyzed for the shared power and the state vector in the dq frame. Figure 14 shows that fitting values are above 98% in all the state variables except for the input inductor currents, which decrease due to the presence of the 10 kHz PWM switching. These results validate the accuracy of the proposed model for the islanded microgrid.  The NRMSE value was also analyzed for the shared power and the state vector in the dq frame. Figure 14 shows that fitting values are above 98% in all the state variables except for the input inductor currents, which decrease due to the presence of the 10 kHz PWM switching. These results validate the accuracy of the proposed model for the islanded microgrid.  Open-loop eigenvalues of G μG (z) and its variations are shown in Figure 15. All the eigenvalues remain inside the unit circle, which implies that the open-loop microgrid is stable in grid-connected mode without a controller. However, after analyzing stability margins, none of the open-loop models were closed-loop stable using a unit feedback. Finally, the singular value diagrams of the nominal G μG (z) and its variations are shown in Figure 16. These diagrams show similar behavior compared to Figure 10. However, there is an additional response below 0 dB that is related to the RL load.   Open-loop eigenvalues of G µG (z) and its variations are shown in Figure 15. All the eigenvalues remain inside the unit circle, which implies that the open-loop microgrid is stable in grid-connected mode without a controller. However, after analyzing stability margins, none of the open-loop models were closed-loop stable using a unit feedback. Finally, the singular value diagrams of the nominal G µG (z) and its variations are shown in Figure 16. These diagrams show similar behavior compared to Figure 10. However, there is an additional response below 0 dB that is related to the RL load. Figure 15. Eigenvalues of the nominal G μG (z) and its variations. Figure 15. Eigenvalues of the nominal G µG (z) and its variations.
Energies 2020, 13, x FOR PEER REVIEW 18 of 30 Figure 16. Singular values diagram for G μG (z) and its variations.

Scenario 2: Grid-Connected LQI Power Controller
The power controller for the grid-connected inverter was developed using (18) with the component values of Inverter 1 from Table 1. The control scheme is shown in Figure 17. To Figure 16. Singular values diagram for G µG (z) and its variations.

Scenario 2: Grid-Connected LQI Power Controller
The power controller for the grid-connected inverter was developed using (18) with the component values of Inverter 1 from Table 1. The control scheme is shown in Figure 17. To synchronize each inverter with the AC bus, a second order generalized integrator (SOGI-PLL) is implemented as shown in Figure 23.

LQI Controller
The LQI controller is designed to minimize the tracking error by computing the integral of the error vector ε = i (Cx i −r i ). The augmented model that includes the tracking error is given by (29) Defining the control law as E dq = −K t X T , the closed-loop model is given by To compute the LQI controller, the following cost function is defined: where Q p and R p are some positive-definite and semi-positive-definite weighting matrices, respectively. The output matrix results by the augmentation of (17): The LQI feedback matrix K t is given by where S p is the solution to the algebraic Ricatti equation [32]:

Performance Analysis
To identify the adequate values of Q p and R p , a stability analysis was performed using open-loop singular value diagrams, closed-loop eigenvalue plots, and closed-loop step responses. It was desired that the closed-loop system reached a steady state in less than 0.005s with a damping ratio less than 0.7. The closed-loop eigenvalues are given by For illustration purposes, the discrete closed-loop eigenvalues were transformed into continuous time using z = e sT . Closed-loop eigenvalues were calculated for different values of q p in Q p = diag 1 1 1 1 100 100 1 1 q p q p and R p = r p I 2×2 . From the eigenvalue plot shown in Figure 18, it can be noticed that the eigenvalues with q p = 9000 are more suitable to fulfill design requirements.

The open-loop transfer function is given by
After selecting Q p , the singular value plot and the step-response plot were analyzed by varying r p . For this analysis, it was desired to attenuate the high-frequency noise in the power measurement. The high-frequency noise is considered a disturbance in the process since it is produced by the transistors. To attenuate the process noise, it is desired for the open-loop SVD bandwidth to be as high as possible without affecting the step-response requirements [25]. Figure 19 shows that a suitable response is achieved for r p =0.0001. The resulting state-feedback matrix is given by The open-loop transfer function is given by After selecting Q p , the singular value plot and the step-response plot were analyzed by varying r p . For this analysis, it was desired to attenuate the high-frequency noise in the power measurement. The high-frequency noise is considered a disturbance in the process since it is produced by the transistors. To attenuate the process noise, it is desired for the open-loop SVD bandwidth to be as high as possible without affecting the step-response requirements [25]. Figure 19 shows that a suitable response is achieved for r p = 0.0001. The resulting state-feedback matrix is given by transistors. To attenuate the process noise, it is desired for the open-loop SVD bandwidth to be as high as possible without affecting the step-response requirements [25]. Figure 19 shows that a suitable response is achieved for r p =0.0001. The resulting state-feedback matrix is given by

Experimental Results
To assess the performance of the proposed model and to validate the closed-loop model, the experimental setup from

Experimental Results
To assess the performance of the proposed model and to validate the closed-loop model, the experimental setup from Figure 4 was used. The experimental response was compared against the mathematical response of the closed-loop model under a step reference of 400 W and 400 VAr. As the closed-loop inputs from (30) include the grid voltage, the acquired voltage measurement from the power authority was transformed to the dq frame and was used as the input of the closed-loop mathematical model.
Experimental and mathematical values for the active and reactive power are shown in Figure 20. As the power measurement contains high-frequency noise generated by the PWM switching, a first-order low-pass filter with a bandwidth of ω c = 10 rad/s was used. Notice that, unlike classical droop controllers, this filter is only used for visualization purposes and is not included in the control loop.  Figure  20. As the power measurement contains high-frequency noise generated by the PWM switching, a first-order low-pass filter with a bandwidth of ω c = 10 rad/s was used. Notice that, unlike classical droop controllers, this filter is only used for visualization purposes and is not included in the control loop. Results from Figure 20 demonstrate that the performance of the proposed controller is adequate. Moreover, the NRMSE for the active power is 98.89% and 97.23% for the reactive power. This demonstrates that the mathematical closed-loop model and that the experimental results are alike. Results from Figure 20 demonstrate that the performance of the proposed controller is adequate. Moreover, the NRMSE for the active power is 98.89% and 97.23% for the reactive power. This demonstrates that the mathematical closed-loop model and that the experimental results are alike.

Scenario 3: Islanded PQ/Vdq LQI-Based Droop-Boost Controller
To demonstrate the effectiveness and the applicability of the islanded model, a microgrid scenario with three inverter-based generators and two loads was proposed, as shown in Figure 21. Connection switches were located at the output of each inverter, at the input to each load, and at the point of connection with the main grid. Without loss of generality, all three inverters had the same LCL filter components to simplify the design procedure. However, the design procedure shown in this section is also suitable for microgrids with different LCL filter components. The parameter specification for the microgrid scenario is shown in Table 2.

Controller Design
The controller presented in this section is designed for each inverter independently. The control scheme for one inverter is shown in Figure 22. Each controller contains an internal LQI controller to regulate the output voltage Vcdq. The voltage reference of the LQI controller V cref is generated by the PQ/Vdq droop-boost controller according to the active and reactive power demanded by the load. The AC bus reference is set to nominal values such that V gref = V gd 0

Controller Design
The controller presented in this section is designed for each inverter independently. The control scheme for one inverter is shown in Figure 22. Each controller contains an internal LQI controller to regulate the output voltage V cdq . The voltage reference of the LQI controller V cref is generated by the PQ/Vdq droop-boost controller according to the active and reactive power demanded by the load. The AC bus reference is set to nominal values such that V gref = V gd 0 . To synchronize each inverter with the AC bus, a second order generalized integrator (SOGI-PLL) is implemented as shown in Figure 23 [33]. The output of the SOGI-PLL is used to perform the dq transformation of the input and output signals of the LQI controller. When the grid connection is lost, the operating frequency of the microgrid drops and the frequency restoration loop is activated. The frequency restoration loop integrates the frequency error and compensates the PLL operating frequency . This way, the microgrid frequency returns to nominal values in islanded mode. The expression of the output frequency of the SOGI-PLL with the proposed frequency restoration loop is given by where F g is zero when the grid connection is lost and one when the grid is engaged. When synchronized, it may be assumed that V gq = 0. Thus, in steady state ω ' ≈ω c .
θ' V ABC SOGI PLL Figure 23. Modified SOGI-PLL. To synchronize each inverter with the AC bus, a second order generalized integrator (SOGI-PLL) is implemented as shown in Figure 23 [33]. The output of the SOGI-PLL is used to perform the dq transformation of the input and output signals of the LQI controller. When the grid connection is lost, the operating frequency of the microgrid drops and the frequency restoration loop is activated. The frequency restoration loop integrates the frequency error and compensates the PLL operating frequency ω . This way, the microgrid frequency returns to nominal values in islanded mode. The expression of the output frequency of the SOGI-PLL with the proposed frequency restoration loop is given by

LQI Controller
where F g is zero when the grid connection is lost and one when the grid is engaged. When synchronized, it may be assumed that V gq = 0. Thus, in steady state ω ≈ ω c .

LQI Controller
Similar to Section 3.2.2, the LQI controller was designed using the augmented model (29). However, the output matrix is now defined to track the voltage error instead of output power as follows: The selection of Q p and R p was made following the same procedure shown in Section 3.2.2 with a desired settling time of 0.1 s and a damping ratio of 0.7. These matrices are given by dq transformation of the input and output signals of the LQI controller. When the grid connection is lost, the operating frequency of the microgrid drops and the frequency restoration loop is activated. The frequency restoration loop integrates the frequency error and compensates the PLL operating frequency . This way, the microgrid frequency returns to nominal values in islanded mode. The expression of the output frequency of the SOGI-PLL with the proposed frequency restoration loop is given by where F g is zero when the grid connection is lost and one when the grid is engaged. When synchronized, it may be assumed that V gq = 0. Thus, in steady state ω ' ≈ω c .

PQ/Vdq Droop-Boost Controller
The feedback control law for the PQ/Vdq droop-boost controller is given by where: Notice that C pq is the same output matrix used in (32). This is to represent the output power as the product C pq X T . Moreover, the matrix D is known as the droop-boost matrix, which droops V cd with the active power and boosts V q with reactive power. V ref is the voltage reference of the islanded microgrid.
To analyze the performance considering voltage and power dynamics, it was desired to integrate both K t and K d into a single state-feedback matrix K INV . Thus, the new feedback control law must integrate the LQI and the PQ/Vdq droop-boost control laws. The new feedback control law is defined by Evaluating (41) into (29) yields to the closed-loop model of the inverter connected to the main grid: where B U = [B 1T B int ]. To analyze the closed-loop microgrid, the islanded microgrid model is defined by using component values from Table 2 in (26). Then, the model is transformed to the dq frame using the transformation shown in [19]. Finally, the microgrid model is discretized and augmented with delay blocks for each input channel using (18). The resulting discrete microgrid model is given by where A µGd and B µGd are the discrete-time form of A µG and B µG augmented with delay as follows: Matrices B µGi represent the discrete form of B µG for the i-th inverter. Matrices A µGij are the 8 × 8 matrices that form the discrete form of A µG as follows: The microgrid state-vector is defined by X µG = X 1 E −11 X 2 E −12 X T3 E −13 from (18).

The input of the microgrid is defined by E
Following the same procedure, the discrete microgrid model is augmented with the integral of the tracking error for the LQI controller as in (29) as follows: where r µG is the voltage reference of the LQI controller. Matrices A µGd , B µGd , and B intµG are given by ; r µG = r 1dq r 2dq r 3dq .
Equation (48) can be rewritten as Then, following the same procedure for the grid-connected closed-loop model (44), the closed-loop microgrid model is defined by where: The closed-loop microgrid model (51) can now be used for analyzing the eigenvalue location and step response of an islanded microgrid using the PQ/Vdq droop-boost controller. The open-loop model can be used to analyze the singular value plot of the controlled microgrid to analyze the frequency response under disturbances. For this experiment, the three inverters have the same rated power. However, for visualization purposes, the droop matrix relation was initially defined as D 2 = 0.9D 1 , and D 3 = 0.95D 1 . The droop matrix for Inverter 1 was defined as D 1 = d 1 0 0 −1 . The closed-loop eigenvalues for the islanded microgrid for different values of d are shown in Figure 24. As d increases, the closed-loop eigenvalues tend to the right half plane indicating instability. To analyze the transient response and frequency response, the singular value diagram is shown in Figure 25. It can be noticed that as d increases, the bandwidth of the open-loop response increases, which makes the system more susceptible to process noise. After analyzing the performance using the three different methods, the droop gains shown in Table 3 were selected:  To analyze the transient response and frequency response, the singular value diagram is shown in Figure 25. It can be noticed that as d increases, the bandwidth of the open-loop response increases, which makes the system more susceptible to process noise. After analyzing the performance using the three different methods, the droop gains shown in Table 3 were selected: To analyze the transient response and frequency response, the singular value diagram is shown in Figure 25. It can be noticed that as d increases, the bandwidth of the open-loop response increases, which makes the system more susceptible to process noise. After analyzing the performance using the three different methods, the droop gains shown in Table 3 were selected:

Experimental Results
To assess the performance of the proposed model and to validate the closed-loop model, the experimental setup from Figure 4 was used. The experimental response was compared against the mathematical response of the closed-loop model under load changes.
Step changes were analyzed in the mathematical model by generating two different closed-loop models (one for each total load value). Then, when Load 2 was connected in the experiment, that signal swapped the mathematical model and the state of the Load 1 mathematical model became the initial state of the mathematical model for Load 2. Experimental results for this experiment are presented in Figure 26. To assess the performance of the proposed model and to validate the closed-loop model, the experimental setup from Figure 4 was used. The experimental response was compared against the mathematical response of the closed-loop model under load changes.
Step changes were analyzed in the mathematical model by generating two different closed-loop models (one for each total load value). Then, when Load 2 was connected in the experiment, that signal swapped the mathematical model and the state of the Load 1 mathematical model became the initial state of the mathematical model for Load 2. Experimental results for this experiment are presented in Figure 26. It can be seen that although the power responses have slight discrepancies, the dynamic response is similar between the experiment and the mathematical simulation. These discrepancies are generated by deviations on the LCL components and the loads. Results from this experiment demonstrate the effectiveness of the proposed controller and the accuracy of the proposed model.

Discussion
In this work, a synchronous model for grid-connected and islanded microgrids is presented. Both models were tested and validated in an experimental setup to demonstrate their accuracy in describing microgrid dynamics. In addition, three scenarios were presented: non-controlled model, LQI power control, and PQ/Vdq droop-boost controller. Both controllers allow to perform stability and performance analysis methods which, unlike approaches found in the literature, can provide a wider perspective of the microgrid in islanded and grid-connected modes. Furthermore, the controlled open-loop model can be used to analyze the microgrid frequency response under disturbances in the process and noise in the sensors. Most of the approaches found in the literature develop the microgrid model based on the controller dynamics, which does not allow to perform open-loop analysis such as singular value diagrams or obtaining stability margins.
The limitations of the proposed models are based on the fact that these models do not include frequency dynamics as other approaches found in literature do. The frequency of the microgrid is It can be seen that although the power responses have slight discrepancies, the dynamic response is similar between the experiment and the mathematical simulation. These discrepancies are generated by deviations on the LCL components and the loads. Results from this experiment demonstrate the effectiveness of the proposed controller and the accuracy of the proposed model.

Discussion
In this work, a synchronous model for grid-connected and islanded microgrids is presented. Both models were tested and validated in an experimental setup to demonstrate their accuracy in describing microgrid dynamics. In addition, three scenarios were presented: non-controlled model, LQI power control, and PQ/Vdq droop-boost controller. Both controllers allow to perform stability and performance analysis methods which, unlike approaches found in the literature, can provide a wider perspective of the microgrid in islanded and grid-connected modes. Furthermore, the controlled open-loop model can be used to analyze the microgrid frequency response under disturbances in the process and noise in the sensors. Most of the approaches found in the literature develop the microgrid model based on the controller dynamics, which does not allow to perform open-loop analysis such as singular value diagrams or obtaining stability margins.
The limitations of the proposed models are based on the fact that these models do not include frequency dynamics as other approaches found in literature do. The frequency of the microgrid is assumed static and all inverters are assumed to be synchronized with the common AC bus. Thus, no frequency stability analysis can be performed for the islanded microgrid model. To perform this, the models must include linearized frequency dynamics and their effects on the reactive components of the microgrid. This is seen as a future research direction of this work. Moreover, the mathematical models assume small deviations from the operating point in the AC bus and do not consider certain non-linear dynamics such as transistor switching, DC bus saturation, nor unbalances. Thus, results may have a slight deviation for transient analysis.
The controllers developed in this work are different from the classical droop controller, where the frequency is reduced with the increase in active power and the amplitude is reduced with the reactive power. This implies that frequency does not have considerable distortion, preserving microgrid power quality. In addition, most of the control computations are linear, which allows to perform a stability analysis for state-space controllers. The power is assumed to be linear as the voltage in the AC bus must be close to the nominal values according to power authority regulations. However, further analysis must be done in order to integrate the proposed controllers with synchronous machines or inverters with classical droop controllers, which consider frequency dynamics.
It is important to remark that the proposed models and the application scenarios are intended to be a tool that help readers to implement non-classical power controllers and analyze their stability, robustness, frequency response, and dynamic response. In addition, the proposed models allow readers to implement linear modern controllers that rely on numerical methods such as LQR, Kalman filters, robust controllers and model predictive control. Furthermore, as the model includes the dynamics of power, it could be used to compute optimal control gains for the PQ-Vdq droop-boost controller. This could increase the robustness and stability of the islanded microgrid.
Finally, the methods presented to develop the proposed models can be used in similar approaches to extend the application scenarios to more complex scenarios where other types of generators are integrated. However, special considerations must be done to include the frequency dynamics in the mathematical model.