Thermodynamics: A Dynamical Systems Approach