Mode-based energy storage control approach for residential photovoltaic systems

: This study presents a novel mode-based energy storage control approach. Assuming that an energy storage device (ESD) is equipped with a set of predetermined real-time control modes, the dispatch objective is to select an optimal mode instead of a continuous charging or discharging power value. A two-stage algorithm is developed for mode selection. In the first stage, a sliding 24 h economic model predictive control algorithm is used to determine the power outputs of the ESD for the next 24 h. In the second stage, the output sign for the next time step determines the class of modes to be elected (charging or discharging). The information from the first stage is used to compute the total cost for each selected mode. The mode with the lowest day-ahead cost is chosen. The residential electricity consumption data collected in the PECAN Street Project is used in the simulation to validate the performance of the proposed algorithm. Simulation results show that using a mode-based approach reduces the sensitivity to forecasting errors along with load and solar variability. The algorithm performance is consistent across different load patterns.

cost for the next time step using mode operation C base yearly base cost for a customer, without ESD ($) C case yearly cost for a customer using one of the algorithms, with ESD ($) C cycles cost of battery degradation per cycle ($/cycle) C EMPC yearly cost for a customer using MIP-only EMPC algorithm and a perfect forecaster ($) C export price to sell electricity ($/kWh) C import price to purchase electricity ($/kWh) C simu yearly cost for a customer ($)  importing status variable (1/0: import/export)

