Calculation of the free energy of a solution