It is will be difficult to get from Santander to the Algarve by train.
According to Renfe.es, the Spanish Train operator, there is only one through route:
This will involve travelling Santander to Madrid and then night train to Lisbon. Thereafter, a Portuguese Railways train ( http://www.cp.pt ) to the Algarve
There is currently a train departure from Santander at 14:05 arriving in Madrid at 18:33, There may be a station change in Madrid but this not clear from the renfe website. The night train to Lisbon Gare Orient departing at 22:25 and arriving at 07:30 the next day. This will connect with the 08:40 departure for the Algarve.
Alternatively, there is a daily regional service leaving Santander for Valladolid at 16:55 arrivng 21:00. Sunday to Friday there is a service departing 19:20 arriving Valladolid at 22:35. The Paris to Lisbon Express passes through Valladolid and departs at 03:20 arriving Lisbon Gare Oriente at 10:54. There is a departure for the Algarve at 13:20 from Lisbon Gare Oriente.
Please note that this is not shown as a through route on any timetables and I suspect one would have difficulty buying through tickets.
If you visit my blog:
http://barlaventostravelblog.blogspot.com/
»» Scroll down on the right hand side until you come to the panel entitled "Algarve & Portugal - Travel Transport Links"
You will find links to certain Portuguese Railways Timetables.