main-content

## Weitere Artikel dieser Ausgabe durch Wischen aufrufen

30.11.2016 | Originalarbeiten | Ausgabe 8/2016 Open Access

# Cost-optimal Control of Photovoltaic Systems with Battery Storage under Variable Electricity Tariffs

Zeitschrift:
e & i Elektrotechnik und Informationstechnik > Ausgabe 8/2016
Autoren:
Harald Kirchsteiger, Philipp Rechberger, Gerald Steinmaurer

## 1 Introduction

Within the last decade, there was a strong increase in the installed photovoltaic (PV) power in Europe which is also reflected in the particular case of Autria [ 1]. Even if the installed power per capita is significantly lower than in other European countries, e.g. Germany, the grid connection of PV starts to influence the stability of the electrical power grid, depending on weather and radiation conditions. In the last 3 years, a substantial number of PV systems has been initially equipped or additionally expanded with electrochemical storage units, mostly based on lead battery and now on lithium technology. The possibility of storing energy instead of simply consuming the produced PV-electricity instantaneously or feeding in into the grid presents an additional degree of freedom. One must decide, if surplus energy from the PV will be stored for later use or fed in. This new opportunity can be an exceptional chance for the grid operator as well as for the end user. At times of an energy overproduction (e.g. a sunny, windy day in the weekend) the supplier could reduce the prices to motivate end users for consumption (or replenishment of storage) at those times. Similarly, at times of an energy shortage prices could be raised to motivate for feed-in. But to gain advantage from a variable tariff, the end user (resp. the PV-inverter) must be informed about the tariff situation and – more complex – has to react adequately to subsequently reduce electricity costs. To find the optimal behaviour with respect to the costs a prediction of electricity demand and PV-production [ 2] is needed.
At the moment electricity tariffs for private customers are mainly constant or change few times a year. Nevertheless time-of-use pricing is a possible option for many electricity providers. Some of them already offer products of this type, also in Austria (e.g. [ 3]). The electricity price may change regularly of up to hourly. It is seen as one method of motivating the consumer for demand response which could result in a better match of electricity production which reduces otherwise necessary deregulation of production or expensive investments in the improvement of the electricity system. A further step could be real-time pricing, where the price is not set in advance. In this paper, a time-of-use tariff is used, where the price changes hourly but is known in advance for a period of at least ten hours. The implementation of real-time-prices needs an additional prediction model which will be part of future works.
The decision problem whether to store energy or directly use it can be stated as a mathematical optimization problem. Figure  1 illustrates all possible energy flows in the considered system setup. While there are only three options without a battery, this number is increased to six when a storage device is included.
Mathematical methods for optimizing energy systems with storage abilities have been developed successfully for other applications, e.g. hybrid vehicles [ 4] or solar thermal systems [ 5].
The idea of utilizing optimization tools for energy management of PV systems including a battery storage is not a new one. Closely related to our work, [ 6] consider a similar setup and analyze multiple optimal charge scenarios: e.g. charging for maximizing battery lifetime, charging for maximizing self-consumption, charging for cost-minimization and others. They use dynamic programming to directly solve the nonlinear optimization problem. They do not consider variable electricity prices. A pricing function consisting of an energy price and a demand price is considered in [ 7]. They use convex optimization to find a near-optimal solution of the optimization problem using a rather detailed battery model. In [ 8] a mixed-integer linear optimization program is used to find the optimal scheduling of household appliances including a heat-pump for heating. A large-scale system with 80kWp, a facility consuming approximately 75MWh per year and a zinc hybrid cathode battery storage is considered in [ 9]. They use receding horizon control to minimize the power consumption from the grid via a set of implemented rules. A model predictive control scheme is employed in [ 10], combined with an artificial neural network for load forecasting and variable prices. To solve the nonlinear optimization problem, also here dynamic programming is utilized.
The aim of this paper is to quantitatively compare cost savings achievable with two different optimization-based control algorithms compared to the standard rule-based operating strategies implemented in currently available inverters when considering a battery storage and variable electricity prices. The first optimal controller has full knowledge of the nonlinear system an can therefore determine the global optimal strategy. The second one uses a linearized system model and cannot capture nonlinearities, e.g. the dependency of the efficiencies of the power inverter on the power output. The comparison is done by simulations using real-world data from residential buildings collected over a full year as input. Please see the section Acknowledgment for a description of the data source.

## 2 Modeling

In this section we describe the mathematical modeling of the power inverter, the battery, and the prediction models.

### 2.1 Aim of the developed models

The models are developed in order to carry out simulations for evaluating various operating strategies of the energy management system. We proceed with a control-oriented way of modeling, focusing on the input-output behavior rather than on modeling the internal processes in detail. Consequently, we assume a static behavior of the power inverter meaning that a requested power output is transmitted instantaneously without any transition caused by the underlying dynamics of the various AC/DC and DC/AC converters.

