Calculation of free energy and entropy change