An MPC Approach for Grid-Forming Inverters: Theory and Experiment

Microgrids (MGs) interest is growing very fast due to the environment urgency and their capability to integrate renewable energy in a flexible way. In particular, islanded MGs in which distributed energy resources (DERs) are connected to the infrastructure with power electronic converters have attracted the interest of many researchers of both academia and industry because management, control and protection of such systems is quite different from the case of traditional networks. According to their operation mode, MGs that power electronic converters can be divided into grid-forming, grid-feeding and grid-supporting inverters. In particular, grid forming inverters are asked to impose voltage and frequency in the MG. This paper aims to propose a model predictive control (MPC) based approach for grid-forming inverters in an islanded MG. The MPC strategy is implemented because of its capability to define the optimal control actions that contemporarily track the desired reference signals and accounts for equality and inequality constraints. The overall problem formulation (objective function and relevant constraints) is described step by step and considers the specificity of the considered DC source. The proposed approach allows for the obtaining of very good results in terms of readiness against disturbances, even if it requires being fed only by local measurements. In order to validate the developed method, this paper proposes an experimental validation of the designed MPC controller in order to show its correct operation on a real system in a power hardware in the loop set-up using a rapid control prototyping approach.


Introduction
The interest in microgrids (MGs) is growing very fast as they represent a possible solution to a complete integration of renewable energy sources (RES) thanks to their flexibility [1][2][3]. The massive number of energy sources connected to the grid through power electronics converters is changing the classic paradigm of the electric power systems [4,5]. This evolution claims for new strategies to ensure power-sharing [6], voltage and frequency control [7] and grid support [8,9].
Inverters that interface distributed energy resources (DERs) to the MG can be classified according to one of the three following operation ways: grid-feeding, grid-forming and grid-supporting power converters [10][11][12].
Grid-feeding converters are designed to supply a specified value of active and reactive power. This operation allows for the considering of the controlled DER as an ideal current source connected to the grid in parallel with high impedance.
Grid-forming converters can be represented as an ideal AC voltage source with a low impedance in series, defining the frequency of the MG and the voltage amplitude at its terminals.
Finally, grid-supporting converters can be either seen as a current or voltage sources in which the current (voltage) is selected according to specified control laws (e.g., droop characteristic [13], voltage/reactive power control curves [14,15], active power/reactive power characteristic [14,15] and so on). Figure 1 schematically represents these operation modes. The traditional control scheme for a grid-forming converter can be found in Figure 2. It is composed of two internal loops regulated by proportional-integrator (PI) controllers [16]. In this control scheme, the amplitude of the voltage at the point of common coupling (PCC) and current are measured and transformed in the dq reference frame by applying the park transformation and comparing to reference values as shown in Figure 2. According to Figure 2, V* represents the AC voltage reference at PCC, v d* and v q* are its d and q components, respectively, while v d (v q ) is the measured direct (quadrature) axis voltage; i d (i q ) is the measured direct (quadrature) axis current and i d* (i q* ) is the corresponding reference; finally U d (U q ) is the d (q) component inverter AC side voltage.
The current trend in developing new grid-forming strategies is to emulate the behavior of a traditional synchronous generator, indeed in that way it is possible to (i) simplify their integration in MG providing virtual inertia and/or to (ii) bring them to behave as similar as possible to something that is well-know and spread [17]; thus it results in the so-called virtual synchronous machine (VSM) control strategy. Converters managed with this kind of control can be used both in island and connected MGs. These strategies use the measurement of the AC variables to detect disturbance, voltage drops or frequency deviation and, through suitable command laws implemented in their own control, make the inverter mimic the synchronous machine. Since VSMs are very flexible, the authors of [18] proposed and verified an approach to mitigate voltage and frequency deviations in MG with synchronous generators. In [19], VSM and droop control dynamics are compared to exploring swing equations. In [20], the authors propose a control strategy in which, using an internal model for the harmonic oscillator, the converter dynamic results increased and exactly matched with the synchronous machine one. Another important control family is composed by controllers that use sliding mode control to improve the transient response [16], applying it in for the inner current control loop [21,22].
Model predictive control (MPC) is also used with success in many fields of applications [23] thanks to its ability to manage multi-objective optimization problems in constrained systems. In [24], authors propose an MPC regulator able to optimize energy and power flows between MGs. In [25], an energy management optimization based on a distributed MPC is proposed; then in [26] a centralized MPC regulator for dynamic optimal power flow between energy storage systems is developed. Finally, MPC has also been used to ensure power grids transient stability [27]. Paper [28] proposes an MPC primary regulator for islanded MGs to control the output voltage of each inverter; instead, in [29] MPC is exploited with sliding mode (SM) to control the inverter output voltage and to limit the current in overload scenarios. Another interesting use of MPC for MGs voltage control is described in [30] where a distributed MPC control is proposed, in which each unit solves its own cost function. Reference [30] proposes a new way to implement secondary control for voltage restoration but there is no novelty for primary control (a simple droop logic is used) and there is no possibility to avoid communication among the units.
Another MPC based approach is provided in [31] where the traditional MPC is coupled with a finite control set MPC, a strategy very common in the power control field, in order to improve the stability and to reduce the total harmonic distortion. An alternative interesting development is provided by [32], in which four MPC implementations are proposed. In this frame, MPC is used with a minimal prediction horizon (one step forward), in fact MPC is used just to provide a better estimation of voltage measurement; it acts similarly to a feedforward compensation. For this reason, the cost function has a very simple formulation The present paper aims at adopting the MPC control strategy to make the inverter behave like an ideal voltage source (grid-forming mode). This is normally done using conventional PI controllers; however, in this case the physical limitation of the converter itself (e.g., maximum current limitation) can be only imposed by means of a saturation in the inner current control loops (see Figure 2). Consequently, when the outer voltage control loop asks for unfeasible currents, the inner loop opens, which means that the overall control scheme is not able to track the voltage reference. Furthermore, the presence of two nested control loops makes the design of the controllers quite cumbersome. In the conventional strategy, there are four PI controllers (direct and quadrature axis voltage and current regulators), which means that there are eight parameters to be set. To the best of the authors knowledge, such choice is typically made by an empirical procedure that must ensure that the dynamics of the outer voltage control loop is much slower than the current controllers one.
On the other hand, the proposed approach allows to impose equality and inequality constraints; so, the controller selects the best control law that respects all such constraints. Furthermore, the only parameters to be set are the weights in the objective function that, as will be clarified later on, are only three and they can be selected independently of each other and represent the strength of the controller to track the reference values for the AC voltage and the system inputs (i.e., the inverter modulating signal frequency and the time derivative of the modulation index).
From a practical standpoint, the proposed MPC approach shall provide a more performing operation of a grid-forming inverter reducing at minimum the condition of maloperation due to the limitation of the converter and providing better time responses thanks to the model-based feature of the MPC technique. Of course, this improved performance requires an increased CPU effort; to check whether it is consistent with available computational resources, an experimental validation of the proposed strategy is presented to highlight the elements to be taken into consideration for a real control implementation and test the effectiveness of the proposed approach.
Experimental results have been obtained thanks to a rapid prototyping system (RPS) located at the laboratory for electric drives at the University of Niš, Serbia. Such RPS uses the dSPACE (DS1103, dSPACE, Paderborn, Germany) environment that allows for the exchange of input and output between on-field devices and the PC.

