Control strategy for battery-supported photovoltaic systems aimed at peak load reduction

The use of photovoltaic (PV) technologies is one of the key means for achieving the balance between operational power demand and generation in net Zero Energy Buildings (nZEBs). However, direct use of PV power on-site is limited due to wide variability and uncertainty of PV output, the temporal mismatch between PV generation and load and other factors. Consequently, in addition to low self-consumption rates, the problem of peak grid load and peak PV feed into the grid persists. Batteries that are coupled to PV units may partially offer the solution to these problems, if operated under an intelligent control strategy. In this paper we proposed a forecast-based control strategy for battery-to-grid interaction aimed at enhancing selfconsumption and at reducing peak load. Python programming environment was used for data processing and algorithm development. Exemplification was made based on the reported hourly energy demand in one office building of 3000 m2 heated floor area located in Trondheim, Norway. Forecasting of electricity load profiles was based on the seasonal autoregressive integral moving average (SARIMA) model. For PV power forecasting, the algorithm communicated with external service – Solcast API. The search method for optimal scheduling of operational time and the extent of charging/discharging was proposed. The results showed that as opposed to conventional battery use, this control strategy allowed to achieve significantly more consistent grid interaction. It offered highly accurate battery scheduling on a day-ahead basis while utilising minimum historical data and computational resources. The algorithm may be beneficial for end-users and grid operators, and thus, it has a high potential for future integration into building energy supply systems.


Introduction
Meeting strategic energy and environmental targets for nations and communities requires significant performance improvements in building sector. Net Zero Energy Buildings (nZEB) would play a crucial role in achieving these targets through low operational energy use and production of renewable energy at a quantity that meets building's delivered energy over the service lifetime [1]. Photovoltaic (PV) energy is considered as the key source that enables nZEB under various climate conditions and related political circumstances. Although grid-connected nZEBs do not require a match between instantaneous PV generation and instantaneous load, it is often preferred to increase the share of PV energy directly consumed on-site (self-consumption rate). One of the reasons for that is profitability as a result of the difference between selfproduced and retail electricity prices, grid feed-in tariffs and numerous incentives [2]. Another reason is the need for more consistent grid interaction, i.e. the solutions for frequency regulations and future power grid reinforcement to handle high PV feed-in and high loads are required otherwise [3]. Maximising the building selfconsumption while avoiding peak grid loads, therefore, is one of the key challenges that is focused by the research initiatives in the discipline. Two distinct but not mutually exclusive approaches can be used to tackle these challenges: demand side management (DSM) and the use of battery energy storage systems (BESS). The former is concerned with shifting the deferable loads to the time when PV system has high output. It often includes rescheduling of heating, ventilation, air conditioning and some other types of household equipment. The other approach enables energy flexibility by using PV energy stored in batteries at the time when load occurs. BESS is recognized as having a larger potential to increase selfconsumption rates [4]. Currently, best practices in the field of energy flexibility involve a combination DSM and BESS [2,5].
For the effective use of both these approaches, a reasonably accurate forecast of energy demand and PV generation in the (nearest) future is required [2]. Instantaneous load and on-site PV power, however, are the sources of variabilities and uncertainties. In addition to thermal properties of the building envelope, climate, energy supply systems, building purpose, occupant behaviour and maintenance practices determine the unique shape of load profile that changes on day-to-day basis. Solar power profile is a function of daily and seasonal variations of both direct and diffuse radiation, outdoor temperature and other factors. For a short-term load forecasting in real-time, building energy performance simulation techniques are rarely used. Detailed simulation is constrained by computational capabilities and the need for exhaustive building-related information. Data-driven approaches, on the contrary, may resolve some of these limitations [6]. Their use for electric energy demand prediction has been mainly done by regression analysis, machine learning techniques, and time series forecasting. With regression analysis, one aims at identifying a set of influential variables and the underlying (often non-linear) model structure. Machine learning techniques offer the benefits of automated pattern discovery instead. Amongst the limitations of both these approaches is the need for several explanatory variables. With time series modelling, however, the prediction of target variables can be made based only on the past observations of itself, i.e. applicable for univariate problems. Therefore, such adaptive, parsimonious time series forecasting is expected to play an important role in facilitating energy flexibility and more consistent grid interaction for nZEBs.
Likewise, real-time PV power forecasting under uncertain weather conditions is one of the fundamental challenges to enable energy flexibility. Practical solutions are offered by persistence models, physical and statistical approaches [7] that utilise sky models or data streams from either satellite imagery or reference PV systems. Recent advancements in the field succeeded at combining these into hybrid approaches which allows to achieve high forecast accuracy [8].
Given that two components, the forecasted PV output and load profiles are available, battery charge/discharge operations can be scheduled with one or more objectives, most often these are maximising self-consumption or battery service lifetime, minimising energy cost, # intensity or peak grid loads. A comprehensive overview of operational strategies for PV-coupled battery systems, their objectives and methods are available in studies [4,9,10].
In this study, some of the best practices related to forecast-based control were implemented and elaborated further. Analysis and modelling tasks were carried out with Python programming language using NumPy, SciPy and Sk-learn libraries for numerical computing, Statsmodels for model training/testing, Pandas for data wrangling, Matplotlib and Seaborn for data visualisation.

