Optimal Design Model for a Residential PV Storage System an Application to the Spanish Case

: Self-consumption of photovoltaic energy is being promoted as an effective way for energy consumption in residential households. The European Directive 944/2019 promotes the use of green energy and battery energy storage systems (BESS) for self-consumption and, in Spain, the 244/2019 Royal Decree of the Spanish electrical regulatory framework allows the self-consumption of energy with a photovoltaic (PV) facility for residential use, as well as the injection of the surplus energy into the grid for which compensation will be received. At the same time, new developments in PV and BESS technologies reduce the costs of facilities, a fact that can increase the proﬁtability of self-consumption through PV energy. This study evaluates the proﬁtability of a household PV facility with BESS using a model based on real market prices, hourly data from user smart meters, and their own location; especially, the model gives the best conﬁguration of PV panels power and BESS capacity. The ﬁnancial indicators taken as reference for the results and conclusions are the Net Present Value (NPV), Internal Rate of Return (IRR), and Investment Return (IR). Our method examines also the effect of the BESS and PV panel costs on the proﬁtability of the facility. Unlike other studies, our model is based on actual (not simulated) demand and price data, and it can be easily extended to other locations and market prices.


Introduction
Many countries in the European Union (EU) have implemented different policies in order to improve and develop solar energy systems (instead of fossil ones) after the European Directive 944/2019 [1]. The objective of this legislative framework is to achieve a cleaner energy generation and decrease the impact of emissions on the environment. In Spain, the 244/2019 Royal Decree [2] established the technical and administrative requirements for the self-generation and consumption of energy. In particular, this decree allows households to inject the surplus energy into the electricity market, being the company with which a user has contracted electricity supply from, to offset the income earned by the prosumer on the electricity bill. At the same time, all the administrative process has been simplified; thus, currently, a seller only has to present to the Spanish Public Administration a formal declaration (endorsed by an engineer) indicating that technical and administrative requirements for the sale of energy are met. The developments of these policies create therefore a suitable framework to support the investment in household PV facilities.
The purpose of this research is to provide an economic and operational model for a household PV facility, with or without a battery energy storage system (BESS), that aims to optimise the power of the PV panels and the capacity of the BESS. With the only input of the household demand and its own location, the proposed model provides the best configuration of them (panels and BESS) according to certain financial indicators; this outcome is especially useful for installers, prosumers and system regulators.
The aim of this paper is to provide a general model that, for a specific user profile and PV facility location, gives the optimal configuration of BESS capacity and PV panel peak power according to the financial indicators Net Present Value (NPV), Internal Rate of Return (IRR) and Return of Investment (IR). Given that the financial indicators depend on the BESS and PV panel costs, and that these costs are falling in recent years, an analysis is carried out to measure the effect of the decreasing trend of these two costs on those financial indicators. In our opinion, this paper presents at least two main contributions: the data sources and the flexibility of the model of energy generation, sales and self-consumption. We use data from the Spanish market: the production of photovoltaic energy has been obtained from PVGIS (a specialized software), while the domestic energy demand comes from the hourly data of the user smart meters. Notice that our demand data is not the result of a simulation process, as is usually the case in the literature in this field; for this reason, the results obtained from our analysis are more accurate than those based on-demand algorithms or simulations. As for the flexibility of the model, it is remarkable that unlike those studies based on mathematical simulation, which are the majority in this field (see, for example, Ghiassi et al. [12]), Zhu et al. [18], Colmenar et al. [21], Bernal and Dufo [22] and Sarasa et al. [23]), our empirical financial model can easily be extended to other locations or pricing schemes.
Finally, the self-consumption model presented in this paper could be interesting for regulators, households, entrepreneurs, and scholars. It is a business opportunity for the system regulator, since it improves the maintenance, developments and losses of the transmission networks, as a consequence of the self-consumption energy and the surplus energy injected into the market. For their part, households and entrepreneurs (prosumers) may know the economic revenues and profitability of the PV facilities, taking into account all the relevant (technical and economic) information, defining the right PV facility and storage capacity. Additionally, this initiative will produce a significant benefit to the environment, as it replaces energy obtained from fossil fuels (at least partially) by one without emissions.
The rest of this paper is organized as follows. Section 2 describes the model, the basic concepts of a PV facility with BESS, and the data description. Section 3 presents the results and financial assessment. Section 4 contains the discussion and, finally, Section 5 the conclusion.

