**5. Conclusions**

This paper proposes a methodology to determine the optimal siting and sizing of energy storage systems along railway lines: the results found show how the proposed approach maximizes the economic return on investment required to install an ESS along a railway line. Using the PSO it is possible to obtain a faster solution than other meta-heuristic algorithms. Using the NPV and the PBP, used by the analysis of investments in financial mathematics, it is possible to directly compare two alternative investments with the same risk profile, thus obtaining a more realistic assessment of the feasibility and convenience of the installation.

The proposed method can be used for any type of d.c. electrified railway line, it can model any existing rolling stock and allows to simulate multiple working timetables and the simultaneous presence of multiple ESSs. In this way it is possible to find the optimal equipment for countless ESSs' installations located along a railway line through a model that is also easy to use.

**Author Contributions:** Conceptualization, R.L., L.P. and A.R.; methodology, N.M.; software, N.M.; validation, L.P.; formal analysis, N.M.; investigation, N.M.; data curation, N.M. and A.R.; writing—original draft preparation, N.M.; writing—review and editing, R.L. and A.R.; visualization, N.M.; supervision, R.L. and A.R. All authors have read and agreed to the published version of the manuscript.

**Funding:** This research received no external funding.

**Conflicts of Interest:** The authors declare no conflict of interest.