### 2.2 Modeling the power inverter

The power inverter has three interfaces: it receives energy from the PV system, transmits/receives energy from the battery, transmits energy to appliances or receives energy from the grid, see Fig.  2. The figure also shows the internal converters which form a common DC-bus. There is also the possibility to have a common AC-bus, which will not be considered here.
Power transformation is associated with losses. In our model, we assume an efficiency $$\eta_{\mathit{PV}-\mathit{AC}}$$ for transforming the energy from the PV generator to the AC connection, $$\eta_{\mathit{PV}-B}$$ for transmission from the PV generator to the battery, $$\eta_{\mathit{AC}-B}$$ for transmission from the AC connection to the battery, and $$\eta_{B-\mathit{AC}}$$ for transmission from the battery to the AC connection, respectively. Those efficiencies depend on several variables, for example on the inverter output power and voltages [ 11] and can be considered as functions $$f_{i}(\cdot):\mathbb{R}^{2} \rightarrow\mathbb{R}, \ i\in\{1,\ldots,4\}$$
\begin{aligned} \eta_{\mathit{PV}-\mathit{AC}} &= f_{1}(P_{x},U_{PV}) \end{aligned}
(1a)
\begin{aligned} \eta_{PV-B} &= f_{2}(P_{B},U_{B}) \end{aligned}
(1b)
\begin{aligned} \eta_{AC-B} &= f_{3}(P_{B},U_{B}) \end{aligned}
(1c)
\begin{aligned} \eta_{B-AC} &= f_{4}(P_{x},U_{B}) \end{aligned}
(1d)
where $$U_{PV}$$ is the PV voltage and $$U_{B}$$ the battery voltage. The dependency of the efficiencies on the ratio between DC power and rated power of the inverter is strong: while efficiency is above 96 % for all manufacturers when DC power is high, it falls below 80 % for low DC-power [ 11].
From the point of view of the inverter, we assume input output efficiencies (see Fig.  2) and not efficiencies of the individual power converters. The numerical determination of the efficiencies (i.e. parametrization of the functions ( 1a)–( 1d)) through experiments for an unknown inverter is likely to be easier in this case.
We assume the following overall behavior of the inverter (see Fig.  3 for a definition of the variables): The inverter receives at any time the desired power to be transmitted from/to the grid, $$P_{N}^{set}$$, from the inverter controller. Knowing the load $$P_{Load}$$, we can compute an intermediate power $$P_{x}$$ which is considered as the output of the inverter. With the current power produced by the PV generator $$P_{PV}=P_{PV1}+P_{PV2}$$, this leads to the required battery power $$P_{B}^{set}$$. There might be cases in which $$P_{B}^{set}$$ is infeasible because of an erroneous setpoint $$P_{N}^{set}$$ coming from the inverter controller. In those cases, the inverter changes $$P_{B}^{set}$$ to a feasible value $$P_{B}$$ (for details see the mathematical description below). Using this value, the actual power $$P_{N}$$ can be computed. The maximum output (rated) power of the inverter is $$P_{I}^{max}$$.
The detailed mathematical description is as follows: (by convention we assume $$P_{B}>0$$ for discharging and $$P_{N}>0$$ if power flows into the grid).

#### 2.2.1 Power to grid, $$P_{N}^{set}\geq0$$

In this case, the desired value for the intermediate power is given by $$P_{x}^{set}=P_{N}^{set}+P_{Load}\geq0$$. If there is sufficient PV power available to drive this power, i.e. $$P_{PV} \eta_{\mathit{PV}-\mathit{AC}}(P_{x}) \geq P_{x}^{set}$$, the remaining power from the PV generator can be used to charge the battery with
$$P_{B}^{set} = - \biggl( P_{PV}- \frac{P_{x}^{set}}{\eta_{\mathit{PV}-\mathit{AC}}(P_{x}^{set})} \biggr) \eta_{PV-B}(P_{B}).$$
(2)
If the available PV power is not sufficient, i.e. $$P_{PV}\eta _{\mathit{PV}-\mathit{AC}}(P_{x}) < P_{x}^{set}$$, the battery needs to be discharged with the power
$$P_{B}^{set}=\frac{P_{x}^{set}-P_{PV}\eta_{\mathit{PV}-\mathit{AC}}(P_{x}^{set})}{\eta _{B-AC}(P_{x}^{set})}.$$
(3)

#### 2.2.2 Power from grid, $$P_{N}^{set}<0$$

