Well, the maximum amount of solar energy we can get, with a collector exactly perpendicular to the rays of the sun, is about 1.35 kilowatts per square meter. So, you'd need 5 million / 1350 = 3700 square meters of solar collecting area to power a steam locomotive with solar energy, in the best case scenario! That's just not practical for a train which is generating power on the go.
But note that pretty much all the power used during the industrial revolution, whether it was fossil fuels like coal, gas, and oil, living matter like wood, hydroelectric power (like a dam or water wheel), or wind power, is ALL solar power anyway! The sun provided the energy for the ancient plants which fed the ancient animals, which became fossil fuels; the sun provided the energy for the trees that were cut down for wood; the sun provided the energy to the atmosphere that evaporated water and carried to the top of a mountain to run down and power a water wheel; the sun provided the energy that heated the atmosphere and created wind!
I hope that helps!