Statistical Mechanics is the basis of molecular level calculations of properties and averages. Nowadays free energy calculations are fairly "turn-the-crank", which is not necessarily a good thing. It is easy to perform a free energy calculation and get a number.
In the molecular dynamics package GROMACS, for instance, alchemical free energy calculations are only valid if done in the NVT ensemble. This is because GROMACS samples potential energies, thus one can calculate (or press a button on pymbar or another piece of software)
\begin{equation} \Delta A = -kT \ln \langle \exp(-\beta \Delta \mathcal{U}) \rangle \end{equation}
Where $\Delta A$ is the difference in the Helmholtz free energy between two states, $\beta = \frac{1}{kT}$, $\mathcal{U}$ is the difference in sampled potential energy between two states, and $\langle \rangle$ is an ensemble average.
If you run an NPT simulation you must instead sample
\begin{equation} \Delta G = -kT \ln \frac{\langle V \exp(-\beta \Delta \mathcal{U}) \rangle}{\langle V \rangle} \end{equation}
While it is tempting to say that the volumes cancel so you only need the ensemble average of the NVT Boltzmann factor, this is not at all correct. GROMACS is aware that it is not correctly sampling the NPT and has tucked away a note in the user manual to the effect that for water at 298.15 K the error is small i.e., less than a kilojoule.
- a kilojoule can make a large difference to an equilibrium constant
- Chemistry does not happen at only 298.15! if you increase the temperature or density of the solvent (not all of us do water) the error quickly gets out of hand - this is particularly true for ionic liquids.
Question:
Is this assumption (possibly error in other codes) present in other codes? Are there any MD codes that properly sample the NPT ensemble for free energy?
Note:
While Godzilla has shown entirely correctly how one should sample the free energy in the NPT, neither his equation, or mine, which is equivalent for $\Delta G$, are implemented in GROMACS, and possibly others. I am looking for if any MD programs do implement the proper free energy sampling. They all properly do NPT sampling (I assume), but sampling the free energy is a step above and beyond.