In this case, the desired value for the intermediate power is given by $$P_{x}^{set}=P_{Load}-|P_{N}^{set}|$$. If the energy flow is into the direction of the grid, i.e. $$P_{x}^{set} \geq0$$, the battery power follows equations ( 2) and ( 3). If the energy flow is into the direction of the inverter, i.e. $$P_{x}^{set} < 0$$, the battery power follows the equation
$$P_{B}^{set} = - \bigl( P_{PV}\eta_{PV-B}(P_{B}) - \big|P_{x}^{set}\big|\eta _{AC-B}(P_{B}) \bigr)$$
(4)

#### 2.2.3 Check for feasibility

The actual battery power depends on the current state of charge ( $$SOC$$) and the constraints on the maximum powers in the following way:
\begin{aligned} &P_{B} = \textstyle\begin{cases} 0 &\mbox{if } P_{B}^{set} > 0 \ \mbox{\&} \ SOC \leq SOC^{min} \\ 0 &\mbox{if } P_{B}^{set} < 0 \ \mbox{\&} \ SOC \geq SOC^{max} \\ P_{B,d}^{max} &\mbox{if } P_{B}^{set} > P_{B,d}^{max} \\ -P_{B,c}^{max} &\mbox{if } P_{B}^{set} < P_{B,d}^{max} \end{cases}\displaystyle \end{aligned}
(5)

#### 2.2.4 Discharge Battery, $$P_{B}>0$$

The sum of PV generated power and battery power needs to sum up to the actual value of $$P_{x}$$, resulting in
\begin{aligned} P_{x} &= P_{PV}\eta_{\mathit{PV}-\mathit{AC}}(P_{x}) + P_{B} \eta_{B-AC}(P_{x}) \geq0 \end{aligned}
(6a)
\begin{aligned} P_{N} &= P_{x} - P_{Load}. \end{aligned}
(6b)

#### 2.2.5 Charge Battery, $$P_{B}<0$$

In this case, we need to further distinguish between $$P_{PV}\eta _{PV-B}(P_{B})\geq|P_{B}|$$, i.e. PV generated power is used to charge the battery and drive the loads, and $$P_{PV}\eta_{PV-B}(P_{B}) < |P_{B}|$$, i.e. the power to charge the battery comes from both the PV generator and the grid. In the former case, we obtain
\begin{aligned} P_{x} &= \biggl( P_{PV}-\frac{|P_{B,ist}|}{\eta_{PV-B}(P_{B})} \biggr) \eta _{\mathit{PV}-\mathit{AC}}(P_{x}) \geq0 \end{aligned}
(7a)
\begin{aligned} P_{N} &= P_{x} - P_{Load} \end{aligned}
(7b)
while in the latter case
\begin{aligned} P_{x} &=-\frac{ ( |P_{B}|-P_{PV}\eta_{PV-B}(P_{B}) )}{\eta _{AC-B}(P_{B})} < 0 \end{aligned}
(7c)
\begin{aligned} P_{N} &= - ( |P_{x}|+P_{Load} ). \end{aligned}
(7d)

### 2.3 Modeling the battery storage

We are assuming a lithium–ion battery with a total storage capacity of $$Q_{B}$$ kWh. With this technology it is not required to always charge the battery fully to avoid loss of capacity. Care has to be taken to not overload the battery which can cause serious damage but is usually handled by a battery controller. When the battery is not used for longer times the charge should be around 40–50 % $$SOC$$ [ 12]. The battery will loose charge when not in use, typically 5 % within a 24 h period [ 12].
For our model, we assume a minimum and maximum state of charge, $$SOC^{min} \leq SOC \leq SOC^{max}$$ to avoid overload and minimize age related capacity loss. The battery can be maximally charged with power $$P_{B,c}^{max}$$ and discharged with power $$P_{B,d}^{max}$$.
To model the 5 % self-discharge the state of charge within a time interval $$\Delta T$$ given in seconds, consider
\begin{aligned} SOC(t+\Delta T) = 0.95^{\frac{\Delta T}{84\,600}} SOC(t) \end{aligned}
(8)
and the definition of $$k_{Batt}=0.95^{\frac{\Delta T}{84\,600}}$$.
In this work, we are not assuming any degradation of the battery over lifetime.

### 2.4 Prediction models

The controllers presented in Sect.  3 will make use of forecasts of the PV energy production and energy demand within the next 24 hours. The development of this kind of prediction models is a scientific topic of its own, see e.g. [ 13] and [ 14] and will not be treated here in detail. In the simulation results presented in section  5, we assume a perfect prediction of the future, i.e. we know precisely what is happening in a 24 hour window in the future. This is clearly an unrealistic assumption, however, it gives us the opportunity to evaluate the maximal performance of the controllers presented. In a next step, which is not under discussion in the current paper, state of the art prediction models can be incorporated in the simulation.
The controllers also make use of future electricity tariffs, which do not need to be predicted but are given in advance by the electricity provider. We assume an electricity price $$p$$ and feed-in tariff $$y$$ both in EUR per kWh and known in advance for the next 24 hours.
\begin{aligned} \mathbf{p}(k) &= \bigl\{ p(k),p(k+1), \ldots, p(k+n) \bigr\} \end{aligned}
(9a)
\begin{aligned} \mathbf{y}(k) &= \bigl\{ y(k),y(k+1), \ldots, y(k+n)\bigr\} \end{aligned}
(9b)

