A Lagrangian approach to classical thermodynamics. (16th March 2017)