Case study
A case study was one non-residential building located in Trondheim, Norway. It is used for health-related and recreational purposes and has the total heated floor area of more than 3000 # . Both electric and district heating energy use for the building were reported on hourly basis and accessible as datetime-indexed arrays through an energy monitoring platform.
Historical data over the entire building's monitoring period of more than five years is illustrated in Fig. 1. Because district heating was utilised in cold periods, electric energy use exhibits weak seasonality through the year. Also, no monthly/weekly seasonality was observed. Since such seasonality in electric energy use is negligible here, further data analysis and algorithm exemplifications are made using the most recent observation (   It can also be observed from Fig. 2 that the series has a strong daily pattern. The lowest electric energy use for the building occurs at around 6:00. It increases in linear or exponential manner through the day, achieves its peak between 15:00 and 23:00 followed by decrease through the night. The building is assumed to have a PV system of 150 total installed capacity in place with southoriented, 30° tilted modules.

Energy use forecasting
For univariate time series forecasting, the Box-Jenkins Autoregressive Integrated Moving Average (ARIMA) model is one of the most commonly used [11,12]. For applications with seasonal effects, ARIMA( , , ) has been modified to the multiplicative seasonal SARIMA( , , ) × ( , , ) : . Studies [13,14] exemplify its application for energy forecasting purposes. Model's parameters are following: , -non-seasonal and seasonal autoregressive (AR) components; , -non-seasonal and seasonal order of differencing; q, Q -non-seasonal and seasonal moving average (MA) components; -periodicity of the season. Detailed formulation for both ARIMA and SARIMA is provided in literature [15]. In this study, an open-source statistical computing package Statsmodels [16] has been used for SARIMA training/testing. Package documentation contains the details on SARIMA implementation in Python.
Model's application requires the series to have constant mean, variance and autocorrelation, i.e. stationary process. This is not the case for original series, as can be seen in Fig. 2. A sequence of steps for process stationarization here involves seasonal and non-seasonal differencing. The corresponding autocorrelation and partial autocorrelation functions (ACF and PACF) are illustrated in Fig. 3. To induce stationarity, the first non-seasonal differencing was taken on the original series: -original series; -backshift operator, such that: The ACF of the resulting series shown in Fig. 3b.1 still indicates the presence of statistically significant lags. Therefore, an additional seasonal differencing step was applied: Referring to the original series, the additional seasonal differencing was obtained as: The newly acquired time series had the mean value close to zero (0.0028) and a reasonably small number of significant autocorrelations as shown in Fig. 3c.1, at lag 1, 2, near-or at the first seasonal lag that did not repeat afterwards. This series was considered stationary, which is also confirmed by the Dickey-Fuller [17] test. The partial autocorrelation function (PACF) plot shown in Fig.  3c.2 exhibits slow decrease at the non-seasonal level and a spike at the seasonal lag. Although further differencing may result in even more consistent series, this step could induce the negative effect of overcomplication and overfitting the model. Moreover, as reported by others [18], these seasonal lags could merely reflect large correlation of non-seasonal ones.
The PACF correlogram in Fig 3c.2 indicates that the first 4 lags are significantly different from zero, thus suggesting the feasible non-seasonal component to be within the range AR ∈ [0,4]. Similarly, from the ACF plot in (Fig. 3c.1) non-seasonal MA ∈ [0,4]. Because PACF and ACF in final series indicate significant near-seasonal lag, the seasonal AR and MA chosen here are 1 and 1.
Since non-seasonal components AR ( ) and MA ( ) are essential for the model performance, their identification in this study is facilitated by grid search method. Grid search over the parameters' space implies training and evaluating the models with all feasible combinations of parameters , . The root mean squared error (RMSE) can serve as a reference metrics for the model performance evaluation used here, defined as: where: -number of samples; The preferred model parameters ( , ), therefore, correspond to the lowest RMSE obtained on the test set.
As an additional measure used to ensure that the selection of and is not affected by coincidental patterns in the series, a -fold cross-validation (CV) procedure is applied. CV for time series models implies splitting the dataset into subsets where a training set is immediately followed by a test set. Thus, 90 most recent days of monitored data are split into = 5 subsets as illustrated in Fig. 4. Grid search is conducted for each CV step. Further, the parameters ( , ) are selected based on average RMSE for all CV steps, as illustrated in Fig. 4 with color-coded heatmap.  Forecasted series overlays closely with the test series. Both, in-and out-of-sample residuals do not exceed 10 ℎ. In-sample residuals follow normal distribution. Out-of-sample residuals density, however, is skewed to the left compared to the shape of equivalent normal distribution which indicates the loss of accuracy in long-term forecasting. Although such systematic error can be neglected in some applications, we restrict this control strategy to day-ahead horizon, where the accuracy is the highest.

