Generation of Alternative Battery Allocation Proposals in Distribution Systems by the Optimization of Different Economic Metrics within a Mathematical Model

Battery systems bring technical and economic advantages to electrical distribution systems (EDSs), as they conveniently store the surplus of cheap renewable generation for use at a more convenient time and contribute to peak shaving. Due to the high cost of batteries, technical and economic studies are needed to evaluate their correct allocation within the EDS. To contribute to this analysis, this paper proposes a stochastic mathematical model for the optimal battery allocation (OBA), which can be guided by the optimization of two different economic metrics: net present value (NPV) and internal rate of return (IRR). The effects of the OBA in the EDS are evaluated considering the stochastic variation of photovoltaic generation and load. Tests with the 33-node IEEE test system indicate that OBA results in voltage profile improvement (~1% at peak time), peak reduction (31.17%), increased photovoltaic hosting capacity (18.8%), and cost reduction (3.06%). Furthermore, it was found that the IRR metric leads to a different solution compared to the traditional NPV optimization due to its inherent consideration of the relation between cash flow and investment. Thus, both NPV and IRR-based allocation alternatives can be used by the decision maker to improve economic and technical operation of the EDS.


Introduction
Modern distribution networks are characterized by the increasing integration of distributed generation (DG) resources, especially from renewable sources. Along with this integration, battery systems have become more adopted in electrical distribution systems (EDSs) due to their ability to store and discharge energy at timely moments to reduce energy purchase costs [1]. Furthermore, batteries allow better use of DG, given their capacity to store the generation surplus as well as to allow the mitigation of risks associated with the intermittence of photovoltaic (PV) and wind DG [2][3][4]. Batteries can also provide other services to the grid such as voltage control and load-shifting [5]. They also have a wide scope of applications ranging from improving short-term power quality to long-term power management, as well as increasing reliability, uninterruptible power supply, and deferral of electric power system upgrades [6].
Even though other energy storage technologies exist, rapid response and controllability have attracted considerable attention around batteries. Moreover, the application of this technology in electric vehicles and mobile devices resulted in further development (e.g., better energy density, increasing efficiency, and more lifespan). Nevertheless, despite offering advantages to the operation of EDSs, batteries are still high-cost resources and their wide allocation in the distribution network is not yet a viable option [7].
Hence, the optimal battery allocation (OBA) is a critical problem to take advantage of the technical benefits of the batteries in an economical way. It is a complex procedure due evaluate specific technologies and investigates which type of application is more viable to install [27,28].
Allocation, sizing, and operation of batteries have been studied in the specialized literature considering different impacts, feasibilities, and economic benefits. However, the mathematical models proposed for the OBA are scarce; moreover, the economic analysis employed to solve that allocation problem is often restricted to the optimization of the NPV, which is not necessarily the best way to assess the economic advantage of the investment. In this context, the proposed approach in this paper allows the definition of the optimal allocation and operation of batteries by adopting a flexible technical and economic evaluation through a mixed-integer two-stage stochastic scenario-based programming model; a second-order conic formulation is adopted to represent the operation of the distribution network. Due to the combinatorial nature of the OBA problem, there is a high number of investment solutions; to help the decision maker, we propose a mathematical model, based on the NPV and internal rate of return (IRR) metrics, that can generate two different solutions. Hence, the main contributions of this work are the following:

1.
A comparative analysis between the solutions obtained using the NPV and the IRR (two well-known economic metrics [29]) as decision-making factors for the allocation and sizing of batteries to improve the integration of renewable distributed energy resources, whereby the mathematical model considers the cost of investments, system operation, and renewable DG units.

2.
A technical analysis of the benefits that the distribution network receives from the allocation of batteries, such as peak reduction, improvement in voltage profile, increasing renewable generation hosting capacity, and reduction of energy losses.
It is worth noting that the proposed formulation is a computationally efficient representation based on two-stage stochastic programming that considers the uncertainties related to renewable DG and demand. The adopted second-order conic power flow representation provides equivalent solutions to an exact nonlinear model. The rest of this paper is organized as follows: Section 2 discusses the OBA problem and defines the representation of the distribution system operation along with the economic metrics (NPV and IRR); the stochastic optimization models are defined in Section 3. The economic and technical results using the IEEE-33 node test system are presented in Section 4. Finally, conclusions are drawn in Section 5.

