科研 Skill

增强采样自由能计算

enhanced-sampling

Covers enhanced sampling methods for atomistic MD (metadynamics, umbrella sampling. Use for rare-event or slow-transition sampling.

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

SKILL.md

Enhanced Sampling

Description

This skill covers enhanced sampling methods for atomistic MD simulations where rare events, large free-energy barriers, or slow conformational transitions prevent standard MD from converging on accessible timescales. It addresses collective variable (CV) selection and validation; umbrella sampling with WHAM/MBAR reconstruction; well-tempered metadynamics; adaptive biasing force; steered MD; temperature replica exchange; accelerated MD; free-energy surface convergence diagnostics; and PLUMED integration with GROMACS, LAMMPS, and ML interatomic potentials. Invoke this skill whenever a process of interest has an estimated barrier ≳ 10 k_B T or an estimated timescale that cannot be sampled directly within the available simulation budget.

Domain Context

Standard MD is limited to continuous trajectories. For a system at 300 K, barrier-crossing events with ΔG‡ ≳ 10 k_B T (≳ 25 kJ/mol) occur with rates of order k ~ ν exp(−ΔG‡/k_B T) ≈ 10¹³ × e⁻¹⁰ s⁻¹ ≈ 10⁻⁸ s⁻¹ — a mean first-passage time of ~100 ns. Protein folding, crystal nucleation, ion permeation through channels, and solid-state diffusion all fall into this regime.

Enhanced sampling methods modify the system to accelerate barrier crossing and then reconstruct the unbiased free energy surface (FES) from the biased simulation. The modifications take four forms:

  1. Bias potentials on collective variables (CVs): A time-varying or history-dependent potential V_bias(ξ) is added along one or more CVs ξ(r). The CV must capture the reaction coordinate — it must separate the metastable states and project out the slow degrees of freedom. A poor CV does not accelerate the relevant transition even if the method runs correctly.
  2. Hamiltonian or temperature ladders (replica exchange): Multiple copies of the system run in parallel at different temperatures or with different Hamiltonians. Exchanges between replicas are accepted with the Metropolis criterion, enabling high-temperature configurations to escape local minima and donate configurations to lower-temperature replicas.
  3. Time-independent bias (flat histogram): The WAN to-WHAM or MBAR approach reconstructs the FES from multiple biased simulations (umbrella sampling windows) by reweighting each frame by the inverse of its bias weight.
  4. Velocity-boosted or modified-potential approaches (accelerated MD): A dihedral or total boost potential is added to reduce barriers globally rather than along a specific CV.

Several non-negotiable physical constraints govern applicability:

  • CV completeness: The CV must have low friction along all relevant slow modes. Hidden slow modes — degrees of freedom orthogonal to the CV that also relax slowly — cause hysteresis and non-reproducible FES estimates even when the CV-projected FES looks converged.
  • Reweightability: The bias must be expressible as a function of the current configuration, not dependent on the trajectory history, for exact reweighting. Metadynamics with a Gaussian hill width smaller than the thermal fluctuation of the CV is not accurately reweightable frame-by-frame; use the time-integrated bias for reweighting.
  • Ergodicity on the biased surface: Enhanced sampling does not solve the ergodicity problem; it shifts it. A metadynamics run that floods a two-minima system will still fail if a third metastable state exists along an orthogonal CV that is not biased.
  • Timescale separation: Replica exchange requires the fast motions (solvent, bond vibrations) to decorrelate within each replica's simulation between swaps. The exchange interval must be long enough that each replica is ergodic on its FES segment between swaps. [EXPERT REVIEW NEEDED]

When to Use This Skill

  • When the process of interest (folding, unbinding, nucleation, diffusion, isomerization, phase transition) is not observed in a plain MD run of the affordable length.
  • When a free energy difference or free energy profile along a reaction coordinate is needed quantitatively.
  • When screening multiple candidate reaction pathways and the correct pathway is unknown a priori.
  • When using ML potentials whose speed advantage over DFT allows access to nanosecond trajectories, but the barrier is still too large for plain MLP-MD to converge.
  • When sampling thermally activated defect migration, adsorption/desorption, or catalytic transitions where DFT-level accuracy is needed but timescales preclude AIMD.

When Not to Use This Skill

  • When the process is not actually slow. If the transition is observed multiple times in a 10 ns plain MD run, enhanced sampling adds complexity and potential bias without benefit. Verify the timescale problem before choosing a method.
  • When a good collective variable is unknown and cannot be constructed. Automated CV discovery (TICA, sketch-map, deep TDA) is a prerequisite, not part of the sampling itself. Metadynamics with a wrong CV wastes compute and produces a meaningless FES.
  • For equilibrium structural observables (RDF, density, bond angles) that are not barrier-limited. Enhanced sampling changes the statistical weights of sampled configurations; using it to compute structural averages requires exact reweighting and introduces additional error versus plain MD.
  • For non-equilibrium or kinetics studies requiring real-time dynamics. Metadynamics and umbrella sampling destroy the real-time kinetics; use transition path sampling or milestoning if rate constants are the target quantity. [EXPERT REVIEW NEEDED]
  • For systems where the bias violates the relevant physics. Biasing a bond length CV across a bond-breaking event with a classical force field is physically meaningless (the force field has no dissociation energy surface). Use ReaxFF or QM/MM for reactive transitions.

Core Concepts

  • Collective variable (CV) / reaction coordinate: A low-dimensional function ξ(r) of all atomic positions that distinguishes the relevant metastable states. Must be differentiable with respect to atomic positions (required for force projection). Common choices: distances, angles, torsions, RMSD to a reference, radius of gyration, coordination numbers, path CVs, TICA or machine-learned CVs. The quality of the CV determines the quality of the entire enhanced sampling calculation.
  • Free energy surface (FES): F(ξ) = −k_B T ln P(ξ) + C, where P(ξ) is the probability density of CV values under the unbiased Boltzmann distribution. The FES encodes all thermodynamic information about the process: barrier heights, free energy differences between states, and relative stability of intermediates.
  • Metadynamics: History-dependent bias V_meta(ξ, t) = Σ_k h exp(−(ξ − ξ_k)² / (2σ²)) accumulated by periodically depositing Gaussian hills at the current CV value. The bias eventually compensates the FES (V_meta → −F(ξ) at convergence). Raw metadynamics oscillates at convergence; well-tempered metadynamics corrects this.
  • Well-tempered metadynamics (WTM): Hills are deposited with a height that decreases exponentially as the bias accumulates: h(t) = h₀ exp(−V_bias(ξ, t) / k_B ΔT), where ΔT is the bias temperature and γ = (T + ΔT)/T is the bias factor. WTM converges to F(ξ) × (T/(T+ΔT)) — a rescaled FES — rather than oscillating. The FES is recovered as F(ξ) = −(1 + T/ΔT) × V_bias(ξ, t→∞) / γ. Standard choice: γ = 10–15 for barriers up to 50–80 kJ/mol at 300 K. [EXPERT REVIEW NEEDED]
  • Umbrella sampling (US): A set of independent simulations, each with a harmonic restraint V_US = (k/2)(ξ − ξ₀)² centered at a different point ξ₀ along the reaction coordinate. The windows together cover the entire pathway from reactant to product. The unbiased FES is reconstructed from all windows simultaneously by WHAM or MBAR. Requires overlapping window distributions; gaps in coverage produce discontinuities in the reconstructed FES.
  • WHAM (Weighted Histogram Analysis Method): Iteratively solves a set of self-consistency equations to find the optimal combination of biased histograms that reconstructs P(ξ). Requires overlapping histograms and converges numerically. Superseded by MBAR for non-histogram-based reconstructions but still standard for simple 1D/2D umbrella sampling.
  • MBAR (Multistate Bennett Acceptance Ratio): Statistically optimal estimator for free energy differences from multiple simulations with different biasing potentials. Does not require binning (no histogram); uses all frames with their exact bias weights. Implemented in PyMBAR (or FastMBAR). More accurate than WHAM for the same data, especially at low frame counts.
  • Adaptive biasing force (ABF): At each CV value, the thermodynamic integration integrand ∂F/∂ξ is estimated from the instantaneous generalized force and accumulated; the accumulated mean force is applied as a counter-bias. Adaptively flattens the FES along the CV without prior knowledge of barrier shape. Implemented in COLVARS (NAMD, LAMMPS, GROMACS) and as abf in PLUMED.
  • Steered MD (SMD): A moving harmonic spring pulls the CV from ξ_start to ξ_end at constant velocity. The work W performed by the spring along the trajectory is measured. The Jarzynski equality ⟨e^{−W/k_B T}⟩ = e^{−ΔF/k_B T} allows recovery of equilibrium ΔF from nonequilibrium pulling; requires many pulling trajectories (typically 50–500) for statistical convergence, and the end-state ΔF is more accurate than the full FES. SMD also generates physically reasonable initial structures for umbrella sampling windows.
  • Temperature replica exchange MD (T-REMD): N replicas run simultaneously at temperatures T₁ < T₂ < … < T_N with exchange attempts between adjacent replicas at intervals τ_swap. Exchange accepted with Metropolis probability P_swap = min(1, exp((β_i − β_j)(E_i − E_j))). At high T, barriers are suppressed; the configurational diversity propagates back to low T. Requires ~20–30% acceptance rate between adjacent replicas; temperature spacing is typically 10–30 K. [EXPERT REVIEW NEEDED]
  • Metadynamics convergence (hills flooding / block analysis): The bias is considered converged when the time-averaged FES computed from the last N_block frames no longer changes as a function of when in the trajectory N_block begins. A practical convergence test: divide the total simulation into blocks; compute the FES from each block independently; compare FES estimates. Large block-to-block variation indicates the bias is still evolving.
  • Reweighting: Any biased MD trajectory can in principle be reweighted to recover unbiased observables: ⟨O⟩_unbias = ⟨O × e^{+V_bias/k_B T}⟩_bias / ⟨e^{+V_bias/k_B T}⟩_bias. In practice, this requires V_bias to be a known, time-independent potential. For WTM where the bias evolves with time, use the instantaneous bias V_bias(ξ, t) evaluated at each frame.
  • Transition-state recrossing and transmission coefficient: Even a perfect FES does not give the rate constant without the transmission coefficient κ, which accounts for trajectory recrossings of the dividing surface. κ < 1 for systems with dynamical friction; it is not accessible from enhanced sampling alone.

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 test the CV before committing to enhanced sampling. Run 5–20 ns of plain MD first, compute P(ξ), and verify that the target states correspond to distinct modes in P(ξ). If they do not, the CV cannot distinguish the states and enhanced sampling will not help.
  • Set SIGMA to 0.3–0.5 × the equilibrium CV standard deviation. Too small: hills overfill the well before the system diffuses across it. Too large: poor FES resolution. Estimate σ_CV from the plain MD test run.
  • Use well-tempered metadynamics (WTM) for all production runs; never use untempered metadynamics. Untempered metadynamics accumulates bias indefinitely, eventually destabilizing all states. WTM converges to a finite bias and is directly reweightable.
  • Always run block analysis before reporting a FES. Divide the trajectory into 5–10 blocks and compute the FES from each block. The maximum block standard deviation is the uncertainty on the FES. Report it alongside every FES figure. A max std of > 2 kJ/mol indicates an unconverged simulation.
  • For umbrella sampling, verify window overlap before running MBAR. Plot the P(ξ) histogram for each window on a single axis. No gaps are allowed between adjacent windows for MBAR to converge. If gaps exist, add intermediate windows before analysis, not after.
  • For T-REMD: check acceptance rates after the first 1 ns and before committing to a full run. A short 5 ns test run with all replicas gives acceptance rate statistics sufficient to decide whether the temperature spacing is correct. Fixing spacing is free; wasting 100 ns per replica on a bad ladder is expensive.
  • Equilibrate with plain MD before starting any enhanced sampling. Starting metadynamics or umbrella sampling from a non-equilibrated structure introduces systematic bias at the initial CV position. The enhanced sampling method will then focus on exploring away from an unphysical starting point rather than the true free energy landscape.
  • For MLP-accelerated enhanced sampling: regularly check committee uncertainty. MACE and NequIP can produce confident but wrong forces outside the training distribution. If the trajectory visits configurations with high committee force variance (σ_F > 0.1–0.5 eV/Å) during enhanced sampling, those frames are unreliable and may produce artifactual FES features. [EXPERT REVIEW NEEDED]
  • Do not mix reweighting from different methods without verification. Mixing WTM-reweighted FES with direct US/MBAR FES requires thermodynamic consistency checks. Use a single method end-to-end, or verify that the two FES agree within uncertainty at an overlapping region.
  • For 2D FES: use METAD with a grid (GRID_MIN/MAX/BIN) rather than list-based HILLS. The grid-based accumulation is an order of magnitude faster for 2D CVs and avoids the O(N) cost per step of summing all deposited hills.

Integration with Other Skills

  • gromacs-workflow: GROMACS provides the MD engine that PLUMED patches into. The production .tpr from that skill is the starting point for all PLUMED-driven enhanced sampling runs. The equilibration protocol from that skill is a prerequisite before metadynamics or umbrella sampling begins.
  • lammps-workflow: PLUMED interfaces with LAMMPS via the fix plumed command, enabling umbrella sampling and metadynamics in LAMMPS simulations of metals, ceramics, and other materials-science systems where GROMACS is not appropriate.
  • md-equilibration: Enhanced sampling must always be preceded by confirmed equilibration. The convergence criteria from that skill (block averaging of T, P, density; stationarity tests) must be satisfied before any biased simulation begins.
  • md-analysis: Post-processing enhanced sampling trajectories requires the PBC unwrapping, trajectory loading, and block averaging methods from that skill, especially for extracting unbiased structural observables from reweighted trajectories.
  • md-force-fields: The choice of force field determines the accuracy of the enhanced sampling FES. The validation criteria and transferability limits from that skill apply equally to enhanced sampling contexts; a FES computed with a poorly parameterized force field is not physically meaningful.
  • free-energy-md [FORWARD REFERENCE — skill not yet created]: Alchemical free energy (FEP) methods compute free energy differences along a coupling parameter λ rather than a physical CV. Umbrella sampling along a physical CV and FEP along λ are complementary and can be combined for protein–ligand binding free energies.
  • coarse-grained-md [FORWARD REFERENCE — skill not yet created]: Enhanced sampling with Martini or other coarse-grained force fields is an important computational strategy: the faster dynamics and lower barrier heights in CG models provide a rougher but much cheaper FES that can guide the design of all-atom enhanced sampling protocols.
  • reactive-md: ReaxFF or QM/MM trajectories can be coupled to PLUMED for enhanced sampling of chemical reactions. The CV must be chosen to describe the bond-forming/breaking event; the reweighting is identical but force field setup differs from classical MD.
  • mlp-validation: Before running MLP-accelerated enhanced sampling, validate the MLP on structures that span the expected CV range. Committee uncertainty along the sampled CV trajectory must be checked; frames with high uncertainty must be flagged or excluded from FES reconstruction.
  • mlp-to-lammps: LAMMPS is the most common engine for MLP-driven MD in materials contexts. PLUMED + LAMMPS + MACE/NequIP via pair_style mace enables enhanced sampling with MLP accuracy at LAMMPS throughput, which is the standard approach for materials-science rare events.
  • scientific-visualization: FES visualization (2D heatmaps, projected FES along CVs, convergence plots), trajectory coloring by CV value, and replica exchange acceptance animations are all common outputs of enhanced sampling that require the plotting patterns from that skill.
  • reproducibility-workflow: Enhanced sampling results depend critically on the PLUMED input file version, hill deposition parameters, and accumulated HILLS file. All three must be archived alongside the trajectory for any published FES. That skill covers DVC-based provenance for large simulation outputs.

Key References

  1. Laio, A. & Parrinello, M. (2002). Escaping free-energy minima. Proceedings of the National Academy of Sciences, 99(20), 12562–12566. https://doi.org/10.1073/pnas.202427399
  2. Barducci, A., Bussi, G., & Parrinello, M. (2008). Well-tempered metadynamics: A smoothly converging and tunable free-energy method. Physical Review Letters, 100(2), 020603. https://doi.org/10.1103/PhysRevLett.100.020603
  3. Tribello, G. A., Bonomi, M., Branduardi, D., Camilloni, C., & Bussi, G. (2014). PLUMED 2: New feathers for an old bird. Computer Physics Communications, 185(2), 604–613. https://doi.org/10.1016/j.cpc.2013.09.018
  4. 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
  5. Frenkel, D. & Smit, B. (2002). Understanding Molecular Simulation: From Algorithms to Applications (2nd ed.). Academic Press. ISBN 978-0-12-267351-1.
  6. Valsson, O., Tiwary, P., & Parrinello, M. (2016). Enhancing important fluctuations: Rare events and metadynamics from a conceptual viewpoint. Annual Review of Physical Chemistry, 67, 159–184. https://doi.org/10.1146/annurev-physchem-040215-112229
  7. Henin, J., Lelievre, T., Shirts, M. R., Valsson, O., & Delemotte, L. (2022). Enhanced sampling methods for molecular dynamics simulations. Living Journal of Computational Molecular Science, 4(1), 1583. https://doi.org/10.33011/livecoms.4.1.1583
  8. Sugita, Y. & Okamoto, Y. (1999). Replica-exchange molecular dynamics method for protein folding. Chemical Physics Letters, 314(1–2), 141–151. https://doi.org/10.1016/S0009-2614(99)01123-9

示例提示词

我想用伞形采样和WHAM计算这个构象转变的自由能垒。

所属插件

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

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

同插件的其他科研 Skill

常见问题

增强采样自由能计算能做什么?

Covers enhanced sampling methods for atomistic MD (metadynamics, umbrella sampling. Use for rare-event or slow-transition sampling。

如何安装增强采样自由能计算?

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

增强采样自由能计算需要哪些权限?

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

增强采样自由能计算经过官方审核吗?

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