Formulation of Stochastic MPC to Balance Intermittent Solar Power with Hydro Power in Microgrid

In a microgrid with both intermittent and dispatchable generation, the intermittency caused by sources such as solar power and wind power can be balanced using dispatchable sources like hydro power. Both generation and consumption are stochastic in nature and require future prediction. The stochasticity of both generation and consumption will drift the grid frequency. Improved performance of the grid can be achieved if the operation of the microgrid is optimized over some horizon, for instance formulating Model Predictive Control (MPC), with the added problem that intermittent sources vary randomly into the future. In this paper, ﬁrst, we have formulated a deterministic MPC and compared it with a PI controller. Second, a stochastic MPC (SMPC) based on a multi-objective optimization (MOO) scheme is presented. Results from deterministic MPC show that the overall performance of MPC is better than the PI controller for dispatch-ing the required amount of hydro power into the grid and simultaneously constraining the grid frequency. Results from SMPC indicate that there exists a trade-off between the amount of water ﬂow through the turbine and the rate of change of the turbine’s valve while constraining the grid frequency.


Background
The demand for electricity generation from renewable energy is increasing because of oil insecurity, climatic concern, and the nuclear power debate. Renewable energy consists of intermittent and dispatchable energy sources. Intermittent generation from sources such as solar power, wind power, and tidal power exhibit fluctuating power production and creates an imbalance between generation and load. However, renewable dispatchable sources such as hydro power plants play a significant role in balancing out the variability caused by intermittent sources.
For instance, in a microgrid supplying electrical power to a common consumer load with generation from intermittent solar power and a dispatchable hydro power plant, injection of intermittent solar power into the grid creates a fluctuation in grid frequency. Assuming that he grid fre-quency must be maintained at the range of (50 ± 5%) Hz, it is of interest to dispatch the required amount of hydro power into the grid for balancing out the load and the generation while maintaining the grid frequency in that range.
However, the required amount of hydro power production can not be dispatched instantaneously. In reality, changes in hydro power production are constrained by inertia in water and rotating mass, and the need to avoid wear and tear in actuators and other equipment. Furthermore, both solar power and consumer load are not known perfectly. The solar power and consumer load intermittency cause power imbalance into the grid and drifting in grid frequency. Improved performance can be achieved if the operation of the microgrid is optimized over some horizon with the added problem that intermittent power varies randomly into the future. Optimal management of dynamic systems over a future horizon with disturbances is often posed as an MPC problem.

Previous Work
An MPC approach had been applied for controlling water flow into the turbine in (Zhou, 2017). The use of MPC with consideration of dynamical model of hydro power systems is presented in (Munoz-Hernandez et al., 2012). Simulation results with different operating conditions and disturbances from previous work emphasize the use of an MPC-based approach over the optimal PI controllers (Avramiotis-Falireas et al., 2013;Bhagdev et al., 2019;Reigstad and Uhlen, 2020). In a recent study of (Pandey et al., 2021) stochastic analysis of deterministic MPC for a dynamical model of microgrid was performed. It is of interest to further extend the work of (Pandey et al., 2021) with SMPC with the addition of comparison between a PI controller and deterministic MPC.

Outline of the Paper
Section 2 provides a system description. The mathematical model of the microgrid is detailed in Section 3. The implementation of a deterministic MPC and a stochastic MPC is given in Section 4 and Section 5, respectively. Section 6 provides results and discussions. Conclusions and future work are outlined in Section 7.

System Description
Consider a microgrid as in Figure 1 a) operated at consumer load P and supplied with intermittent solar power  P s . The difference between the intermittent generation and load is balanced with dispatchable hydro power P h . Figure  1 b) shows the hydro power plant with reservoir, intake, surge tank, penstock, and turbine connected to the microgrid with an electrical generator. Figure 1 c) shows the N s future scenarios generated in SMPC from the past data of P s and P . SMPC, as shown in the figure, keeps track of the constraint violation in grid frequency f for 50 ± 5% Hz and generates the turbine valve signal u v and hydro power P h dispatched into the grid based on the stochastic input from solar and consumer load.

Hydro Power Plant
The mathematical model for a hydro power plant shown in Figure 1 b) is taken from (Pandey et al., 2021) and given as with algebriac equations given by where the intake, the surge tank, and the penstock are subscripted with i, s and p, respectively. h is is the water level andV is the volumetric flow rate. Readers are requested to follow (Pandey et al., 2021) for notation.

Solar Power and Consumer Load
Solar power is calculated based on the solar irradiance k I and given by P s = η s Ak I where η s is the efficiency of a solar panel and A is the effective area of panels in the solar farm. In contrast, the consumer load P is modeled with the measurement data.