## 3 Control strategies

The main purpose of the controllers designed here, is to find the operating strategy of the battery storage which leads to a minimum of the costs for the user.
The overall control system works in the following way: First, the controller provides the desired power to be transmitted/received from the grid $$P_{N}^{set}$$. Second, the power inverter checks if the setpoint can be reached with the current PV generated power and battery SOC. In the case of a feasible setpoint we have $$P_{N} = P_{N}^{set}$$, otherwise there will be a disagreement. Up to some extent, any disagreement will be compensated by adjusting the battery charge/discharge power though this is limited by the SOC. Reasons for infeasible setpoints are incomplete system information for the controller, no precise knowledge of the efficiencies or inaccurate predictions, to name a few.

### 3.1 Rule-based control

The rule-based controller implements the following four guidelines based on the information on current consumption $$P_{Load}$$, current PV generated power $$P_{PV}$$ and current battery SOC. It does not make use of any predictions of the future.
1)
Discharge the battery if the consumption is greater than the current PV generated power and the battery state of charge (SOC) is above minimum.

2)
Obtain energy from the grid if the consumption is greater than the current PV generated power and the battery SOC is at a minimum.

3)
Feed into grid if the consumption is smaller than the current PV generated power and battery SOC is at a maximum.

4)
Charge the battery if the consumption is smaller than the current PV generated power and battery SOC is below maximum.

Similar controllers are implemented in currently available power inverters designed for use with battery storage. Mathematically, the four guidelines stated above are translated to (see the blockdiagram in Fig.  3)
1)
$$P_{Load} > P_{PV}$$ & $$SOC > SOC^{min}$$
\begin{aligned} P_{B} = \textstyle\begin{cases} P_{Load}-P_{PV} &\mbox{if } P_{Load}-P_{PV} < P_{B,d}^{max} \\ P_{B,d}^{max} &\mbox{if } P_{Load}-P_{PV} \geq P_{B,d}^{max} \end{cases}\displaystyle \end{aligned}
(10a)
\begin{aligned} P_{N}^{set} = P_{PV}+P_{B}-P_{Load} \end{aligned}
(10b)

2)
$$P_{Load} > P_{PV}$$ & $$SOC \leq SOC^{min}$$
\begin{aligned} P_{B} &= 0 \end{aligned}
(11a)
\begin{aligned} P_{N}^{set} &= -(P_{Load}-P_{PV}) \end{aligned}
(11b)

3)
$$P_{Load} \leq P_{PV}$$ & $$SOC \geq SOC^{max}$$
\begin{aligned} P_{B} &= 0 \end{aligned}
(12a)
\begin{aligned} P_{N}^{set} &= P_{PV}-P_{Load} \end{aligned}
(12b)

4)
$$P_{Load} \leq P_{PV}$$ & $$SOC < SOC^{max}$$
\begin{aligned} P_{B} = \textstyle\begin{cases} P_{PV}-P_{Load} &\mbox{if } P_{PV}-P_{Load} \leq P_{B,c}^{max} \\ P_{B,c}^{max} &\mbox{if } P_{PV}-P_{Load} > P_{B,c}^{max} \end{cases}\displaystyle \end{aligned}
(13a)
\begin{aligned} P_{N}^{set} = P_{PV} - P_{B} - P_{Load} \end{aligned}
(13b)

Note that this simple controller is not using any information on the efficiencies of the inverter.

### 3.2 Brute force control

