Battery Size Optimization With Customer PV Installations and Domestic Load Profile

Photovoltaic (PV) is a highly feasible solution for modern renewable energy-powered residential buildings in terms of deployment and cost reduction of utility bills. The installation of solar PV systems along with optimal battery energy storage systems (BESS) size is the most popular energy cost minimization solution and will continue to increase rapidly in the coming years considering the European Union (EU) framework for nearly zero energy buildings (nZEBs). The current methods lack BESS size optimization and a comprehensive solution to charge/discharge BESS from PV and the grid. The main goal is to be self-sufficient and sustainable while having minimal dependence on the electrical grid. Therefore, this paper presents an efficient energy management model and optimal size of the BESS as two key factors to effectively minimize the total energy consumption cost of the nZEBs while having a minimum dependence on the grid. The energy management system is developed using linear programming and solved using simplex and interior-point methods. In addition, a heuristic algorithm is presented to determine the optimized charging and discharging schedule for nZEBs. A detailed techno-economic analysis of the proposed system is conducted for the whole year (covering all four seasons summer, winter, spring, and autumn) considering three common residential building cases and three different electricity pricing methods. We determined that seasonal electricity pricing is the favorable and economical option to schedule charging and discharging of BESS from the grid in several terms such as, minimum total hours of grid usage, the maximum number of charging hours of BESS from the solar PV system, maximum BESS discharging hours to sell energy, the minimum number of BESS charging hours from the grid, maximum number of discharging hours for energy usage within nZEBs, maximum revenue earned, and peak electrical load reduction for the grid.