Optimal Battery Allocation
The main objectives of this work are determining alternative proposals for the OBA problem using efficient off-the-shelf software, which provides a suitable framework for the attainment of global optimality for convex models [30]. NPV and IRR economic metrics are integrated into the model to guide the optimization problem and generate different solutions. Furthermore, the corresponding technical performances considering the nonaccountable benefits that battery allocation provides to the EDS are analyzed. For this purpose, the mathematical formulation that represents the effects of the distribution networks in the presence of distributed photovoltaic generation along with battery allocation is presented in this section. Subsequently, the economic objectives using the NPV and IRR are presented along with a discussion of some of their characteristics.
The resulting optimization problem considers a two-stage stochastic scenario-based optimization approach to handle the uncertainties related to the demanded load and the PV generation. This is done through a set of scenarios, represented by the index s, in a 24-h time window, i.e., the scenarios represent the possible variations within the same hour of the uncertain parameters. Moreover, the variations in demand and generation throughout a typical day are represented for each time level by the hourly index t. The mathematical formulation is built using an investment decision variable (ρ m ) for battery system allocation at node m.

Technical and Operational Constraints
Three types of constraints are considered in this work. The first one is related to the single-phase representation of the EDS operation. The second set of constraints represents the operation and allocation of batteries, in which the decision variable ρ m determines if the node m has allocated a battery system. The third set of constraints describes the operation of the renewable DG units based on PV technology.

Network Operation Constraints
The representation of the EDS operation with batteries is based on the AC Branch Flow model proposed by [30] and defined by (1)- (6). Equations (1) and (2) guarantee the active and reactive power balance at each node, whereby variables P mn,t,s , Q mn,t,s , and I sqr km,t,s correspond to the active and reactive power flows, and the square of the current through circuit mn, for period t at scenario s. Furthermore, variables P b+ m,t,s and P b− m,t,s represent the injected and absorbed power for the batteries at node m, while P SE m,t,s and Q SE m,t,s define the active and reactive powers supplied by the substation at node m. Hence, variable P DG m,t,s represents the active power supplied by the DG unit at node m.
Equation (3)  and V sqr n,t,s represent the squared voltage at node m and n, respectively. The second-order constraint (4) calculates the squared current magnitude in the circuit mn. Hereinafter, (5) and (6) limit the squares of voltage and current magnitudes. The voltage V sqr n,t,s is limited by the upper and lower bounds V and V as expressed in (5) 0 ≤ I sqr mn,t,s ≤ I 2 ; ∀ mn, t, s In the previous expressions, resistance, reactance, and impedance of the mn circuit are defined by parameters R mn , X mn , and Z mn respectively. Parameters P d m,t,s and Q d m,t,s set the active and reactive power demand for each node m, in period t, at scenario s.

Battery System Operation
Battery operation is expected to bring technical improvements to the EDS, such as reducing peak demand, increasing the hosting capacity, improving the voltage profile, and reducing energy losses. The previous enhancements are a consequence of the capability of the batteries to absorb power in periods in which the demand and energy price are low and then inject the stored energy in periods of high demand and energy price. These two characteristics are established in expressions (7)−(10), which are based on [31]. Constraints (7) and (8) limit the power injected and absorbed by the batteries into the distribution system. The operation of a battery is modeled using two continuous decision variables (P b+ m,t,s and P b− m,t,s ) for the injection (discharging) and absorption (charging). Thus, the optimal charging/discharging strategy for the batteries is also identified within the solution of the optimization problem to define the best allocation decision. P b+ m,t,s is limited by the device power capacity along with the allocation decision, as expressed in (7). Similarly, P b− m,t,s is limited by (8). Furthermore, Equations (9) and (10)  previous period, the self-discharge, the energy absorbed, and the energy injected, as defined by (9). The battery's energy is limited by the energy capacity along with the allocation decision, as outlined in (10). Since there are physical restrictions for the installation of batteries, not all nodes are allowed for the allocation; therefore, the parameter b m is used in the formulation to indicate the nodes suitable for allocation, as shown in (11), while (12) sets the binary nature of the decision variable ρ m . 0 ≤ P b+ m,t,s ≤ P inv ·ρ m ; ∀ m, t, s In the above expressions, parameter P inv represents the capacity of injection and absorption of the battery inverter, while parameters E b and E b are the minimum and maximum energy that can be stored in the battery, η b represents its round-trip efficiency, and β b is its self-discharge rate.