A Model for Energy Self-Consumption Using PV Panels
The model used in this paper is designed for a home with a PV panel connected to the grid and which may or may not have an energy storage system-the two scenarios are analysed. Network defection is not considered, as the economic impact of a breakdown in the facility of the residential user would be much greater than the possible benefits from this alternative. In addition, being connected to the grid allows the obtaining of additional incomes by injecting the electricity produced into the grid at times when it surpasses the residential electricity demand [25]. Considering the existence of energy storage, Figure 1 depicts schematically the main parts of the household facility and the energy flows between the different parts. Each residential facility consists of three different components, which are managed by a control system: a battery system (BESS), the PV panels and an inverter module.
The first configuration analysed consists of a residential user connected to the grid and PV panels and without BESS-note that, in this scenario, the BESS component has to be removed from Figure 1. In this configuration, the savings come from the energy consumed from the PV panels (avoiding, therefore, the grid consumption) plus the income obtained from the surplus energy sold to the network. When the residential demand is higher than the production of PV panels, grid energy needs to be consumed to fully cover the domestic demand. The profitability of this facility mainly depends on the energy produced by the PV panels (either providing savings or incomes) and the cost of the facility, factors which Sustainability 2021, 13, 575 5 of 26 will be driven by the size of the BESS and PV panels. This model is similar to the one proposed by Arcos et al. [26], although this last study does not consider the possibility of selling surplus energy to the market. The first configuration analysed consists of a residential user connected to the grid and PV panels and without BESS-note that, in this scenario, the BESS component has to be removed from Figure 1. In this configuration, the savings come from the energy consumed from the PV panels (avoiding, therefore, the grid consumption) plus the income obtained from the surplus energy sold to the network. When the residential demand is higher than the production of PV panels, grid energy needs to be consumed to fully cover the domestic demand. The profitability of this facility mainly depends on the energy produced by the PV panels (either providing savings or incomes) and the cost of the facility, factors which will be driven by the size of the BESS and PV panels. This model is similar to the one proposed by Arcos et al. [26], although this last study does not consider the possibility of selling surplus energy to the market.
The second configuration is a little more sophisticated than the first one and, until recently, it was not allowed in some European countries, including Spain. The difference with the first scenario is the existence of a BESS which is connected to the PV facility. Then, the PV energy has three possible destinations, in this order: the domestic demand, the battery (if PV generation exceeds residential demand during off-peak hours, case II in Table 1), and the grid (if generation exceeds demand and the battery is either fully charged or partially charged and the hours are peak hours, case I in Table 1). The residential demand is satisfied firstly with the production of the PV panels, secondly with the BESS energy and finally, if necessary, with the grid (as in case III, Table 1). The BESS is a key element in the model because it allows the storage of surplus energy for further consumption (for example, in night hours). The BESS is charged with the excess of power produced by the PV panels during off-peak hours, and it is discharged when the PV production cannot meet the residential demand, a fact that happens mainly during the night. The operating model offers two main benefits: the savings for the energy consumed from the PV panel and the BESS unit (therefore avoiding the grid energy consumption) and the incomes from the energy sold to the market according to net-metering regulations. The second configuration is a little more sophisticated than the first one and, until recently, it was not allowed in some European countries, including Spain. The difference with the first scenario is the existence of a BESS which is connected to the PV facility. Then, the PV energy has three possible destinations, in this order: the domestic demand, the battery (if PV generation exceeds residential demand during off-peak hours, case II in Table 1), and the grid (if generation exceeds demand and the battery is either fully charged or partially charged and the hours are peak hours, case I in Table 1). The residential demand is satisfied firstly with the production of the PV panels, secondly with the BESS energy and finally, if necessary, with the grid (as in case III, Table 1). The BESS is a key element in the model because it allows the storage of surplus energy for further consumption (for example, in night hours). The BESS is charged with the excess of power produced by the PV panels during off-peak hours, and it is discharged when the PV production cannot meet the residential demand, a fact that happens mainly during the night. The operating model offers two main benefits: the savings for the energy consumed from the PV panel and the BESS unit (therefore avoiding the grid energy consumption) and the incomes from the energy sold to the market according to net-metering regulations. Table 1 shows the operating model for the PV generation in the facility. Given the operating model described in Table 1, the main economic question that this paper addresses is: "Given a user's annual hourly demand, which is the PV and BESS size configuration that optimises the investment?". For this purpose, three financial indicators are calculated for different configurations of BESS and PV panels: the net present value (NPV), the investment return (IR) and the internal rate of return (IRR). The operation of the PV system with storage is described in Equations (1)-(5).
Equation (1) models the hourly charge level (E BL ) of the BESS at the beginning of each hour, as the battery charge level at the beginning of the previous hour (E −1 BL ), plus a percentage of the PV energy delivered by the panels to the battery (E CH ), minus the energy outflow from the BESS used for consumption (E B C ). Parameter η represents the round trip efficiency of the BESS, according to which not all the energy received from the panel (E CH ) can be stored in the battery and not all the energy outflow is consumed by the household. The energy stored can not exceed the limit capacity of the battery (P B ).
Equations (2a) and (2b) model the hourly energy generation of the PV panels, as well as its destination. The PV energy generation (E PV ) can be modelled as the expected PV energy generation every hour (e G )-data from PVGIS (Photovoltaic Geographical Information System)-plus a random disturbance (u G ) which follows a normal distribution N(0, σ u 2 ), and allows controlling for certain unexpected events such as unexpected cloudiness, an unexpected failure of the PV installation, measurement errors, etc. This PV energy can be used directly for self-consumption (E PV C ) or to be sold to the market (E S ) when it is a peak hour or the battery is full (Equation (2a)). When the BESS is partially charged and the hour is off-peak, part of the PV energy (E PV ) is also used to charge the battery (E CH )-Equation (2b).
Equations (3a) and (3b) show that the hourly energy consumed from the facility (E F ) is the sum of the energy supplied directly from the PV panels (E PV C ) and the energy supplied by the BESS (E B C ), when the production of PV energy (E PV ) is lower than the energy demanded by the household (E D )-Equation (3a). If the production of PV energy (E PV ) is greater than the energy demanded (E D ), the PV panels can support directly the demand (Equation (3b)).
The hourly surplus energy produced by the PV panels (E EX , Equation (4)) is defined as the difference between the PV energy generation (E PV ) and the energy used directly by the household from the panels (E PV C ). This surplus energy (E EX ) is intended to be sold in the market (E S ) or to charge the BESS (E CH ).
Equations (5a) and (5b) describe the hourly energy consumed by the household (E D ). The real energy demanded by the household (E D ) is the sum of the expected demand (e D ) and the random disturbance ( v d ∼ N(0, σ 2 u ) of zero mean. When the energy supplied directly by the PV panels (E PV C ) and the energy supplied by the BESS (E B C ) is equal to the energy demanded (Equation (5a)), it is not necessary to buy energy from the market; the household is powered only by the facility. In the case of energy supplied by the facility, (E F ) is not able to fully cover the household demand (Equation (5b)), it is necessary to purchase energy in the market (E P ). The financial model is formulated in Equations (6)- (12). Equation (6) computes the annual income received (IC) in the year t from the energy sale (E S ) at market price (PE). Equation (7) defines the annual savings (S) coming from the energy consumed but not purchased in the market; that is, the energy consumed from the facility (E F ), valued at market price (PE) plus the access tariff (AT).
Finally, the cash flow in the year t (CF t ) is defined in Equation (8) as the incomes from sales (IC t ) plus the savings from self-consumption (S t ) minus the acquisition cost of new devices in the year t (I t ), if any.
Observe that sales (E S ) and self-consumption from the facility (E F ) are increased by more powerful PV panels (P PV ) and higher BESS capacity (P B ), also the falling network consumption (E P ). The greater these two determinants (P PV and P B ), the greater the savings, the incomes and, consequently, the cash flows from the facility.
The model for the facility without BESS can be easily adapted from this one by removing its influence; that is, the capacity of the BESS (P B ), its charge level (E BL ), the energy used to charge it (E CH ), and the consumption from it (E B C ) become null. Additionally, we drop Equation (1) and unify Equations (2a) and (2b) by removing E CH and their respective conditions.
Once we generate the cash flows for each possible configuration (facility with or without BESS), the project NPV and the IR indicator are mathematically defined by the following equations: where n is the number of years of the project, CF t is the cash-flow of the year t, k is the discount rate, and I 0 represents the cost of the facility at the beginning of the project (initial investment), i.e., the panels and BESS acquisition costs. For its part, the IRR index is given by the discount rate k at which the NPV equals 0, having the following equation: Finally, the investment required is defined as follows: where C PV and C B are the cost of the panels and BESS respectively. They are obtained by multiplying the power of the PV panel (P PV ) and the capacity of the BESS (P B ) by their respective unitary costs (C uPV and C uB )-the BESS cost would be zero for the facility without storage. With the analysis above, we define the optimisation problem as follows: Mathematical Model Given: (1) An hourly PV energy generation E PV .
(2) The hourly demand profile, E D . (3) The energy price (PE) and access tariff (AT).
(4) The round trip efficiency of the BESS (η). (5) The daily peak hours and off-peak hours.
Find: PV panel peak power (P PV ) and battery capacity (P B ) for different scenarios of investment costs (I t ) and annual residential demand (D).

4.
Surplus energy constraint: Hourly demand constraints: Observe that the model and methodology presented in this paper can be easily implemented in other market frameworks since costs, incomes and savings of the project are based on real market variables (on an hourly basis).

Model Input Information
This section describes the data used in the model. We analyse four different data sources: demand profiles, energy price and tariffs, facility technology, and location and energy production. The hourly consumption of the domestic household (E D ) is one of the main variables considered in the analysis as it is the key element for PV power and BESS capacity optimisation. The standard consumption of a residential household during a day depends on the month of the year considered, which in turn is influenced by external variables such as weather conditions or holiday seasons. As a representative example, Figure 2 shows the hourly household consumption from the grid (E P ) obtained from the OMIE (Iberian Electricity Market Operator) on the 15th day of four different months: March, June, September and December. This variable is obtained from the smart meters installed in domestic households [27,28]. Consumption from the grid ( ) falls during the night hours from 0.4 kWh to 0.2 kWh, with similar patterns for each month. This is because few devices are connected to the network during the night, apart from the ones which need to be always connected (such as refrigerators). After that, demand increases from 7:00 a.m. reaching a local maximum at 14:00, ranging the consumption in this last hour from 0.45 (September) to 0.55 kWh (December). This growth is observed because people connect devices to the network (for instance, air conditioning, electric oven, hob, etc.). From 14:00, the curves show different patterns, as the work and weather conditions are different from one month to another. After a slight decrease between 14:00 and 18:00, consumption increases again until 22:00 reaching, at that hour, the peak of daily consumption, being in the range of 0.45 (September) and 0.6 kWh (December).
The seasonality of energy consumption from the grid ( ) is represented in Figure 3, depicting the total amount of energy demanded in every month. As can be observed, summer and winter months present the higher rates due to the devices used in order to mitigate the effects of the weather conditions. The range of the total monthly consumption is between 253 kWh in May and 339 kWh in January. Consumption from the grid (E P ) falls during the night hours from 0.4 kWh to 0.2 kWh, with similar patterns for each month. This is because few devices are connected to the network during the night, apart from the ones which need to be always connected (such as refrigerators). After that, demand increases from 7:00 a.m. reaching a local maximum at 14:00, ranging the consumption in this last hour from 0.45 (September) to 0.55 kWh (December). This growth is observed because people connect devices to the network (for instance, air conditioning, electric oven, hob, etc.). From 14:00, the curves show different patterns, as the work and weather conditions are different from one month to another. After a slight decrease between 14:00 and 18:00, consumption increases again until 22:00 reaching, at that hour, the peak of daily consumption, being in the range of 0.45 (September) and 0.6 kWh (December).
The seasonality of energy consumption from the grid (E P ) is represented in Figure 3, depicting the total amount of energy demanded in every month. As can be observed, summer and winter months present the higher rates due to the devices used in order to mitigate the effects of the weather conditions. The range of the total monthly consumption is between 253 kWh in May and 339 kWh in January.

Energy Price and Tariffs
The market price of the energy (PE) is an hourly variable which can be obtained from the OMIE database [29]. OMIE is the nominated electricity operator for managing the Iberian Peninsula's electricity markets. It operates 24/7 and manages the transactions for the sellers and buyers who trade on the electrical market. There are more than 1000 agents in total and involving over 15 million transactions per year. Through all the bids for selling and acquiring energy, OMIE builds the aggregate supply and demand curves and implements the matching process, starting with the cheapest offers until demand is satisfied in each programming period, and resulting in the end with the price and the amount of energy in the period [30]. Figure 4 shows that the crossing point of both aggregate curves determines the market price (PE) and the quantity of energy for the scheduling period. Note that the day-ahead prices are important in our model because they allow for the determining of the cost of the bill paid to the market.
(such as refrigerators). After that, demand increases from 7:00 a.m. reaching a local maximum at 14:00, ranging the consumption in this last hour from 0.45 (September) to 0.55 kWh (December). This growth is observed because people connect devices to the network (for instance, air conditioning, electric oven, hob, etc.). From 14:00, the curves show different patterns, as the work and weather conditions are different from one month to another. After a slight decrease between 14:00 and 18:00, consumption increases again until 22:00 reaching, at that hour, the peak of daily consumption, being in the range of 0.45 (September) and 0.6 kWh (December).
The seasonality of energy consumption from the grid ( ) is represented in Figure 3, depicting the total amount of energy demanded in every month. As can be observed, summer and winter months present the higher rates due to the devices used in order to mitigate the effects of the weather conditions. The range of the total monthly consumption is between 253 kWh in May and 339 kWh in January.

Energy Price and Tariffs
The market price of the energy (PE) is an hourly variable which can be obtained from the OMIE database [29]. OMIE is the nominated electricity operator for managing the Iberian Peninsula's electricity markets. It operates 24/7 and manages the transactions for the sellers and buyers who trade on the electrical market. There are more than 1000 agents in total and involving over 15 million transactions per year. Through all the bids for selling and acquiring energy, OMIE builds the aggregate supply and demand curves and implements the matching process, starting with the cheapest offers until demand is satisfied in each programming period, and resulting in the end with the price and the amount of energy in the period [30]. Figure 4 shows that the crossing point of both aggregate curves determines the market price (PE) and the quantity of energy for the scheduling period. Note that the day-ahead prices are important in our model because they allow for the determining of the cost of the bill paid to the market. The day-ahead market price is fixed every hour, depending on the total energy demanded by consumers and the type and quantity of energy bids offered by the suppliers (green or non-renewable energies). As an example, Figure 5 contains the average hourly prices (PE) for March, June, September and December. The day-ahead market price is fixed every hour, depending on the total energy demanded by consumers and the type and quantity of energy bids offered by the suppliers (green or non-renewable energies). As an example, Figure 5 contains the average hourly prices (PE) for March, June, September and December.
Note that the shape of the curves is similar to that of the daily household consumption (E P ) of the previous section ( Figure 2), with similar peak and off-peak hours during the day. Winter and summer months have the most expensive prices, caused by the peak in energy demand, their market prices being nearly one and a half times the prices of the cheapest months (March and September). The effect of the energy demanded on the market price is also observed during the entire day. In this sense, those hours with higher demand also have higher prices. The day-ahead market price is fixed every hour, depending on the total energy demanded by consumers and the type and quantity of energy bids offered by the suppliers (green or non-renewable energies). As an example, Figure 5 contains the average hourly prices (PE) for March, June, September and December. Additionally, when energy from the grid is consumed (E P ), it is necessary to pay an hourly access tariff (AT). There is also a yearly price (PP), related to electrical power contracted by the user (CoP). This model assumes the 2.0 HDT hourly discrimination Spanish tariff for the domestic household, with a contracted power of 4.4 kW (CoP). This tariff is regulated by the Spanish Government; its value depends on both the peak and off-peak hours and the season of the year. Table 2 summarizes the values of the tariffs used in this research. The Value Added Tax (VAT) for energy consumption in Spain is 21.0% and it is applicable to the complete energy bill. Moreover, there is a specific electricity tax of 5.11% on the net consumption bill and contracted power [30].

Technology of the Facility
The facilities assessed in this research are composed of several PV panels (made from crystalline silicone) [9], an inverter and a BESS to store the surplus energy. The slope and azimuth angle can be adjusted to the location where they are installed, in order to maximize energy production. Additionally, the energy generation of these panels (E P ) depends on their own peak power (P PV ). Then, higher peak power derives in higher energy generation, as is exemplified in Figure 6 for PV panels located in Seville City on 21 June. Higher peak powers provide also greater amounts of energy that can be used for self-consumption (E PV C ), BESS storage (E CH ), or electricity sale (E S )-Equations (2a) and (2b)-, thus generating greater cash flows (CF t , Equation (8)). The panel acquisition costs (C PV ) are also more expensive, so the facility needs to be adjusted to the hourly user demand (E D ) in order to make it profitable. In this research, the unitary cost for the PV panels (C uPV ) is 900 €/kWp (In addition to these references, the unitary cost of the PV system has been contrasted with a real offer made by a local contractor in Spain; the offer includes EPC, BoS, inverter, PV modules and others) [31][32][33]. An important aspect to take into account is that this cost refers to the total price of an installed roof PV system, including Engineering Procurement and Construction (EPC), Balance of Systems (BoS), inverter, PV modules and others. The only cost that has not been considered in this total is the fixed installation cost (permitting and other legal issues) since in many Spanish municipalities there are equivalent subsidies that offset these costs-note also that this assumption simplifies the programming of the model. The BESS uses a Li-Ion battery-a detailed study of the different categories of energy storage technologies, as well as their technical performance and future perspectives, can be found in Arcos et al. [35]. Following these authors, Table 3 presents the main characteristics of the Li-Ion batteries, which are obtained by combining information from various sources: Gomez et al. [36], Segui [37], Bardo   The current performance of this type of storage technology has been significantly improved in recent years. In particular, the unitary cost ( ) has been reduced by an average of 20% per year during the period 2010-2019 and, given the intensity of research focused on this field, it is foreseeable that the downward trend will continue. If the cost reduction continues at this rate, costs would be halved in 3.5 years (Equation (12)).

Location and Energy Production
The energy generated ( ) depends on the solar irradiation received by the PV panels during the day and on their own peak power. The Photovoltaic Geographical Infor- The BESS uses a Li-Ion battery-a detailed study of the different categories of energy storage technologies, as well as their technical performance and future perspectives, can be found in Arcos et al. [35]. Following these authors, Table 3 presents the main characteristics of the Li-Ion batteries, which are obtained by combining information from various sources: Gomez et al. [36], Segui [37], Bardo   The current performance of this type of storage technology has been significantly improved in recent years. In particular, the unitary cost (C uB ) has been reduced by an average of 20% per year during the period 2010-2019 and, given the intensity of research focused on this field, it is foreseeable that the downward trend will continue. If the cost reduction continues at this rate, costs would be halved in 3.5 years (Equation (12)).

Location and Energy Production
The energy generated (E PV ) depends on the solar irradiation received by the PV panels during the day and on their own peak power. The Photovoltaic Geographical Information System (PVGIS) of the European Commission provides information about the irradiation received on a PV panel, depending on its own position (latitude and inclination) and considering also the sunlight reflection, the changes in the solar spectrum, and the module temperature. The facility is located in Seville City, but the model can also be implemented in another location, knowing the hourly demand (see Figure 3). The parameters of the PV panel configuration (obtained from PVGIS) are shown in Table 4. The curve of the hourly energy generated (E PV ) by a 1.0 kWp PV panel located at Seville City is shown in Figure 7, taking the first day of March, June, September and December as references.  The curve of the hourly energy generated ( ) by a 1.0 kWp PV panel located at Seville City is shown in Figure 7, taking the first day of March, June, September and December as references. Note that the maximum energy production for a PV panel ( ) happens around 12:00 regardless of the month considered. Moreover, as the production depends on the solar irradiation received, the summer months present the higher production rates, while the winter months present the lower rates. An important thing to note is that the time slot in which the panels produce energy is longer in summer months (approximately two hours earlier in the morning and two hours later in the evening) as a consequence of the greater amount of sun hours.
The superposition of the demand profile ( ) and the production curve ( ) during the day will show the intervals where the facility is able to fully cover household demand.  Note that the maximum energy production for a PV panel (E PV ) happens around 12:00 regardless of the month considered. Moreover, as the production depends on the solar irradiation received, the summer months present the higher production rates, while the winter months present the lower rates. An important thing to note is that the time slot in which the panels produce energy is longer in summer months (approximately two hours earlier in the morning and two hours later in the evening) as a consequence of the greater amount of sun hours.
The superposition of the demand profile (E D ) and the production curve (E PV ) during the day will show the intervals where the facility is able to fully cover household demand.  For the hourly slot from 7:00 to 14:00, the facility is able to fully cover the demand ( ) directly with the production of the PV panels ( ) and, at the same time, produces surplus energy ( ), which can be used to feed into the network ( ) or stored in the battery ( ), Equation (4)). From 14:00, the energy production is lower than the demand and the household needs to be supported firstly from the battery ( ) and secondly, if necessary, from the network ( ), Equation (5)). Figure 9 shows the total monthly energy consumed and produced for our representative household. The energy generated ( ) covers around 30% of the annual energy demand ( ) during the winter months (January and December), while in the summer months it can cover above 50%, allowing a greater amount for consumption ( ) and sales ( ), and generating greater sales (IC) and savings (S)-Equations (6) and (7).