Grid
The grid is modeled with the swing equation given as where P m is the mechanical power input into the microgrid with and P e is the electrical power load from the grid. The total inertia of the grid is represented by J.

Canonical Representation of the Model
The differential algebraic equations (DAEs) can be written in a canonical form of where x, z, u, and θ represents system states, algebraic variables, inputs, and parameters respectively. w is the process disturbances and v is the measurement noise. For the microgrid shown in Figure 1 a) represented by mathematical equations from Eqs.
(1) to (10), we have where the intermittent solar power P s is considered as process disturbance and all states are assumed to be measured.

Case Study
It is of interest to see how a 5 MW hydro power plant can be used for balancing a 4 MW rated consumer load supplied with solar power.

Cost Function
The chosen cost function for formulating optimal control problem (OCP) for the deterministic MPC is taken from (Pandey et al., 2021) given as where and h represents low and high bounds for states, inputs, and rate of change of inputs. N p is the number of future samples in the prediction horizon where OCP is formulated. p is scalar weight for tuning the controller. r is the reference taken for consumer load power P .

OCP Formulated in JuMP.jl
The internal structure of OCP is formulated in the Julia language 1 using JuMP.jl (Dunning et al., 2017), a Julia package for modeling mathematical optimization problems. JuMP provides an easy way of describing optimization problems containing linear and nonlinear constraints. JuMP also supports automatic differentiation (AD) using the package ForwardDiff.jl (Revels et al., 2016) which is 1 https://julialang.org/  x * (1) , u * (1) , y * (1) represents first optimal values of states, control inputs and control outputs from OCP. We have assumed that all the states are known. These optimal control inputs are then applied to the emulated real plant developed in OpenModelica 4 . Similarly, both the optimal states and the control inputs are applied to the mathematical model. The states, inputs, and outputs are accessed through OMJulia APIs for further iteration.  (González et al., 2020). Comparison of the different stochastic MPC algorithms are out of the scope of this paper. In this paper, more focus is on the implementation of the dynamic formulation of the microgrid with stochastic solar power and load power. We have chosen multiobjective optimization (MOO) based stochastic MPC with similar formulation from the previous work our institution (Menchacatorre et al., 2020) as it is easier to formulate and have a quick analysis. In MOO-based stochastic MPC, we create scenarios of random disturbances; and in our case the random disturbances are P s and P . Each scenario is then assigned with an objective function or a constraint. When each of the objective functions is summed together by assigning weights to each of the objectives, a single objective function is created which is called a weighted-sum MOO.

Cost Function
The MOO based cost function for N s number of stochastic scenarios for P s and P is given as where we have considered each of the scenarios to be equally important; thus the total objective is formulated summing objective function of each of the scenarios. This cost function is used for formulating OCP for stochastic MPC. A stochastic MPC is formulated by solving OCP for each iteration considering N p number of future samples in the prediction horizon.

Stochastic Scenarios for P s and P
Real measurement for solar irradiance is taken for Kjølnes Ring 56, Campus Porsgrunn, University of South-Eastern Norway, 9.6714 longitudes and 59.13814 latitudes from www.solcast.com. The measurement data is updated at every 5 min throughout the day. The real measurement for consumer load is taken for monthly hourly averaged load for Norway from ENTOS-E 5 . The magnitude of measurement data for electrical demand is modified as per our case study with a microgrid with a power capacity of 5 5 https://www.entsoe.eu/data/power-stats/  MW keeping the load dynamics preserved in hourly data. Furthermore, the hourly sampled data is interpolated for creating consumer load with a sampling of 5 min.
Between each of the measurements, scenarios are generated using a stochastic evolution equation considering a Brownian motion 6 . The stochastic evolution equation based on the Brownian motion is used as a generatrix and a straight line between the two measurements is used as a directrix. Figure 3 shows the method for generating future scenarios based on the past and current measurements sampled 6 https://en.wikipedia.org/wiki/Brownian_motion at 5 min. In the figure, the future measurement F is predicted from past measurement P and current measurement C. Assuming measurement P,C and F are co-linear we have The stochastic scenarios are then creating using Brownian motion between current measurement C and future prediction F. Figure 4 a) shows consumer load on a typical day with measurement data taken at 5 min. Figure 4 b) shows rate of change of consumer load for ∆t → 5 min where the data points within a day consist of 288 data points and represented as P = {P [m] ∀m ∈ 1 : 288}. The figure shows that the bound for ∆P ∆t=5 min lies in [−0.002, 0.009]. The standard deviation for Brownian motion for creating scenarios is then set to > 0.011. Figure 4 c) shows the future predicted P from the past measurement P and current measurement C considering co-linear existence between P,C and F as shown in  predicting P s as shown in Figure 5 where the standard deviation for Brownian motion is set to > 0.3 which is comparatively larger than in case of consumer load scenarios generation. The standard deviation in scenarios is much higher in case of prediction of P s because of the clouds. A more rigorous algorithm for predicting scenarios of P s depends on the information of clouds injected into the prediction algorithms. Since we have only focused on formulation of stochastic MPC, we neglected the part of considering cloud information while generating scenarios for P s .

Stochastic OCP
We have considered the prediction horizon of N p = 10. The discretization time of the controller for SMPC is chosen to be ∆t = 5 s based on our previous work for a microgrid with around 5 MW (Pandey et al., 2021). For moving along the stochastic prediction horizon of P s and P , the states and the outputs are updated taking the mean of the first value of each of the scenarios of states and outputs from the stochastic OCP.
6 Results and Discussions 6.1 Deterministic MPC Figure 6 shows setpoint tracking formulation of consumer load P using both deterministic MPC and a PI controller. The MPC is characterized by tuning parameter p = 0.1, N p = 5 and ∆t = 1 s. Similarly, the PI controller is characterized with K p = 0.05 and T i = 3 s. The initial tuning of the PI controller is based on the SIMC method (Skogestad, 2001) and the final tuning was performed manually. The setpoint tracking of P using the PI controller is performed using OpenHPL in OpenModelica while the MPC is formulated as in Figure 2 in conjunction with real plant considering from OpenHPL and the control model is formulated in Julia. The control model is discretized using Euler discretization. Figure 6 a) shows the setpoint tracking using both MPC and PI controller. A step change in P is performed at time =25 s while a step change in P s is performed at time =50 s. Figure 6 b) shows the hydro power dispatched into the grid from both the MPC and the PI controller. The control input, turbine valve signal u v , for controlling the flow rate through the penstock for balancing the load and the generation is shown in Figure 6 c). Similarly, Figure 6 d) shows the grid frequency f of the microgrid. In Figure 6 c) we see that u v in case of the MPC is smoother and less fluctuating than u v in case of the PI controller. Furthermore, since an MPC works based on the future horizon, in Figure 6 c) the turbine valve signal u v in case of the MPC is increased from 0.4 to 0.6 at time ≈23 s keeping the constraint in grid frequency for f ≈ 50 Hz (small deviation not shown in the figure). Contrary to the performance of the MPC, from the figure the turbine valve signal is increased exactly at time =25 s while the grid frequency f fluctuates from 50 Hz to 47.5 Hz. The PI controller is able to regain  the grid frequency around 50 Hz after ≈ 5 s. Similar, results can be seen in the case of hydro power P h dispatched into the grid and the electrical power P e . The similar dynamics of P and P e with u v in case of both the MPC and the PI controller can be related from Equations (4), (7), and (9). Overall, the performance of the MPC is better than that of the PI controller. Figure 7 shows the tracking of the future predicted consumer load P based on the future prediction of solar power P s into the grid where both future predicted P and P s are taken from Section 5.2. The MOO based stochastic MPC is characterized by N p = 10, N s = 20, p = 0.1 and ∆t = 5 s. The next scenarios for P and P s are updated every 5 min = 300 s using the current measurement C and the past measurement P as shown in Figure 3. Figure 7 a) shows the turbine valve signal u v generated for each of the scenarios considering a deterministic MPC. The results for u v from the deterministic MPC for each of the scenarios are considered as an ensemble of trajectories for u v . In the figure, u v (MOO) is the results from the stochastic MPC based on MOO in tandem with the ensemble of results from deterministic MPC for each of the scenarios. The fluctuation in the grid frequency is negligible as in the range of 1 · 10 −4 rad/s for both the deterministic and stochastic case as shown in Figure 7 f). Figure 7 b), c), d) and e) show the results from both the deterministic and stochastic case for hydro dispatched P h , electrical power into the grid P e , flowrate into the penstockV p , and the water mass oscillation inside the surge tank h, respectively.

Conclusions and Future Work
In this paper formulation of a deterministic and a stochastic MPC is performed for a microgrid supplied with intermittent solar power and dispatchable hydro power for constraining the grid frequency at f = 50 Hz. A deterministic MPC is compared with a PI controller. Furthermore, for the stochastic MPC, the scenarios for solar power and the consumer load are predicted using Brownian motion using past and current measurement data. A MOO-based stochastic MPC is implemented.
Results indicate that the deterministic MPC performs better for constraining the grid frequency of the microgrid at f = 50 Hz than to the PI controller. The stochastic MPC based on MOO shows better result than deterministic MPC while constraining the grid frequency.
Future work includes the implementation of stochastic MPC with scenario generation for solar power with the inclusion of cloud factors.