Operation of the Renewable Distributed Generation
The renewable DG units considered in this formulation are PV systems. The injected power (P DG m,t,s ) at node m in period t, is modeled according to (13), in which P DG is the maximum power of the generating unit, and δ t,s is the PV generation factor for period t at scenario s. P DG m,t,s = P DG ·δ t,s ; ∀m, t, s

Economic Metrics Integrated into the OBA Problem
Investments in batteries represent large capital expenditures. Therefore, decisions about their allocation and sizing are a task that should be carefully assessed. One of the most important criteria to evaluate investment projects is the economic benefit, which in most cases is represented by two different economic metrics: (1) NPV and (2) IRR. Aiming the generation of alternative solutions that can be used by the decision maker to define the OBA investment, those economic metrics are adopted here to guide the optimization problem; this is done by independently optimizing objective functions associated with the NPV and IRR metrics. Both metrics are presented below, along with the formulation of the two optimization problems.

Net Present Value
Net present value is one of the most used financial metrics to evaluate investment projects by any kind of company. Regarding OBA, it is the most frequent financial criterion to determine the benefit in operational cost reduction due to the installation of batteries; batteries can be used to reduce the cost of the energy by charging at low price and discharging when the price is high, which, in turn, is reflected in savings in the cash flow. This financial metric is widely accepted due to its ease of interpretation: a positive value presumes the acceptance of the project since the benefits outweigh the initial investments in a time horizon. Conversely, a negative value indicates the rejection of the project since the benefits do not cover the initial investments in a time horizon. When two or more projects are evaluated, they can be ranked from the largest to the smallest NPV [29]. Equation (14) calculates the NPV for an annual cash flow F i and an investment B, considering a discount rate λ and a planning horizon τ [29].
The fast interpretation and ease assessments of NPV contrast with some of its disadvantages. The first one is related to the dependence on the discount rate, which must be carefully defined before economic assessment [32]; generally, it is calculated as the weighted average cost of capital or with another methodology. To exemplify this, consider two battery types with a lifespan of 10 years to be installed in a node: one "conventional" type battery and one with more advanced high technology. The installation and annual maintenance costs of the regular battery are $10,000 and $3000 per year. The high technology battery has costs equal to $18,000 and $1800 per year [33]. To choose a battery type is to determine whether the benefits of maintenance costs ($3000 and $1800) justify the difference between the initial investment difference ($8000). The cash flow of Figure 1 summarizes this information, while Table 1 shows the NPV of selecting the high technology battery over the conventional one for different discount rates λ, from 0% to 20%. It can be observed that lower discount rates favor the adoption of the high technology alternative, in accordance with [34].
teries; batteries can be used to reduce the cost of the energy by charging at low price and discharging when the price is high, which, in turn, is reflected in savings in the cash flow. This financial metric is widely accepted due to its ease of interpretation: a positive value presumes the acceptance of the project since the benefits outweigh the initial investments in a time horizon. Conversely, a negative value indicates the rejection of the project since the benefits do not cover the initial investments in a time horizon. When two or more projects are evaluated, they can be ranked from the largest to the smallest NPV [29].
Equation (14) calculates the NPV for an annual cash flow and an investment , considering a discount rate and a planning horizon [29].
The fast interpretation and ease assessments of NPV contrast with some of its disadvantages. The first one is related to the dependence on the discount rate, which must be carefully defined before economic assessment [32]; generally, it is calculated as the weighted average cost of capital or with another methodology. To exemplify this, consider two battery types with a lifespan of 10 years to be installed in a node: one "conventional" type battery and one with more advanced high technology. The installation and annual maintenance costs of the regular battery are $10,000 and $3000 per year. The high technology battery has costs equal to $18,000 and $1800 per year [33]. To choose a battery type is to determine whether the benefits of maintenance costs ($3000 and $1800) justify the difference between the initial investment difference ($8000). The cash flow of Figure 1 summarizes this information, while Table 1 shows the NPV of selecting the high technology battery over the conventional one for different discount rates λ, from 0% to 20%. It can be observed that lower discount rates favor the adoption of the high technology alternative, in accordance with [34].    The second disadvantage of the NPV is that it does not provide information about the initial effort. One project could have a higher NPV in comparison to a second alternative. However, the investment of the first project could be so high that the ratio NPV/investment may be lower than the one related to the second project; in this case, the best economic choice is the second option, as shown in [10]. For instance, consider the case of two investments, A and B, related to two different battery technologies. Table 2 summarizes the economic evaluation. If the decision were made considering only the NPV of both investments, A would be selected. On the other hand, the ratio between the NPV and the initial investment indicates that option B is worthy and further analyses are required.

