科研 Skill

分子动力学自由能计算

free-energy-md

Covers quantitative free-energy calculations from MD: alchemical FEP/TI/BAR/MBAR, umbrella-sampling PMF. Use when computing thermodynamic free energies from simulation.

发布者 Codar安全审核通过v0.1.0更新于 2026-11-18

SKILL.md

Free-Energy MD

Description

This skill covers quantitative free-energy calculations from molecular dynamics: alchemical methods (free energy perturbation, thermodynamic integration, BAR, MBAR), potential of mean force from umbrella sampling, absolute and relative binding/hydration/solvation free energies, thermodynamic cycles, lambda schedules and soft-core potentials, overlap diagnostics, standard-state corrections, and statistical uncertainty analysis using pymbar and alchemlyb. GROMACS provides the simulation engine with the lambda free-energy infrastructure; PLUMED provides CV-based PMF calculations; pymbar/alchemlyb provide statistically optimal analysis. Invoke this skill when a quantitative ΔG, ΔΔG, or PMF is the target observable and cannot be obtained from plain MD averages.

Domain Context

Free-energy calculations in MD operate on two distinct paradigms:

Alchemical methods compute ΔG by coupling a Hamiltonian H(λ) that interpolates between two physical end-states (λ = 0 and λ = 1) through unphysical intermediate states. The Zwanzig relation gives ΔG = −k_B T ln⟨exp(−ΔU/k_B T)⟩₀, which converges only when the configuration spaces of the two states overlap sufficiently. BAR and MBAR exploit bidirectional sampling across multiple lambda windows to give statistically optimal estimates. No physical trajectory connects the two end-states; the path is a computational construction, but the endpoint free-energy difference is exact in the limit of convergence.

PMF methods compute F(ξ) = −k_B T ln P(ξ) directly along a physical collective variable (CV) by enhanced sampling. The PMF is a projection of the true free energy landscape onto one or two coordinates; its accuracy depends on the quality of the CV as a reaction coordinate.

Several physical constraints govern applicability:

  • Phase-space overlap requirement: For FEP (Zwanzig), the configurations sampled at λ = 0 must include configurations representative of λ = 1. A metric: if exp(−ΔU/k_B T) is dominated by a handful of frames (effective sample size N_eff ≪ N), the estimate is unreliable. BAR/MBAR relax this by pooling data from all intermediate windows.
  • Soft-core potentials at lambda endpoints: At λ → 0 or λ → 1, a fully decoupled particle has a core that overlaps with solvent, creating numerical singularities in dU/dλ and instability in the integrator. Soft-core (Beutler) potentials replace the Lennard-Jones core with a regularized form that remains finite at λ = 0. All production alchemical FEP requires soft-core LJ.
  • Standard-state correction for binding: Absolute binding free energies ΔG_bind are referenced to a standard state of 1 M (1 mol/L). Restraints that confine the ligand during alchemical annihilation impose a loss of translational/rotational entropy that must be corrected analytically (Boresch correction). Omitting this correction can introduce errors of 10–30 kJ/mol. [EXPERT REVIEW NEEDED]
  • Thermodynamic cycle closure: Free energies are state functions. The sum of ΔG around a closed thermodynamic cycle must equal zero. A non-zero cycle closure error ≥ 1 kJ/mol indicates either a numerical problem (insufficient sampling in a window) or a force-field inconsistency. Use cycle closure as a convergence diagnostic.
  • Force-field accuracy is the dominant error source. A perfectly converged FEP calculation with a poorly parameterized force field gives a precisely wrong answer. Experimental validation of the method on a known binding affinity series is required before applying it to novel systems.

When to Use This Skill

  • Hydration free energies: ΔG_hyd = ΔG(liquid) − ΔG(gas), the fundamental benchmark for force-field parameterization.
  • Absolute binding free energies (ABFE) of protein–ligand complexes where a quantitative Kd estimate is needed.
  • Relative binding free energies (RBFE): comparing two ligands that share a common scaffold, where the alchemical perturbation is small.
  • Solvation and adsorption free energies for ions, small molecules, or polymers in solvents or at interfaces.
  • Conformational free energies: the ΔG between two structural states of a peptide or polymer when a PMF along a structural CV is desired.
  • Pore or channel permeation free energies (PMF of ion along channel z-axis) where no good force-field parameterization of the transition is available and enhanced sampling is used instead.

