I had to wonder about the point of this - railways are set up to use electricity, it would seem the simplest thing is just to go all in on that.
I do wonder about the railways utilising the large surface areas they have to generate electricity. Banging solar panels on sheds and stations is a no-brainer but, with better solar panel technology (printable, flexible, more robust, etc) could you not lay miles of them alongside (or even between?) the tracks? They could end up generating all the electricity they needed.