Internal Rate of Return
The IRR is the rate λ IRR for which the NPV of a project is zero [29]. Conceptually, this rate indicates the actual return on any project; if the IRR is greater than the minimum attractive rate of return, the project is economically viable; otherwise, the project should be discarded. When two or more projects are compared, not only the IRR information must be taken into consideration but also the value of their initial investment within an incremental analysis [29]. Following the IRR definition, (15) calculates the rate λ IRR using similar parameters and variables involved in the NPV computation, except for the discount rate, which is the very IRR that is being calculated.
The calculation of the IRR for the cash flow in Figure 1 leads to λ IRR equal to 8%; the investment could be convenient if that value is higher than the minimum attractive rate of return. Considering again the options in Table 2, one of the technology options will be favored depending on the stated discount rate for the NPV calculation. Intensive initial investment options are favored by low discount rates, while less investment intensive options are favored by high discount rates under an assessment based on the NPV. Another advantage worth mentioning is that the IRR's interpretation by decision-makers is direct and does not have ambiguities.
The most relevant issue of IRR is related to its calculation, which is usually a hard task because of its nonlinear nature, which may lead to obtaining more than one value and, consequently, to more than one interpretation. Moreover, using IRR as an optimization criterion increases its difficulty when neither investment values nor cash flows are known in advance.

Formulation of the Objective Function with the Integration of Economic Metrics
The NPV assesses the benefit obtained in the EDS operation by the allocation of batteries as a reduction in the annual operating costs. Equations (16)- (20) allow the calculation of the NPV, in which (16) and (17) represent the investment in batteries along with the investment budget, while (18) defines the equivalent cash flow F i . The annual EDS operating cost without batteries is calculated employing (19), whereas (20) determines the annual EDS operating cost with batteries. Following, the second objective function maximizes the IRR using the same investment and cash flow definitions in the set of Equations (16)- (20).
Equation (16) establishes the investment B as the sum of allocation battery cost in the nodes jointly with the inverter battery system cost. The allocation cost is defined as the product of the maximum energy capacity of the battery E b and its cost per kWh (ς); the cost of the inverter σ is proportional to its power capacity P inv . Both costs are subject to the allocation decision in each node, which is represented by the binary variable ρ m . As expressed in (17), the total battery investment must be lower than the budget B.
The second component of the NPV is the cash flow F i , which sets the benefits related to battery allocation, in which the annual operating cost of the EDS without batteries O 0 is defined as the energy supplied costs by the substation plus energy purchases from distributed generators, as expressed in (19). The substation's energy cost is equal to the product of the power supplied by the substation P SE,I m,t,s , the time duration ∆ t , and the cost c SE t,s per kWh, while the cost of energy purchased from DG units is equal to the product of the power supplied by the generators P DG,I m,t,s , the time duration ∆ t , and the cost c DG t,s of kWh. The annual operating cost of the EDS with batteries (O B ) is equivalent to the O 0 definition, as shown in (20). However, the powers provided by the substation P SE m,t,s and delivered by the distributed generators P DG m,t,s are defined under the presence of the batteries and are different from the operating point used in the O 0 calculation. In the former expressions, ∆ t corresponds to the duration of each period t, ξ s is the probability of each stochastic scenario s, and the parameter α corresponds to the number of days in a year. Likewise, maintenance costs in (20) are calculated as a proportional value (γ) of the investment.

