Optimal energy management for PV-integrated residential systems including energy storage system

Economic proﬁt is the main incentive for PV-integrated residential prosumers, so energy management algorithms play a key role in these systems. The main priority of conventional rule-based energy management systems (REMS) is to supply the demand. As a result, the total amount of energy sold to the distribution network, and consequently the user proﬁt in such systems, is not considerable. This study proposes a smart energy management system (SEMS) for optimal energy management in a grid-connected residential photovoltaic (PV) system, including battery as an energy storage unit. The proposed method, which is simulated by MATLAB, using real values for load and PV characteristics, will result in achieving an economic plan for battery operation based on a discretised state of charge of the battery. Experimental tests, carried out to verify the simulation results, demonstrate a noticeable increase in the prosumer beneﬁts as well as the load proﬁle correction compared to the classic energy management algorithms.


INTRODUCTION
In recent years, distributed generation has been developed in large scales, most of which in the form of renewable resources due to the depletion of fossil fuel resources as well as environmental concerns [1]. As an example, the number of residential prosumers, who have equipped their houses with photovoltaic (PV) systems, has been drastically increased in Queensland, Australia in which PV systems with 10 kW of output power or less have been installed in over 30% of the residential buildings, reaching its total solar power generation to the remarkable capacity of 1500 MW [2].
Two fundamental drawbacks against further expansion of these systems are the high cost of solar equipment and their low efficiency [3]. These two obstacles decrease the system profitability and hence increase the period of return of interest [4]. Numerous studies have been done in distribution networks in order to mitigate the impacts of these impediments on the expansion of PV systems. In [5], optimal allocation and sizing of the energy storage device are discussed in a microgrid considering the electricity market context. In [6], the storage potential of battery-integrated PV systems and their ability to participate in demand response programs are compared in terms of the reduction of the electricity bill. Another trending policy in some countries is to offer incentives such as electricity feed-in tariffs (FITs) [7] for small-scale grid-connected PVs to encourage customers and investors to generate green solar power and participate in electricity markets [8,9]. While newer technologies of cell production are developed continuously at research centers to reduce the prices, there is an alternative method to increase the economic profit for investment, which is realised through maximising the total energy sold to the utility grid, while supplying the local demand.
The home energy management system (HEMS) controls the direction and magnitude of power flowing to/from the battery as well as the power transferred to/from the grid [10,11]. Therefore, the energy management algorithm plays a key role in determining the revenues and costs of the system resulted from the power exchange with the grid. In typical standalone or grid-connected residential PV systems, a predefined set of if-then clauses are employed for the purpose of energy management known as rule-based energy management system (REMS) [12]. Generally, the function of such algorithms is to calculate the reference values of power for each converter to track, based on periodic measurements of PV output power (P PV ) and load demand (P Load ). Thus, the generated solar power is transmitted either to load for consumption or to the battery for storage or to the grid for sale.
Since the efficiency of solar panels is of low orders compared to other resources [13], HEMS needs to be energy efficient under any operational scenarios, in order to minimise residential demand dependence on grid power. However, the major drawback of the REMS control scheme is the fact that the overall efficiency of such systems varies significantly for different consumers [14] since a predefined set of rules is used in REMS, regardless of prosumer's load pattern. In other words, the efficiency of REMS-controlled systems is affected by changes in a user's load pattern or from one user to another.
The major novelty of the present study differs from the relevant work in the literature in several aspects. In [15], a mixedinteger linear programming (MILP) method is proposed for minimising the operational costs of a hybrid AC/DC microgrid, including PV generation and battery energy storage system (BESS). However, constraints regarding battery have not been considered in the objective function (OF) formulation. The authors in [16] have proposed an optimisation-based HEMS for a residential building with both fixed and schedulable loads. In this study, power flow between residential unit and utility is unidirectional, that is, power sale to the grid is not considered. Moreover, the optimisation is conducted only for a fixed tariff scheme. In [17] optimum scheduling for power-sharing is determined in a residential system containing both heat storage and BESS in order to minimise costs and CO 2 emissions. However, no load forecasting method is utilised for the day-ahead operation of the energy system. Also, the profit obtained from energy selling to the grid is not considered in the cost function. Finally, in [18], an innovative analytical technique is utilised for addressing battery lifetime degradation in PV-integrated systems due to frequent charging/discharging cycles. Using the proposed method, battery optimal size can be calculated via analysing short-term fluctuations of irradiance and load profiles. In the conducted optimisation, prosumer's profitability has not been of interest.
According to the above-mentioned issues, this study proposes a smart energy management system (SEMS) algorithm for grid-connected PV systems to increase the residential PV system adaptability with different user's dynamic demand patterns. The proposed SEMS utilises a dynamic load forecasting method in order to track the consumption pattern throughout the system operation. Using the forecasted load pattern, an optimisation is performed to determine the power flowing through each element of the system for the day ahead, with the goal of maximising prosumer's benefits. The optimisation is a multistage decision-making process based on the load demand and PV output power forecast. Simulation results, verified by experimental tests, demonstrate that applying the proposed algorithm leads to maximising the economic benefits during the long-term operation of the PV-integrated energy system. The contributions of this study are as follows: 1. An optimisation algorithm is proposed with the purpose of maximising prosumer's economic benefits, based on the dayahead load demand forecast and PV generation estimation. 2. A hybrid statistical model is implemented for load demand forecast and a real-time error correction procedure is pro- The rest of this study is organised as follows. In Section 2, topology and model configuration of the proposed system, including PV array, battery, and converters, as well as load forecasting unit and SEMS are introduced. The proposed energy management system (EMS) is further discussed in Section 3. The simulation and experimental results are shown and discussed in Section 4. Finally, the conclusion is presented in Section 5.