Buildings account for nearly 40% of the global energy consumption, which accords them prominence in the energy market [1]. According to studies, about 36% of buildings in the European Union (EU) are older than 50 years and are energy inefficient [1], [2]. Therefore, the EU framework 2010/31/EU and its amended version 2018/844/EU defined the energy targets for 2050. As per this directive, all the newly constructed buildings in the EU after 2020 must be nearly zero-energy buildings (nZEBs) [3]. These buildings will be powered through renewable energy sources (RES) while having a minimal dependency on the grid [4]. Therefore, the accumulated sum of energy consumption in the buildings will need be near zero. However, RES at the grid-scale for nZEBs requires efficient and smart energy management systems, including photovoltaic (PV) systems, battery energy storage systems (BESS), and power electronics equipment [5]- [7]. The optimal energy management in nZEBs designs has been the subject of a substantial amount of research work. In [8], the authors proposed a technique for optimal energy management and better air quality within the building. In another study, efficient energy usage employing demand response (DR) and demand-side management (DSM) are elaborated and implemented in smart buildings [9]. Although the aforementioned methods are effective to a certain level, they were lacking to address the problem of load shifting concerning consumers' behavior. Therefore, in [10], the authors solved this problem using an efficient energy management system using RES for optimal self-consumption.
As electricity is a major component in the energy consumption share of any building; therefore, a comprehensive energy management model is required to control and manage the energy to certain levels required for nZEBs [11], [12]. A comprehensive energy management system must include a detailed energy usage strategy, sufficient RES availability, and optimal battery storage size. Furthermore, a robust control algorithm to manage battery charging and charging while minimizing dependence on the grid and maintaining an accumulated annual energy level near zero [13]- [15].
In [16], linear programming (LP) algorithm was developed for a photovoltaic-based energy management system to minimize peak electrical load. The forecasted PV and load data were used in the development of this algorithm. In [17], the authors further improved the performance of the proposed model given in [18] by improving the accuracy of the forecasted data. Another probabilistic method for efficient energy scheduling is proposed to reduce the cost of energy consumption [19]. A new LP algorithm was proposed to predict the usage schedule of electrical appliances while integrating electricity price, BESS, and RES to develop an energy management model [20]. The authors used the model predictive control (MPC) technique for the grid, RES, diesel generator, and BESS of an electric vehicle. In [19], the authors used both heuristic techniques and optimization methods to minimize the peak load of the grid. LP and Markov chain models were used to charge and discharge the battery. In [21], the LP algorithm was also used to optimize energy and cost management of energy generated from mixed sources, such as solar, gas generator, and batteries.
The Monte Carlo method was used to determine uncertainties in solar irradiance data for the BESS [22]. In [23], a Swiss study used a genetic algorithm to optimize the operation of a BESS for a residential building. Residential BESS was made economically viable by using a self-sufficient photovoltaic system and a load shifting technique at the dynamic energy price of the grid. The techno-economic analysis of a grid-connected solar PV-based system including BESS was presented in [24]. A learning-based optimization algorithm was used to minimize the net present cost (NPC) and cost of energy (CoE), the proposed technique was claimed to be 15.6% and 16.8% more efficient compared to the particle swarm and the genetic algorithm, respectively. A study on off-grid BESS optimization was conducted in the U.S. for two different residential locations [25]. The mixed-integer programming method was used to preschedule the load and forecast the energy from solar PV using solar irradiance. In another study, the cost and size of the BESS are optimized using the heuristic method and stochastic gradient for a campus area in Turkey. Both PV and wind were used as RES with large battery banks, these results of energy generation were initially optimized in a previous study by the same authors [26]. The economic analysis of a grid-connected PV system for residential users is also given in [27]. The authors also calculated the initial investment and the payback period. VOLUME 10, 2022 All the above-mentioned studies indicate that there is a wide variety of algorithms for energy dispatch and management in residential buildings to minimize the cost of energy consumption. The energy generation system can contain a grid-connected PV and a BESS. However, to achieve the goal of nZEBs, the methods are still lacking the optimized size and capacity of BESS and the charging/discharging of available energy storage for internal usage or selling to the grid and making it economically viable. To address this challenging problem, the possible complexities are system designing, control, and stochasticity in energy generation. Moreover, if forecast data for electrical load and energy are used, there is always the possibility of forecasting errors.
This study is part of an energy router (ER) based building energy management system. The details of energy ER are given in [28]. Taking into account aforementioned conditions, the focus of this study is to optimize the size of the BESS and design an efficient control algorithm to minimize grid dependency and develop a self-sustained energy management model for nZEBs. The main contributions of the paper are: • A battery size estimation method is presented for gridconnected BESS. To estimate the optimized size of the BESS and the feasible rated PV system for different residential buildings, the three most common cases of residential buildings are considered, such as a small flat/apartment, a medium-size residential home, and a residential apartment building.
• A heuristic-based algorithm is developed for optimized battery charging and discharging technique. The algorithm incorporates real-time data traces of residential load, PV energy generation, and electricity prices from the Estonian energy market. The algorithm is designed to minimize the usage of energy from the grid and to make the whole system self-sustained and selfsufficient. Moreover, the heuristics algorithm is tested for three battery bank charging scenarios from the grid: (a) price not applicable, (b) fix price, and (c) seasonal price.
• A linear and convex model is developed for the energy consumption cost minimization problem for the nZEBs. The model is solved using a simplex algorithm and the interior point method.
• A detailed techno-economic analysis of the proposed methodology is conducted to determine the feasibility of the proposed system. The analysis is carried out under different variations, such as different load cases, different BESS charging threshold prices, and BESS sizes.
The rest of the paper is structured as follows: Section 2 describes the data profiles that include the details of residential load cases, PV generation scenarios, and the energy market prices in Estonia. Section 3 discusses the estimation of battery size, battery charging/discharging algorithm, and the optimization algorithm for the total energy consumption cost of the nZEBs. Section 4 presents a detailed economic analysis of the proposed method for the three electrical load cases. Section 5 discusses the results of the study along with a detailed comparison with previous similar studies. The paper is concluded in Section 6 along with future research directions.

II. DATA PROFILES
This section presents a detailed description of the real-time residential electrical load dataset and real-time solar power generation profiles for three different rated solar PV systems.