Optimization Problems for each Economic Metric
In this section, the two optimization problems related to the economic metrics, NPV and IRR, are defined. The first optimization problem corresponds to the maximization of the NPV, subject to (1)-(13), (16)- (20). This mathematical model is a mixed-integer second-order conic programming problem and can be summarized in (21), which can be solved using off-the-shelf software guaranteeing the convergence to the optimal solution.
The second optimization problem provides a solution for the OBA through an objective function corresponding to maximize the variable λ IRR , subject to (1)-(13), (15)- (20). Variable λ IRR is maximized to identify one solution that would be an interesting alternative for the decision maker. In that way, two different solutions can be generated. The resulting mathematical model (22) corresponds to a mixed-integer nonlinear programming problem, which is difficult to solve because of the high nonlinearity present in (15). Thus, the following section describes an iterative procedure to determine the best solution for the OBA when the optimization process is guided by the IRR metric.

Strategy to Solve the Optimization Problem When the IRR Metric Is Used
The maximization of the IRR is not suitable to be directly solved using mixed-integer convex commercial solvers. Thus, the following iterative procedure, illustrated in Figure 2, is proposed here:

1.
Define a minimum discount rate (λ min ) and set it as the discount rate (λ).

2.
Solve the problem (22) and calculate λ IRR for the solution obtained.

3.
If there is no more allocation (i.e., ρ m = 0 for all the nodes), increase the discount rate (λ = λ + ∆) and go back to step 2; otherwise, go to step 4.

4.
Choose the optimal value for the IRR solution (λ IRR * ) as the one with the maximum IRR value (λ IRR ).
2, is proposed here: 1. Define a minimum discount rate ( ) and set it as the discount rate ( ). 2. Solve the problem (22) and calculate for the solution obtained. 3. If there is no more allocation (i.e., = 0 for all the nodes), increase the discount rate ( = + ∆) and go back to step 2; otherwise, go to step 4. 4. Choose the optimal value for the IRR solution ( * ) as the one with the maximum IRR value ( ).

Tests and Results
The optimal solutions for the optimization problems (21) and (22) are presented in this section to illustrate the economics and technical benefits when NPV and IRR metrics lead separately the decision process for the OBA problem. To make both economic and technical comparisons, a base case of EDS operation is calculated without the allocation of batteries. The proposed mathematical models have been applied in an adapted version of the IEEE 33-node test system [35] that has a nominal voltage of 12.66 kV and includes one substation, 32 load nodes, and 3 PV units in nodes 9, 16, and 30, as shown in Figure 3. Each PV unit has a generating capacity of 990 kW, which corresponds to a renewable energy penetration of 80%.