SYSTEM TOPOLOGY AND CONFIGURATION
As shown in Figure 1, the proposed PV system is composed of the following components: MPPT-controlled PV array, battery storage and charge controller, load forecast unit, DC/AC converter and SEMS.

Battery storage and charge controller
A battery is integrated into the power system shown in Figure 2 not only to mitigate PV power fluctuations before being transferred to the grid but, more importantly, to save PV excess energy for later use. In other words, without a storage device, the only possible energy exchange strategy is to transfer the excess (deficit) PV power to (from) the grid [19]. In this study, a lead-acid battery [20] with a total capacity of 10 kWh and a nominal voltage of 24 V is used for simulation purposes. The storage capacity of batteries is chosen relatively higher than the average to indicate the best performance of the proposed algorithm because it increases the system potential to draw energy from the grid in off-peak periods and to sell in peak intervals. The 10 kWh storage capacity is calculated according to the constraints imposed on battery, including minimum and maximum allowable SOC, as well as the battery maximum System layout in PV-integrated energy system including battery charge/discharge power and off-peak period duration [21], which will be discussed further in Section 3.2.
It should be noted that although selecting lower capacities decreases the initial investment costs, it diminishes the total stored energy available for selling to the grid which reduces prosumer's profit during system operation. Therefore, battery capacity must be selected according to the difference between selling and buying prices of electricity to/from the grid.
The battery bank is connected to the DC bus through a bidirectional DC/DC buck-boost converter, which controls the charging/discharging power.

SEMS controller
Energy management in residential PV systems with storage can be defined as an optimal power flow control scheme in an energy layout as illustrated in Figure 2. Since the battery and grid power are the dependent variables [22], there is one degree of freedom, that is, the magnitude of power transferred to/from the grid in each time interval which can be controlled.

Load forecasting analysis
Load forecasting is an essential requirement for the proposed SEMS algorithm because along with the PV power forecast [23], it provides insight into lack or excess of energy at each time interval for hours ahead. There are numerous mathematical and statistical models for load forecasting purposes [24,25]. This study uses a combination of two statistical estimation models, that is, weighted moving average (WMA) and linear approximation to minimise the mismatch between estimated and actual values. WMA model averages a preset number of previous data samples with different weight coefficients to predict the next day's demand [26]. WMA's major preference over many other load estimation models is its ability to consider as many data samples as required for achieving the desired precision. Moreover, it assigns different weight coefficients to effectively address last day's load data over previous days', so that the credibility of the results would increase. On the other hand, a drawback of this model is its inability to follow the demand Flowchart diagram of rule-based energy management system (REMS) algorithm growth immediately, that is, the output value of WMA model is always between the minimum and maximum data values, regardless of the sudden load increase. Therefore, in this study, a linear approximation based on the two most recent data samples has been used in conjunction with WMA model to enable the system to track the sudden load growth, for the day-ahead planning. The equation for the proposed hybrid model is as follows: (1) The error analysis of the proposed forecast algorithm done in Section 4 shows the effectiveness of the proposed hybrid model for the load demand prediction.