Some Remarks about the MPC Technique
Consider the following time-invariant-affine discrete time system: where x k ∈ R n and u k ∈ R m represent the states and inputs, respectively, at time kT s , being T s the sampling time. The MPC regulator acts to control the states of the system to a reference value x ref by computing the solution of the following constrained quadratic programming (QP) problem: where e k is the state vector error, x k + 1|k refers to the prediction of the state at time (k + 1)T s calculated at time kT s and N is the prediction horizon, i.e., the number of samples taken into account in the is the vector containing the optimal input vector u k , while Q = Q T , R = R T are symmetric and positive semi-definite weighting matrices. H u , K u , H x , K x are the matrices that define the constraints for the controlled system. The MPC controller generates the control action using this strategy: at each step the control solves the optimization problem (2), predicts the evolution of the state variables based on their current values and calculates the optimal input for the system within the control horizon. Then, only the first step u k is applied to the system while the rest of the solution is just discarded. The process is then repeated: a new prediction of the evolution of the states is calculated based on the measurements of their current value, and another set of optimal control action is produced (Figure 3). If the considered model is not linear, at any sampling step kT s a linearization procedure around x k is required to obtain the system described in (1). More details can be found in [33].

MPC Controller Design for Grid-Forming Inverters
The aim of the proposed MPC controller is that of providing a decentralized control of the MG and thus the control needs to be implemented without knowing the MG topology and parameters and relying only on local measurements.
Let's consider a generic distributed generator (DG) as depicted in Figure 4. It consists of a generic DC source, a DC link with suitable DC filters, a full IGBT bridge inverter, an AC filter and finally a PCC. In order to perform the design procedure for the MPC controller, it is necessary to define a mathematical model for the controlled system. Such a model is here proposed according to the following assumptions [34,35]: • AC side of the MG is supposed to be at steady state while DC dynamics are fully considered; • Higher-order harmonics are neglected; The shunt section of the AC filter is neglected.
The resulting model, represented in Figure 5, has been extensively validated with experimental measurements, as detailed in [35]. The phasor of the line-to-ground voltages at the inverter output . V inv (t) and at the harmonic-filter output . V ac (t) can be respectively written as: .
where m a is the inverter modulation index, V dc is the DC link voltage and V ac is the line-to-ground voltage at the harmonic-filter output. The phase angles can be written as follows: where ω is the angular frequency of the inverter modulation signals and ω f is the AC bus frequency measured via phase lock-loop (PLL). In the following equations, the explicit time dependence will be omitted for notation simplification. The active power flow P ac injected by the unit into the MG is given by: where x f is the longitudinal reactance of the harmonic-filter at rated frequency. Obviously, if the AC filter is composed of an LCL configuration, x f represents the sum of the two reactances in series according to the former hypothesis.
Substituting (8) and (9) in (10) one gets: Defining: and Equation (11) can be rewritten as: Considering now the differential equation that describes the DC link voltage dynamics, it follows that: where C is the DC link capacitor and P dc is the power coming from the DC source that can be written as: where I dc is a given function of V dc depending on the specific nature of the source. Substituting (14) and (15) into (16), it is possible to write the dynamic system of the DG: System (17) is a non-linear continuous-time system in the form: .
where u = [m a , ω] T is the input vector, i.e., the variable to be provided by the controller, x = [V dc , δ] T is the state vector and g = [V ac , σ, ω f ] T is a vector that collects measurements and estimated variables.
In particular, V ac and ω f, can be easily measured, while σ can be estimated as follows: As specified before, the mathematical model for the prediction in MPC controllers (1) can be obtained at any time t * linearizing System (17) around x(t * ). Performing the linearization procedure, System (17) becomes: where the system matrices are defined as: Then, since MPC control works in the discrete-time domain, (20) needs to be further discretized as follows: x k+1 = (I + T s A * )x k + T s B * u k + T s G * g k + T s D * (25) where the subscript k denotes the system variables discretized at the sampling time kT s . Since during the prediction the time evolution of the measurements are unknown, they are supposed to remain constant during the prediction horizon N, i.e., g k is considered as a state with no dynamics as described by the following equation: Furthermore, since the objective of the control is to reach a constant modulating index at a steady state within the range (0-1.156) instead of considering m a as a control variable for the system, its derivative J is taken as an input. Thus, a new dynamic equation m a,k + 1 = m a,k + T s * J K is added to (25). The resulting general DG model of the kind (1) necessary for the prediction computed by the controller is written as: where: where T s B * (1) and T s B * (2) are the first and the second column of the matrix T s B * , respectively. Moreover, some relevant constraints (see (4) and (5)) are implemented. The angular frequency for the inverter modulation signals ω acts on the system to satisfy the control objectives within the operational limits to achieve MG power quality: The modulation index is constrained, as follows, to guarantee the inverter working in its linear operational range: To ensure that even during a transient the inverter capability curve is never exceeded (i.e., the inverter is never overloaded) the following constraint, after a linearization procedure, is implemented: where Q ac can be expressed as a combination of state and input as follows: As specified before, grid-forming inverters must regulate their AC terminal voltage. In the proposed approach, the aforementioned goal is obtained expressing the desired voltage in terms of states and inputs of the controlled system and using the industrial voltage drop expression: One can combine (36), (35), (14) and (6) to obtain the V ac formulation composed of just states, inputs and constants: Indicating with ω n the rated frequency of the MG and with V ac,ref the reference for V ac , one can define e = V ac − V ac,ref and u re f = [ω n 0] T (where the zero in the second component of u re f means that the control objective is to obtain a constant modulation index no matter its value).
The resulting objective function is then: is the vector containing the optimal input vectorȗ = u − u re f . R = diag (R ω ; R J ), where R ω and R J represent the weights for the input and Q V is the weight for the voltage error.
As a result, one obtains that MPC regulator works based on the following measurements: voltage, active power, the angular frequency at the inverter AC side and DC link voltage. Then, the online optimization process is performed to generate the control signals for the inverter PWM modulation. The overall control scheme of the generic DG unit is reported in Figure 6.

