Thermodynamics of clouds