PROPOSED EMS
The noticeable difference between peak and off-peak demand causes the losses to increase, operational stability margins to reduce and the system expansion costs to grow. Therefore, smoothening the load profile is of great technical and economic importance. In this regard, EMS plays a key role in PV-integrated systems, since reducing power demand from the grid at peak periods and increasing in off-peak periods lead to a smoother residential load profile and consequently overall demand profile. This is possible through the presence of battery as an energy storage device in the system. The flowchart diagram of the common REMS algorithm in PV-integrated systems under the time of use (TOU) tariff system is illustrated in Figure 3. However, in the proposed SEMS algorithm, discrete optimisation is performed based on maximising the user's profit.
In this study the battery's SOC is selected as the criterion for combinations (states) at each time interval in the problem statement. Accordingly, battery's SOC is the primary output variable of the optimal transitionary plan because other variables such as battery power (P Batt ) and grid power (P Grid ) are dependent ones Forward discrete programming diagram [27] which can be calculated using Equations (1) and (2):

Optimal operation scheme of battery
Being suitable for achieving a set of global optimisation goals considering constraints, in this algorithm, all the feasible paths from initial to the final point (hour) are assessed based on an OF. As shown in Figure 4, it is a multistage decision-making process in which every stage depends upon its predecessors and successors [27]. In each transition from state i of stage k to state j of stage k + 1, the value of the OF is calculated. This procedure is repeated for all the possible transitions and a predefined number of maximum OF values are selected for stage h. This is repeated for all the stages until an optimal path, that is, the optimal sequence of states for all stages is obtained.
According to the optimisation constraints, the proposed algorithm eliminates the infeasible transitions and calculates the OF only in the feasible transitions starting from t = 0, towards t = 24 of the next day. Then, the most profitable route can be determined accordingly. Decreasing the calculation burden regarding the infeasible transitions makes the proposed algorithm suitable to be implemented in online energy management units.
In this study, the diagram is composed of N stages (hours), each of which contains M states (discretised battery SOC levels). The goal is to find the optimal sequence of SOC transitions from the initial time to the final with the highest value for the OF, which will be discussed in Section 3.2. Values of N and M can be obtained from Equations (4) and (5) based on step sizes, Δt and ΔSOC: In this study, N = 24 and M = 29 which lead to ΔSOC steps of 2.5%. To assure the operational safety margins of the battery, SOC max and SOC min are usually selected between 0% and 100%. While small values of the variables Δt and ΔSOC will lead to higher accuracy and more optimal solution, they also result in exponentially longer computational time. Therefore, these step sizes must be selected with respect to the requirements of a particular problem. It should be noted that not all the M combinations for each hour are feasible due to the optimisation constraints which will be discussed further in the next subsection.