Experimental Setup
In order to validate the performances of the proposed MPC decentralized controller for grid-forming inverters, an experimental set-up with rapid control prototyping features was realized.
The experimental layout is depicted in Figure 7 and was realized at the laboratory for electric drives at the University of Niš, Serbia (Figure 8 includes a photo taken in the laboratory during the tests).  In order to experimentally confirm the proposed algorithm, and due to the lack of a programmable DC power source, a simple setup was made. The DC side of the DG unit is achieved using rectification of the AC grid voltage (400 V) using a variable-ratio autotransformer and a diode bridge rectifier. The following part of the experimental set-up is composed by a DC link with suitable inductances and capacitance, an IGBT inverter and two passive loads. The autotransformer rating is 7.6 kVA with ratio 400V/223 V and 4.7% short circuit voltage. The data of the main passive components from Figure 7 can be found in Table 1. Two different constant resistive loads are at disposal: i.e., Load 1 and Load 2 with a resistance of 66 Ω and 160 Ω, respectively. The inverter is a Danfoss FC 302, rate current 8.2 A. The inverter is controlled via a dSPACE DS 1103 real-time controller, whose board was used to collect the measured signals and to drive the inverter. The control algorithm is developed in MATLAB/Simulink (2017b, Natick, MA USA), while some parts of code are made as C++ (Microtec PowerPC C/C++ Compiler Ver. 3.8.61, dSPACE, Paderborn, Germany) functions in order to solve the QP problem in real-time. In these experiments, the QP problem was solved using qpOASES (v 3.0, OPTEC) [36,37], an open-source library for C++, which proposes some simplified tools for this kind of interface in which more than one software is involved. In Table 2, it is possible to find the control variables used in the experimental test described in the following section. Examining (16), it is apparent that a relationship between voltage and current of the DC source is required. Thus, before proceeding with the MPC controller implementation, a simple experimental campaign has been performed to define the V/I characteristic of the available source (main grid and autotransformer, diode bridge, DC link). More details about this procedure are included in the Appendix A For the specified powertrain, the obtained characteristic is shown in Figure 9, in which the blue stars represent the discrete experimental characteristic and the red line represents the best 5th order polynomial interpolation used for the controller implementation. For the sake of completeness, it is important to highlight that this procedure is useless if a DC/DC converter is inserted in the power train between the source and the inverter because the converter can be controlled in order to impose any desired V/I characteristic on the inverter DC side.