Technical and Financial Results of the Self-consumption Model
In this section, technical and financial results are presented for the residential facility For the hourly slot from 7:00 to 14:00, the facility is able to fully cover the demand (E D ) directly with the production of the PV panels (E PV ) and, at the same time, produces surplus energy (E EX ), which can be used to feed into the network (E S ) or stored in the battery (E CH ), Equation (4)). From 14:00, the energy production is lower than the demand and the household needs to be supported firstly from the battery (E B C ) and secondly, if necessary, from the network (E P ), Equation (5)). Figure 9 shows the total monthly energy consumed and produced for our representative household. For the hourly slot from 7:00 to 14:00, the facility is able to fully cover the demand ( ) directly with the production of the PV panels ( ) and, at the same time, produces surplus energy ( ), which can be used to feed into the network ( ) or stored in the battery ( ), Equation (4)). From 14:00, the energy production is lower than the demand and the household needs to be supported firstly from the battery ( ) and secondly, if necessary, from the network ( ), Equation (5)). Figure 9 shows the total monthly energy consumed and produced for our representative household. The energy generated ( ) covers around 30% of the annual energy demand ( ) during the winter months (January and December), while in the summer months it can cover above 50%, allowing a greater amount for consumption ( ) and sales ( ), and generating greater sales (IC) and savings (S)-Equations (6) and (7).