A. LOAD PROFILE
In this study, the real-time residential electrical load data from the Estonian low-distribution network is used. The data was measured and collected in a rural county in Estonia for a whole year with a frequency of one hour. The schematic of the grid is shown in Figure 1. This grid segment has 8 residential loads and 3 auxiliary loads like lighting, pumping station and heat station. In the study, three different residential electrical load cases are under consideration: (a) case 1 (load 1): a small flat/apartment with a limited number of appliances and having an overall low load, (b) case 2 (load 3): a residential house, and (c) case 3 (load 7): a residential apartment building. Table 1 enlists the statistical details for the aforementioned three cases. From the collected data profile, it is illustrated that the average electrical load for a small apartment is 0.08 kW, 0.76 kW for a residential household, and 11.9 kW for the whole apartment building. The accumulated yearly power consumption for all these cases is also presented in Table 1. The hourly electrical load for all three cases is depicted in figure 2. It is observed from Figure 2 (a) that in an hour, the electrical load for case 1 rarely goes above 1 kW. There are only seven instants in a whole year when the power consumption surpasses 1 kW. Similarly, for Case 2, the peak load (hourly average) is around 6 kW and it only happened twice a year.  However, the average electrical load is around 0.76 kW is considerably low compared to the peak load. As case 3 represents the energy consumption for a whole residential building; therefore, a seasonal trend of electrical load is clearly visible in Figure 1(c), which is low in summers (May-August) and high in winters (November -March) due to the heating load, and due to this fact, the peak load occurs in winter.

B. PV PROFILE
Estonia lies in the northeastern part of the EU and this region, the sunlight per day in summers is on average 16-18 hours while in winters it reduces to on average 4-6 hours in a day. Moreover, in Estonia, the solar irradiance intensity is nearly the same across the country. Therefore, solar power generation from PV installations in any part of Estonia does not have a significant variation in output. However, it is still highly dependent on the weather conditions. The solar PV systems proposed in this study are 5 kW, 10 kW, and 20 kW for case 1, case 2, and Case 3, respectively as mentioned in Table 2 [27]. The solar power output for a 5 kW PV system is shown in Figure 3.  From figure 2, it is evident that solar energy generation is high from March to September and low in the other months. The accumulated energy with solar PV installation and the respective residential electrical load is shown in figure 4. From March to September, solar energy generation is mainly greater while the electrical load is on the lower side; therefore, the overall energy is in surplus and can be sold to the grid. The maximum energy that can be sold to the grid is 4.5 kW, 9.6 kW and 15.2 kW, respectively, for the three load cases discussed in Table 1.
In case 1 and case 2, with the installation of the roof-top PV system, the dependency on the grid has fallen significantly in terms of the number of hours throughout the year. Throughout the year, the accumulated energy generated by the solar PV system is accessible compared to the electrical load required, as shown in Table 13. However, for case 3, the grid dependency still exists as the electrical load is higher compared to the installed PV system. Therefore, a larger rated PV system is required for case 3 and reduces the accumulated energy requirement from the grid by 22%, which is significant in terms of economics as the energy bill is substantially reduced.  A more detailed economic analysis of the cases is given in section 4.

III. BATTERY ENERGY STORAGE SYSTEM (BESS)
In recent years, battery storage technologies have seen rapid growth for the applications, such as PV-based storage systems, portable devices, industry, and electrical vehicles [29]. The most commonly used batteries are Lithium-Ion (Li-ion) batteries and nickel manganese cobalt oxide (NMC) batteries [3]. Over the years, due to advanced technological developments and bulk generation, the cost of batteries has been significantly reduced [30]. An estimated cost of battery per kWh is around 100 e [31]. However, the life cycle and limited usage cycle still required significant improvements. It is expected that in the coming years, with the advancement in technology new batteries will be available having a life cycle of around 20 years [32].
Currently, most of the BESS installed with solar PV systems have Li-ion batteries for residential buildings. They are preferred due to their lack of maintenance requirements, compact size, and higher efficiency of more than 85% [33]. However, the practical life of these batteries is around 5 years due to the limited number of charge/recharge cycles [34]. Due to this fact, it is challenging in terms of economic viability as the payback period of a Li-Ion battery cannot be compensated for in 5 years [35]. Therefore, the installation of PV-based BESS is usually supported by the government in Estonia in terms of subsidy and reduced tariffs [36], [37]. However, optimal battery size calculation is still needed to further minimize operational costs.

