Algorithmadvanced
Hyperdynamics
Adds a bias potential that is zero at transition states, so MD escapes basins faster and the true time follows from the boost factor.
- Time
- O(n (G + d)) worst
- Space
- O(d) extra
- Where
- G = the cost of one force and bias evaluation; d = the number of coordinates; n = the number of steps of the biased run
- Model
- Real RAM
- Properties
- randomizednot exactiterativerandomized
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Arthur F. Voter, 1997
Hyperdynamics accelerates a molecular dynamics simulation of a system that moves by rare escapes from basins of its potential energy. It adds a bias potential that raises the bottom of the basin and is exactly zero near every dividing surface that leads out of it. The biased system escapes sooner, and through the same exits with the same relative probabilities. Each step of length advances the physical clock by , so the sum over the run estimates the escape time of the unbiased system. The argument is exact for the rates of transition state theory; for real dynamics it is an approximation, and the speedup, called the boost, is a measured property of each run, not a guarantee.
In plain words
A ball in a deep bowl shakes for a long time before it jumps over the rim. Most of the time is spent near the bottom. Fill the bottom of the bowl with sand, but do not touch the rim. Now the ball jumps out much sooner. Because the rim is the same, the ball leaves by the same gaps as before, in the same proportions.
The only thing that is wrong is the clock. When the ball is on the sand, time in the real bowl would pass faster, because the real ball would be lower and would take longer to get out. So each tick on the sand counts as more than one tick, by a factor that grows with the depth of the sand. Added up, the ticks give the real time of the jump.
The problem
The input is a potential , a dynamics that samples the canonical ensemble at temperature (here Brownian dynamics; in materials, Langevin dynamics or molecular dynamics with a thermostat), and a bias for the current basin . The output is the next state, the basin the system escapes to, and the escape time, so that a sequence of escapes is a sample of the state-to-state dynamics over times far beyond direct simulation. The method assumes that escapes are rare: the system equilibrates in long before it leaves, so the escape is a Poisson process with the rates of transition state theory.
The algorithm
HYPERDYNAMICS(x, V, ΔV, k_B T, h)- 1
t_hyper ← 0 - 2
repeat - 3
evaluate ΔV(x) and ∇ΔV(x) ▷ zero near every dividing surface - 4
t_hyper ← t_hyper + h exp(ΔV(x) / k_B T) ▷ the boosted clock - 5
x ← x - h ∇(V + ΔV)(x) + sqrt(2 k_B T h) ξ, ξ standard normal - 6
until x has left the basin - 7
return x, t_hyper
Line L5 is one Euler-Maruyama step of overdamped Langevin dynamics on the biased potential, with mobility 1 and the time step . Any dynamics that samples the canonical ensemble works here. Line L4 is the change of clock: a step at a point with a large bias counts for more physical time. Line L6 needs a test that the system has left the basin, for example a short minimization that ends in a different minimum. The outer loop repeats this from the new basin with a new bias, and adds the hyper times. The boost of a run is for steps.
The implementation provides one simple bias with a flat floor, inside the basin: the biased potential is , and the bias is zero wherever , which includes the barrier region if is below the lowest saddle. For many atoms this needs a bias defined from local quantities; Voter's bias of 1997 is zero where the lowest curvature of is negative, which is true near every saddle.
Example
The clock by hand. Take with the barrier at , , the flat floor for , and . At the minimum , and the biased potential is flat, so the drift is zero. Each step there advances the clock by . Two steps give . Where , for example at where , a step counts as .
Exact times. For this one-dimensional dynamics the mean escape times have closed forms (the formula is in the proof). Let the escape be the first arrival at , beyond the barrier, from . With quadrature:
| unbiased mean time | mean hyper time | mean simulated time | time boost | |||
|---|---|---|---|---|---|---|
| 0.25 | 0.4 | 65.925 | 67.400 | 25.819 | 2.55 | 2.585 |
| 0.25 | 0.6 | 65.925 | 71.527 | 14.591 | 4.52 | 4.757 |
| 0.25 | 0.8 | 65.925 | 84.155 | 8.632 | 7.64 | 8.993 |
| 0.1667 | 0.6 | 477.635 | 505.383 | 36.886 | 12.95 | 13.439 |
| 0.125 | 0.6 | 3480.215 | 3597.905 | 89.391 | 38.93 | 39.816 |
The time boost is the unbiased time over the simulated time of the biased run. The last column is the boost of transition state theory, the ratio of the basin integrals of and over . Three facts show in the table. The boost grows like , so it is large at low temperature. The hyper time overestimates the true time, by 2.2 %, 8.5 % and 28 % at as the floor rises: this dynamics has recrossings, and the floor gets close to the barrier. At lower temperature, with the same floor, the error falls (5.8 % and 3.4 %).
A measurement. Runs of line L5 with random.Random(1), , and , for steps, gave 134 escapes with a mean hyper time of (one standard error), against from the formula, and a measured boost of . This boost is a measurement of these runs.
Correctness
The proof below is the argument of transition state theory. The TST rate through a dividing surface is the equilibrium flux through the surface over the probability of the basin, . The bias does not change on the surfaces, so it does not change the fluxes. It only lowers the probability weight of the basin, from to . So every rate is multiplied by the same factor , the branching ratios are unchanged, and the average of along the biased run, which line L4 computes, restores the time. This is exact for TST rates. For the true dynamics, it is as good as TST itself in the biased and the unbiased system: it needs the bias to be exactly zero where recrossings happen, and the biased basin to still hold the system long enough to equilibrate. The table above shows the size of the error for a diffusion with recrossings.
Proof: Why the boosted clock gives the escape time under transition state theoryfull
The claim of hyperdynamics is a claim about transition state theory (TST) rates, not about every dynamics. We prove it for TST rates, then say what it means for the dynamics of the implementation.
Setting. The system is in a basin with dividing surfaces to the neighbouring basins. The canonical density at is proportional to in position space. The TST rate through is the one-way equilibrium flux through divided by the probability of :
where the constant comes from the integral over the velocities and does not depend on (in mass-weighted coordinates ; see harmonic transition state theory). The bias is zero on every . The biased system has the potential and the TST rates .
Lemma 1 (the fluxes do not change). for every .
Proof. On , , so the two surface integrals are equal, and the velocity factor is the same.
Lemma 2 (the basin integrals). , the average of over the biased canonical density in .
Proof. .
Theorem (Voter 1997). Under the hypotheses above:
- for every . All rates are divided by the same number, the boost .
- The probability that the escape goes through , , is the same for the biased and the unbiased system.
- If the biased system escapes after steps of length that sample the biased density in , the hyper time is up to the error of a time average, and the mean of is , so the mean of is , the mean escape time of the unbiased system.
Proof. Part 1 follows from Lemmas 1 and 2: . Part 2 follows from part 1, because the common factor cancels in the ratio. Part 3: under the TST hypotheses the escape is a Poisson process, so the escape time of the biased system is exponential with mean , independent of the path inside . The time average of along a long run in tends to by the ergodic theorem for the biased dynamics. The mean of is then times the mean biased escape time, and part 1 gives . because .
The conditions in the proof. Lemma 1 needs the bias to be exactly zero on the dividing surfaces. If it is not, the biased system escapes through a lowered barrier, both and the branching ratios change, and the hyper time is too long by an unknown factor. Part 3 needs the time average to be close to the canonical average, so the biased basin must still have a separation of time scales: the system must equilibrate in the biased basin before it escapes. A bias that fills the basin up to the barrier removes this separation.
What the theorem means for real dynamics. The theorem is exact for TST rates. For a dynamics with recrossings, such as the overdamped Langevin dynamics of the implementation, it holds only approximately. For a one-dimensional diffusion with an absorbing point beyond the barrier, the mean of the boosted clock from solves the backward equation , whose solution is
The unbiased mean first passage time has in place of . The two agree up to the contribution of the region where to the outer integral, which is small compared with the contribution of the barrier region by a factor of order for the flat bias with floor and barrier . So the error vanishes as the gap between the bias and the barrier grows in units of . On the page example, it is 2.2 % for and 8.5 % for at .
What is not proved. The speedup is not part of the theorem. The boost depends on the bias, the system and the temperature, and the boost of a run is a measurement. The theorem does not say how to build a bias that is zero on dividing surfaces that are not known in advance; each bias form in use comes with its own argument for this.
Complexity
A run of biased steps costs evaluations of the force and the bias, in the real RAM model, and memory. It reaches the physical time for the boost . The cost of the bias matters: a bias from the lowest Hessian eigenvalue needs several extra force calls per step (a dimer style rotation), which can cancel much of the boost; biases from bond lengths cost little. The boost is a measurement: values from a few to are reported in the literature for low temperature and simple systems, and it falls fast as the temperature rises or the system grows, because a safe bias must stay below the lowest barrier anywhere in the system.
Properties
- Exact under TST. With a bias that is zero on the dividing surfaces, the TST rates of all exits are divided by the same boost. No knowledge of the exits is needed.
- Randomized. The output is one sample of the escape; averages need many escapes.
- Serial. It accelerates one trajectory. It can be combined with parallel replica dynamics.
- Boost limited by the lowest barrier. The bias must vanish near every saddle, including the lowest one, so the boost is at most of order for the lowest barrier of the basin.
Variants and improvements
- Flat bias. The bias of the example costs nothing but needs a floor below every saddle of the basin, which is known only in small models.
- Hessian based bias. Voter's bias of 1997 depends on the lowest eigenvalue of the Hessian, which is negative near every first-order saddle, so the bias vanishes there without knowing the saddles.
- Bond boost. For materials, a bias that depends on the largest change of bond length in the system is cheap, and is zero when one bond is stretched far, which is what happens at a saddle.
- Accelerated MD in biomolecules. A flat bias on the total energy or on the dihedral energy is used to sample conformations; the boosted time there is often not physical, because the conditions above do not hold.
- Metadynamics and umbrella sampling also add a bias, but to compute free energies; the bias there does not vanish on the dividing surfaces, so the time is not preserved.
When to use it
Use hyperdynamics for a system with rare escapes, at a low temperature where the boost is large, and when you can build a bias that is provably zero near all saddles of the basin, for example for surface diffusion and small defect clusters. Use kinetic Monte Carlo when the event catalog is known, parallel replica dynamics when many processors are available and the bias is hard to build, and temperature accelerated dynamics when harmonic TST is accurate for all events.
Pitfalls
- A bias that does not vanish at a saddle. The system escapes through a lowered barrier, and both the time and the choice of exit are wrong. Nothing in the run shows this.
- A bias that is too high. If the floor comes close to the barrier, the biased basin no longer holds the system, the escape is no longer a Poisson process with TST rates, and the hyper time is biased, by 28 % in the table for .
- Few escapes. A single hyper time is one sample of an exponential law, with a relative standard deviation of 1. Averages need many escapes.
- Confusing the boost with an error bar. A large boost says nothing about the accuracy; check against direct MD at a higher temperature where both are possible.
Implementations
Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/hyperdynamics/. The authors are listed in prov/W145MS.jsonl.
"""Hyperdynamics (Voter 1997) on overdamped Langevin dynamics.
The dynamics runs on the biased potential V + dV, where the bias dV >= 0
is zero near every dividing surface out of the current basin. Each step
of length h adds h exp(dV(x) / kT) to the hyper time instead of h. When
the system leaves the basin, the hyper time is an estimate of the escape
time of the unbiased dynamics, under the assumptions of transition state
theory (no correlated recrossings, and local equilibrium in the basin).
The dynamics here is dx = -grad(V + dV) dt + sqrt(2 kT) dW, with mobility
1, integrated by the Euler-Maruyama method with time step h. The boost,
hyper time over simulated time, is a measurement of one run.
A simple bias with a flat floor is given: dV = max(0, V_c - V) inside the
basin. It is zero where V >= V_c, which includes the barrier region if V_c
is below the barrier. Such a bias needs the basin to be known; biases for
real systems use local quantities such as the bond lengths.
"""
import math
from typing import Callable, Sequence
Vector = list[float]
def flat_bias(potential: Callable[[Sequence[float]], tuple[float, Vector]], v_c: float,
in_basin: Callable[[Sequence[float]], bool]):
"""Return f(x) -> (dV, grad dV) for dV = max(0, v_c - V(x)) inside the basin, 0 outside."""
def bias(x):
v, g = potential(x)
if in_basin(x) and v < v_c:
return v_c - v, [-c for c in g]
return 0.0, [0.0] * len(x)
return bias
def hyperdynamics(x0: Sequence[float], potential, bias, kT: float, h: float,
escaped: Callable[[Sequence[float]], bool], rng, max_steps: int = 10**6):
"""Run biased overdamped Langevin dynamics until escaped(x) is True.
potential(x) and bias(x) return (value, gradient). rng needs gauss(0, 1).
Returns (x, hyper_time, steps, done): the final point, the boosted clock
sum of h exp(dV / kT), the number of steps and whether the escape
happened. The boost of the run is hyper_time / (steps * h).
"""
x = list(x0)
t_hyper = 0.0 # @line L1
s = math.sqrt(2.0 * kT * h)
for step in range(1, max_steps + 1): # @line L2
dv, gb = bias(x) # @line L3
t_hyper += h * math.exp(dv / kT) # @line L4
g = potential(x)[1]
x = [xi - h * (gi + bi) + s * rng.gauss(0.0, 1.0) # @line L5
for xi, gi, bi in zip(x, g, gb)]
if escaped(x): # @line L6
return x, t_hyper, step, True # @line L7
return x, t_hyper, max_steps, False
test_hyperdynamics.py 121 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/hyperdynamics/. The authors are listed in prov/W145MS.jsonl.
import math
import random
import pytest
from hyperdynamics import flat_bias, hyperdynamics
KT = 0.25
V_C = 0.6
def double_well(x):
return (x[0] ** 2 - 1.0) ** 2, [4.0 * x[0] * (x[0] ** 2 - 1.0)]
def in_left(x):
return x[0] < 0.0
def past_barrier(x):
return x[0] >= 0.5
class ZeroNoise:
def gauss(self, mu, sigma):
return 0.0
def exact_times(kT, v_c, x_b=0.5, lo=-2.5, n=4000):
"""Mean escape times from x = -1 to x_b for the dynamics of the module.
Returns (T, T_boost, T_wall): the unbiased mean first passage time, the
mean of the boosted clock, and the mean simulated time of the biased run,
from the formula T(y) = (1/kT) int_y^x_b e^(beta U(z)) int_-inf^z w(u) du dz
with U = V or V + dV and w = e^(-beta V) or e^(-beta (V + dV)).
"""
beta = 1.0 / kT
def v(u):
return (u * u - 1.0) ** 2
def vb(u):
return v(u) + (max(0.0, v_c - v(u)) if u < 0.0 else 0.0)
dz = (x_b - lo) / n
t = tb = tw = cum = cumb = 0.0
for i in range(n):
m = lo + (i + 0.5) * dz
cum += 0.5 * math.exp(-beta * v(m)) * dz
cumb += 0.5 * math.exp(-beta * vb(m)) * dz
if m > -1.0:
t += math.exp(beta * v(m)) * cum * dz
tb += math.exp(beta * vb(m)) * cum * dz
tw += math.exp(beta * vb(m)) * cumb * dz
cum += 0.5 * math.exp(-beta * v(m)) * dz
cumb += 0.5 * math.exp(-beta * vb(m)) * dz
return t / kT, tb / kT, tw / kT
def test_flat_bias_values():
bias = flat_bias(double_well, V_C, in_left)
assert bias([-1.0]) == (pytest.approx(0.6), [pytest.approx(0.0)])
# Near the barrier top V > V_C, so the bias is zero.
assert bias([-0.2])[0] == 0.0
# Outside the basin the bias is zero even where V < V_C.
assert bias([1.0])[0] == 0.0
# On the floor, V + dV is flat: the two gradients cancel.
x = [-1.2]
assert double_well(x)[1][0] + bias(x)[1][0] == pytest.approx(0.0, abs=1e-12)
def test_clock_by_hand():
bias = flat_bias(double_well, V_C, in_left)
x, t, steps, done = hyperdynamics([-1.0], double_well, bias, KT, 0.02, past_barrier, ZeroNoise(), max_steps=2)
assert not done and steps == 2
assert x == [-1.0]
assert t == pytest.approx(2 * 0.02 * math.exp(0.6 / 0.25))
assert t == pytest.approx(0.440927, abs=1e-6)
def test_zero_bias_is_plain_dynamics():
zero = flat_bias(double_well, -1.0, in_left)
x, t, steps, done = hyperdynamics([-1.0], double_well, zero, KT, 0.02, past_barrier, random.Random(3), max_steps=500)
assert t == pytest.approx(steps * 0.02)
def test_exact_times_of_the_page():
t, tb, tw = exact_times(KT, V_C)
assert t == pytest.approx(65.925, abs=1e-2)
assert tb == pytest.approx(71.527, abs=1e-2)
assert tw == pytest.approx(14.591, abs=1e-2)
# Without a bias the three agree.
t0, tb0, tw0 = exact_times(KT, 0.0)
assert t0 == pytest.approx(tb0) and t0 == pytest.approx(tw0)
def test_boosted_escape_times_are_statistically_right():
# At most 10000 steps in total: the check is loose, about 3 standard errors.
h = 0.02
rng = random.Random(1)
bias = flat_bias(double_well, V_C, in_left)
hyper, wall = [], []
used = 0
while used < 10000:
x, t, steps, done = hyperdynamics([-1.0], double_well, bias, KT, h, past_barrier, rng,
max_steps=10000 - used)
used += steps
if done:
hyper.append(t)
wall.append(steps * h)
n = len(hyper)
assert n >= 10
mean = sum(hyper) / n
sd = math.sqrt(sum((v - mean) ** 2 for v in hyper) / (n - 1))
_, tb, tw = exact_times(KT, V_C)
assert abs(mean - tb) < 3.0 * sd / math.sqrt(n)
# The measured boost of the runs: hyper time over simulated time.
boost = sum(hyper) / sum(wall)
assert 3.0 < boost < 7.0
History
Voter introduced hyperdynamics in 1997, as the first of his accelerated molecular dynamics methods, with the boosted clock and a bias based on the lowest curvature of the potential. He then gave parallel replica dynamics in 1998 and, with Sorensen, temperature accelerated dynamics in 2000. The review of Voter, Montalenti and Germann in 2002 compares the three methods and the conditions under which each is accurate.
References
- Arthur F. Voter, Hyperdynamics: accelerated molecular dynamics of infrequent events, Physical Review Letters 78(20), 1997, 3908-3911, the bias potential that vanishes at the dividing surfaces, the boosted time and the argument from transition state theory
- Arthur F. Voter, Francesco Montalenti and Timothy C. Germann, Extending the time scale in atomistic simulation of materials, Annual Review of Materials Research 32, 2002, 321-346, the review of hyperdynamics, parallel replica dynamics and temperature accelerated dynamics, with the conditions on the bias
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag W145MS Edit this page History Report an error Markdown