The purpose of this controller is to determine the maximum achievable performance in terms of minimum costs for the user in the given setup. The strategy consists of evaluating all possible costs associated with all possible combinations of free variables. Since the controller has perfect system knowledge, it considers the full timescale of a year when computing the optimal battery charging strategy. There is no need for re-computation every $$T_{s}$$ minutes (like in the linear optimization described below) although this could be done without major changes to the algorithm. To make this problem computationally tractable, the free variables are usually quantized. Nevertheless, the computational demands are high which makes this an off-line solution which cannot be implemented in a real-time control system.
For our implementation we assume both a quantization of the battery power $$P_{B}$$ and a discretization of the time $$t$$. The smallest increment of the battery power is denoted with $$\Delta P_{B}$$, the time increment (sample time) is $$T_{s}$$. The current time is then $$t(k) = k T_{s}, k\in\{0,\ldots, T\}$$. At any time instant, the battery power is a member of the set
\begin{aligned} \mathcal{P}_{B} = \bigl[-P_{B,d}^{max},\ldots,- \Delta P_{B}, 0, \Delta P_{B}, \ldots, P_{B,c}^{max} \bigr]. \end{aligned}
(14)
For simplicity of exposition, and without loss of generality, we assume in the following $$P_{B,d}^{max} = P_{B,c}^{max} = P_{B}^{max}$$ and define $$m\in\mathbb{R}$$ such that $$P_{B}^{max} = m \Delta P_{B}$$. The cardinality of $$\mathcal{P}_{B}$$ is then $$p=2m+1$$. A quantization of the battery power automatically leads to a quantization of the stored energy in the battery (e.g. the $$SOC$$) which is given by the set
\begin{aligned} \mathcal{S} = [0,\ \Delta P_{B} T_{s},\ 2\Delta P_{B} T_{s}, \ldots,\ Q_{B}], \end{aligned}
(15)
with the total battery capacity $$Q_{B}$$ and cardinality $$n=1+\frac {Q_{B}}{\Delta P_{B} T_{s}}$$.
Knowing the PV generated power $$P_{PV}$$ and the load $$P_{Load}$$, for every element $$P_{B} \in\mathcal{P}_{B}$$ the power to the grid $$P_{N}$$ is well defined and can be calculated using Eqs. ( 6a)–( 7d) presented in the last two subsections in Section  2.2. Multiplying with the known electricity costs we obtain the cost vector
\begin{aligned} c(k) = \bigl[ c_{m}(k) \ \ldots \ c_{1}(k) \ c_{0}(k) \ \ldots \ c_{-m}(k)\bigr] ^{T} \end{aligned}
(16)
which is of dimension $$\mathbb{R}^{2m+1}$$. The first and last element correspond to the costs when the battery is maximally discharged and charged, respectively. Based on the cost vector associated with the current time step, we define a cost matrix
\begin{aligned} \varGamma(k)\triangleq \begin{bmatrix} c_{0}(k) & c_{1}(k) & \ldots& c_{m}(k) & & \oslash\\ c_{-1}(k) & c_{0}(k) & & \vdots & \ddots & \vdots \\ c_{-2}(k) & c_{-1}(k) & \ddots& \vdots & & \oslash\\ \vdots & \ddots & & c_{0}(k) & & c_{m}(k) \\ c_{-m}(k) & \ddots & & c_{-1}(k) & \ddots & c_{m-1}(k)\\ \oslash & c_{-m}(k) & & & \ddots & \vdots\\ \oslash & \oslash & \ddots& & & \\ \oslash & \oslash & & c_{-m}(k) & & c_{0}(k) \end{bmatrix} \end{aligned}
(17)
which, column-by-column, consists of distinct fragments of the cost vector. The dimension is $$\varGamma(k) \in\mathbb{R}^{n\times n}$$. Every row and column of $$\varGamma(k)$$ is associated with a specific state of charge $$SOC(k)$$ and $$SOC(k-1)$$ respectively. For example, column $$j$$ is based on a state of charge $$(j-1)\Delta P_{B} T_{s}$$ of the previous sample time. Then, every row in this column gives the cost when a specific battery power is applied. Moreover, costs in line $$i$$ are then the costs when charging/discharging the battery from a $$SOC$$ $$(j-1)\Delta P_{B} T_{s}$$ to $$SOC$$ $$(i-1) P_{B} T_{s}$$. Thus, $$\varGamma(k)$$ includes the full information of all possible combinations. Note that entries denoted with “⊘” are incompatible combinations, e.g. when the battery is (almost) empty, even when charging at maximum power, it will not be full within one sample interval $$T_{s}$$.
Consider a vector $$\kappa(k-1)\in\mathbb{R}^{(1\times n)}$$ which contains the (minimal) costs to reach all possible battery states $$\mathcal{S}$$ at time $$k-1$$ starting with an initial state of charge at time $$k=0$$. For the current time $$k$$, we can compute the total costs by
\begin{aligned} \hat{\kappa}(k) = \varGamma(k) + v \kappa(k-1),\quad\hat{\kappa}(k) \in \mathbb{R}^{(n\times n)} \end{aligned}
(18)
using $$v= [ 1,\ldots,1 ] ^{T}$$. To find the minimal costs, we need to find the minimum alongside the columns of this matrix. A minimum of row $$i$$ of $$\hat{\kappa}(k)$$ in column $$j$$ implies that state of charge $$(i-1)\Delta P_{B} T_{s}$$ at time $$k$$ can be reached optimally via the state of charge $$(j-1)\Delta P_{B} T_{s}$$ at time $$k-1$$ and a charging/discharging power associated with $$\varGamma(k)_{(i,j)}$$. An updated $$\kappa(k)$$ is thus given by the individual minimum of all rows of $$\hat{\kappa}(k)$$.
The iterative brute force algorithm can be stated now: Starting with $$k=0$$ and an initial state of charge, compute $$c(k)$$ ( 16), construct $$\varGamma(k)$$ according to ( 17), determine the total costs $$\hat{\kappa}(k)$$ using ( 18). Determine the minimum of $$\hat{\kappa}(k)$$ for every row and use those values as for the next time step. Iterate $$k\rightarrow(k+1)$$ until a final time $$k=T$$. At the final time step, find the global minimal cost by the minimum in the vector $$\kappa(T)$$.
Note that this basic algorithm can be easily extended to consider $$SOC$$ constraints in the form $$SOC^{min} \leq SOC(k) \leq SOC^{max}$$ by adding a high penalty to the rows of $$\varGamma(k)$$ which correspond to the prohibited $$SOC$$ values.
Remark 1
When considering $$p$$ possibilities to choose from for $$P_{B}$$ and $$k$$ time steps, there would be $$p^{k}$$ different operating strategies for the battery to evaluate. Even for only a few $$p$$ and small times, this becomes computationally very demanding. However, since the whole system is considered static, we do not need to evaluate all $$p^{k}$$ situations. If, at some point, we arrive at a specific state $$s\in\mathcal{S}$$ this point is already reached with minimum costs. Then, to find the optimum for the next time step it suffices to evaluate all possible combinations of battery power starting from $$s$$ since any other starting point would be associated with higher costs while the current costs (given in ( 16)) are the same for both cases.
Please note that this efficient implementation still does not enable an on-line use of the algorithm.