When Not to Use This Skill

  • When the process involves bond breaking or formation. Alchemical FEP is defined for fixed-topology Hamiltonians. Reactive transitions require QM/MM or ReaxFF and different free-energy methods (finite-temperature string, metadynamics with bond-order CV).
  • When a quick estimate suffices. MM/GBSA or MM/PBSA post-processing of an existing trajectory gives rough ΔG estimates (±5–15 kJ/mol) in minutes. Alchemical FEP is 100–1000× more expensive but gives uncertainties of 1–3 kJ/mol if converged. Use the cheaper method first for screening.
  • When the force field is not validated for the system of interest. An un-validated force field for a ligand functional group (rare tautomer, exotic heteroatom, unusual formal charge) makes any FEP result unreliable regardless of statistical convergence.
  • When the timescale problem is not solved by the lambda schedule. If the protein undergoes a slow conformational change that couples to ligand binding, alchemical FEP will not converge unless the protein conformational change is also sampled at every lambda window. This is the most common cause of hysteresis in ABFE calculations.
  • When enhanced sampling has not been applied to a high-barrier PMF. Plain MD umbrella sampling fails if the unbiased trajectories within each window do not visit the window center. Verify that the equilibrium fluctuation of the CV exceeds the window spacing before trusting a WHAM/MBAR reconstruction.