Tests and Results
The optimal solutions for the optimization problems (21) and (22) are presented in this section to illustrate the economics and technical benefits when NPV and IRR metrics lead separately the decision process for the OBA problem. To make both economic and technical comparisons, a base case of EDS operation is calculated without the allocation of batteries. The proposed mathematical models have been applied in an adapted version of the IEEE 33-node test system [35] that has a nominal voltage of 12.66 kV and includes one substation, 32 load nodes, and 3 PV units in nodes 9, 16, and 30, as shown in Figure 3. Each PV unit has a generating capacity of 990 kW, which corresponds to a renewable energy penetration of 80%.  The price of the energy purchased of PV generation is considered 0.07 $/kWh. Additionally, Figure 4 the stochastic scenarios related to solar and load power as well as the energy price at the substation; all the information was taken from [36], whereby four scenarios are assessed to represent different conditions of solar irradiance, from a clear day (scenario I) to a cloudy day (scenario IV), thus resembling variations of PV generation. Figure 4b shows the daily variation of the demands for each of the four scenarios. Note that scenario I (the highest PV generation) has the lowest load, which would lead to higher voltage rise at noon. On the other hand, scenario IV (the lowest PV generation) has a peak load at 18 h (higher than nominal), resulting in a higher voltage drop. That combination of scenarios allows the evaluation of those opposite operation states within the optimization problem. The price of the energy purchased of PV generation is considered 0.07 $/kWh. Additionally, Figure 4 the stochastic scenarios related to solar and load power as well as the energy price at the substation; all the information was taken from [36], whereby four scenarios are assessed to represent different conditions of solar irradiance, from a clear day (scenario I) to a cloudy day (scenario IV), thus resembling variations of PV generation. Figure 4b shows the daily variation of the demands for each of the four scenarios. Note that scenario I (the highest PV generation) has the lowest load, which would lead to higher voltage rise at noon. On the other hand, scenario IV (the lowest PV generation) has a peak load at 18 h (higher than nominal), resulting in a higher voltage drop. That combination of scenarios allows the evaluation of those opposite operation states within the optimization problem.
(scenario I) to a cloudy day (scenario IV), thus resembling variations of PV generation. Figure 4b shows the daily variation of the demands for each of the four scenarios. Note that scenario I (the highest PV generation) has the lowest load, which would lead to higher voltage rise at noon. On the other hand, scenario IV (the lowest PV generation) has a peak load at 18 h (higher than nominal), resulting in a higher voltage drop. That combination of scenarios allows the evaluation of those opposite operation states within the optimization problem.  For allocation purposes, it is considered a lithium nickel cobalt aluminum oxide (Liion NCA) battery, with a self-discharge rate of = 0.2% per day, being able to discharge 90% of its stored energy. Moreover, this type of battery has injection and absorption efficiencies ( ) equal to 0.96 and a lifespan of 18 years. Besides, each module has a capacity of 400 kWh along with an inverter power of 100 kW. The investment cost in one batterystorage system is $63,100, its maintenance cost is equal to 1.5% of the investment, and the budget is $500,000. The above information takes into account the projections for 2030 estimated by [37]. The mathematical models were implemented in the AMPL mathematical language [38] and solved using CPLEX 12.9 [39] in a computer with an AMD Ryzen 7 3700X processor. All data used in this work are available in the online repository [40]. Although the computational effort is not crucial for an allocation problem, it was verified that the solution of each optimization problem can be achieved under one minute, which indicates the relatively low complexity of the proposed method.
For the optimization of the NPV, a discount rate of 4% was considered (i.e., minimum attractive rate of return). The NPV decision determines the allocation of 7 batteries in the network (at nodes 13, 15, 24, 26, 28, 30, and 32), as shown in Figure 5. On the other hand, the solution found with the optimization of the IRR indicates just one battery allocation at node 32, as shown in Figure 6. For allocation purposes, it is considered a lithium nickel cobalt aluminum oxide (Li-ion NCA) battery, with a self-discharge rate of β = 0.2% per day, being able to discharge 90% of its stored energy. Moreover, this type of battery has injection and absorption efficiencies (η b ) equal to 0.96 and a lifespan of 18 years. Besides, each module has a capacity of 400 kWh along with an inverter power of 100 kW. The investment cost in one batterystorage system is $63,100, its maintenance cost is equal to 1.5% of the investment, and the budget is $500,000. The above information takes into account the projections for 2030 estimated by [37]. The mathematical models were implemented in the AMPL mathematical language [38] and solved using CPLEX 12.9 [39] in a computer with an AMD Ryzen 7 3700X processor. All data used in this work are available in the online repository [40]. Although the computational effort is not crucial for an allocation problem, it was verified that the solution of each optimization problem can be achieved under one minute, which indicates the relatively low complexity of the proposed method.
For the optimization of the NPV, a discount rate of 4% was considered (i.e., minimum attractive rate of return). The NPV decision determines the allocation of 7 batteries in the network (at nodes 13, 15, 24, 26, 28, 30, and 32), as shown in Figure 5. On the other hand, the solution found with the optimization of the IRR indicates just one battery allocation at node 32, as shown in Figure 6. that the solution of each optimization problem can be achieved under one minute, which indicates the relatively low complexity of the proposed method.
For the optimization of the NPV, a discount rate of 4% was considered (i.e., minimum attractive rate of return). The NPV decision determines the allocation of 7 batteries in the network (at nodes 13, 15, 24, 26, 28, 30, and 32), as shown in Figure 5. On the other hand, the solution found with the optimization of the IRR indicates just one battery allocation at node 32, as shown in Figure 6.  Although the computational effort is not crucial for an allocation problem, it was verified that the solution of each optimization problem can be achieved under one minute, which indicates the relatively low complexity of the proposed method.
For the optimization of the NPV, a discount rate of 4% was considered (i.e., minimum attractive rate of return). The NPV decision determines the allocation of 7 batteries in the network (at nodes 13, 15, 24, 26, 28, 30, and 32), as shown in Figure 5. On the other hand, the solution found with the optimization of the IRR indicates just one battery allocation at node 32, as shown in Figure 6.

