Development and application of a QM/MM method for free energy calculations