SEMS algorithm
The proposed SEMS algorithm analyses all the feasible paths connecting the initial state to the final one to determine the optimal path. In each hour of the next day, instantaneous values of P PV and P Load will be measured. In the case of discrepancy with the forecasted values [28], a real-time error correction algorithm will function in such a way that the battery SOC profile will comply with the precalculated optimal path as much as possible. The real-time error correction algorithm measures the instantaneous values of P PV and P Load at the beginning of each time interval and compares (P PV -P Load ) with the power required to follow the optimum SOC path, which is defined by SEMS in the previous day. If there is an excess (lack) of power, the difference is sold to (bought from) the grid.
The performance of the proposed method and its sensitivity to FIT pricing policies under both fixed and TOU tariff systems are evaluated by simulating the home energy system. The OF of the optimisation problem is formulated as Equation (6): When fixed electricity price is applied to the home energy system, Pr b (t) is a time-invariant variable, that is, Pr b when the TOU pricing scheme is applied, Pr b (t) is dictated by the upstream network as mentioned in Equation (7): While in certain countries, Pr s is time-dependent [29], many others have set a constant price for the rate of energy transmitted to the grid regardless of the time period in which the energy is delivered. Therefore, in this study and under both tariff systems, Pr s is considered to be fixed.
The optimisation constraints are as follows: 1. Power generation and consumption balance; sum of PV generation and the power bought from the grid must equal the sum of load and battery power: ∀k ∈ {0, T }; P PV,k = P Grid,k + P Load,k + P Batt,k 2. battery SOC upper and lower limits, which are chosen 85% and 15%, respectively: 3. battery charge/discharge rate limit: 4. initial and final battery SOC equality; this constraint is taken into consideration to maintain the battery SOC balance under continuous long-time operation of the system. In this study, initial SOC is selected to be 50%.
The notation used for power signs is selected as follows. Load and PV power are always non-negative, stated in Equations (12) and (13).
Battery power is a positive (negative) variable in the charging (discharging) period, as expressed in Equation (14).
Power transferred to the grid is a positive (negative) variable in power selling (buying) conditions, as addressed in Equation (15).
As stated in Equations (12) and (13), load and PV power are positive values while battery power can be positive, addressing charging state or negative indicating discharging condition. Grid power may be positive in the case of transmitting energy to grid and negative when buying from it.
It should be noted that on the first day, SEMS is executed based on the REMS algorithm because no historical load data is available. The flowchart diagram of the proposed algorithm is shown in Figure 5. As can be seen, OF (i,j) calculates the value of the OF in the transition from state i of a particular hour (stage) to state j of the next hour. The maximum value of OF (i,j) as well as the index j, are saved in arrays Max(h) and Φ(h), respectively. This is carried out for all the stages from 0 to 23 h to find Φ(h) for each hour of the following day. Therefore, the output array of the optimisation problem, which contains optimal SOC values for each hour of the next 24 hours, is obtained.