Technical and Financial Results of the Self-consumption Model
In this section, technical and financial results are presented for the residential facility with or without BESS. The life of the project has been fixed at 25 years, with a discount rate of 6.5% [45]. The shelf life of the BESS corresponds to 5000 charge cycles. If we assume one charge cycle per day, it would be necessary to replace the BESS after the thirteenth  The energy generated (E PV ) covers around 30% of the annual energy demand (E D ) during the winter months (January and December), while in the summer months it can cover above 50%, allowing a greater amount for consumption (E F ) and sales (E S ), and generating greater sales (IC) and savings (S)-Equations (6) and (7).

Technical and Financial Results of the Self-consumption Model
In this section, technical and financial results are presented for the residential facility with or without BESS. The life of the project has been fixed at 25 years, with a discount rate of 6.5% [45]. The shelf life of the BESS corresponds to 5000 charge cycles. If we assume one charge cycle per day, it would be necessary to replace the BESS after the thirteenth year. However, we have decided to replace it in year twelve in order to avoid battery malfunction problems. Note that the investment produced in that year will negatively affect its corresponding cash flow (Equation (8)). Our analysis allows us to measure the economic effect of changes in domestic consumption and in the prices of the panels and the BES System.

Household PV Panels Without Storage
The energy production of the facility (E PV ) increases with the peak power of the PV panel installed (P PV ), making the household more autonomous (less dependent on the network) and the savings (S) and incomes (IC) higher. The annual proportion of facility energy production (D/ E PV ) which is intended for self-consumption (E F ) depends on the peak power of the panels, as is shown in Figure 10 for domestic demand (D) of 3500 kWh.

