MPC for Optimized Energy Exchange between Two Renewable-Energy Prosumers

: Renewable energy and information technologies are changing electrical energy distribution, favoring a move towards distributed production and trading between many buyers and sellers. There is new potential for trading between prosumers, entities which both consume and produce energy in small quantities. This work explores the optimization of energy trading between two prosumers, each of which consists of a load, renewable supply, and energy storage. The problem is described within a model predictive control (MPC) framework, which includes a single objective function to penalize undesirable behavior, such as the use of energy from a utility company. MPC integrates future predictions of supply and demand into current dispatch decisions. The control system determines energy ﬂows between each renewable supply and load, battery usage, and transfers between the two prosumers. At each time step, future predictions are used to create an optimized power dispatch strategy between the system prosumers, maximizing renewable energy use. Modeling results indicate that this coordinated energy sharing between a pair of prosumers can improve their overall renewable energy penetration. For one speciﬁc choice of prosumers (mixed residential–commercial) penetration is shown to increase from 71% to 84%.


Introduction
Electric power grids are currently undergoing a transition from large centralized power stations to distributed generation, which includes significant renewable components [1]. Utilizing a high percentage of intermittent renewable energy creates new engineering problems, requiring greater flexibility from controllable power sources and large-scale energy storage systems. Information technology is also shaping changes to the energy sector, allowing for automated and reliable tracking of transactions between many buyers and sellers [2]. The new ability for small prosumers to trade directly with each other creates potential to improve renewable energy utilization. This work explores an optimal dispatch algorithm that controls all energy flows within two prosumers (small scale producers and consumers, such as homes with rooftop PV) and determines when they should share energy.

Outline and Scope of This Work
The approach in this work is to develop a single dispatching scheme that coordinates a pair of prosumers to optimize their overall renewable energy penetration. This is unique in that it utilizes future predictions of supply and load for both prosumers and creates a single objective function to optimize. The control scheme determines the flows within each prosumer, as well as the energy trading between them, to optimize an objective, effectively turning the two prosumers into a single operating unit. This is conceived here as a centralized approach that could be implemented by a third party who receives data from both prosumers, as well as weather forecasts, and transmits real-time energy allocation instructions back to the prosumers. Future work will focus on a decentralized version of this concept, operating in a manner like the prosumer network in New York mentioned earlier [11]. The scheme would also require cooperation from the local utility company, in terms of reasonable tariffs for utilizing their infrastructure and for purchasing excess energy from the prosumers. The two prosumers can be pre-existing entities (prosumers) that are ideally selected to be complementary, such that one is likely to have an energy deficit when the other has a surplus. The proposed control scheme enables better overall penetration for the two prosumers and reduces the exchanges between them and external providers. The behavior of the algorithm can be modified through the objective function, by including terms that reflect battery storage lifetime, for example.

Model Productive Control
Model predictive control (MPC) refers to techniques that utilize models of a process and incorporate future predictions of performance and external variables to systematically determine control signals by minimizing an objective function at each time step [16]. These algorithms predict future process behavior and choose a control sequence to optimize an objective function based on these predictions. The initial value of this control sequence is retained before advancing the prediction window into the future for the next time step. Applications of MPC include industrial control of robots, servo motors, steam generators, and control of anesthesia delivery [17]. As well as having the ability to utilize available forecasting data, MPC can efficiently incorporate constraints and manage multiple control variables. MPC does have a large computational burden (the optimization) at each time step, although this is only a problem for applications that require high-speed sampling. A generic MPC schematic is illustrated in Figure 1, where a process model predicts future outputs based on previous inputs/outputs and optimized future control signals. MPC is frequently applied to power delivery systems, especially those that involve renewable sources and distributed generation. For example, MPC is used in maximum power point tracking for DC power systems, to manage the fluctuating output from a PV array connected to a constant DC bus [18]. Active and reactive power disturbances that occur within combined wind-turbine and battery microgrids can also be controlled by MPC, while maximizing power delivery from the turbines [19]. These algorithms have also been used to mitigate disturbances caused by errors in weather forecasting models in a distributed generation system [20]. Figure 2 below illustrates the main components of the two prosumers used in this study and power flows between them. These two prosumers are envisioned as two prosumers within a larger network of prosumers. The structure of both prosumers is the same, consisting of a load, renewable energy supply, battery storage, and connections to other sources of power, such as the other prosumers in the larger network and/or a retail energy supplier. Transactions between the two prosumers are shown as power flows through the peer-to-peer transactions block.