Core Concepts

  • Free energy perturbation (FEP / Zwanzig equation): ΔG(0→1) = −k_B T ln⟨exp(−(U_1 − U_0)/k_B T)⟩₀. Converges only when the phase-space overlap between state 0 and state 1 is high. Direct application is limited to very small perturbations (ΔU ≲ 3 k_B T for most frames). Used in practice as the foundation for lambda-window methods.
  • Thermodynamic integration (TI): ΔG(0→1) = ∫₀¹ ⟨∂H/∂λ⟩_λ dλ. The derivative ⟨∂H/∂λ⟩_λ is ensemble-averaged at each lambda window; the integral is evaluated numerically (trapezoidal or Gaussian quadrature). TI requires ⟨∂H/∂λ⟩_λ to be smooth in λ; discontinuities at λ endpoints indicate soft-core or sampling problems.
  • Bennett Acceptance Ratio (BAR): Solves the implicit equation ΔG = k_B T ln[⟨f(U₀ − U₁ − C)⟩₁ / ⟨f(U₁ − U₀ + C)⟩₀] + C, where f is the Fermi function. BAR uses samples from both states simultaneously and is the minimum-variance estimator for two-state free energy differences. Implemented in pymbar.
  • Multistate BAR (MBAR): Generalizes BAR to N states simultaneously. Uses all samples from all lambda windows to estimate all pairwise free energy differences and their covariance. Statistically optimal; equivalent to BAR for two states but significantly more accurate when N ≥ 3 states and their overlaps are heterogeneous. Implemented in pymbar; integrated into alchemlyb.
  • Lambda coupling parameter (λ): Parameterizes the Hamiltonian between two end-states. For a disappearing ligand: λ = 0 (ligand fully interacting) → λ = 1 (ligand fully decoupled). Separate lambda schedules for electrostatics (q-lambda) and LJ (vdw-lambda) improve numerical stability: decouple charges first (λ_q: 0→1), then LJ (λ_vdw: 0→1). GROMACS uses separate lambda vectors for each energy term.
  • Soft-core LJ (Beutler potential): V_sc(r, λ) = 4 ε λ^n [(α_LJ σ^6 (1−λ)^m + r^6)^{−2} − (α_LJ σ^6 (1−λ)^m + r^6)^{−1}]. The α_LJ parameter (typically 0.5) and softcore power (sc-power = 1 in GROMACS) regularize the λ → 0 singularity. Without soft-core, ∂H/∂λ diverges as λ → 0 for an annihilating atom and the simulation crashes.
  • dhdl.xvg (GROMACS free-energy output): At each lambda window, GROMACS writes ∂H/∂λ values (for TI) and H(λ) − H(λ_current) for all other lambda states (for BAR/MBAR) to dhdl.xvg at every nstdhdl step. alchemlyb reads all dhdl.xvg files and extracts the data in a consistent pandas DataFrame format.
  • Phase-space overlap matrix: An N_windows × N_windows matrix O_ij = ⟨exp(−(U_j − U_i)/2k_B T)⟩_i² / (⟨exp(−(U_j − U_i)/k_B T)⟩_i × ⟨1⟩_j). Diagonal entries are 1; off-diagonal entries near 1 indicate good overlap; entries ≈ 0 indicate that windows i and j have no configurational overlap and the free energy estimate between them is unreliable. Computed by pymbar.MBAR.compute_overlap_matrix().
  • Boresch absolute binding free energy and standard-state correction: When a ligand is alchemically annihilated in the complex, its translational and rotational entropy is restricted by harmonic restraints (3 distance + 3 angle + 3 dihedral). The correction for removing these restraints and converting to 1 M standard state is: ΔG_std = −k_B T ln[8 π² C° r₀² sin(θ_A0) sin(θ_B0) / (K_r K_{θA} K_{θB} K_{φA} K_{φB} K_{φC})^{1/2} (2πk_BT)^3]. The analytical expression requires the equilibrium restraint geometry and spring constants. [EXPERT REVIEW NEEDED: numerical value depends sensitively on restraint parameters]
  • Thermodynamic cycle: For RBFE (relative binding FE), compute ΔΔG_bind = ΔG_complex(A→B) − ΔG_solvent(A→B) where A and B are two ligands. Both legs are alchemical perturbations. The relative result ΔΔG_bind does not require absolute free energies; only the difference between the two alchemical legs. Cycle closure: ΔG_complex + ΔG_bind(B) − ΔG_solvent − ΔG_bind(A) = 0.
  • Hysteresis: The forward ΔG(0→1) and reverse ΔG(1→0) disagree when computed independently from Zwanzig. Hysteresis magnitude |ΔG_forward + ΔG_reverse| > 1 kJ/mol indicates insufficient phase-space overlap or a slow conformational change coupled to the alchemical path. BAR/MBAR reduce hysteresis by optimally combining forward and reverse samples, but cannot eliminate it from insufficient sampling.
  • Effective sample size (N_eff): N_eff = (Σ w_i)² / Σ w_i² where w_i = exp(−U/k_B T). For a good FEP estimate: N_eff/N > 0.1. If N_eff/N < 0.01, the estimate is unreliable regardless of N; more intermediate lambda windows are required.

Key Workflows

Full steps for each part are in references/key-workflows/; open the one you need:

Common Failure Modes

Moved to references/common-failure-modes.md to keep this file short; read it when this part is needed.