Household PV Panels Without Storage
The energy production of the facility ( ) increases with the peak power of the PV panel installed ( ), making the household more autonomous (less dependent on the network) and the savings (S) and incomes (IC) higher. The annual proportion of facility energy production (D / ) which is intended for self-consumption ( ) depends on the peak power of the panels, as is shown in Figure 10 for domestic demand (D) of 3500 kWh. The curve reveals that this proportion falls with higher panel peak power, going from 100% for a 0.5 kWp panel to 30% for a 3.5 kWp panel. When the peak power ( ) increases, the cash flow (CF) from sales (IC) and savings (S) increases as well, but the key question is whether this cash flow increase offsets the cost of more expensive panels ( ) and, therefore, the greater investment needed ( , Equation (11)). Technical and economic outcomes are shown in Table 5 for a residential demand (D) of 3500 kWh without BESS; also, the financial indicators can be graphically inspected in Figures 11 (NPV and IRR) and 12 (IR).  The curve reveals that this proportion falls with higher panel peak power, going from 100% for a 0.5 kWp panel to 30% for a 3.5 kWp panel. When the peak power (P PV ) increases, the cash flow (CF) from sales (IC) and savings (S) increases as well, but the key question is whether this cash flow increase offsets the cost of more expensive panels (C PV ) and, therefore, the greater investment needed (I 0 , Equation (11)). Technical and economic outcomes are shown in Table 5 for a residential demand (D) of 3500 kWh without BESS; also, the financial indicators can be graphically inspected in Figure 11 (NPV and IRR) and Figure 12 (IR).
The facility with 0.5 kWp PV panels (the lowest peak power considered) shows the best IRR and IR ratios, reaching the values 14.4% and 0.8 respectively-observe that for this panel size, all the PV energy is used for self-consumption (no PV energy is wasted), thus generating the corresponding savings (S). The IR decreases with the peak power (P PV ) because the NPV increase is lower than the increase in the investment (I 0 , I 12 ) assumed for the acquisition of PV panels with higher peak powers. In this way, notice that the investment required for a 3.5 kWp facility is seven times the cost of a 0.5 kWp one, while the NPV is nearly three times higher. Therefore, the IR decreases gradually from 0.8 to 0.34; Sustainability 2021, 13, 575 16 of 26 note also that the NPV grows with P PV because the discounted cash-flows (savings plus incomes) grow more than the initial investment when the peak power of the panel increases. Table 5. Parameters for PV installation without battery energy storage systems (BESS) (Domestic demand 300 kWh).   The facility with 0.5 kWp PV panels (the lowest peak power considered) shows the best IRR and IR ratios, reaching the values 14.4% and 0.8 respectively-observe that for this panel size, all the PV energy is used for self-consumption (no PV energy is wasted), thus generating the corresponding savings (S). The IR decreases with the peak power ( ) because the NPV increase is lower than the increase in the investment ( , ) assumed for the acquisition of PV panels with higher peak powers. In this way, notice that the invest-  The facility with 0.5 kWp PV panels (the lowest peak power considered) shows the best IRR and IR ratios, reaching the values 14.4% and 0.8 respectively-observe that for this panel size, all the PV energy is used for self-consumption (no PV energy is wasted), thus generating the corresponding savings (S). The IR decreases with the peak power ( ) because the NPV increase is lower than the increase in the investment ( , ) assumed for the acquisition of PV panels with higher peak powers. In this way, notice that the investment required for a 3.5 kWp facility is seven times the cost of a 0.5 kWp one, while the NPV is nearly three times higher. Therefore, the IR decreases gradually from 0.8 to 0.34;  As observed in Figure 10 for the case of 900 €/kWp panel cost, Figure 13 shows that, for any panel cost considered, the optimal size of the facility is the smallest one (0.5 kWp). Furthermore, as would be expected, given a panel peak power, it can be observed that the financial indicator improves as the unitary cost of the panel is assumed to be lower -we would be obtaining the same cash flows with a lower investment. Finally, we wonder if a higher demand (D) can make profitable the installation of a higher power facility, as this can cover more energy demanded by the domestic household and therefore increase the savings on the bill (S). Figure 14 represents the IR indicator for different PV peak powers and levels of residential power demand. In this simulation, the 0.5 kWp facility again shows the best IR ratio; however, notice that this ratio does not change with the power demand, as the total PV energy produced is used for self-consumption at all residential demand levels. For values of 2.5 kWp or higher, the IR ratios are nearly straight lines with a slope of 0.1 per 1 500 kWh of residential As observed in Figure 10 for the case of 900 €/kWp panel cost, Figure 13 shows that, for any panel cost considered, the optimal size of the facility is the smallest one (0.5 kWp). Furthermore, as would be expected, given a panel peak power, it can be observed that the financial indicator improves as the unitary cost of the panel is assumed to be lower-we would be obtaining the same cash flows with a lower investment. Finally, we wonder if a higher demand (D) can make profitable the installation of a higher power facility, as this can cover more energy demanded by the domestic household and therefore increase the savings on the bill (S). Figure 14 represents the IR indicator for different PV peak powers and levels of residential power demand. As observed in Figure 10 for the case of 900 €/kWp panel cost, Figure 13 shows that, for any panel cost considered, the optimal size of the facility is the smallest one (0.5 kWp). Furthermore, as would be expected, given a panel peak power, it can be observed that the financial indicator improves as the unitary cost of the panel is assumed to be lower -we would be obtaining the same cash flows with a lower investment. Finally, we wonder if a higher demand (D) can make profitable the installation of a higher power facility, as this can cover more energy demanded by the domestic household and therefore increase the savings on the bill (S). Figure 14 represents the IR indicator for different PV peak powers and levels of residential power demand. In this simulation, the 0.5 kWp facility again shows the best IR ratio; however, notice that this ratio does not change with the power demand, as the total PV energy produced is used for self-consumption at all residential demand levels. For values of 2.5 kWp or higher, the IR ratios are nearly straight lines with a slope of 0.1 per 1 500 kWh of residential In this simulation, the 0.5 kWp facility again shows the best IR ratio; however, notice that this ratio does not change with the power demand, as the total PV energy produced is used for self-consumption at all residential demand levels. For values of 2.5 kWp or higher, the IR ratios are nearly straight lines with a slope of 0.1 per 1 500 kWh of residential demand. Taking into account that higher levels of demand (D) imply greater self-consumption and therefore greater savings (and fewer possibilities of selling energy to the market), these positive slopes would indicate that a scenario of high demand, where the main source of cash-flow is given by savings, is more profitable than a scenario of low demand, where the incomes from selling off the surplus energy have a greater weight.