A. BATTERY SIZE CALCULATION
The battery size calculation involves many important parameters, such as total energy used in a day, number of days for which the backup from the battery is required, the nominal voltage of the battery and the battery efficiency. The following Eqn. (1) is used to calculate the battery capacity [29]: Here, E BC represents the battery capacity is kWh, η is the battery efficiency, N is the number of autonomous days for which the battery operation is required, DoD is the depth of discharge for the battery, and E Day is the average daily energy used. The battery size is usually calculated against the peak load in a single day. However, as the peak load happens only a few times during a year, the calculations for the battery capacity can be made using the average load in a day or median load value. Among the most important parameters in BESS is the state of charge (SoC) of the battery. The SoC indicates how much energy is stored in the battery. The SoC is computed using Eqn. (2) [29]: where n represents the number of states, st is the sampling interval, K p indicates the online and offline status (typically 0 or 1), and E z is the charging power in kW. The parameters P z is calculated as [29]: The proposed heuristic algorithm for battery charging and discharging is evaluated on hourly real-time data traces of electrical load and energy generation from the corresponding rated PV system. The estimated battery sizes and the parameters for all three cases described in table 1 are given in table 3.

B. HEURISTIC ALGORITHM FOR BATTERY CHARGING AND DISCHARGING
If the energy generation from the solar PV system is greater than the electrical load, then the battery will be charged. Moreover, if the load is greater than the solar PV energy generation, then the battery will be discharged to compensate for the difference between solar PV energy and excessive electrical load. In the second scenario, if the battery is charged to a certain level and still the solar PV energy generation is greater than the electrical load, then the extra energy will be sold to the grid at a predefined cost. Similarly, the battery can be charged from the grid if the electricity price is below a certain threshold value. Furthermore, if the electricity price is greater than another defined threshold value, then the energy stored in the BESS can be sold to the grid. A detailed description of the heuristic algorithm is given in table 4.

C. LINEAR PROGRAMMING (FOR ENERGY COST OPTIMIZATION)
The electricity pricing threshold selection for the charging of BESS from the grid and utilization of BESS for grid support is a tricky problem. In the Estonian energy market, the real-time electricity price dynamically changes every hour. Estonia is a member of the Nord pool which is a European power market consisting of 16 countries with 360 companies that trade in the power market [38]. Therefore, the electricity price depends on factors season, availability of RES, demand, and supply thus there are many variations in the electricity price. The real-time electricity price for Estonia in 2020 is shown in figure 5, which clearly illustrates the dynamic behavior of the energy market. In figure 5, the peak value for electricity is 0.25 e/kWh and the lowest value is 0.001 e/kWh. However, the average price range throughout the year is 0.05 e/kWh [38]. Therefore, by keeping in view, the dynamic electricity pricing, battery charging and discharging heuristics, solar power generation, energy purchase from and sell to the grid, and dynamic nature of energy consumption within the nZEBs, an LP model is developed to minimize the total energy consumption cost for the nZEBs. Moreover, the algorithm also decides the optimized value of electricity for charging the battery from the grid and discharging the battery to the grid. However, as a reliability constraint, battery cannot be charged more than 90% and discharged less than 20%. The battery management constraints are defined in such a way that minimizes the utilization of energy from the grid both for residential load and battery charging while utilizing a maximum of solar PV energy. Batteries are charged when the electricity price is low. The excess energy in BESS is only sold to the grid when the electricity price is high to make this system economically viable.
The following linear and convex optimization function is defined to minimize the net energy consumption cost for any nZEBs considering the installed PV system, BESS, and the electricity price constraints. The optimization problem is defined as: Subject to E pur where f is the objective function to be minimized that is defined in the standard minimization form having equality constraints, inequality constraints (all are in the form of less than equal to) and bounds of the problem.
where the X min = 0 kWh for every electrical energy. The linear programming problem defined in Eqn. (4) is solved using the simplex algorithm and interior point method. Equation (5) is the equality constraint that represents the energy balance between the energy sources (such as grid, solar PV system, and battery bank) and the electrical load of nZEBs. Equation (5) clearly indicates that the energy imbalance between the electrical load of nZEBs and the power generation of the solar PV system is maintained using the energy purchased/sold from the grid and the charging/storage of the battery bank. However, this decision is made by the linear programming algorithm. Moreover, Eqn. (6) -Eqn. (9) are the inequality constraints and from Eqn. (10) to Eqn. (15), the bounds of the variables are defined.
The BESS charging is under consideration in three different electricity pricing scenarios from the grid: (a) price not applicable, (b) fixed price, and (c) seasonal price. In the price not applicable scenario, we eliminate the option of BESS charging from the grid at any offered cost by the grid. Equation (7) will ensure that the battery will never charge from the grid. In fixed price scenario, we have the option to charge BESS from the grid provided the electricity cost is less than a certain defined threshold field for the whole year. In the seasonal price scenario, the electricity cost threshold for BESS charging varies seasonally. Therefore, in the second and third cases the equality constraints of Eqn. (7) are ignored.

