We show that under rather general assumptions on the form of the entropy function, the energy balance equation for a system in thermodynamic equilibrium is equivalent to a set of nonlinear equations of hydrodynamic type. This set of equations is integrable via the method of the characteristics and it provides the equation of state for the gas. The shock wave catastrophe set identifies the phase transition. A family of explicitly solvable models of non-hydrodynamic type such as the classical plasma and the ideal Bose gas are also discussed.