Technical Analysis
This section presents the technical analysis based on the benefits that batteries bring to the EDS as loss reduction, voltage improvement, peak reduction, and PV hosting capacity. The above benefices are measured for the NPV and IRR solutions compared to the base case without batteries.
The energy losses and the minimum voltages of each solution are compared with respect to the base case, as shown in Table 3. It is observed that both solutions reduce the energy losses, whereby the NPV solution has a better improvement compared to the IRR solution. The results for the minimum voltage show that the NPV solution is slightly better than the IRR solution and the base case.  Figure 7a illustrates the power provided by the substation for each solution as well as the base case in stochastic scenario 1, which corresponds to the worst demand scenario. It is observed a peak reduction in the afternoon hours (around 18 h). As expected, the solution with the highest number of batteries, provided by the NPV optimization, generates a greater peak reduction of 31%, while the IRR solution generates a reduction equal to 4.54%. It is important to note that when the battery absorbs power no new peaks are produced for any of the NPV and IRR solutions.
as the base case in stochastic scenario 1, which corresponds to the worst demand scenario. It is observed a peak reduction in the afternoon hours (around 18 h). As expected, the solution with the highest number of batteries, provided by the NPV optimization, generates a greater peak reduction of 31%, while the IRR solution generates a reduction equal to 4.54%. It is important to note that when the battery absorbs power no new peaks are produced for any of the NPV and IRR solutions.   Figure 7b shows the voltage profile throughout the day for the base, the NPV, and the IRR cases, for the stochastic scenario 1 at node 32. This particular node was chosen since both the NPV and the IRR solutions allocate a battery there. This figure shows an improvement in the voltage at peak hours: 1.79% for the NPV solution and 0.53% for the IRR solution. Furthermore, during the battery absorption period, which occurs between hours 1 and 6, the voltage level drops, without exceeding the limits of the EDS.
The last technical analysis is related to the improvement in the hosting capacity of PV generation due to the OBA. Here, the PV hosting capacity is assessed as the maximum PV power that could be installed in the system without causing operational issues. Table 4 shows the PV hosting capacity for each solution, whereby the IRR solution could uphold an increase of 6.3% of PV penetration, and the NPV solution, even with more batteries, could uphold an increase of 18.8%, just 11.8% more compared to the IRR solution.