IV. RESULTS & DISCUSSIONS
This section presents the technical and economic impact of BESS charging and discharging heuristic algorithm under three different electricity pricing scenarios from the grid, such as (a) price not applicable, (b) fix price, and (c) seasonal price. Moreover, energy cost minimization model-based economic analysis results are also discussed in detail. The implementation and simulation of the proposed algorithms are carried out in MATLAB running on an Intel Core i7-9700 CPU with 64 GB RAM.

A. TECHNO-ECONOMIC ANALYSIS OF BESS CHARGING AND DISCHARGING
The first scenario includes no BESS charging from the grid at all; however, the BESS can be discharged to empower the grid, when the electricity cost is higher than 0.1 e/kWh (one of the highest costs, 90 percentile). The only viable option for BESS charging is from available PV energy. For the second scenario, the BESS can be charged both from the grid and PV system. However, the PV is the preferred source for BESS charging while the battery can be charged from the grid only if the electricity price is less than 0.01 e/kWh (one of the lowest values). This price threshold is low compared to the average electricity price, which is around 0.03 e/kWh during the year. Battery energy can also be sold to the grid if the price is greater than or equal to 0.06 e/kWh. The price threshold is computed using the LP algorithm. These values were initially obtained from the hit and trial method and later verified with the LP algorithm, as they showed the same results.
For the third scenario, the prices for battery charging/discharging from/to the grid are varied on a seasonal basis. These values of charging/discharging prices are again obtained from the LP method. The battery charging prices from the grid is less than 0.033 e/kWh, 0.024 e/kWh, 0.03 e/kWh and 0.038 e/kWh for winter, spring, summer, and autumn, respectively. Similarly, energy is sold to the BESS grid when prices are higher than 0.061 e/kWh, 0.058 e/kWh, 0.065 e/kWh, and 0.072 e/kWh for winter, spring, summer, and autumn, respectively. The electricity prices for purchasing and selling have a difference of around 3 cents, which provides a significant margin for the nZEBs to minimize total energy consumption cost. Moreover, we computed the SoC for BESS for all three pricing scenarios and plotted them in figure 6. In Figure 6, it is evident that SoC is on the lower side in winters and high in summers because in considered region (Estonia), total energy consumption increases in winters due to the heating and lighting load along with increased BESS utilization. Moreover, in Figure 6(c), the variations in SoC are observed to be more compared to  the other two, as the battery is charged and discharged more times showing active status. Furthermore, there are not many intervals where there is a stagnant line showing no activity. Therefore, to compute the optimal economic impact of BESS, a detailed analysis is conducted and tabulated in Table 4 in terms of the number of hours of utilization, payback period, and peak power drawn and injected into the grid.
In table 5, for the calculated optimal BESS size, the total hours of grid usage are more for the price, not applicable scenarios compared to the other two pricing scenarios when we opt not to charge BESS from the grid because the energy is coming from a European market and the price can be high. Similarly, the total number of BESS charging hours from the solar PV system is greater for the first two scenarios compared to the seasonal pricing scenario. Moreover, the number of discharging hours of BESS for selling energy to the grid is more for the seasonal pricing scenario while the number of charging hours of BESS from the grid is also high for the seasonal pricing scenario due to low and feasible seasonal electricity cost offered for BESS charging and discharging.
Furthermore, the number of discharging hours of BESS for energy usage within the nZEBs is also on the higher side for the seasonal pricing scenario. Additionally, we computed the total revenue earned for the nZEBs under all three pricing scenarios and illustrate that the seasonal pricing scenario is the most viable option. We concluded that offering seasonal lower pricing for BESS charging from the grid and high pricing for BESS discharging to the grid is financially viable for BESS. However, the dependency of BESS on the grid also increases, which is indicated by the high peak load values from/ to the grid. Therefore, a tradeoff exists to optimize this challenge.
In a similar manner as illustrated in Table 5, to study the impact of increase and decrease in BESS size, we independently varied the BESS size from 10% of the proposed optimal value to 500% of the proposed value. Here, the size 100% indicates the theoretical battery size calculated using Eqn. (1). This variation in BESS size is tested for the three VOLUME 10, 2022 load cases, small apartment, residential house and residential building, as discussed in section 2.1. The results of the BESS variations for case 1, case 2, and case 3 are discussed in tables 6, 7 and 8, respectively.
From these tables, it is concluded that with increasing battery size, the value of 'j' decreases, indicating a lower dependency on the grid in the three cases. In addition, the value of 'd' increases which shows that the battery is now used more for internal usage. The number of charging hours 'a' shows a straight line around 110% for cases 1 and 2. Moreover, the battery discharging hours to grid 'b' also shows the lowest value before starting to increase again. This represents the optimal battery, and it also gives optimal values for other parameters as well. As the battery size is increased further, it may give good numbers, but affect the economic aspects badly.