Experimental Results
This section aims at describing the HIL test performed to validate the proposed approach. Such a test includes several events in cascade. At first, a ramp increase is provided for the grid voltage, from 35 V to 175 V RMS phase to phase in 4 s, starting at 5 s. This first part allows pointing out the proper operation of voltage control. In this first phase, only Load 1 is connected. Secondly, Load 2 is connected in parallel with Load 1 at 16 s, before being disconnected at 19.5 s. Finally, at 22.3 s, Load 1 is also disconnected, leaving the system in a no-load condition. Figure 10 represents the measured RMS grid voltage; its profile is very satisfactory since it never exceeds the range V ac,ref ± 10%. Instead, Figure 11 shows the active power supplied by the converter.  From Figure 11 one can notice that in the first transient, power increases due to the increase of voltage and the resistive nature of the load. Once that voltage reached its final value, the active power production is equal to 175 2 /66 = 464 W. Then, at about 16 s, power increases due to the connection of the second load up to ((1/66) + (1/165)) * 175 2 = 650 W before reducing progressively up to almost zero (compensating losses in the system). Looking together at Figures 10 and 11, one can notice how the voltage regulation has low sensitivity to power variation, providing a very satisfactory result for the inverter operation. For the sake of completeness, Figures 12 and 13 report the two MPC controller outputs i.e., the modulation index and the modulation frequency.  Finally, Figure 14 highlights the dynamics of the DC link voltage during the experiment. As can be seen from the figure, in correspondence of each load increase, the DC voltage decreases because it is the DC capacitor that initially provides the necessary load power. Then, the DC source current increases providing itself the necessary amount of power for the load, which results in a stabilization of the DC voltage. Please note that no DC voltage controller is implemented here because this would be strictly related to the specific nature of the DC source (e.g., a PV unit should implement a MPPT algorithm, a storage should be equipped with a suitable battery management system and so on). During this test, the run time of the QP was recorded between 0.78 and 0.91 ms, i.e., shorter than the MPC sampling time (T s ) equal to 1 ms.

