Learn

Free energy and enhanced sampling

The free energy F(x) along a coordinate x tells you which states are stable and how high the barriers between them are. Plain MD gets it from how often each x is visited, but barriers of more than a few kT are crossed so rarely that the histogram never fills. Enhanced sampling methods solve this problem. All the examples on this page use the same double well.

    Free energy from a histogram

    If the simulation samples the Boltzmann distribution, the probability of x gives the free energy directly.

    F(x) = −kT ln P(x) + const

    The catch is ergodicity, because the walker has to cross the barrier many times. The crossing rate falls roughly as exp(−ΔF/kT).

    Try: lower kT. The barrier region stays empty, and the estimate falls apart.

    Umbrella sampling and WHAM

    In umbrella sampling, you run several simulations, and each one is held near a different point x by a harmonic spring (an umbrella). Each window samples its small region well, including the top of the barrier.

    WHAM (weighted histogram analysis) then removes the effect of the springs and stitches the windows into one free energy curve. It solves two equations self-consistently, for P(x) and for the free energy fi of each window.

    Try: too few windows or too stiff springs leave gaps between the histograms, and the curve breaks at these gaps.

    Metadynamics

    Metadynamics builds a bias as it goes. Every so often it drops a small Gaussian hill at the current position. The hills pile up in the well where the system sits, until it spills over the barrier into the next well. Once the landscape is flat, the accumulated bias is the negative of the free energy.

    Vbias(x, t) = Σ H exp(−(x − xk)2 / 2w2)
    F(x) ≈ −Vbias(x) + const

    Well-tempered metadynamics shrinks the hills over time, so that the estimate converges smoothly.

    Try: big hills fill the wells fast but give a rough estimate, while small hills are slow and smooth.

    Metadynamics on a 2D landscape

    The idea is easiest to see in two collective variables. The walker starts trapped in the deepest basin. Each hill makes the place it has been a little less attractive, so it is pushed to explore. The basin fills like a bowl being filled with sand. Then, the walker spills into the next basin, and that basin fills too.

    In a real run, the collective variables (CVs) are quantities such as a distance, an angle, or a coordination number, chosen so that they separate the states that you care about. Picking good CVs is the hard part. If a slow motion is missing from the CVs, metadynamics will not speed it up.

    Try: compare plain and well-tempered hills. Plain hills keep piling up and overfill the landscape, while well-tempered hills get smaller where the bias is already high, so the shading settles down. Click to restart somewhere else.

    Replica exchange

    In replica exchange, you run copies of the system at several temperatures. The hot copies cross barriers easily. Every so often, neighboring copies try to swap configurations, and a swap is accepted with a Metropolis rule that keeps every temperature sampling correctly.

    P(swap) = min(1, exp[(βi − βj)(Ui − Uj)])

    The cold copy then gets new configurations from the hot ones, without needing to know the reaction coordinate. The temperatures must be close enough for the swaps to be accepted.

    Try: switch the swaps off. The cold replica then stays stuck in its starting well.

    Steered MD and the Jarzynski equality

    Steered MD pulls the system along x with a moving spring and measures the work. Pulling fast wastes energy as heat, so the average work is larger than ΔF. However, Jarzynski showed that an exponential average of the work gives ΔF exactly, even for fast pulling.

    ΔF = −kT ln ⟨ exp(−W/kT) ⟩

    The exponential average is dominated by rare pulls with low work, so in practice, you need many pulls, or slow ones.

    Try: pull fast, and compare the mean work with the Jarzynski estimate. The true ΔF here is 0.