Free-Energy Perturbation: A Pedagogical Introduction

by Corin Wagen · Mar 4, 2026

This interactive tutorial illustrates the core concepts behind free-energy perturbation (FEP) using simple 1D toy systems where we can compare numerical estimates to exact analytical results. While there's a lot that's not included in this tutorial, we hope that this helps give scientists who aren't already stat-mech experts a sense for what's going on "under the hood" in FEP.

What Problem Are We Solving?

We want to compute the free-energy difference ΔA\Delta A between two thermodynamic states (0 and 1) with potential energy functions U0(x)U_0(x) and U1(x)U_1(x). In real life, these two states might be two ligands bound to a protein or two ionization states of a molecule.

The free energy AA is related to the partition function ZZ:

A=kBTlnZA = -k_B T \ln Z

where Z=eβU(x)dxZ = \int e^{-\beta U(x)} dx and β=1/kBT\beta = 1/k_B T. (TT is the temperature and kBk_B is Boltzmann's constant.)

The challenge is that we can't easily compute ZZ directly in complex systems. Instead, we can sample configurations from a Boltzmann distribution. FEP provides a way for us to convert these samples into an estimate of ΔA\Delta A.

Let's make this concrete. We'll use harmonic oscillators for this tutorial because they have analytical solutions; the potential energy is determined by the spring constant kk and the equilibrium position x0x_0:

U(x)=12k(xx0)2U(x) = \frac{1}{2} k (x - x_0)^2

The partition function is Z=2π/βkZ = \sqrt{2\pi / \beta k}, giving:

A=12kBTln(βk2π)A = \frac{1}{2} k_B T \ln\left(\frac{\beta k}{2\pi}\right)

For two oscillators with force constants k0k_0 and k1k_1 (same center):

ΔAexact=12kBTln(k1k0)\Delta A_{exact} = \frac{1}{2} k_B T \ln\left(\frac{k_1}{k_0}\right)

Use the sliders below to explore how the potentials and Boltzmann distributions change with different force constants:

Loading chart ...

The Zwanzig Equation

The Zwanzig equation (1954) gives us an exact expression for ΔA\Delta A that doesn't depend on the partition function:

ΔA=A1A0=kBTlneβ(U1U0)0\Delta A = A_1 - A_0 = -k_B T \ln \left\langle e^{-\beta (U_1 - U_0)} \right\rangle_0

Here, 0\langle \cdot \rangle_0 denotes an ensemble average over configurations sampled from state 0.

In practice, we:

  1. Sample configurations {xi}\{x_i\} from the Boltzmann distribution of state 0
  2. Compute ΔUi=U1(xi)U0(xi)\Delta U_i = U_1(x_i) - U_0(x_i) for each configuration
  3. Estimate: ΔAkBTln(1NieβΔUi)\Delta A \approx -k_B T \ln \left( \frac{1}{N} \sum_i e^{-\beta \Delta U_i} \right)

The accuracy of the output result depends on the accuracy of the ensemble average. Try different sample sizes and resample to see how the estimate varies:

Loading chart ...

The Overlap Problem

This simple approach works well when the two states have good phase-space overlap. When the states are very different, though, sampling becomes much harder. Try increasing k1k_1 below and see how the accuracy of the ΔA\Delta A estimate changes for different sample numbers:

Loading chart ...

When the states are too different, most samples from state 0 have very high energies in state 1, leading to Boltzmann factors near zero. The average is then dominated by a few rare samples, causing high variance and unreliable estimates.

Fortunately, there's a solution. Instead of jumping directly from state 0 to state 1, we introduce intermediate states parameterized by λ[0,1]\lambda \in [0, 1]:

Uλ(x)=(1λ)U0(x)+λU1(x)U_\lambda(x) = (1-\lambda) U_0(x) + \lambda U_1(x)

For our harmonic oscillators:

Uλ(x)=12kλx2wherekλ=(1λ)k0+λk1U_\lambda(x) = \frac{1}{2} k_\lambda x^2 \quad \text{where} \quad k_\lambda = (1-\lambda) k_0 + \lambda k_1

Now we can compute ΔA\Delta A as a sum of small steps:

ΔA=i=0n1ΔAλiλi+1\Delta A = \sum_{i=0}^{n-1} \Delta A_{\lambda_i \to \lambda_{i+1}}

Using intermediate states allows us to compute accurate free-energy estimates even between very different states. Try adding intermediate states below and see how the estimate of ΔA\Delta A changes. (You can click "Resample" to rerun the simulation.)

Loading chart ...

Adding just a few lambda windows dramatically increases the accuracy of the simulation, but there are diminishing marginal returns: once there's sufficient overlap between adjacent states, more windows just adds complexity without increasing accuracy.

Shifted Oscillators

Now let's consider oscillators with different centers.

For harmonic oscillators with the same force constant but different centers, ΔA=0\Delta A = 0 regardless of the shift (the partition function only depends on kk, not x0x_0). But the Zwanzig equation will have trouble due to poor overlap and typically predict non-zero values. Try this yourself by increasing Δx\Delta x on the slider below; as before, adding lambda windows prevents poor overlap and allows us to get the correct prediction.

Loading chart ...

Real-World FEP

These toy systems illustrate some of the key concepts of FEP: small perturbations are easy to model, while larger perturbations often have insufficient phase-space overlap and require large numbers of intermediates to give reliable results. This is why relative binding affinities are so much easier to compute than absolute binding affinities, and also why small chemical perturbations are easier to handle than large chemical perturbations.

In practical FEP simulations used to compute protein–ligand binding affinity, the potential-energy function is much more complicated and it's not possible to directly sample from the Boltzmann distribution. Instead, we have to run molecular dynamics, which introduces an additional set of sampling challenges. State-of-the-art FEP engines like TMD incorporate a large number of "tricks" aimed at increasing sampling as much as possible: grand canonical Monte Carlo water sampling, local resampling, replica exchange with solute temperating, and so on.

If you're interested in trying FEP on real problems, Rowan offers self-service and managed FEP calculations designed to accelerate early-stage drug discovery.

Banner background image

Start running calculations in minutes!

Our platform lets you submit, view, analyze, and share calculations using cutting-edge methods trusted by hundreds of leading scientists. We give every new user 500 free credits to start, plus more every week. Making an account and running your first calculation takes only seconds: start using Rowan today!

Start computing →

What to read next

NMR Spectroscopy

NMR Spectroscopy

the importance of NMR spectroscopy; the languorousness typical of state-of-the-art methods; MagNET, a new model, and its Rowan workflow; testimonials and case studies; new agent benchmarks
Jul 23, 2026 · Corin Wagen and Eli Mann
Testing Rowan-Enabled Agents on DrugDiscoveryBench

Testing Rowan-Enabled Agents on DrugDiscoveryBench

How access to Rowan's computational tools affects scientific agents' performance on early-stage drug-discovery tasks.
Jul 21, 2026 · Eli Mann
Automating Transition-State Search

Automating Transition-State Search

strings and bands; interpolating between states; searching for transitions; confirmation; Vicena integration; recent blogs
Jul 20, 2026 · Jonathon Vandezande and Corin Wagen
Case Studies with Rowan's Hydration-Site Analysis

Case Studies with Rowan's Hydration-Site Analysis

Benchmarking Rowan's hydration-site detection on five documented protein–ligand complexes.
Jul 16, 2026 · Ishaan Ganti and Corin Wagen
What to Do with a Pose

What to Do with a Pose

A few helpful ideas for further analysis or calculations to run.
Jul 15, 2026 · Corin Wagen
Well-Prepared Proteins and How to Use Them

Well-Prepared Proteins and How to Use Them

better protein preparation through ML; Gnina & covalent docking; MM/GBSA refinement; fast MD and more trajectory analysis; synthetic RBFE intermediates; resubmitting FEP graphs without rerunning legs
Jul 9, 2026 · Ari Wagen, Nick Casetti, Zachary Fried, Corin Wagen, Ishaan Ganti, and Elias Mann
Symmetry, X-Ray Diffraction (XRD), Band Structures, and Elastic Tensors

Symmetry, X-Ray Diffraction (XRD), Band Structures, and Elastic Tensors

symmetry and asymmetry; reflections on X-rays; structure, both electronic and crystalline; stressing crystals
Jun 23, 2026 · Jonathon Vandezande and Raphael Stone
openconf and other Open-Source Projects

openconf and other Open-Source Projects

enabling & being enabled by open science; lacunæ in open-source conformer generators; a fast Monte Carlo–powered solution; macrocycles; obtaining topologies from 3D coordinates; fast Butina splitting
Jun 17, 2026 · Corin Wagen, Nick Casetti, Jonathon Vandezande, and Eli Mann
OpenFold3 and Co-Folding with Templates

OpenFold3 and Co-Folding with Templates

a new and different co-folding model; co-folding conditioned with user-specified templates; protein structure overlays; support for the mmCIF file format
Jun 1, 2026 · Ari Wagen
Quantum ESPRESSO & Academic FEP Access

Quantum ESPRESSO & Academic FEP Access

why one should run plane-wave DFT; how to configure and run Quantum ESPRESSO in Rowan; a graphitic case study; FEP now available for academic groups; a fast way to do Butina splitting on big datasets
May 28, 2026 · Jonathon Vandezande and Raphael Stone