### 3.3 Receeding horizon linear optimal control

The previously discussed brute force algorithm leads to the global optimal solution but is computationally intractable for real-time application. In this section, we formulate an optimization based controller which can find a solution very effectively but is only sub-optimal. Also this controller works on a discrete time basis with a sample time of $$T_{s}$$ and considers a window of 24 hours into the future where electricity prices, loads and PV production are assumed to be known (or predicted by a model). The choice of a 24-hour window seems reasonable, since this is the cycle where PV-power can be predicted with high accuracy and the electricity prices are known precisely. The result of the controller at time $$k$$ is an optimal schedule of the grid power for the next 24 hours,
\begin{aligned} \mathbf{P}_{\mathbf{N}}^{*}(k) = \bigl\{ P_{N}^{*}(k), P_{N}^{*}(k+1),\ldots,P_{N}^{*}(k+n_{p}) \bigr\} \end{aligned}
(19)
where $$n_{p}$$ denotes a prediction horizon. Then, the first element of this optimal sequence is forwarded to the power inverter $$P_{N}^{set}=P_{N}^{*}(k)$$ while the remaining sequence is neglected. At the next time-step $$k\rightarrow k+1$$ new information becomes available since the 24 hour window moves forwards and the subsequent optimization leads to an updated schedule ( 19). This receeding horizon control strategy is well understood [ 15] and used in many industrial applications [ 16].
To formulate the cost function for minimization, we define the energy in a time interval $$\Delta T$$ by
\begin{aligned} E(k) = \int_{k\Delta T}^{(k+1)\Delta T} P(t)\, dt. \end{aligned}
(20)
Also consider the definition of the following variables: energy into the grid $$E_{N+}$$, energy from the grid $$E_{N-}$$, energy from battery (discharge) $$E_{B+}$$, energy to battery (charge) $$E_{B-}$$, intermediate energy into direction grid (see Fig.  3) $$E_{x+}$$, intermediate energy from grid $$E_{x-}$$, energy from PV generator to AC output of the inverter $$E_{PV1}$$, energy from PV generator to battery $$E_{PV2}$$.
Using those definitions, the following equations need to be satisfied at any time $$k \in\{0\ldots T \}$$:
\begin{aligned} E_{x+}(k) - E_{PV1}(k) \eta_{\mathit{PV}-\mathit{AC}} - E_{B+}(k) \eta_{B-AC} &=0 \end{aligned}
(21a)
\begin{aligned} E_{B-}(k) - E_{PV2}(k) \eta_{PV_{B}} - E_{x-}(k) \eta_{AC-B} &=0 \end{aligned}
(21b)
\begin{aligned} E_{x+}(k) - E_{x-}(k) - E_{N+}(k) + E_{N-}(k) &= E_{L}(k) \end{aligned}
(21c)
\begin{aligned} E_{PV1}(k) + E_{PV2}(k) &= E_{PV}(k) \end{aligned}
(21d)
which follow directly from the block diagram in Fig.  3.
The prediction of the battery state of charge is
\begin{aligned} SOC(k+1)=SOC(k) k_{Batt} + \frac{E_{B-}(k)-E_{B+}(k)}{Q_{B}} \end{aligned}
(22)
which can be used iteratively to compute predictions up to the desired prediction horizon.
There are several constraints on the variables which need to be fulfilled:
\begin{aligned} E_{N+} & \geq0 \end{aligned}
(23a)
\begin{aligned} E_{N-} & \geq0 \end{aligned}
(23b)
\begin{aligned} 0 \leq E_{B+}& \leq E_{B,d}^{max} \end{aligned}
(23c)
\begin{aligned} 0 \leq P_{B-}& \leq E_{B,c}^{max} \end{aligned}
(23d)
\begin{aligned} 0 \leq E_{x+}& \leq E_{I}^{max} \end{aligned}
(23e)
\begin{aligned} E_{x-}& \geq0 \end{aligned}
(23f)
\begin{aligned} E_{PV1}& \geq0 \end{aligned}
(23g)
\begin{aligned} E_{PV2}& \geq0 \end{aligned}
(23h)
\begin{aligned} SOC^{min} \leq SOC & \leq SOC^{max}. \end{aligned}
(23i)
Finally, we define a state vector $$x$$ and a gradient $$f$$ using ( 9a)–( 9b)
\begin{aligned} x &= [E_{N-},\: E_{N+},\: E_{B-},\: E_{B+},\: E_{x-},\: E_{x+},\: E_{PV1},\: E_{PV2}]^{T} \\ f &= [ \mathbf{p},\: - \mathbf{y},\: 0,\: 0, \: 0, \:0, \:0, \:0]^{T} \end{aligned}
and state the optimization problem
\begin{aligned} \min_{x} & \ f^{T} x \\ &\ \mbox{s.t.}\ (21a)\mbox{--}(21d),\ (22),\ (23a)\mbox{--}(23i) \end{aligned}
(24)
in the form of a linear program [ 17] which can be efficiently solved using standard tools.
The optimal solution $$x^{*}(k)$$ of the optimization problem contains the optimal schedule for the grid power ( 19) and can be obtained by simply dividing the energies by the time interval $$\Delta T$$.
Also note that in the framework of a linear program, only constant efficiencies can be considered. This means, the functions ( 1a)–( 1d) need to be approximated with a value which reflects the average operating conditions of the power inverter. This is a crucial limitation as will be shown in the results section.

