I study public transportation in college and know that many railroads in the US used to be electrified, but no longer are. I also have older family members that used to be employed by the Chicago, Milwaukee, St. Paul and Pacific Railroad and they recall a time that they took electrified commuter trains to and from Chicago, but electric trains don't run on that segment of track anymore. I was curious about what incentives drove this shift to diesel away from electric when electrified trains don't incur fuel costs.
Based on US diesel and electricity prices c. 2010, the fuel/electricity cost using diesel is about 3-4 times that of electricity. In addition, the maintenance cost of electric locomotives is about 1/2 that of diesel locomotives, and the cost of lubricants is also about 1/2. These costs are all approximately proportional to the distance travelled, so the per km cost of operating electric locomotives is much less.
However, it is common to see diesel locomotives hauling freight on electrified lines. Freight haulage is typically long-distance, and if the lines were electrified for commuter services, the electrification only covered a relatively short distance of track. For the freight trains to go beyond the electrified section, diesel locomotives are needed.
The alternative is to extend the electrification to cover the entire freight route. However, the initial cost of electrification is high, approximately US$1.7 million per km, to cover the cost of substations, overhead lines, etc. Maintenance costs are relatively low, about $6,000 per km per year. Assuming a lifetime of 75 years, the lifetime maintenance cost is about 1/4 of the initial installation cost. That is, 80% of the cost of electrification is paid-up front.
The cost of electrification is important for two reasons. First, if the traffic density on the track is too low, the saving on operating cost per km per locomotive is not enough to cover the cost of electrification over the lifetime of the equipment. A common rule of thumb is that 40 trains are required per day for electrification to save money in the long term. If traffic is low, it doesn't pay to electrify - freight companies will continue using diesel locomotives.
Second, even if the traffic density is high enough for electrification to save money in the long term, this up-front cost is a formidable barrier for private rail companies. For example, Union Pacific has an annual revenue of about $20 billion, and a net income of about $6 billion. They operate 52,000km of routes. If they invested their entire net income in electrification, electrification of their network would take 15 years. The Chicago, Milwaukee, St. Paul and Pacific Railroad, if they had been able to operate with similarly profitability as Union Pacific (as opposed to losing money - they were losing $100 million per year in the late 1970s, $340 million in today's dollars), their net income (based on 1979 revenue) would be worth about $385 million per year, in today's dollars. This would cover the electrification of 225km of line per year, which would have been a 71-year electrification project (for the length of track before they got rid of most of their track c. 1980 in an attempt to become profitable). As it was, the Chicago, Milwaukee, St. Paul and Pacific Railroad didn't have a high density of traffic, nor enough profit, to do such things. Thus, any freight that went past electrified sections of their track was hauled by diesel.
Reference:
Costs used in the above analysis are from: