I did this in September 2021. I bought my train ticket for departure from Atocha 5 hours after scheduled arrival of my plane to Barajas. This gave me some slack in case my flight was delayed. However, it wasn't delayed and I had 2 hours to kill prior to train departure. That gave me time to walk...