## 4 Measurement data

To evaluate the effectiveness of the three described algorithms in Sect.  3 simulation scenarios are constructed. Electrical load measurements, PV production measurements and tariff curves were used which represent a realistic operation of a domestic home over a full year cycle.

As load curve the measurement of a typical Austrian household with 2 adults and one child of the year 2015 with an annual consumption of approximately 5 MWh was used. This was measured at a sampling frequency of five minutes which was then refined with data with one-second resolution. This process was carried out by selecting five minute samples of one-second data which contain the same energy as the original five-minute data.

### 4.2 PV Generated Data

As a basis of the production data the measurements of a Si-based irradiance as well as temperature and wind sensors in Wels, Upper Austria, were used. This data is of the year 2015 with a resolution of one minute. To create a dataset of real power, models of the PV-LIB toolbox [ 18] were used to represent a PV system with an installed power of 5.8 kWp.

### 4.3 Electricity costs

The costs of electricity of domestic consumers usually consist of an energy part as well as an additional fixed and energy-dependent part containing taxes, fees and grid costs. These additional costs were calculated for an Upper-Austrian location with 10.9 €ct/kWh. For the energy part the historical spot price of the Energy Exchange Austria (EXXA) of the year 2015 with a mean value of 3.2 €ct/kWh was used. The Austrian spot market price changes hourly and is usually available around noon for the next day in case of online use. The combined electricity price is in this case quite low (the Austrian average is around 18 €ct/kWh) but shows the expected development of the overall electricity prices in Europe. For selling surplus energy a monthly mean of the spot market price without any additional costs was assumed.
Figure  4 provides a graphical representation of the measurement data used in the simulation study.

## 5 Simulation results

In this section we present results for a simulated period of a full year in a head-to-head comparison of the three different controllers.

### 5.1 Simulation settings

Simulations were carried out with a sample time $$\Delta T$$ of 15 minutes which seems to be a sensible choice [ 6]. The battery state of charge was constrained by $$SOC^{min}=0.3$$ and $$SOC^{max}=0.98$$. We assume a maximum charging/discharging power of $$P_{B,c}^{max} = P_{B,d}^{max} = 3000~\mbox{W}$$. The linear optimization controller used average efficiencies of $$\eta _{\mathit{PV}-\mathit{AC}}=0.92$$, $$\eta_{PB-B}=0.87$$, $$\eta_{AC-B}=0.93$$, $$\eta_{B-AC}=0.91$$. To determine the potential benefits of differently sized batteries, also compared to no battery at all, battery sizes of 0 kWh (no battery), 5 kWh and 10 kWh were simulated.