Case Study
The differences between the prosumers are captured in the two load profiles and the renewable energy profiles, the example used throughout this work imagines one load as residential and the other as commercial, although the system applies to any two loads that are complementary to one another. The residential and commercial load profiles are modeled based on real data, and renewable energy resource (RER) supplies are based on typical meteorological year (TMY) weather data and models for PV and wind turbines. The modeling presented here does not include currents or voltages, just discrete hourly energy flows. Variable energy pricing is not modeled, although the MPC objective function contains parameters that could depend on energy prices. Although there are several MPC formulations possible, here, a state space approach is used because it allows for handling many variables easily.
The cost function is formulated as a constrained quadratic, whose complexity depends on the number of variables and the length of the control horizon. Referring again to Figure 2, it is possible to consider MPC operation with or without the energy sharing. This can be easily achieved by adjusting constraint parameters within the algorithm. This allows for exploration of the potential benefit of coupling two prosumers within a larger network of prosumers. Energy sharing between the two coupled prosumers is prioritized over energy sharing with other prosumers in the network.

Problem Formulation
The MPC algorithm is designed to maximize the use of renewable power for the two loads, minimizing the trading that occurs with the rest of the network or other retail energy suppliers. This means that the algorithm seeks to isolate the coupled prosumers as much as possible from the rest of the energy network. The following subsections define the MPC problem, including a battery storage model, state-space formulation, objective function, a reference trajectory based on forecast information, and all system constraints.

Battery Storage
Using k to represent hourly time steps (k = 1, 2, 3, . . . ), the two battery states of charge SOC R (k) and SOC C (k), both in kWh, are combined into a single vector, This vector will become part of the state-space model, and it is used to construct a recursive matrix algebra update for the batteries, with the following equation and definitions.
In these definitions, η C and η D are the charging and discharging efficiencies for energy transfers to the battery P 3R ,P 3C and from the battery P 4R ,P 4C , respectively. The vector u(k) is defined as the control vector for the system, and it contains all the energy flows that the algorithm must choose at each time step. These flows are all functions of k, although this is not shown to simplify the expressions.

State-Space Formulation
To develop a state-space representation of the system, it is first necessary to define an objective function and system outputs. Table 1 organizes the definitions of objective function terms and corresponding outputs. Each term represents a system energy component that can be penalized by selection of corresponding weighting terms, C 1 to C 5 . Note that renewable energy that is consumed directly by the loads is not penalized, whereas there are objective terms for externally supplied power (J 1R , J 1C ), energy into and out of the batteries (J 2R , J 2C ), energy flows to other network prosumers (J 3R , J 3C ), RER flows between the coupled prosumers (J 4R , J 4C ), and battery flows between the coupled prosumers (J 5R , J 5C ). Constants C 1 to C 5 serve as weighting parameters that can modify the relative significance of each objective term. The definition of the terms (J 1R ) relies on the constraint that the load must be completely satisfied at each time step (P 1R = P LR − P 2R − P 4R − P CR − P BCR ). The same constraint holds for the commercial prosumer.
To formulate the state-space model, we define the ten system outputs listed in Table 1 which are combined as a single output vector y(k). The system input x(k) is constructed from x m (k) and y(k). The following expressions summarize these relationships.

System Outputs Objective Function Terms Description
Energy purchased from other network prosumers or retail suppliers Charging and discharging energy transfer to battery Energy sold to other network prosumers Energy transferred from the residential renewable energy resource (RER) supply to the commercial load and vice versa Energy transferred from the residential battery to the commercial load and vice versa Where R-residential prosumer and C-commercial prosumer.

MPC Objective Function and Reference Trajectory
The MPC objective function is defined at each time step by summing all ten terms in Table 1. The function looks forward to a time horizon defined by N p , summing energy terms over a selected time interval according to To develop an expression for J(k) that can be expressed as a quadratic, we define where the notation y(k + i|k) represents the predicted value of y at step i associated with sampling time k.
Using the same notation, future predictions for residential and commercial loads are represented by P LR (k + i|k) and P LC (k + i|k), respectively. These could be generated from historical data, models for human behavior, weather forecasts, etc. Similarly, future predictions for residential and commercial RER outputs are represented by P RER R (k + i|k) and P RER C (k + i|k), respectively, as would be generated from weather forecasts and models for the various hardware components involved in renewable power generation. All the predicted quantities, for each time step into the future up to the prediction horizon N p , are combined into a single reference trajectory vector R(k), given by . . .
The output vector Y(k) should follow this reference, and the minimization of the MPC objective can now be re-expressed in quadratic form:

System Constraints
There are two main equality constraints in the system model, such that the power total flows into the loads meet those loads exactly at each time interval, P LC (k) = P 2C (k) + P 4C (k) + P 1C (k) + P RC (k) + P BRC (k).
The power flows that form the control vector u(k), must meet various inequality constraints. Each of these flows is non-negative and each has an upper bound. In addition, transfers from the RER and battery to the residential load cannot exceed the load Also, the three power flows from the RER supply cannot exceed the total available RER output at any time.
The inequality constraints can now be summarized in a single expression where γ 1 = [γ R , γ C ] , the inequality is taken elementwise, and γ R and γ C are defined as where M R and M C are defined as The constraints are applied to the predicted control flows at each future time step, using the following definition of the predictive control vector, where N C is the control horizon.
The constraints are then applied at each time step, where The predicted values of the state of charge can now be written as By defining the predictive state of charge X m (k) as Since each storage system state of charge is constrained to be between upper and lower limits, this can be applied to each of the predicted values x m (k + i|k) in the predictive state of charge.
The constraints can then be represented in one inequality where γ 2 and M 2 are defined as

MPC Algorithm
Given the system model, Equation (2); the objective function, Equation (3); and the constraint equation on Equation (16), it is possible to develop the MPC algorithm, as outlined by Wang [21]. First, the following MPC gains are formed: Using these definitions, the predicted output vector becomes Y(k) = Fx(k) + φU(k). This allows the quadratic form of the objective in Equation (5) to be rewritten as The minimization of the objective function can now be expressed using terms that depend only on U(k), Using Matlab© quadratic programming optimization routine at Equation (21) is solved under the constraints in Equation (16). A receding horizon control is implemented by keeping u(k), the first 10 elements U(k). All system states, inputs, and outputs are then updated using u(k) and state-space, Equation (2), for the next time k = k + 1, and the process is then repeated for the next time step.

Load and Supply Forecasting
To evaluate this MPC approach requires realistic data for residential and commercial loads, RER supply profiles for the locations of these loads, and methods for forecasting these four quantities into the future. The load profiles used are derived from residential apartment meter readings and a model for a commercial-kitchen electrical load, resulting in hourly demand P LR (k) and P L C(k) for one year [6]. At each hour k, the demand forecasts P LR (k + i|k) and P LC (k + i|k) for i = 1, . . . , N P are selected randomly and uniformly from 60% to 140% of the actual future demand, where N P is the predicted horizon of future load demand and equal to 24 h.
The RER profiles P RER R and P RER C are each created as a mix of wind and solar power, using wind turbines 3 m 2 swept area per turbine), fixed position solar panels 2 m 2 per panel), and a model that converts TMY data for Ohio into hourly turbine and solar PV output [6]. The residential RER system has 1 turbine, 150 panels, and 220 kWh battery capacity; and the commercial RER system has 2 turbines, 120 panels, and 180 kWh battery capacity. The RER output forecasts at each hour k, P RER R (k + i|k) and P RER C (k + i|k) for i = 1, . . . , N P are selected randomly and uniformly from 80% to 120% of the actual RER powers, where N P is the predict horizon of future supply and equal to 24 h. Figures 3 and 4 show examples of demand and supply profiles for the residential and commercial systems. The vertical line in each subplot indicates current time k, corresponding to midnight, with one day of past (historical) values to the left and one day of future forecasted values to the right. Actual future load and supply (which would not be known in a real application) are also shown to illustrate forecasting error.