B. ECONOMIC ANALYSIS
Considering Vision 2030, the concept of nZEBs is growing rapidly across the EU. Therefore, a detailed economic analysis of the installed energy management system of nZEBs is mandatory from a business perspective. If the energy management system is financially viable, it may encourage other building operators to convert conventional residential buildings and homes as nZEBs. Therefore, we separately evaluate and discuss the PV-based BESS designs for all three load cases. The economic analysis for a PVbased BESS requires considering several parameters that are sequentially discussed in this section. First, the initial investment cost, C PV for the solar PV system is computed using Eqn. (17) [14]: where C u PV (t) is the per-unit cost incurred by the solar PV system, P rated is the rated power, n is the lifetime of PV system in years, and i(1+i) n (1+i) n −1 is the present cost compared to the annual investment. Similarly, the initial investment cost of the BESS system is calculated as [14]: where C ch,u bat (t) is the per-unit cost of BESS charging, C Inv./Unit is the inverter cost per unit, P rated is the rated power of the inverter, n is the lifetime of the battery in years, and i(1+i) n (1+i) n −1 is the present cost compared to the annual investment. Moreover, considering every available energy source to balance the electrical load of nZEBs, the energy balance equation for nZEBs is computed using Eqn. (5). Furthermore, the first two terms of Eqn. (4) are used to calculate the energy purchasing and energy selling prices to the grid, respectively.
In the Estonian electricity market price of electricity is dynamically changing every hour. Therefore, the sampling time considered in this study is taken as 1 hour. The current price of a battery in Estonian is around 100 e/kWh whereas the price of the PV system is around 0.4 e/W [3], [39]. Table 9 shows the economic analysis of all three load cases with PV installation and without the BESS. With the installation of the PV system, the dependence on the grid is significantly reduced in all three load cases. For case 1 and case 2, the energy purchase from the grid is zero for the whole year, instead, the energy is in excess for a certain number of hours and sold to the grid. However, in case 3, the electricity bill is not zero but has been reduced by very significant, nearly 65% margin. In case 3, the average and peak loads are 11.9 kW and 36.7 kW, respectively.
The BESS price for the under-discussion three load cases is taken as 400 e, 3300 e and 51800 e, respectively depending on their optimal BESS size calculation. Table 10 shows the net cost of energy with the different BESS sizes for the three load cases. The net price of energy usage is negative for both case 1 and case 2, indicating that the energy was surplus compared to the load requirements and was sold to the grid. In addition, there is a direct relationship between the BESS size and the net cost of energy. However, case 3 is presenting a different scenario. The net energy price is still positive, which means that the energy is still being used excessively from the grid. This is because the BESS is designed with respect to the high value of the load. The installed PV capacity for this system is low and it must compensate for the load and charge the BESS. Therefore, in most hours, after electrical load compensation, very little energy is available for the BESS to be charged to its full potential. The simulation results for PV systems with 30 kW, 40 kW, 60 kW, and 80 kW for case 3 are shown in table 11.
The simulation results with higher-rated PV systems for case 3 indicate that the net energy cost reduces significantly. The grid dependency decreases, and the net energy cost is surplus when the rating of the PV system is increased to 80 kW and 100 kW. The system will earn around 1800 euros revenue for one year. The maximum power drawn from the grid and injected into the grid is shown in table 12. The peak load from the grid is decreasing and energy transferred to the grid is increasing. The peak loads from the grid increase 2 to 4 times with the increase in BESS size.
The payback periods for all three load cases are shown in Table 13. The cost calculations in this table include some approximations in the prices of the inverters and batteries.
The installation cost and the cost of land in the case of ground installation have not been included, the payback period varies between 10 to 20 years for all three load cases.
The payback periods for case 1 and case 2 are around 10 and 13 years respectively, while for case 3 even with the increase in the PV capacity it is between 16 to 27 years. The cost of additional PV energy availability increases the total savings, but the increased cost of PV and inverter size keep the resultant payback period nearly the same.