PV power forecasting
As was mentioned before, the proposed control strategy involved communication with external service Solcast API [19] to obtain high-quality PV output forecast. Data request included geospatial (latitude and longitude) and technical information about the PV system (installed capacity, azimuth and tilt angle). The API's response is a datetime-indexed array of the forecasted PV power with 30 minutes temporal resolution over a span of 7 days. Further data wrangling involves two steps. Since the response dataset is UCT-indexed, a conversion to local time is needed. Also, original data is converted from power to energy units and from 30 minutes to hourly intervals. An example of postprocessed API's response based on PV system's parameters mentioned in Section 2.1 is illustrated in Fig. 6.

Load matching
Given that the energy use and PV generation profiles were known, the task of load matching was to allocate the aggregated daily PV energy to the time when energy use is the highest on that day. This implies finding threshold value ( ) that separates grid from battery energy use. The task could be formulated as follows: -absolute error tolerance, ℎ. Solving this problem analytically would require approximating the load and PV curves and their subsequent integration. To avoid the associated loss of accuracy, a numerical search technique has been implemented instead. Namely a dichotomous search algorithm was used to find the threshold value . Fig. 7 illustrates the search for on Oct. 9 '( , 2018. By gradually eliminating half of the continuous search space that was known at previous iteration, the condition (eq. 6) is achieved in a recursive manner after 8 iterations with = 11 ℎ, which yields:

