*2.3. Economic Model*

The methodology developed uses the net present value (NPV) of a storage system as a target function. The net present value (NPV) of an investment at time n = 0 (today) is equal to the discounted cash flow (Cn) from year n = 1 to n = N (end of useful life of the accumulator) minus the amount of the investment (I0) at the start of the investment (n = 0) and the replacement costs in the useful life period (Crep).The NPV is mathematically expressed as:

$$\text{NPV} = -\text{I}\_0 + \sum\_{n=1}^{N} \frac{\text{C}\_n}{\left(1 + \text{ir}\right)^n} - \text{C}\_{\text{rep}} \tag{7}$$

The cash flow Cn of year "n" is equal to all the income In minus the operating and maintenance expenses En of that year:

$$\mathbf{C}\_{\mathbf{n}} = \mathbf{I}\_{\mathbf{n}} - \mathbf{E}\_{\mathbf{n}} \tag{8}$$

In and En are expressed by the following equations:

$$\mathbf{I}\_{\mathbf{n}} = (\mathbf{Energy}\_{\text{noacc\\_n}} - \mathbf{Energy}\_{\text{withacc\\_n}}) \cdot \mathbf{C}\_{\text{ch}} \tag{9}$$

$$\text{Energy}\_{\text{noacc\\_}n} = \text{Energy}\_{\text{noacc\\_day}} \cdot \text{N}\_{\text{d}} \tag{10}$$

$$\text{Energy}\_{\text{noacc\\_day}} = \left(\text{Energy}\_{\text{noacc\\_peak}} \cdot \text{N}\_{\text{pp}}\right) + \left(\text{Energy}\_{\text{noacc\\_soft}} \cdot \text{N}\_{\text{sp}}\right) \tag{11}$$

Energwithacc\_n = Energwithacc\_day·Nd (12)

$$\text{Energy}\_{\text{without\\_day}} = \left(\text{Energy}\_{\text{without\\_peak}} \cdot \text{N}\_{\text{pp}}\right) + \left(\text{Energy}\_{\text{without\\_soft}} \cdot \text{N}\_{\text{sp}}\right) \tag{13}$$

$$\mathbf{E}\_{\rm n} = \mathbf{C}\_{\rm f} \cdot \mathbf{P}\_{\rm acc} + \mathbf{C}\_{\rm v} \cdot \text{Energy}\_{\rm day}^{\rm acc} \cdot \mathbf{N}\_{\rm d} + \frac{\text{Energy}\_{\rm day}^{\rm acc}}{n\_{\rm CH}} \mathbf{C}\_{\rm CH} \tag{14}$$

The first term represents the fixed costs of the ESS according to the installed power; the second term the variable costs according to the energy supplied by the ESS in a year. The third term represents the recharge costs of the ESS, a function of the energy delivered in a working day, the cost coe fficient of electricity and the average charging e fficiency of the ESS:

$$\text{Energy}^{\text{acc}}\_{\text{day}} = (\text{Energy}^{\text{acc}}\_{\text{peak}} \cdot \text{N}\_{\text{PP}}) + (\text{Energy}^{\text{acc}}\_{\text{soft}} \cdot \text{N}\_{\text{SP}}) \tag{15}$$

Energaccpeak and Energaccsoft, as well as Energnoacc\_peak, Energnoacc\_soft, Energwithacc\_peak and Energwithacc\_soft, are taken from the railway simulator when simulating a railway line with an ESS, of which values of position, nominal power and nominal energy are inserted.

When the NPV found by the algorithm is a positive solution, the payback period (PBP), which allows to calculate the time within the capital invested (I0) in the purchase of a medium-long-cycle production factor is recovered through the net financial flows generated (Cn) is also calculated to obtain a further indicator of the economic convenience of the investment:

$$\text{PBP} = \frac{\text{I}\_0}{\text{C}\_{\text{in}}} \tag{16}$$

I0 is the capital cost of the accumulator and is:

$$\mathbf{I}\_0 = \mathbf{C}\_P \cdot \mathbf{P}\_{\text{acc}} + \mathbf{C}\_E \cdot \text{Energy}\_{\text{acc}} \tag{17}$$

Crep is the future value of replacement cost and is shown by Equation (18) [40]:

$$\mathbb{C}\_{\text{rep}} = \mathbb{C}\_{\text{RP}}[(1+\text{ir})^{-\text{L}\_{\text{R}}} + (1+\text{ir})^{-2\text{L}\_{\text{R}}} + \dots + (1+\text{ir})^{-\text{num}\cdot\text{L}\_{\text{R}}}] \tag{18}$$

where "num" is the number of times the battery must be replaced during the life of the ESS.

The software is able to simulate, in a standard working day, the charge and discharge cycles followed by the ESS. It is possible to obtain the duration (nbatt) of the batteries; once the useful life (N) of the ESS. Using Equation (19) it is possible calculate how many times it is necessary to replace the batteries:

$$\text{num} = \frac{\text{N}}{\text{rg}\_{\text{batt}}} \tag{19}$$

*2.4. Optimization*