Household PV Panels with Storage
In this scenario, the PV panels are connected to a BESS where the part of the energy produced (and not consumed) is stored (E BL > 0) during off-peak hours if the battery is partially charged, B BL < P B (Equation (1)). The advantage of the use of the BESS is that the surplus energy (E EX ) is not immediately sold as in the first configuration but can be stored for further self-consumption, making the savings greater than in a non-storage scenario, or sold to the market when the energy tariff is more expensive. As we saw in Section 2.1, when the BESS is fully charged (E BL = P B ), the surplus energy is sold to the market regardless of the time of day (peak or off-peak hour).
BESS units with different capacities are simulated in this section (from 0.5 kWh to 3.0 kWh) for a residential consumption of D = 3500 kWh and a unitary panel cost of 900 €/kWp. Sales (IC) and savings (S) are discounted to determine the NPV, IRR and IR indicators for each configuration. Figure 15 depicts the NPV values; an almost linear positive relationship can be observed between the NPV and the BESS capacity (P B ) for any given value of PV peak power (P PV ). Moreover, the NPV grows with the power of the PV panels. Both technical attributes, P B and P PV , allow an increase in savings (a greater amount of energy demand is covered with the facility, E F ) and sales (a greater amount of energy is sold to the market, E S ). However, it is assumed that the user has limited economic resources to invest in the facility so that it is necessary to find the optimal configuration concerning the IRR and IR indicators. demand. Taking into account that higher levels of demand (D) imply greater self-consumption and therefore greater savings (and fewer possibilities of selling energy to the market), these positive slopes would indicate that a scenario of high demand, where the main source of cash-flow is given by savings, is more profitable than a scenario of low demand, where the incomes from selling off the surplus energy have a greater weight.