Results and discussion
Given the techniques discussed above, this study proposed the algorithm for day-ahead battery operation scheduling that follows a block diagram in Fig. 8.
The first step was to send two data requests: one for historical energy use data (of a desired length, e.g. = 90 days) and one for PV output forecast (installed capacity, latitude, longitude, the azimuth and the tilt of the PV modules). The response from Solcast API was then converted to local time, from power to estimated energy units and from 30 minutes to hourly time resolution. Since the day-ahead forecast was used, the series is cut at 24 '( element. The response from the energy monitoring system's API is a datetime-indexed array of length = 24 . 5 grid search and cross-validation steps were taken after which the SARIMA model parameters ( , ) were selected such that the corresponding average RMSE is the smallest. With these parameters, SARIMA( , 1, ) × (1,1,1) #E was trained using the entire -length training set. The trained model was further used for predicting energy use for the following day. Both arrays, the forecasted energy use and PV output enter the load matching unit and follow the procedure described in Section 2.4. After the load matching task was completed, the delay of 24 hours is initiated. The output of load matching unit was the reshaped grid load profile and the recommended battery charge/discharge dynamics (as exemplified in Fig. 9) to achieve such peak shaving effect.  Technical and climate conditions under the test case did not entail the need for controlling grid feed-in, because daily aggregated PV energy is always smaller than aggregated energy use. In case if daily PV generation was higher, a search algorithm would separate PV profile into two parts, one for self-consumption and one for grid export: Thus, an algorithm suggests a reshaped profile, where the peak energy use and/or PV feed-in are avoided. Significantly more consistent energy use profile can be achieved for the days with high PV output, e.g. Oct. 8 '( and Oct. 10 '( . Over the entire period between Oct. 8 '( and Oct. 14 '( , 461 ℎ of available PV energy offer 5% to 51% reduction of daily peak energy use from the grid.
This approach for day-ahead scheduling of battery operational time and intensity remains relatively simple and requires little historical data. It may also be used to reshape load profiles in response to dynamic energy price or # intensity.
The selection of some parameters for SARIMA was justified and automated. However, a different case study might reveal the need to conduct grid search over a larger set of parameters, e.g. seasonal components ( , ) or to make more steps to achieve stationary series ( , ). Additional strong seasonality in building operation, e.g. weekly/holiday-based, monthly or annually, may require added complexity of SARIMA, resampling the underlying data or considering another time series model. The needed length of historical data must be satisfied accordingly. Further automation of these procedures, therefore, is needed to achieve more robust battery control that would suit the buildings of various types and more complex load profiles. For on-site algorithm deployment, as opposed to forecasting carried out in data centres, optimization of computational time and resources usage may be necessary.
Forecasting and control principles used in this study exclude the adaptation to sudden, unforeseen changes that may occur on the short term. Also, no attention is given to the potential technical limitations associated with charge/discharge intensity, critical depletion and system's losses. The authors anticipate the best application of the algorithm in combination with model predictive control or similar.
Expanding the forecasting horizon and considering a more long-term control strategy may offer even more consistent load profile. This option, however, is limited by accuracy (as can be seen in Fig. 5) and data needs in forecasting techniques currently used. Potential improvements of energy use forecasting can be achieved through including exogenous variables in time series modelling, e.g. thermal properties of building envelope, HVAC equipment specifications/setpoints and detailed data of occupant behaviour. The improvement of forecasting accuracy is also expected through supplementing time series models with other techniques, as discussed elsewhere [6].
Longer-term control strategies are likely to require more battery storage capacity. Techno-economic feasibility studies of such measures would have to address the trade-off between self-consumption rate, smoothness of grid interaction, battery capacity and utilization rate. This should be in line with the measures to prolong battery service lifetime as discussed in study [20]. As outlined in another study [4], the acceptance of such control strategies in buildings and communities highly depends on economic, technological and policy-related factors.

Conclusions
In order to meet energy efficiency and environmental targets without compromising grid stability, an increased self-consumption while smoothing grid interaction has to be promoted in nZEBs. This challenge requires not only capacity gains for PV systems and energy storage units, but more intelligent approaches for their utilization. The latter relies strongly on accurate energy and PV output forecasting.
With this article, an autonomous, parsimonious forecast-based control strategy was proposed. High performance of building energy use forecasting was achieved with time series model SARIMA supplemented by grid search for parameter identification and 5-fold cross validation. The proposed algorithm benefits from high quality satellite-derived PV power forecasting services. It is shown that for peak shaving purposes, the battery operation time and intensity can be scheduled on a day-ahead basis.
Such control strategies are likely to contribute to achieving the energy and environmental targets under the growing demand for efficient built environment. An increasing accessibility of PV systems and energy storage solutions are expected to positively influence their adoption.