It should take around three days. see http://www.justlanded.com/english/spain/tools/articles/travel_leisure/rail_network_train_standards_and_tickets
There are a number of possible routes. The one...
around 25km, but it is very well connected by car, via the first ring road (M30) northbound, taking the exit to A2 highway and then going straight ahead for 10km. A taxi trip is around 25€ off-peak...
I found a few for sale poking around on the web.
http://www.jlconsulting.ca/locomotives.php
or....
http://www.emdiesels.com/emdweb/emd_index.jsp
You can buy or lease.
Madrid-Lisbon by train.
There is a daily night train that joins Madrid and Lisbon.
It takes about 10-11 hours to get from one city to the other. The train leaves at around 10pm and arrives at around...