### 5.2 Results

Table  1 presents the total costs associated with the three different controllers and battery sizes. There is a significant cost-saving potential when a battery is included in the system. Cost-savings can be further increased with the brute force controller, and also modestly with the linear optimization controller.
Table 1.
Total costs and rel. improvement w.r.t the rule-based case for different setups
Controller
Storage capacity
0 kWh
5 kWh
10 kWh
Rule-based
350.82€
258.13€
197.28€
Brute force

230.44€
159.27€
Linear optimization

252.30€
188.86€

Rel. Improvement
Brute force

10.73 %
19.27 %
Linear optimization

2.26 %
4.27 %
A detailed analysis of the results shows that the brute force algorithm achieves less costs in every single week of the year, see Fig.  5. The linear optimization controller in contrast is not always better than the standard rule-based approach, see Fig.  6. This is mainly due to the use of average instead of the actual efficiencies which are given by Eqs. ( 1a)–( 1d) but cannot be implemented within the linear-program schematic. Changing the average values of the efficiencies inside the optimization (they are constant for the entire 1 year simulation) has a strong influence on savings in particular weeks, however the overall performance over a year varies only slightly.
The benefits regarding costs of the two controllers are associated with an increased usage of the battery storage. While the standard control typically performs one battery cycle per day, the others charge and discharge more often when the conditions are appropriate (e.g. a low electricity price in the middle of the night), leading to an increased number of battery cycles. The rule-base controller charged the battery with a total of 1831 kWh a year, the linear optimization controller with 2393 kWh and the brute force controller with 2570 kWh, respectively in the case of the 10 kWh battery.
Looking at the statistical distribution of the daily battery charging power in Fig.  7 the differences become evident: only in 25 % of the days the brute force control charges with less than 6.5 kWh and the 50 % box is quite narrow.
Note that in our battery model we do not consider aging effects of the battery. The increased number of charging cycles could be considered in the mathematical model and also in the controllers, but was not part of the current research. An increased battery usage will in general reduce the battery lifetime.
The largest improvement is achieved in week 49, see Fig.  5 and Fig.  6. In this particular week, as can be seen in Fig.  8, electrical load is following a regular pattern for this home, however, PV production is very poor (see the middle subplot). As a consequence, the rule-based controller hardly ever uses the battery in this week (see SOC-plot in Fig.  9). The brute force algorithm instead utilizes the information on electricity price and charges the battery extensively every day in the early morning when prices reach a minimum, see Fig.  10. The stored energy is then used for consumption, when energy prices are higher during the day.

## 6 Conclusions and discussion

A control-oriented way of modeling a power inverter connected with a PV system and a battery for storage, and three different control strategies with the aim of minimizing the electricity costs for the consumer were presented. Realistic simulations using real-world measurement data over one year from a domestic home revealed the cost benefits of different setups.
The brute force controller was implemented to obtain the minimally achievable costs when assuming perfect system knowledge and without real time implementation constraints. A significant cost reduction of 19.27 % compared to the rule-based controller was achieved with a 10 kWh battery. Due to its high computational demands and because of no use of feedback, this controller cannot be implemented in reality.
The linear optimization controller is able to obtain a cost reduction with respect to the standard controller but cannot come close to the brute force algorithm. This is mainly because of two reasons: First, the implementation as a linear program can only handle average efficiencies of the inverter, while the brute force controller has detailed information on the efficiencies functions. Second, the brute force controller considers the full time period of a year when computing the battery charge plan while the linear optimization is based on a receding time frame of 24 hours. Nevertheless, cost reductions of 4.27 % are possible. Better results are expected when efficiencies functions are considered, which would require to adopt nonlinear programming techniques which in turn cause an increase in computational complexity. A piecewise affine approximation of the nonlinear function using mixed integer linear programming will be the center of future research. The approximation will introduce additional nonlinearities since the efficiencies are multiplied by the decision variables.
The computational complexity of the linear optimization controller is moderate and solutions can be easily found within reasonable sample times.
The results presented indicate the potential cost savings under ideal conditions, but did not show the effect of prediction uncertainties. In reality, less performance is to be expected.

## Acknowledgements

This work has been partially supported by the FFG in the framework of the Austrian Energieforschungsprogramm. The fruitful cooperation and discussions with Thomas Natschläger, Christian Lettner and Patrick Traxler from the Software Competence Center Hagenberg, Austria, is highly acknowledged. The electrical consumption data was generated in the research project “ADRES-CONCEPT” (EZ-IF: Development of concepts for ADRES – Autonomous Decentralized Regenerative Energy Systems, project no. 815 674). This project was funded by the Austrian Climate and Energy Fund and performed under the program “ENERGIE DER ZUKUNFT”.