I always wondered why electrification of major rail lines is not accompanied by updating and implementation of a more modern and efficient power grip. The two can parallel each other due to right of ways and while you cannot directly power your train from those high voltage lines the substations along the way make for good connection points
I don't know about other countries, but in India, the Rail power grid is completely isolated from the consumer grid.
Also, from a technical standpoint, especially for renewable energy systems, it's best to have isolated pockets of energy generation and consumption rather than a country wide grid.
Due to the intermittent nature of power available from renewable energy sources, it's best to have micro grids and micro storage systems.
In case of railway lines, the load on the network can be calculated to a very good accuracy, unlike the consumer grid. Hypothetically, this can mean that the rail grid can be isolated and be managed at a very high efficiency level.