Simulation results
Running the simulation in a 1-week time period, the following results have been achieved for battery SOC and power as well as the power exchanged with the grid. In order to increase the validity of the results, real temperature and irradiance data have been obtained from an actual weather station database [30] to emulate the PV system more accurately. Moreover, the power flow within system components is controlled by tracking the reference values of power in corresponding converters in the system. For instance, the load power is drawn according to the forecasted load profile of the day ahead. Since most of the residential loads are resistive, only active power is studied in this study. However, the AC/DC converter control scheme can be configured such that the required reactive power can also be generated to supply inductive loads demand. The array configuration properties and characteristics are listed in Table 1, based on which the PV system output power is calculated as illustrated in Figure 6. The perturb and observe algorithm [31] is used in the MPPT controller with a sampling frequency of 0.05 Hz. The control signal is applied to a unidirectional DC/DC boost converter with the switching frequency of 30 kHz. The boost converter is utilised not only to control FIGURE 6 PV system output power in simulation fluctuations of array output voltage but also to match it with the DC bus voltage, that is, 340 V in this study, because no step-up transformer is used in this scheme [32]. As presented in Equation (16), the DC voltage level is selected according to the requirements of the full-bridge AC/DC converter to provide a sinusoidal output for AC loads with an RMS value of 220 V [33]: Equation (16) yields a minimum value of 312 V for the DC link voltage. In this study, the DC link voltage is selected with a safety margin of 10% leading to 340 V.
Furthermore, the weather station database is used in conjunction with the shading coefficient to estimate the solar irradiance and hence the available solar power of the day ahead [30].
As mentioned in Section 2, the load forecast unit is one of the critical parts in SEMS. A comparison is performed between two values of the window length, that is, n in a 1-week test period to evaluate the effectiveness of the window length parameter. The results are illustrated in Figure 7. The load data is obtained from [34] and is discretised to 15-min intervals, in order to limit the total number of combinations. Also, it must be mentioned that sampling load profile leads to the elimination of spikes, which is intrinsic to residential loads.
The performance of the load forecasting module can be evaluated by calculating error using Equation (17). The error percentages for n = 6 and n = 27 are 12.33% and 7.83%, respectively: Figure 8 illustrates the comparative results for battery SOC, battery power and grid exchange power variations, in the fixed tariff system. Recall that positive and negative values represent charging and discharging state of the battery or selling and buying to/from the grid, respectively. As shown in Figure 8(c), the energy transferring to the grid has occurred only in a small number of periods when REMS is applied to the system, while in the proposed SEMS algorithm there is power selling up to 1200 W for relatively long periods. Using the same sets of P PV and P Load profiles for both algorithms and regarding Figure 8(b) and Equation (11), it can be deduced that the excess energy available for selling to the grid under the SEMS algorithm in peak period is the result of extra energy drawn from the grid at prior off-peak periods. This is what leads to peak shaving and load profile smoothening feature of the proposed algorithm.
As shown in Figure 8(a), the battery under the REMS algorithm works in many periods to SOC min constraint as opposed to the proposed SEMS algorithm, in which the battery contributes more in energy exchange. It can be deduced that the profitability of the proposed algorithm is higher than REMS with the same battery capacity.
Comparative results in the TOU tariff scheme are illustrated in Figure 9. By comparing Figure 9(a) with Figure 8(a), it can    be seen that under the REMS algorithm, the amplitude of variations of SOC is higher in the TOU tariff system. Furthermore, according to Figure 9(b), while battery SOC has been increased during off-peak periods with the rate of P Max Batt under both algorithms, the discharge pattern of the battery under SEMS is more regulated around peak periods due to the effectiveness of the proposed method, which results in selling more energy to the grid than the REMS algorithm.
The comparative financial results under fixed and TOU tariff schemes are listed in Tables 2 and 3, respectively, in which the positive profit values correspond with revenues in total. Likewise, the percentages of profit increase in SEMS algorithms are shown in parentheses with respect to the corresponding REMS values. The FIT (Pr s ) is 4900 IRR/kWh. Moreover, buying prices of electricity from the grid (Pr b ) under the TOU tariff system in the off-peak, shoulder, and peak intervals are 245, 490 and 980 IRR/kWh, respectively, while it is 490 IRR/kWh under fixed tariff system.
As listed in Tables 2 and 3, the proposed algorithm has been significantly effective in profiting from the FIT system by decreasing the total expenses under fixed tariff as well as increasing the total profit under TOU tariff. According to Table 3, the proposed SEMS has decreased the system operation costs leading to 370% improvement in the energy system profit. Moreover, since widening the data window of the load forecasting method generally leads to higher demand predication accuracy, the system yields more profit with n = 27 compared to n = 6. This has become possible via prolonged periods of battery charge in off-peak and discharge in peak intervals. Compared to the fixed tariff system, the effectiveness of the proposed algorithm is much more conspicuous under the TOU tariff system. This is due to the difference between tariffs in off-peak, shoulder, and peak intervals. It should be noted that the values in Tables 2 and 3 are calculated using the simultaneity factor method based on a preselected array maximum power [35]. Figure 10 shows an experimental setup of the system using the proposed algorithm, which is implemented to verify the applicability of the simulation results under real operating conditions. The central controller is implemented using an AVR microcontroller unit (MCU), which is responsible for energy management and power sharing in the system. The PV system includes four PV panels with a maximum power of 20 W, each connected to a boost DC/DC converter to assure that partial shading would not affect the system performance. To achieve a higher capacity factor during the test period, a single-axis sun tracker is installed. Two test scenarios have been carried out under the TOU tariff system, using both REMS and SEMS algorithms in a 1week test period with the time steps of 15 min. The first test is intended to validate simulation results under normal operating conditions. While in the second scenario, system performance is assessed under varying load conditions, where solar generation and battery would not suffice to supply the demand per se. Table 4 presents the electrical characteristics of the test system.

