Thermodynamics of urban population flows