Economic Analysis
The economic analyses of the solutions obtained by the maximization of the NPV and IRR are shown here, along with a discussion about how those solutions can be compared. The NPV of this solution is $90,300 and corresponds to an investment of $441,700.
The proposed iterative search presented in Figure 2 was employed to find the IRR solution considering an initial discount rate (λ min ) of 1% and an increasing step (∆) of 0.02%. As result, the IRR solution (7.02%) was found with a discount rate of 7%. This solution presents the lowest investment with just one battery allocation (at node 32, as shown in Figure 6) and an investment of $63,100. The solutions found within the search process for the maximum IRR are illustrated in Figure 8. The NPV of this solution is $90,300 and corresponds to an investment of $441,700.
The proposed iterative search presented in Figure 2 was employed to find the IRR solution considering an initial discount rate ( ) of 1% and an increasing step (∆) of 0.02%. As result, the IRR solution (7.02%) was found with a discount rate of 7%. This solution presents the lowest investment with just one battery allocation (at node 32, as shown in Figure 6) and an investment of $63,100. The solutions found within the search process for the maximum IRR are illustrated in Figure 8. When both NPV and TIR solutions are compared, it is noticeable that the IRR solution has an investment equal to 14% of the NPV investment. Moreover, comparing the operation cost of both solutions, the IRR's operation cost is 0.45% lower than the operation cost of the base case, while the operation cost of the NPV solution is 3.06% lower. Albeit the difference in allocation of both solutions is large, this is not reflected in a significant decrease in operating costs. Table 5 summarizes the information about both economic metrics as well as the information about the base case. Table 5. Economic information of the alternative solutions found for the optimal battery allocation (OBA) problem. When both NPV and TIR solutions are compared, it is noticeable that the IRR solution has an investment equal to 14% of the NPV investment. Moreover, comparing the operation cost of both solutions, the IRR's operation cost is 0.45% lower than the operation cost of the base case, while the operation cost of the NPV solution is 3.06% lower. Albeit the difference in allocation of both solutions is large, this is not reflected in a significant decrease in operating costs. Table 5 summarizes the information about both economic metrics as well as the information about the base case. The results show that the IRR solution is averse to investing in more than one battery. Defining the allocation based on the IRR metric leads to a low number of batteries, given that the system already operates and can be profitable without major investments. On the other hand, the NPV solution shows a commitment to allocate more batteries; although a higher investment is required, more attractive operating costs are achieved, according to the defined discount rate.
Having the OBA alternatives identified using the NPV and IRR is helpful for the decision planner. After those alternatives are defined, the decision planner can apply an incremental cash flow analysis to determine which of the two alternatives is the most attractive [29]. Within that analysis, the minimum attractive rate of return should be also considered to verify if the adopted project has indeed economic benefit. The application of an incremental cash flow analysis (cash flow of the NPV solution minus cash flow of the IRR solution) leads to an incremental internal rate of return of 6.42%, which indicates that the NPV solution is the most attractive alternative if the budget is $500,000. Nevertheless, the solution found using the IRR is still worthy to be analyzed within the EDS planning since with just one battery and a fraction of the investment, the system's operation gets a significant improvement.

Conclusions
To take advantage of the technical and economic benefits of batteries in the electrical distribution system, their suitable allocation is crucial. This task is usually guided using different economic metrics such as net present value (NPV) and internal rate of return (IRR). In this paper, both metrics were used to guide the optimization process modeled by a two-stage stochastic programming formulation, where the economic and technical benefits of optimal battery allocation (OBA) in an electrical distribution system were evaluated considering the integration of distributed photovoltaic generation. The proposed method generates two different solutions for the OBA problem that can be helpful for the EDS planner.
The results achieved for the IEEE 33-node test system indicate that OBA leads to improvement of voltage profile, peak reduction, increased hosting capacity of photovoltaic generation, and cost reduction when compared to the operation without batteries. However, the use of each metric leads to different investment decisions: For an existing distribution network, it is less economically attractive to invest in more than one battery if evaluated via IRR, while an assessment using the NPV may be more prone to allocation when the discount rate is low.
The technical results show that battery allocation is beneficial to the distribution system, although this improvement is not proportional to the number of allocated batteries; as shown in the results for the analyzed technical indicators, allocation of seven batteries does not produce gains seven times higher. It was verified that, for the IEEE 33-node test system, the optimal allocation considering the NPV indicates a higher number of batteries (7), which contrasts with just one battery defined by the optimization of the IRR; however, this high difference is not reflected in a large improvement in technical performance for all indicators (e.g., voltage, energy losses, photovoltaic hosting capacity, and cost); this difference only is evident in the reduction of peak load.
Future work could include a multi-objective proposal considering economic and technical optimization to analyze the trade-off between both aspects of battery allocation in the distribution system. Energy stored in a battery at node m, in period t, at scenario s. Square of the voltage magnitude at node m, in period t, at scenario s.