Experimental results
The test load profile for the first scenario, is illustrated in Figure 11 along with the forecasted load data with a window length of n = 27.  The real-time power profile of PV generation for the first scenario is depicted in Figure 12. The experimental results of this scenario under both EMS algorithms are shown in Figure 13. As shown in Figures 13(a) and (b), during the night time at offpeak intervals, the battery has been charged under both algorithms with the maximum power rate. However, with the SEMS algorithm implementation, it has been discharged more during shoulder and peak intervals compared to the REMS algorithm. Considering Figure 13(c), it can be concluded that in contrast with the REMS algorithm results, in which there is barely any power transferred to the grid, the proposed SEMS algorithm has effectively utilised the available energy stored in the battery for selling to the power network. It should be mentioned that both algorithms have the same performance in buying energy from the grid in off-peak time intervals, due to the lower Pr b rate. However, under the SEMS scheme, the battery discharges more during the shoulder and peak hours in order to decrease the total energy imported from the utility or to increase the energy injected to the grid.
Moreover, by comparing Figure 13(a) with Figure 9(a), it can be concluded that in contrast to the REMS algorithm, the battery SOC has reached its maximum allowable limit (which is 85%) under the proposed SEMS algorithm, in both simulation and experimental tests. This denotes that the proposed algorithm enables the system to store more energy for supplying the demand in upcoming hours. Comparison between two SOC graphs in Figure 13(a) also indicates that the battery utilisation factor is higher under the proposed SEMS algorithm. In other words, under SEMS, the battery has been charged to a higher percentage, and also discharge deeper than the REMS  As shown in Figure 12, it can be concluded that PV-generated power has declined in second day of the test period (from t = 135 to t = 160). This explains why in Figure 13(c) the net energy sold to the grid in this time interval is negative, meaning that the flow of energy is from utility grid. Because of the noticeable difference of energy buy and sell tariffs, system performance is still beneficial to the prosumer in this time interval.
In the second experimental test, the load profile of Figure 14 is used for the 1-week test period. As can be seen, compared to Figure 11, demand of the fifth day (from t = 384 to t = 480) as well as the seventh day (from t = 576 to t = 672) have been increased with a scale factor of 50% in order to create a noticeable discrepancy with the forecasted value to model load variations from the usual consumption pattern. Furthermore, load demand exceeds the sum of solar generation and P Max Batt . Figure 15 depicts the solar generated power during the test.
The results of this scenario under both algorithms are depicted in Figure 16. According to Figure 16(a), battery's depth of discharge (DoD) in SEMS covers a larger range compared to REMS, leading to a higher utilisation factor for battery. Considering Figure 16(b), under REMS and during peak intervals (from t = 464 to t = 480) battery has reached its maximum power, delivering as much power to the load as possible. However, sum of P Max Batt and array power cannot fulfill the increased load demand. Moreover, regarding Figure 16(c), due to the large discrepancy between estimated and actual load values during peak hours, power is imported from the grid inevitably. This lowers the economic performance of the system. This is done according to the real-time error correction algorithm logic, which tries to track the precalculated optimum path.
The increased load of the fifth day causes the estimated value of the sixth day to increase as well. This creates a converse condition compared to the day before. Therefore, as shown in Figure 16(b), comparing with days before, the battery is drained less during shoulder load (from t = 512 to t = 560) to maintain FIGURE 15 PV power generation profile in second test scenario sufficient charge for the more important peak hours. This is why during peak period, battery is discharged with maximum rate. Figure 16(c) also demonstrates this fact, as power is injected to the grid during these hours, unlike any other day before.
According to Figure 16(c), similar to the fifth day, during the seventh day of the test, the system has injected less energy to the grid, as a result of the great mismatch between estimated and actual load values. Additionally, during peak hours, energy has been imported from the grid to meet the demand.

CONCLUSION
In this study, an SEMS algorithm is proposed to optimise the economic profitability of the residential PV systems, through maximising the total amount of energy available for selling to the grid when the FIT scheme is applied. The proposed SEMS method utilises a novel load forecast model for the next 24 hours to determine the optimal energy management plan for the battery storage for all time intervals of the day ahead. Compared with the REMS algorithm, the simulation results demonstrate a significant increase in the system profitability as well as the load profile correction under the proposed SEMS algorithm, especially when the TOU scheme is applied. In other words, the results suggest that by controlling the system using the proposed method, less power is drawn from the grid in peak intervals, while more is drawn during the off-peak intervals under TOU tariff system. This in turn leads to higher responsiveness of the load and hence increases the system profitability. Therefore, the proposed algorithm not only benefits the prosumer by maximising the profits achieved from the FIT incentive but it also decreases the pressure on the utility by smoothening the load profile.
As explained in Section 4.2, a test system with two operating scenarios was set up to get experimental results to verify the outcomes of the simulations.