Best Practices

  • Always decouple electrostatics before LJ. Remove partial charges first (q-lambda: 0→1 with vdw-lambda = 0), then remove LJ (vdw-lambda: 0→1 with q-lambda = 1). Decoupling LJ first from a charged particle involves a Born-charging artifact where a neutral hard sphere in water has an anomalously high free energy of hydration.
  • Use MBAR over TI or BAR for all production calculations. MBAR is statistically optimal and uses all data from all windows simultaneously. TI is a useful cross-check; agreement between MBAR and TI to within 0.5 kJ/mol is a necessary (not sufficient) convergence indicator.
  • Always inspect the MBAR overlap matrix before reporting ΔG. A single adjacent window pair with O < 0.03 will make the entire MBAR estimate unreliable. This check takes 10 seconds and prevents reporting a wrong number with false confidence.
  • Use the forward-backward convergence plot as the primary convergence metric. The MBAR internal error underestimates the true statistical error when autocorrelation is high. The forward-backward spread and block averaging std provide independent estimates of uncertainty that should be reported alongside the MBAR error.
  • Equilibrate each lambda window independently before production. Starting every window from the same structure (e.g., the NPT equilibrated complex at λ=0) and collecting production immediately leads to slow modes being unsampled in windows far from λ=0. Each window needs 1–5 ns of equilibration in the lambda subspace. The init-lambda-state mdp parameter selects the equilibration lambda.
  • For ABFE: always compute and report the Boresch correction. The standard-state correction for translational and rotational restraints is always significant (typically +10 to +30 kJ/mol) and is exact analytically given the restraint parameters. Never report an ABFE without it, and always state the restraint parameters and correction value in the methods.
  • Run at least three independent repeats for any ABFE or RBFE result. The spread between independent runs (different initial velocities, different initial solvent configurations) is a practical estimate of the systematic convergence error. Publication-quality results require N ≥ 3 repeats. [EXPERT REVIEW NEEDED]
  • Use nstdhdl = 50–100 for small molecules, nstdhdl = 100–250 for protein-ligand. Too large: autocorrelation time not captured by the dhdl output, leading to underestimated effective sample size. Too small: file size becomes the bottleneck (a 100 ns run at nstdhdl=10 produces ~100 GB of dhdl.xvg for 20 lambda windows). Balance accuracy and storage.
  • For TI: use finer lambda spacing near λ=0 for LJ annihilation. The TI integrand ⟨∂H/∂λ⟩_λ diverges as λ→0 for LJ interactions even with soft-core (it remains finite but rises steeply). Gaussian quadrature with optimal nodes is more accurate than uniform spacing for the LJ leg; use points at λ = 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0 rather than uniform 0.1 increments.

Integration with Other Skills

  • enhanced-sampling: Umbrella sampling and metadynamics-based PMF calculations overlap directly with free-energy MD. That skill covers PLUMED CV setup, WTM, and PMF reweighting. This skill covers alchemical FEP/MBAR analysis. For systems where both a physical CV (for PMF) and an alchemical path (for ΔG_bind) are relevant, the two approaches provide complementary information.
  • gromacs-workflow: GROMACS provides the simulation engine and the free-energy mdp section for all alchemical calculations. The .top, .mdp, grompp → mdrun pipeline, and PME setup from that skill are direct prerequisites for any GROMACS-based FEP calculation.
  • lammps-workflow: LAMMPS implements alchemical FEP via the fix adapt and compute fep commands. For materials-science systems (ion insertion, solvation in non-aqueous solvents, surface adsorption) where GROMACS force fields are not available, LAMMPS is the standard FEP engine.
  • md-equilibration: Each lambda window must be independently equilibrated before production. The equilibration criteria from that skill (block averaging of temperature, pressure, and structural observables; stationarity tests) apply per window, not just for the λ=0 starting state.
  • md-analysis: Block averaging, autocorrelation analysis, and effective sample size estimation from that skill are prerequisites for interpreting dhdl.xvg time series. Trajectory-level structural checks (ligand RMSD, protein RMSD, water coordination number vs. λ) verify that each window is sampling the correct state.
  • md-force-fields: Force-field accuracy is the dominant error source in free-energy calculations. GAFF2 and CGenFF parameterization for ligands, water model selection, and ionic parameter quality all directly affect the accuracy of ΔG_hyd and ΔG_bind estimates. That skill covers validation benchmarks and known limitations.
  • coarse-grained-md [FORWARD REFERENCE — skill not yet created]: Martini CG free-energy calculations are an important screening tool for membrane permeability and lipid–ligand interactions. The alchemical methods described here apply to CG force fields with modified lambda schedules appropriate for CG bead resolution.
  • mlp-validation: Free-energy calculations with ML interatomic potentials (MACE, NequIP) require that the MLP is validated across the full alchemical path from λ=0 to λ=1. Committee uncertainty must be checked at each lambda window; windows where the MLP is extrapolating produce unreliable dhdl values.
  • scientific-visualization: MBAR overlap matrix heatmaps, TI integrand plots, forward-backward convergence plots, PMF profiles with uncertainty envelopes, and thermodynamic cycle diagrams are all standard FEP output figures requiring the matplotlib patterns from that skill.
  • reproducibility-workflow: Free-energy calculations require archiving all lambda-window mdp files, topology, dhdl.xvg files, and the alchemlyb analysis script. The GROMACS .tpr for each window is the canonical reproducibility record. That skill covers DVC-based provenance and the run-metadata structure for large multi-window datasets.