Household PV Panels with Storage
In this scenario, the PV panels are connected to a BESS where the part of the energy produced (and not consumed) is stored ( > 0) during off-peak hours if the battery is partially charged, < (Equation (1)). The advantage of the use of the BESS is that the surplus energy ( ) is not immediately sold as in the first configuration but can be stored for further self-consumption, making the savings greater than in a non-storage scenario, or sold to the market when the energy tariff is more expensive. As we saw in Section 2.1, when the BESS is fully charged ( = ), the surplus energy is sold to the market regardless of the time of day (peak or off-peak hour).
BESS units with different capacities are simulated in this section (from 0.5 kWh to 3.0 kWh) for a residential consumption of D = 3500 kWh and a unitary panel cost of 900 €/kWp. Sales (IC) and savings (S) are discounted to determine the NPV, IRR and IR indicators for each configuration. Figure 15 depicts the NPV values; an almost linear positive relationship can be observed between the NPV and the BESS capacity ( ) for any given value of PV peak power ( ). Moreover, the NPV grows with the power of the PV panels. Both technical attributes, and , allow an increase in savings (a greater amount of energy demand is covered with the facility, ) and sales (a greater amount of energy is sold to the market, ). However, it is assumed that the user has limited economic resources to invest in the facility so that it is necessary to find the optimal configuration concerning the IRR and IR indicators.  Figure 16 shows the IRR values regarding the PV panel peak power ( ) and BESS capacity ( ). The IRR tends to decrease with the peak power of the PV panel and to increase with the capacity of the battery, although the latter happens only up to a certain level of BESS capacity that oscillates between 2.0 and 2.5 kWh. The exception to this behaviour is observed in the panel of the lowest peak power (0.5 kWp), whose IRR rate tends to fall with the size of the battery; it seems that when the panel is too small there is no point in investing in a battery which is too large, given the limited capacity of the panel to generate savings and sales. We can conclude that, in optimal terms, both sizes (panel and battery) have to be consistent; we should not combine a very small panel with a very  Figure 16 shows the IRR values regarding the PV panel peak power (P PV ) and BESS capacity (P B ). The IRR tends to decrease with the peak power of the PV panel and to increase with the capacity of the battery, although the latter happens only up to a certain level of BESS capacity that oscillates between 2.0 and 2.5 kWh. The exception to this behaviour is observed in the panel of the lowest peak power (0.5 kWp), whose IRR rate tends to fall with the size of the battery; it seems that when the panel is too small there is no point in investing in a battery which is too large, given the limited capacity of the panel to generate savings and sales. We can conclude that, in optimal terms, both sizes (panel and battery) have to be consistent; we should not combine a very small panel with a very large battery, nor a very large panel with a very small battery. For instance, in our case, the optimal configuration is reached for a 1.0 kWp PV panel and a BESS of 2.0 kWh, which generates an IRR of 14.4%.   Figure 17 shows the IR indicator for different configurations of PV panel peak power ( ) and battery capacity ( ). For a battery capacity greater than zero, the 1.0 kWp PV panel with a BESS capacity from 0.5 to 2.0 kWh presents the highest IR values, which move in a range between 0.72 and 0.74. The facility with a 1.0 kWp PV panel and a 2.0 kWh capacity is the optimal configuration for a residential demand (D) of 3500 kWh and a unitary panel cost of 900 €/kWp; this is because it obtains the maximum IR (0.74) and IRR (14.4%) indicators and an NPV (812.14€) which is relatively high within 1.0 kWp panels. In any case, for those panels greater than 0.5 kWp, the IR indicator behaves roughly flatly when presented, depending on the battery size (at least up to a size of 2.5 kWh); that is because the greater savings and NPV that a larger battery allows is offset by the greater investment required.  Figure 17 shows the IR indicator for different configurations of PV panel peak power (P PV ) and battery capacity (P B ). For a battery capacity greater than zero, the 1.0 kWp PV panel with a BESS capacity from 0.5 to 2.0 kWh presents the highest IR values, which move in a range between 0.72 and 0.74. The facility with a 1.0 kWp PV panel and a 2.0 kWh capacity is the optimal configuration for a residential demand (D) of 3500 kWh and a unitary panel cost of 900 €/kWp; this is because it obtains the maximum IR (0.74) and IRR (14.4%) indicators and an NPV (812.14 €) which is relatively high within 1.0 kWp panels. In any case, for those panels greater than 0.5 kWp, the IR indicator behaves roughly flatly when presented, depending on the battery size (at least up to a size of 2.5 kWh); that is because the greater savings and NPV that a larger battery allows is offset by the greater investment required.
The unitary cost of panels (C uPV ) and BESS (C uB ) has fallen during recent years causing a reduction in the investment considered in our study (I 0 , I 12 ) and, therefore, an increase in the financial indicators. On the other hand, a higher residential demand (D) could require a greater BESS capacity or PV panel peak power in the optimal configuration, so that the energy consumed directly from the facility (E F ) would increase, expanding both savings and cash flows. For this reason, an analysis is performed varying the unitary costs of the PV panel (C uPV ) and BESS (C uB ), and the residential demand (D) in order to find the most suitable configuration in each of the cases. For this analysis, we take the optimal panel of 1.0 kWp, a battery cost of 100 €/kWh (This quantity comes from real offers made by local contractors, and includes both the battery, as well as the structures, wiring, control and measurement systems, . . . ), and a demand (D) of 3500 kWh. Table 6 shows the financial indicators for the optimal BESS capacity (P B ) to be used at different panel unitary prices (C uPV ) from 700 €/kWp to 1200 €/kWp. a unitary panel cost of 900 €/kWp; this is because it obtains the maximum IR (0.74) and IRR (14.4%) indicators and an NPV (812.14€) which is relatively high within 1.0 kWp panels. In any case, for those panels greater than 0.5 kWp, the IR indicator behaves roughly flatly when presented, depending on the battery size (at least up to a size of 2.5 kWh); that is because the greater savings and NPV that a larger battery allows is offset by the greater investment required. The unitary cost of panels ( ) and BESS ( ) has fallen during recent years causing a reduction in the investment considered in our study ( , ) and, therefore, an increase in the financial indicators. On the other hand, a higher residential demand (D) could require a greater BESS capacity or PV panel peak power in the optimal configuration, so that the energy consumed directly from the facility ( ) would increase, expanding both savings and cash flows. For this reason, an analysis is performed varying the unitary costs of the PV panel ( ) and BESS ( ), and the residential demand (D) in  We find that an increase in the unitary cost of the panel (C uPV ) affects the optimal BESS capacity (P B ) to be installed depending on the financial indicator considered. According to the NPV criterion, the optimal BESS capacity is of 2.0 kWh independently of the unitary cost of the panel (C uPV ), while this one needs to be lower for cheaper unitary cost if IR or IRR criteria are used. We also observe that as the unitary cost of panels increases all the indicators tend to decrease due to the higher investment; note that the cash flows generated by the facility do not depend on the cost of the panel but on its peak power (Equations (6)-(8)), which remains fixed at 1.0 kWp in Table 6. When the panel unitary cost falls below the reference value (900 €/kWh), the optimal BESS capacity begins to depend on the financial indicator used. If we follow the NPV criterion, the 2.0 kWh BESS capacity is the optimal one, but if the IRR or IR indicators are used, the optimal BESS capacity (P B ) is progressively reduced till the value of 0.5 kWh for a unitary panel cost of 700 €/kWp. In this case, the reduction in the investment (due to a cheaper panel and lower BESS capacity) is higher (in absolute value) than that of the cash flows; the cash-flow reduction being due to operating with a smaller battery.
In the same way, the unitary BESS cost (C uB ) affects the financial indicators as the investment in the facility varies both in the initial year and in the year of replacement of the battery (year 12). It is important to note that, in practice, the cost of the BESS has fallen during the last few years due to technical and production developments. Table 7 represents the optimal BESS capacity for different unitary costs (C uB ) for a demand (D) of 3500 kWh and a 1.0 kWp PV panel at the current cost price of 900 €/kWp (C uPV ). The fall in the BESS unitary cost (C uB ) involves an increase in all the financial indicators and the installation of a BESS with higher capacity due to the lower investment required. The reduction in the BESS unitary cost price allows the installation of higher BESS capacity, which improves the cash flows (CF) through the increase of the saving (S) of the energy directly consumed from BESS (E B C , Equation (3)) and therefore reaches higher financial indexes.
When the NPV criterion is used, we observe that the BESS unitary price (C uB ) needs to fall to 90 €/kWh to change from the 2.0 kWh BESS capacity (current optimal configuration) to the one of 2.5 kWh-this size (2.5 kWh) represents the optimal BESS capacity within the range of 50 to 100 €/kWh. The IR and IRR criteria need the unitary price (C uB ) to be 50 €/kWh to switch from the current optimal BESS capacity (2.0 kWh) to the one of 2.5 kWh.
Finally, an analysis of the optimal configuration of PV panel peak power (P PV ) and BESS capacity (P B ), at their current unitary cost prices (C uPV = 900 €/kWp, C uB = 100 €/kWh), has been carried out for different residential demands (D). Table 8 reveals that as long as the demand (D) increases, the peak power of panels (P PV ) and the capacity of the BESS (P B ) need to be increased as well, thus improving all the financial indicators. In this situation, the cash flow generated by the savings (S) and energy sold to the market (E S ) associated with a higher residential demand covers the increase in the investment for the acquisition of higher PV panel power and BESS capacity (I). Note that an increase in residential demand implies an increase in the consumption of energy from the facility (E F ). For this to be possible, the BESS capacity (P B ) or the peak power of the panels (P PV ) needs to be higher according to Equation (3). If the NPV criterion is used, the PV panel peak power needs to be as high as possible (3.5 kWp), as there is a positive relationship with energy production (E PV ) and, therefore, with the cash-flows through savings and sales. At the same time, the consumption from the grid (E P ) is also reduced to satisfy residential demand when the panel is larger. The BESS capacity gradually increases with the demand (D) from 1.5 kWh to the highest value of 5.0 kWh when demand reaches 8000 kWh.
According to the IR and IRR criteria, the peak power of the panel (P PV ) and the BESS capacity (P B ) increase gradually with residential demand (D), but in this case, the values obtained for panel and BESS sizes are lower than those obtained with the NPV criterion. Note also that the IRR index is in the range (13.57%, 14.01%), while the IR is always above 0.69 with no significant changes from a residential demand of 5000 kWh and above, varying from 0.84 to 0.86. This is because the NPV generated with higher devices has approximately the same increase in its own acquisition cost. It should also be highlighted that an increase of 1500 kWh in demand involves an increase of 0.5 kWp in the panel size and 1.0 kWh in the BESS capacity.