V. COMPARISON WITH PREVIOUS STUDIES
Previously, many studies have been conducted on the optimal designing of batteries, control algorithms, and economic VOLUME 10, 2022  feasibilities as discussed earlier in Section 1. The study in Greece found that BESS can reduce the cost of bills by 20% [40]. In [41], the economic analysis of PV paired with BESS showed that the system can reduce 41% to 74% of the cost of energy from the grid. The BESS alone can provide a 25% to 35% cost reduction in cost.
A Belgian residential data was used to develop a BESS sizing method based on voltage sensitivity. The BESS life was determined to be 15 years for 80% PV power threshold and 10 years for 70% threshold [42]. In [43], a study conducted in Japan indicated that PV-BESS can reduce the peak load of the grid to 1.1%. However, the value of the peak load varies by season. The payback period in the same study was found   to be 18 years. An optimal battery size tool was designed and the payback of the BESS was found to be around 40 years [3]. However, the author reported that if there is a 10% increase in the electricity sales cost to the grid, the payback time will reduce by up to 10 years.
In comparison to the studies mentioned above, the results presented in our study are more dynamic and cover a broader aspect of BESS. The proposed LP algorithm for energy cost minimization along with the optimized value of BESS presents a viable economic analysis for nZEBs. The results showed that the payback period of this PV and BESS system is around 10 to 13 years. The first two cases showed that there is no need to pay for energy at all and also that the domestic users will sell excess energy to the grid with 5 and 10 kW PV installations along with BESS. In the reduction in the third case, the electricity cost is around 65% with 20 kW PV-BESS.

VI. CONCLUSION
Optimal sizing of the BESS is an important prospect for nZEBs. The inappropriate BESS size can have both technical and economic implications. Similarly, the BESS requires an efficient control algorithm for the optimal performance of the battery. conversely, the BESS needs to be made economically feasible for the consumers to invest in it. Currently, the price of BESS is very high; therefore, in many countries, governments and grid operators offer several incentives to consumers. However, the price of BESS is also expected to drop in the coming years.
This study presents the findings to test different BESS sizes for the three most common residential buildings based on their electrical load and recommended rated PV systems. The purpose is to find the optimal size of the BESS that is technically viable and economically beneficial. For the three different residential buildings, the real-time residential load data was taken from the Estonian low voltage distribution network for a small apartment, a medium-sized household, and a whole apartment building. Moreover, real-case data for the corresponding three rated solar PV systems is also measured and used. Based on these three electrical loads and solar PV profiles, the theoretical size of the suitable BESS is determined for each residential building. An effective heuristic algorithm is proposed for the scheduling of BESS charging and discharging under the influence of two energy sources, such as solar PV system and grid.
Furthermore, we develop an LP model to compute the total cost of energy consumption of the nZEBs considering the viable electricity price of the grid, the available energy of the solar PV system and the grid, the BESS charging and discharging schedule, and the total electrical load of the residential building. The LP model is optimized to minimize the total energy consumption cost for nZEBs. The proposed LP model along with the heuristic algorithm for BESS battery charging and discharging schedule is rigorously tested by varying three different electricity pricing scenarios and variable BESS sizes. In addition, a detailed comparative analysis is conducted based on minimum utilization of the grid, maximum charging of BESS from the solar PV system, and maximum BESS discharging for internal usage. The economic analysis of the proposed BESS for all three cases with the implementation of the proposed algorithm indicates that the payback time of small and medium-size residential load scenarios varies from 10 to 13 years. The PV-BESS will have a payback period of around 20 years for large residential buildings if the PV size is small. However, it is around 16 years when a larger PV system is installed.
For future works, the proposed algorithm will be implemented in the energy router currently under development for the energy management system for nZEBs. In this way, the performance of the algorithm will be tested and verified experimentally in a real-time application. Moreover, different optimization algorithms can be investigated for this problem to have a comparative analysis with the proposed one.