Conclusions
This paper proposed an innovative control architecture for grid-forming inverter control in islanded MGs. The proposed approach is based on the well-known MPC technique that has been implemented that considers the specific characteristic of the DG unit source on the inverter DC side. In the first part of the paper, the proposed MPC controller has been fully described providing all the necessary information to implement the features of a grid-forming inverter (control goals) accounting for quality ranges of the involved variables (control constraints). After the definition of the proposed MPC controller, the paper focused on the validation of the proposed approach. As well known, the MPC approach usually suffers from implementation issues, due to the fact that it requires the solution of an optimization problem, and this may be too cumbersome from a computational point of view. For this reason, an experimental validation of a proposed control system was performed at the laboratory for electric drives of the University of Niš, Serbia. The experimental validation pointed out the good operation of the proposed controller from both a technical and computational point of view.
On the basis of this important result, the future development of this activity will point to the extension of the proposed MPC approach in a multi-inverter islanded MG, where more than one inverter will have to cope with frequency and voltage regulation. The capabilities of the proposed MPC approach may allow for the elaboration of the design of a communication-less architecture capable of coping with primary regulation in an islanded MG in an effective and reliable way. the same used and described in Sections 3 and 4. V/I characteristic was determined by defining 23 different working points (V dc ; I dc ) obtained with 23 different values of the resistor R c in the range (50 Ω-∞) (see dots in Figure 9). Current and voltage measuring devices appear in Figure A1. Then a fitting tool (e.g., Matlab Basic Fitting) allowed to obtain an analytical relationship I dc (V dc ) between DC voltage and current that best fits experimental data. In this work, a 5th order polynomial is used, whose coefficients are listed in Table A1.  Figure A1. Characterization experiment setup.