Discussion
The current situation of energy policies in Spain and the improved performance achieved by PV facilities combined with BESS units make economic research necessary in order to determine whether they are profitable for domestic self-consumption. Considering a standard residential household located in Seville City, the research conducted reveals that the facility of PV panels without BESS obtains a maximum investment return (IR) of around 0.8 (being the IRR 14.4%) with low peak power PV panels (P PV ) (not higher than 1.0 kWp). The acquisition investment of more powerful panels is not compensated by the cash flows received by both the energy sold to the market and the monetary savings from the energy self-consumption. In the case that the unitary panel cost (C uPV ) falls below 900 €/kWp, the 0.5 kWp panels also obtain the best IR and IRR for each unitary PV cost price. We observed a linear dependency of the IR with the unitary cost price of the 1.0 kWp panel, and in the case that the unitary cost price (C uPV ) falls from 900 €/kWp to 700 €/kWp, the IR increases from 0.8 to 1.3. Only when the user demand (D) is increased, the use of more powerful PV panels (P PV ) is recommended, as the cash flows generated are higher and cover the increase in the investment. In this way, a facility can gradually increase the peak power of the panels, as long as the residential demand is increased as well.
The use of BESS is feasible in order to store the surplus energy produced in the off-peak hours by the panels and, therefore, to increase the savings because of the energy consumed from the BESS. The analysis indicates that a 2.0 kWh BESS with a 1.0 kWp PV panel is the optimal configuration for a 3500 kWh residential demand (D), reaching 0.78 of IR and 14.43% of IRR under the current unitary prices of PV panels (C uPV = 900 €/kWp) and BESS (C uB = 100 €/kWh). In this case, it is also shown that the cash flows obtained by the use of more powerful panels and BESS units do not compensate for the increase in the required investment for the given demand (3500 kWh).
Attending to the IR and IRR criteria, the cost analysis conducted reveals that the optimal BESS capacity (P B ) needs to be decreased when the unitary cost of the 1.0 kWp PV panels (C uPV ) decreases as well (ceteris paribus) because the cash flow generated by savings and sales do not compensate for the investment in a BESS with higher capacity. In the case that the unitary cost of the 1.0 kWp PV panel falls 22% from the current price (from 900 €/kWp to 700 €/kWp), the IR is increased by approximately 100% since it goes from 0.8 to 1.17. The fall in the unitary cost of the BESS (C uB ) from 100 €/kWh to 50 €/kWh (-50%) requires an increase in the optimal BESS capacity from 2.0 kWh to 2.5 kWh, which increases the IR index by about 25%. Given the current unitary costs of the devices (C uPV = 900 €/kWp and C uB = 100 €/kWh), we also observe a positive linear dependency of the PV peak power and the BESS capacity with respect to the residential demand. In this way, if the residential demand (D) is increased in 1500 kWh, the PV peak power (P PV ) needs to be increased in 0.5 kWp and the BESS capacity (P B ) in 1.0 kWh.

Conclusions
The model presented in this paper uses data from user smart meters and a defined location of a PV facility in order to find the optimal configuration of the BESS equipment and the PV panels in a domestic environment. With the current unitary cost prices of BESS and PV panels, a facility without a BESS (the first scenario analysed) located in Seville City (Southern Spain) needs to install a 0.5 kWp PV panel to obtain the best IRR index (14.0%) and return of investments (IR = 0.8), having also an NPV of 358 €. On the other hand, the facility with BESS (the second scenario analysed) needs to install a 1.0 kWp PV panel with a 2.0 kWh BESS to reach the optimal configuration, obtaining an IRR of 14.43%, an IR of 0.78, and an NPV of 812.54 €.
The technology improvements in BESS and PV panels during the last few years makes them less and less expensive. For an optimal facility with BESS, the conclusion is that the elasticity of the IRR index to the current PV price is −1.59; that elasticity being −2.18 for the IR indicator. In the case of the current BESS price, the battery cost elasticity of the financial indicators has been determined in −0.28 and −0.54 for the IRR and IR indicators respectively. In both cases, as long as the unitary prices fall, the facility allows the installation of higher power PV panels and BESS.
Finally, we should highlight that this model is useful for users (prosumers), electrical installers, engineering consultants and also Governments, since it provides the formula (to be used at any facility location) to determine the optimal configuration (in financial terms) of PV panels and BESS capacity and, at the same time, measure the effect of changes in PV panels and BESS prices on the profitability of the facility. This tool contributes also to the sustainability of the electrical market and the stability of the grid, as less energy is produced and transported through the network.

Acknowledgments:
The authors would like to thank the former master's degree student Juan Felipe Hinestroza.

Conflicts of Interest:
The authors declare no conflict of interest. Year of the project (year) u G Error term of the energy generation (kWh) v D Error term of the energy demand (kWh) η

BESS
Round trip efficiency of the battery (%) σ u Standard deviation of normal distribution