A method of molecular simulation of free energy