Key References

  1. Zwanzig, R. W. (1954). High-temperature equation of state by a perturbation method. I. Nonpolar gases. Journal of Chemical Physics, 22(8), 1420–1426. https://doi.org/10.1063/1.1740409
  2. Bennett, C. H. (1976). Efficient estimation of free energy differences from Monte Carlo data. Journal of Computational Physics, 22(2), 245–268. https://doi.org/10.1016/0021-9991(76)90078-4
  3. Shirts, M. R. & Chodera, J. D. (2008). Statistically optimal analysis of samples from multiple equilibrium states. Journal of Chemical Physics, 129(12), 124105. https://doi.org/10.1063/1.2978177
  4. Boresch, S., Tettinger, F., Leitgeb, M., & Karplus, M. (2003). Absolute binding free energies: A quantitative approach for their calculation. Journal of Physical Chemistry B, 107(35), 9535–9551. https://doi.org/10.1021/jp0217839
  5. Klimovich, P. V., Shirts, M. R., & Mobley, D. L. (2015). Guidelines for the analysis of free energy calculations. Journal of Computer-Aided Molecular Design, 29(5), 397–411. https://doi.org/10.1007/s10822-015-9840-9
  6. Cournia, Z., Allen, B., & Sherman, W. (2017). Relative binding free energy calculations in drug discovery: Recent advances and practical considerations. Journal of Chemical Information and Modeling, 57(12), 2911–2937. https://doi.org/10.1021/acs.jcim.7b00564
  7. Pohorille, A., Jarzynski, C., & Chipot, C. (2010). Good practices in free-energy calculations. Journal of Physical Chemistry B, 114(32), 10235–10253. https://doi.org/10.1021/jp102971x
  8. Gapsys, V., Pérez-Benito, L., Aldeghi, M., Seeliger, D., van Vlijmen, H., Tresadern, G., & de Groot, B. L. (2020). Large scale relative protein–ligand binding affinities using non-equilibrium alchemy. Chemical Science, 11(4), 1140–1152. https://doi.org/10.1039/C9SC03754C

示例提示词

我想用热力学积分方法计算这个配体与蛋白质的结合自由能。

所属插件

计算材料学:第一性原理与原子模拟面向计算材料研究:DFT 与第一性原理(VASP、Quantum ESPRESSO、CP2K、AiiDA)、缺陷/表面/声子/弹性常数、机器学习势函数训练与验证、分子动力学与增强采样、晶体性质图神经网络与生成模型。

安装该插件会一并获得同领域的 35 个 Skill / MCP。

同插件的其他科研 Skill

常见问题

分子动力学自由能计算能做什么?

Covers quantitative free-energy calculations from MD: alchemical FEP/TI/BAR/MBAR, umbrella-sampling PMF. Use when computing thermodynamic free energies from simulation。

如何安装分子动力学自由能计算?

在科搭 Codar 左侧点击「插件」,在「组件」页签搜索「分子动力学自由能计算」并安装;在 Claude Code 或 Codex 中可以发送本页的安装提示词,或下载 Skill 包后解压到 ~/.claude/skills 或 ~/.codex/skills。

分子动力学自由能计算需要哪些权限?

该科研 Skill没有声明额外权限;执行具体操作时仍由 Agent 按自身规则请求确认。

分子动力学自由能计算经过官方审核吗?

是。SpeedSkills 收录的每个版本都会记录内容摘要与权限声明,当前版本已通过安全审核。