Performance Benefit of Prosumer Pairing
The MPC algorithm can be operated in two ways, with or without sharing between the paired prosumers. To run the algorithm in unshared mode, the parameters P max RC , P max CR , P max BCR , and P max BRC are all set to zero, which prevents the MPC algorithm from sharing energy between the prosumers. By running the algorithm for the full year, sharing and unsharing, comparisons can be made between the two scenarios to illustrate the benefits of sharing/pairing. For the paired mode of operation, Figure 5 shows the monthly total energies that flow between the paired prosumers. This figure illustrates some seasonal activity, in that more energy is transferred from the residential to the commercial prosumer in the summer compared to the winter months. We can also see that on average, the residential prosumer has more excess energy to transfer to the commercial prosumer. The upper plot in Figure 6 shows average daily behavior for the full year, illustrating RER energy surplus (production minus load) for both prosumers. These plots indicate when each prosumer has a surplus (more RER output than load) and when each has a deficit (less RER output than load). The solar activity is apparent in these plots, showing an average surplus energy in the afternoon. There are times during the day when there are significant differences between the surplus energy available in the two prosumers. During this time, it is expected that one prosumer will be likely to transfer energy to the other prosumer, confirmed by the positive energy transfers evident in the lower plot. Clearly, the commercial prosumer transfers more energy to the residential prosumer in the morning, and vice-versa in the afternoon. This indicates how the MPC algorithm exploits differences between the two paired prosumers. Figure 7 shows total purchases from external prosumers in the network for both paired prosumers, using both modes of operation (sharing versus unshared). Clearly, the amount of energy needed from outside sources drops when the two prosumers are paired.    Table 2 summarizes total results for paired versus unpaired MPC operation. If the two prosumers under consideration are unpaired, the combined percentage of the loads met with RER energy is 75%, which increases to 86% when the loads are paired. In other words, a greater percentage of the RER output remains within the two prosumer paired system. The total RER output that is transferred to outside prosumers in the network decreases for the paired case. Table 2. Performance for both operating modes.

Unpaired Paired
Percentage of both loads satisfied by RER production 71% 84% Percentage of total RER output transferred to other prosumers 39% 32%

Conclusions
This work describes the utility of an MPC approach for efficiently coupling two prosumers, each with their own renewable energy supply and battery storage. This builds upon earlier research which explored MPC for managing one prosumer's energy flows to another prosumer. Here, a single MPC dispatch algorithm manages all flows internal to the paired prosumers, as well as shared energy flows between them. By exploiting differences between the two prosumers' supply and load profiles, higher renewable energy penetration is achieved for the coupled system relative to the penetration achieved if the prosumers operate independently. An example of a residential prosumer paired with a commercial prosumer is presented to illustrate this point. The MPC approach utilizes forecasts of supply and demand, ensuring the batteries are drained prior to times of anticipated excess supply, and the batteries are full prior to times of anticipated excess demand.
Renewable penetration could be further improved by networking more than two prosumers in this manner, although the current MPC formulation may not scale easily due to the number of variables involved. One approach for scaling may be to only apply MPC to manage shared energy flows, but not flows that are internal to each prosumer.
Although this work does not explicitly consider energy pricing, the coefficients for the MPC objective function could be functions (changing in time, if necessary) of prices. The coefficients could similarly be adjusted to more precisely reflect battery efficiency and life, losses due to DC to AC conversion, physical distances between prosumers, and other electrical or economic considerations. Such approaches can further refine the potential of an MPC approach to optimized energy exchange. Future research will consider the algorithm's performance with a smaller time-step, and modifications necessary to handle rapid fluctuations in load and supply.
Author Contributions: I.A. designed the model, computational the framework, analysed the data, and wrote the manuscript. M.D. contributed to the design, implementation of the research, and supervised the project. R.O. provided critical feedback and helped shape the research. All authors discussed the results and contributed to the final manuscript.