Introduction
High penetration of residential and commercial rooftop solar photovoltaic (PV) systems may increase power fluctuations in distribution feeders and reverse power flow directions. As a result, utilities may experience voltage issues. The intermittency of the solar generation resources resulting in backfeeding power and power swings are the main causes of these problems. In Germany, the feed-in-tariff [1] is being reduced, while in Hawaii, backfeeding is no longer allowed for newly installed PV systems [2]. Therefore, installing energy storage devices (ESDs) to store excess solar power and smooth power fluctuations is an increasingly attractive option to co-locate with residential and commercial PV systems. Another key driver for residential and commercial ESD adoption is the increase in reliability and resiliency to have backup power supplies during outages [3]. The main ESDs used for residential PV applications are different types of battery storage systems. In [4]  show that lithium-ion batteries can yield positive net present values while lead acid cannot due to the high recurring capital cost. Profitability remains highly dependent on battery economics. The objectives of scheduling and dispatching the battery systems include minimising utility bills [5,6], smoothing PV outputs, maximising self-consumed solar energy [7], and providing different grid services [8,9]. A variety of methods, such as dynamic programming [10], fuzzy logic [11], mixed integer programming (MIP) [12], and stochastic programming [13], have been proposed to solve these scheduling issues and dispatch the battery power outputs in real time. Among them, the most commonly used approach is the MIP-based approach that can find the optimal power outputs of the battery at each dispatch interval over a given scheduling period considering its operational constraints.
However, the MIP-based methods are sensitive to the accuracy of the load, PV, and price forecast. Unfortunately, for realistic residential load and PV data sets, day-ahead load forecast error is ∼20% [14,15]. The forecast accuracy of PV power outputs depends on the type of day. On a cloudy day, the forecast error can be over 50% [16,17]. In this error range, the optimality of the schedule obtained by the MIP methods will no longer hold. To cope with the forecasting errors, multi-stage algorithms (e.g. [12,[18][19][20]) are proposed. First, an optimal schedule is developed based on 24 h load and PV forecasts. Then, the schedule is adjusted every hour or every few minutes based on the updated forecast values.
Other methods to reach optimality under uncertainties and forecast errors are model predictive control (MPC) [21,22] and stochastic programming [13,23]. MPC has been previously used to control DER or energy storage, in [19] a multi-stage MPC is used to control energy storage considering load, solar and marker uncertainties. A two-stage MPC, for scheduling and real-time control, is proposed to test the optimality of the solution depending on predictions inaccuracies. MPC is a receding horizon optimisation-based algorithm that is used to adapt to uncertainties as fast as possible while optimising over the next horizon. However, the decisions will still be based on predictions and will be dependent on their accuracy. The main benefit would be to adapt faster to changing predictions and re-evaluate the best course of actions. Using stochastic programming can further reduce the dependence on prediction accuracy. In [24] stochastic programming is used for a virtual power plant scheduling problem with uncertainty on the load and market prices. A probabilistic optimisation method is applied in [?] to minimise customer's cost while considering load and solar uncertainties. The main advantages are to be able to take a less risky course of actions and use probabilistic methods to evaluate the next control actions.
All algorithms described previously determine the optimal battery power outputs to meet a specific objective, such as minimising payment or smoothing the power fluctuations. In this paper, the goal is to replace a continuous value target for the end of the next time step, by a mode of operation for the next time step. Residential applications are a particular problem due to the unpredictability of the load. The limitation of the previous algorithms is the lack of adaptability to this characteristic between control decisions. If an algorithm outputs a continuous value, it does not provide information on how to reach this goal. It is one of the reasons why rule-based algorithms can achieve very high performance in simple residential settings.
Oftentimes, for residential applications, the main issue for controlling batteries is deciding how to charge and discharge instead of determining the optimal charging and discharging power (due to uncertainty in forecasting the load). The important control information is to know, for example, if the battery should charge the excess of solar or discharge following the load instead of aiming for an objective that might not hold due to the unpredictable nature of the load. Assume that a battery storage system can be equipped with a controller with a set of built-in, real-time control modes. In this paper, we present a novel mode-based control approach so an external controller will control the operation of a battery system via selecting one of its built-in control modes. The design of the real-time control modes is first introduced; then, a two-stage algorithm for real-time optimal mode selection is presented. In the first stage, a 24 h economic model predictive control (EMPC) algorithm is used to determine the optimal battery power outputs for the next 24 h. Then, based on the optimal power output of the next hour, unsuitable modes for the next operating hour are eliminated. In the second stage, assuming that the battery is operating at one of the suitable modes in the next hour, the 24 h EMPC is run again to calculate the total day-ahead cost. Select the mode with the lowest cost to be the operation mode for the next hour. Note that a distinct difference between our approach and the approaches described previously is that, instead of calculating the optimal hourly battery charging and discharging power, the optimal battery operation mode is selected for the next hour.
Validation tests are conducted using 190 actual residential load and PV profiles collected in the PECAN street project [25]. The simulation results demonstrate that the mode-based approach outperforms the MIP-based approach consistently and shows less sensitivity to PV and load forecasting errors and load pattern changes.
The main contributions of the paper are twofold. First, we designed nine primary real-time operation modes for charging and discharging residential energy storage systems that cover a wide range of battery operation conditions. Second, we developed a twostage mode selection algorithm to select the operation mode for real-time operation. To the best of our knowledge, such an algorithm has never been proposed for residential energy storage applications.
The rest of the paper is organised as follows: Section 2 introduces the design of the real-time operation modes and architecture of the mode-based control approach. Section 3 presents the problem formulation. The simulation setups and results are discussed in Section 4. The conclusions and future work are summarised in Section 5.

Design of the real-time operation modes
The main advantage of using a mode-based control approach is to allow battery manufacturers to provide a set of standardised operation modes in a battery controller that can be fine tuned to achieve desired performances (e.g. high efficiency and long lifetime) at the battery cell level. Since the external controller needs only to select the best mode from a few built-in modes for the battery system to work at, the control and sensing tasks can be distributed to the battery controller and make the battery system a truly plug-and-play device. Fundamentally, this approach belongs to distributed, discrete control because it focuses on finding the best combination of a set of modes to realise a variety of control objectives. Thus, more built-in control modes bring more flexibility in control. However, the complexity of both the battery controller and the external controller will also increase. Therefore, in this paper, we introduce nine real-time operations modes: four charging modes, four discharging modes, and one idling mode, as shown in Table 1.
The normal process for identifying operation modes is explained as follows. First, optimisation-based algorithms (e.g. mixed integer linear programming-based algorithms) can be used to identify the optimal minute-by-minute battery power output using a perfect forecast for a selected utility rate. In this paper, we used time-of-use rate cases in Hawaii and California with net energy metering. Then, the resulting time series are analysed to summarise a set of common behaviours (i.e. idle, charging from solar, discharging following the load, charging at full power, discharging at full power, plus the associated modes with an energy limit). We initially selected nine modes (see Table 1) and then reduced them to five modes (see Section 3.4, Table 2) based on performance comparison results. This set of modes has been designed for TOU-based battery operations.
In this paper, the application we select illustrates how the modebased approach is: minimising the customers utility bill under the time-of-use rate. This application is selected because it is the most commonly used application in practice for residential energy storage. In addition, because actual load data and utility rates can be used in case studies, meaningful performance comparisons can be made with existing methods (e.g. MIP-based algorithms) to benchmark the performance of the mode-based algorithm.

Control logic of the idling and charging modes
Since the main goal of charging batteries in residential PV applications is storing excess PV power or charging at low price periods for future use, we designed four charging modes to meet these control objectives. First, let the battery power output, P B , be positive when charging and let the net load, P net , be positive if the load exceeds the solar generation. Second, let the mode selection occurs at the beginning of each hour and let the minimum operation period for each mode be an hour. During the ith hour, the mode controller will adjust battery power, P B ( j), every minute. Thus, Δt = 1/60 hour, j = 1...60, and i = 1...24. Define P CLim ( j) as the charging limit set by the customer for the jth interval and E CLim as the energy charging limit for the hour. Based on these assumptions, at the jth time interval, the netload, P net ( j), is calculated as Based on the battery energy level, E B ( j), and the battery energy limit, E max , the battery charging power cap, P CCap ( j), is calculated as Then, the battery charging power of mode m at the jth time interval, P B ( j) m , is calculated as: In the 'idling' mode, the battery output is simple zero, so we have

Control logic of the four discharging modes
Since the main goal of discharging ESDs in residential PV applications is supplying load at high price periods or using selfgenerated power, we designed four discharging modes to meet these control objectives. Similar to the charging modes, at the jth interval of the ith hour, we first calculate the battery discharging power cap P DCap ( j) as Define P DLim ( j) as the discharging limit set by the customer and E D lim as the discharge energy limit of the hour. Then, the battery discharging power of discharging mode m at the ith time interval, P B ( j) m , is calculated as Equations (4), (6), (10), and (12) represent the modes with an energy limit, E CLim or E DLim , for an hour i. Note that j represents the jth minute in the hour i. Under those modes, we keep track of the energy charged or discharged from the starting minute of the hour i (i.e. j = 1) to the jth minute of the hour i. Once the hourly charging or discharging energy limit is reached, the battery will idle for the remainder of the hour i. Based on (3)-(12), battery manufacturers can implement the built-in modes at the battery controller level [26]. An external controller, such as a home energy management system controller, can simply control the battery system by letting it operate at one of the nine modes instead of trying to determine the actual battery power outputs for the battery system at each time interval. This can greatly simplify the interface between the external controller and the battery system, making the battery system plug-and-play with guaranteed performance. In the next section, we introduce the method for selecting the best operation mode.

Mode-based controller design
In this section, we introduce the EMPC algorithm, the forecasting algorithms, and the mode-based dispatch algorithm.

EMPC method
In [21,27], the authors introduced the MPC method to minimise the deviations from given set points. The MPC is used to schedule appliances considering both newly updated information and forecasts. The MPC strength, lying in its recurrent optimisation process, is to minimise the impact of the forecast inaccuracies on the scheduling. In [22], the authors proposed the EMPC method to determine the set points for the ESD controller instead of minimising the deviations from the set points sent to the ESD controller, the EMPC uses a cost function as its objective function.
In this paper, we adapted the EMPC approach to determine the optimal hourly set point for the battery power over the next 24 h period. The objective function of the EMPC problem is to minimise the 24 h cost considering the cost of import and export energy as well as the cost of battery degradation, so we have s.t.
P import , P export , N cycles , P charge , P discharge ≥ 0 Equation (13) represents the objective function, the goal is to minimise the cost of electricity for the next 24 h considering the cost of battery degradation. The energy balance constraint is represented in (14). The constraint on the battery energy is represented in (15), while (16) and (17) represent the constraints on the battery power. Equations (18) and (19) are used to set a limit to the power that can be imported or exporter from/to the grid. u 1 and u 2 are binary variables to ensure the system does not charge and discharge at the same time, or import and export at the same time.
Equations (20), (22) and (23) show how the energy quantity related to the battery is calculated. Note that because the EMPC calculates hourly schedules, ΔT = 1 can be omitted from the problem formulation. We also used a simplified method to calculate the number of battery cycles in (21). More sophisticated methods for estimating effective battery cycles to account for degradation can be used, but because our focus is to formulate the mode-based control algorithm, we chose to use a simplified battery cycle calculation as an illustration for how to account for battery degradation.

Forecast methods
One of the main motivations in the development of the mode-based approach is to make the ESD dispatch less sensitive to the accuracy of forecast methods. Therefore, it is critical that the performance of the proposed algorithm is tested when using different forecasting methods and compared with the MIP-based approach. The EMPC algorithm requires price, load, and PV forecast as inputs. Since we use the time-of-use rate as an illustration of the mode-based control approach, price forecast is no longer required. So we consider mainly the accuracy of the load and PV forecast in our case studies. In [28], we described three forecasters (see Fig. 1): a perfect forecaster, an average load forecaster, and a neural-network-based forecaster. In this paper, we have demonstrated that for the modebased controller, an average load forecaster outperforms a neuralnetwork forecaster. Note that the average load forecaster is the yearly average load used as a constant forecaster.

Mode selection
In the mode-based approach, the external controller no longer sends set points [i.e. P B (i) or P B ( j)] to the battery system for controlling its real-time operation. Instead, the controller lets the battery system operate in one of the nine modes listed in Table 1.
To select the best mode, a straightforward approach is in reference to P B * (i), the optimal hourly battery power calculated by EMPC. Therefore, in the first stage, based on the 24 h ahead forecast of PV, load, and price, 24 h ahead optimal hourly battery power outputs, P B * (i), are obtained using (13) for optimising the energy bill for the next 24 h period (e.g. i = 1...24), as shown in Fig. 2. Fig. 2 showcases the different time scales of the EMPC-based scheduling and the real-time mode selection. First, run the EMPC scheduling algorithm to determine the hourly operation schedule from 1 to 24 h. Based on the EMPC calculated battery operation status for an hour 1, a real-time mode selection process determines the best mode for hour 1. Then, the battery will be operated by the selected mode in real time on a minute-by-minute basis for hour 1.
Based on the optimal action the battery should take for the next hour [i.e. P B * (1)], one can eliminate unfit control modes. For example, if the EMPC results show that the battery should charge at 2 kW for the next hour (i.e. P B * (1) = 2 kW), all the discharging modes are eliminated and all the charging modes are selected for the next stage comparison. Note that although an EMPC-based approach is used in this case to minimise the bill for the user over the 24 h period, one can use other methods for obtaining the operational trends. At the end of each first stage, we obtain the total cost of the 24 h scheduling period, C total * i = 1...24 = z 1 , the optimal ESD output for the next operation hour, P B * (1), and all feasible battery operation modes f. In addition, to determine the charging and discharging energy limit for modes 2, 4, 6, and 8, we have In the second stage, for each feasible mode, we calculate the minute-by-minute P B ( j) f using (3)-(12) for the first hour (i.e. when i = 1). Also, C(1) f and SOC(60) f can be calculated based on P B ( j) f . Using SOC(60) f as the initial condition, we run EMPC again for period i = 2...24 to calculate z 2 f . Then, the total cost is calculated by After we obtain the total cost for the next day for each feasible mode, the mode with the least cost can be selected. If the total cost of the optimal mode exceeds k% of the optimal solution z 1 , we will impose the charging or discharging energy limit, E CLim or E DLim . The algorithm for the mode-based control is summarised in Algorithm 1 (see Fig. 3).

Reduced mode operation
To simplify the operation, one can use a subset of the nine modes defined in Table 1. In the next section, we will model reduced modes operation, in which case, the five modes described in Table 2 will be used. By comparing the performance with the fullmode cases, one can determine what the marginal benefits are to have any additional mode. The algorithm for the reduced mode control is summarised in Algorithm 2. Algorithm 2: Control algorithm for reduced-mode operation 1: Steps 1-17 are the same as the full mode operation 2: Select the optimal charging mode m * as follows: ...

…
k × z 1 < C total 1 < C total 3 , select mode 1 k × z 1 < C total 3 < C total 1 , select mode 3 3: Select the optimal discharging mode m * as follows: ... … k × z 1 < C total 5 < C total 7 , select mode 5 k × z 1 < C total 7 < C total 5 , select mode 7 Considering modes with energy limit is necessary to reach close to the MIP performance with a perfect forecaster. This is due to discharging before the high-cost hours for example. If it is known that the house will consume 5 kWh during the peak hours and the state of energy of the battery is 6 kWh, the battery can discharge 1 kWh before the peak hours; if the cost is higher before rather than after the peak hours. However, without a perfect forecaster, the amount of energy to discharge during the shoulder hour is dependent on the forecast accuracy.

Simulation results
The simulation setup, performance evaluation criterion, and simulation results are presented in this section.

Simulation setup
Data collected in the Pecan Street project [25] are used to benchmark and validate the performance of the proposed modebased approach. We selected 190 houses in Austin, Texas, for the study. All households have sub-metered data for PV and total load with minute-by-minute data points in the year 2015 (i.e. 365 × 24 × 60 data points). Therefore, each simulation run is 1 year with a 1 min interval. The characteristics of this data set are summarised in Table 3.
Hawaii time-of-use (TOU) rate (see Table 4) is used in the simulation, so no price forecast is needed. In Hawaii, no backfeed is allowed so the main goal for controlling energy storage systems is self-consuming solar generation and shifting consumption to low price periods. Six scenarios (see Table 5) are simulated to compare the performance of the mode-based algorithm with the base case and the MIP-based EMPC algorithm when using different forecaster. Case 1 is designed to demonstrate the optimality of the mode-based approach so we assume in this case the load forecast is perfect. Case 2 is designed to show the sensitivity of the modebased algorithm with respect to the forecast accuracy. An average load forecast is an inaccurate energy forecaster comparing with other sophisticated forecasters as it yields only a daily average load. We will demonstrate how optimality will be influenced if such a forecaster is used. Then, we demonstrate a reduced mode operation, in which case 5 modes (see Table 2) instead of nine modes (see Table 1) are used. This case compares whether or not additional modes are needed. To compare the influence of the battery size, we modelled two battery sizes: 7 kWh/3 kW and 4 kWh/2 kW. In both cases, the charging and discharging powers are the same and the round trip efficiency is 90%.

Performance evaluation criterion
To evaluate the performance of different cases, we calculate the percentage of the maximum savings achieved, PMSA, for each house in the data set as where C base is the annual cost of the base case where no battery is installed; C EMPC is the annual cost of the EMPC plus perfect load forecast case so it represents the optimal cost; and C case is the cost of the four mode-based control cases described in Table 5.
The annual cost is calculated as where P import (i, j) can be calculated using (14) and C import (i, j) is the TOU rate. Note that because we used the Hawaii TOU rate, backfeeding power is not allowed so it is not paid. Therefore, in (28), there is no export-related revenue.

Simulation results for 190 households
In Table 6 we compiled the saving results and the PMSA results for the different cases studied in this paper. We can observe that cases 1 and 3 yield close to the maximum performance. Showing that using modes + perfect forecast does not have a significant impact on performance. The modes outperform the EMPC with AL forecast. Using the simplified mode algorithm yields better performance than the full mode algorithm while using an average load forecast. As shown in Fig. 4, using the EMPC algorithm, the battery receives from the central controller hourly set points that are optimised based on 24 h ahead forecast. Since the actual load varies within each hour, the battery may either over-discharge or under-discharge when forecasting accuracy is poor. The battery mode-based controller charges/discharges minute-by-minute to reach an overall goal of self-consumption while shifting energy to the off-peak hours. Therefore, the controller tends to let the battery follow the net load. Thus, the forecast inaccuracy has a very little impact on the mode-based algorithm. Since the mode-based algorithm approximates the optimal action in each hour, the main goal for benchmarking its performance is to estimate to what extent the optimality can be reached using (27) and (28).
To quantify the influence of selecting different battery sizes on optimality, we modelled two battery sizes: 7 kWh/3 kW and 4 kWh/2 kW. As shown in Fig. 5, in case 1, we achieve very close to 100% PMSA for both battery sizes for all 190 houses. When an average load forecaster (i.e. case 2) is used, the PMSA for the 4 kWh/2 kW battery is slightly (∼5%) better. Overall, the mode-    based approach achieves more than 70% expected savings for over 95% of the 190 houses. Since the test results are consistent across 190 houses, we conclude that the algorithm meets the need for a majority of customers. In addition, because the results are obtained using a daily average load forecast, the results demonstrate that the mode-based approach is less sensitive to the forecaster accuracy.
Define PV-to-load ratio as the yearly PV generation divided by the yearly load consumption. We plot the PMSA of the 190 houses with respect to the PV-to-load ratio for the 7 kWh/3 kW battery in Fig. 6. A small positive correlation with the PV-to-load ratio is observed. When the PV capacity is equal to or greater than the total load consumption over the year, the PMSA is normally above 80%. This shows that for a house with higher electricity consumption, the PMSA is usually higher.

Reduced mode operation
In reduced mode operation, we will not enforce the energy limit. Thus, we remove the modes 2, 4, 6, and 8 from the suitable mode sets as shown in Table 2. Then, we compared the PMSA of the reduced-mode operation with the full mode operation.
As shown in Fig. 7, although the PMSA is still above 95%, the reduced mode control algorithm can no longer achieve 100% expected savings when the load forecast is perfect. This is because enforcing an energy limit helps the mode-based algorithm to achieve optimality when forecasting is accurate. However, if only an average load forecaster is used, the average PMSA of the reduced mode algorithm is higher than that of the full mode. This is mainly because adding a charging or discharging highly depends on forecasting accuracy. When using an average load forecaster, E CLim (i) and E DLim (i) can no longer reflect a good estimation for the optimal charging or discharging energy for the hour, so having E CLim and E DLim will not improve the overall performance. This case demonstrates that it is not necessary for all modes to be selected and used in operation.
Without a perfect forecaster: the battery could over-discharge before the peak hours and reduce the overall performance of the system. The reduced mode control eliminates this possibility of setting energy limits; therefore, further reduces the need for an accurate forecast. Removing energy limits eliminates the possibility to 'pre-discharge' and would allow keeping more energy for the peak hours.

Comparison with MPC
In Fig. 8, the reduced modes algorithm is compared with an EMPC algorithm with 5 min time step, 24 h horizon during the month of August on 20 houses from the same data set as previously used. It can be observed that with a perfect forecaster the EMPC finds the optimal solution but in the presence of the average load forecaster, the mode-based algorithm performs better. The low performance of the EMPC can be explained by the usage of a constant load forecaster, using a constant forecaster does not allow to take advantage of the receding horizon at a lower time step as the prediction of the future does not change.

Conclusion
This paper presents a mode-based scheduling approach for standardising the energy storage controller design. When controlling batteries for residential PV applications under the timeof-use rate, instead of sending the device charging or discharging power command, the system controller can send to the energy storage controller a mode command for the storage devices to be operated in one of the built-in modes for the next hour based on the 24 h forecast. This will allow the energy storage controller to make real-time power adjustments for meeting the control objective. By doing so, the central controller will distribute the real-time control function to the local controller while providing the local controller  with a guidance for minimising the cost in the whole scheduling period.
Using actual measurement data from 190 houses in Austin, Texas, comparisons are made to quantify the sensitivity of the mode-based control with respect to the forecaster accuracy, battery size, and PV-to-load ratio. We also show that based on forecasting accuracy, reduced mode operation can outperform the full mode operation. From those simulation results, we conclude that: • the mode-base algorithm is less sensitive to the forecaster accuracy compared to the MIP-based algorithms; • the mode-based algorithm can be used as a generic control algorithm with very little customisation because its performance is consistent for the 190 houses when different battery size is selected; • with a perfect forecaster, the mode-based approach can achieve the theoretical best performance achieved by the MIP-based algorithms; • and the reduced mode operation may yield better performance than the full mode operation when forecaster is not accurate.
Our future work will focus on using machine learning algorithms for mode selection. This will allow us to advise customers which sets of mode to use even without historical data.

Acknowledgments
This project was funded by Total Inc. and SunPower. The authors wish to thank Franck Ragot, Brice Chung, and Carl Lenox for their valuable comments and support on the project.