Algorithmresearch
Temperature accelerated dynamics
Finds transitions at high temperature and extrapolates their times to low temperature with harmonic transition state theory.
- Time
- O(n S) expected
- Space
- O(n) extra
- Where
- S = the cost of one escape (molecular dynamics and a saddle search); n = the number of high temperature escapes before the stop
- Model
- Real RAM
- Properties
- randomizednot exactiterativerandomized
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Mads R. Sorensen, Arthur F. Voter, 2000
Temperature accelerated dynamics (TAD) finds the next escape of a system from an energy basin at a low temperature by running molecular dynamics at a high temperature , where escapes are frequent. Each time the system escapes, the saddle of the escape is found, the system is put back into the basin, and the time of the escape is extrapolated to the low temperature with harmonic transition state theory. The event with the shortest extrapolated time is the next event at the low temperature. The high temperature run can stop early, at a time that bounds, with a chosen confidence, the extrapolated time of any event not seen yet. The method assumes HTST at both temperatures and a known lower bound on the prefactors. The boost is a measurement of each run.
In plain words
At room temperature a system waits a long time before each change. Heat it, and the changes come much faster. But heat does not speed up every change by the same factor: a change over a high barrier speeds up more than a change over a low one. So the first change in the hot system may not be the first change in the cold one.
TAD keeps a list. Each time the hot system makes a change, it measures how high the barrier was, puts the system back, and works out when that change would have happened in the cold system. The change with the earliest cold time wins. After a while, any change not seen yet would have a cold time too late to win, with high confidence, and the search stops.
The problem
The input is a basin, a dynamics at a temperature , a way to find the saddle energy of an escape (a nudged elastic band or a dimer search), the low temperature , a lower bound on the HTST prefactors, and a confidence level . The output is the next event at and its time. The method assumes that every event has the HTST rate , with the same prefactor and barrier at both temperatures.
The algorithm
TAD(basin, T_low, T_high, ν_min, δ)- 1
t_high ← 0; t_short ← ∞; t_stop ← ∞ - 2
while t_high < t_stop - 3
run MD at T_high to the next escape, or to t_stop; t_high ← t_high + its time - 4
if the escape is a new event: find its saddle energy E_a; put the system back in the basin - 5
t_low ← t_high exp(E_a (1/(k_B T_low) - 1/(k_B T_high))) - 6
if t_low < t_short: t_short ← t_low; best ← this event - 7
t_stop ← (ln(1/δ)/ν_min) (ν_min t_short / ln(1/δ))^(T_low/T_high) - 8
return best, t_short
Line L4 matters twice. Only the first occurrence of each event is extrapolated, because a repeat says nothing new. And the system is put back into the basin after an escape, so that the high temperature run continues to sample escapes from the same basin; then the escapes of each event form a Poisson process. Line L5 is the HTST ratio of the rates at the two temperatures: the prefactor cancels, and only the barrier is needed. Line L7 is the stop rule: an event not seen by has, with confidence , a rate at so small that its extrapolated time is longer than , because its prefactor is at least . After the return, the low temperature clock advances by , the system moves to the end state of the event best, and TAD starts again in the new basin.
Example
By hand. Take , , and , so and line L7 reads . The first escape is event with at : , and . The next escape is event with at : , which is shorter, so is the best event and . Now and the run stops. The result is event at the low temperature time 1.832. Event came first at the high temperature, but comes first at the low one, because its barrier is lower.
A catalog. Take three events with prefactors and barriers eV, K and K. The high temperature run is the race of the three HTST Poisson processes (a stand-in for MD that satisfies the assumptions exactly). At 600 K the event frequencies are 0.230, 0.437 and 0.333 and the mean escape time is 3645 ps. At 300 K the exact probabilities are 0.518, 0.374 and 0.108, and the mean time is ps. 2000 runs of TAD, random.Random(4):
| (1/ps) | event | event | event | mean (ps) | mean (ps) | measured boost | escapes per run | |
|---|---|---|---|---|---|---|---|---|
| 1 | 0.001 | 0.516 | 0.368 | 0.116 | 26092 | 4782 | 8.13 | |
| 1 | 0.05 | 0.514 | 0.375 | 0.111 | 17462 | 7434 | 5.76 | |
| 1 | 0.3 | 0.500 | 0.388 | 0.113 | 11164 | 11650 | 4.01 | |
| 20 | 0.001 | 0.378 | 0.479 | 0.144 | 6439 | 22830 | 2.63 | |
| 100 | 0.001 | 0.258 | 0.460 | 0.282 | 4104 | 49930 | 1.69 |
The standard error of a fraction is about 0.011, and of the mean time about ps. With , a true lower bound, the fractions and the mean time agree with the exact law for every shown; the bound of the proof is not tight. With or 100, above the prefactor of event , the run stops before the slow event is seen, and the result is wrong. The boost, the low temperature time over the high temperature time, is a measurement; it grows as the assumptions are weakened.
Correctness
The proof is in the correctness proof of this page. Under HTST the first high temperature time of event is exponential with the rate , and the factor of line L5 is , so the extrapolated time is exponential with the low temperature rate . The events are independent because the system is put back into the basin. So the minimum of the extrapolated times is the race of exponential clocks at , which is exact if all events are seen. The stop rule loses an event only if its extrapolated time would beat although it was not seen by ; with , this has a probability less than for each event. Both results are theorems in the HTST model. For a real system they are as good as HTST: anharmonic effects and events that matter only at the high temperature are errors that the method does not detect.
Proof: Why the extrapolated times give the low temperature event, and the error of the stop timefull
The claim of TAD is a claim under harmonic transition state theory (HTST). We state the model, prove that the extrapolation is exact in the model, and bound the error of the stop rule.
Model. The basin has events . Under HTST, event has the rate at temperature , with a prefactor and a barrier that do not depend on . At the high temperature, the system is put back into the basin after each escape, so the occurrences of event form a Poisson process of rate , independent of the other events. Let be the first occurrence of event ; then are independent and exponential with the rates . Write , , , and .
Lemma 1 (the extrapolation). The extrapolated times of line L5 are independent and exponential with the rates .
Proof. Under HTST, , because the prefactor cancels. If is exponential with rate , then is exponential with rate . So is exponential with rate . Independence carries over from the .
Theorem 1 (exact without a stop). If the high temperature run continues until every event has occurred once, the event with the shortest and the time have the law of the first event at the low temperature: the time is exponential with rate , and the event is with probability .
Proof. By Lemma 1, the are independent exponential clocks with the low temperature rates. The first of independent exponential clocks has these two laws; this is the race of the kinetic Monte Carlo method.
Theorem 2 (the stop rule). Suppose that for every event. Let , and let the run stop at , where is the shortest extrapolated time of the events seen so far (line L7). Then for each event , the probability that is not seen before the stop and would have had a shorter extrapolated time than the accepted event is less than . So the result differs from the exact result of Theorem 1 with probability less than .
Proof. Fix and condition on the first occurrences of all other events. The value at the stop, and so , depend only on the events seen, so if is not seen they are fixed numbers, independent of . Event causes an error only if and .
First, a bound on the low temperature rate. From and we get . Since and , . With and the definition of , which gives :
Now the probability. means . So the error has the probability
The right side is positive only if , that is, , because . Then it is less than . The bound holds for every value of the other events, so it holds without the condition. A union bound over the events gives the last claim.
What the theorems need. Both theorems use HTST at both temperatures: the same prefactor and barrier at and , and independent exponential escapes. Anharmonic effects change the prefactor with temperature, and at a high temperature new events (with high barriers and large prefactors) can become important; then the extrapolation is wrong by the ratio of the true rates to the HTST rates. Theorem 2 also needs to be a true lower bound on the prefactors. The test with , above every prefactor, shows the failure: the slow event with the lowest barrier is missed.
What is not proved. The boost is not part of the theorems. It is a measurement of each run.
The derivation of here is ours. We did not compare it line by line with the equation in the paper of Sorensen and Voter.
Complexity
For escapes before the stop, the cost is high temperature runs to an escape plus one saddle search for each new event, in the real RAM model, and memory for the list of events. The number of escapes grows like times a factor that depends on the spread of the barriers, and the boost is roughly from line L7; the boost of a run is a measurement.
Properties
- Exact under HTST with all events seen. The extrapolation maps the high temperature law to the low temperature law event by event.
- Controlled error from the stop. With a true , the probability of a wrong event is at most for each event.
- Needs the barriers. Unlike parallel replica dynamics, every new event needs a saddle search.
- Randomized. The output is one sample of the next event.
Variants and improvements
- A known minimum barrier. If all barriers of the basin are known to be at least , the stop rule can use in place of, or with, , and the run can stop earlier.
- Synthetic mode. Once the events of a basin are known, their HTST rates are known, and the high temperature run can be replaced by draws from the catalog, as in the example.
- Reuse of past visits. When the system comes back to a basin, the high temperature time already spent there and the events found can be kept.
- Parallel TAD. Several high temperature runs of the same basin, or of basins that the system will probably visit next, run at the same time.
When to use it
Use TAD for solids at low temperature, where HTST is accurate and escapes are much too rare for direct MD, and where saddle searches are affordable, for example for diffusion on metal surfaces and the growth of films. Do not use it when the prefactors depend strongly on the temperature, for soft or entropic systems, or when the high temperature opens events, such as melting, that do not exist at the low one. Use kinetic Monte Carlo when the catalog is known in advance, and parallel replica dynamics when HTST is not reliable.
Pitfalls
- A prefactor bound that is too high. The stop comes too early, and slow events with low barriers are missed, as the rows with and 100 show. Nothing in the run shows this.
- Anharmonic effects. At the high temperature the rates deviate from HTST, and the extrapolation is wrong by the ratio of the true rate to the HTST rate.
- A high temperature that is too high. Events with high barriers and large prefactors dominate, the run needs more escapes, and the system may melt or change phase.
- Forgetting to put the system back. Without the reflection into the basin, the run leaves the basin and the events no longer race from the same state.
- Counting repeats. A repeated event must keep its first time; using a later time biases the extrapolation.
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/temperature-accelerated-dynamics/. The authors are listed in prov/FJ0MZ4.jsonl.
"""One basin of temperature accelerated dynamics (Sorensen and Voter 2000).
The dynamics runs at a high temperature T_high. Each escape from the basin
is an event: its saddle energy E_a (above the minimum) is found, and the
system goes back into the basin. The time t_high of the first occurrence
of each event is extrapolated to the low temperature T_low with harmonic
transition state theory (HTST):
t_low = t_high exp(E_a (1 / kT_low - 1 / kT_high)).
The event with the shortest t_low is the one that happens first at T_low.
The high temperature run stops at
t_stop = (ln(1/delta) / nu_min) (nu_min t_short / ln(1/delta))^(T_low / T_high),
where t_short is the shortest t_low so far. If every event has an HTST
prefactor of at least nu_min, then with confidence 1 - delta no event not
seen by t_stop would have a shorter t_low.
The method assumes HTST at both temperatures: each event is a Poisson
process with the rate nu exp(-E_a / kT), with the same nu at both
temperatures. The boost t_short / t_high is a measurement.
"""
import math
from typing import Callable, Hashable
def temperature_accelerated_dynamics(run_high: Callable, barrier: Callable[[Hashable], float],
kT_low: float, kT_high: float, nu_min: float, delta: float,
rng, max_escapes: int = 10**6):
"""Find the first event of the basin at the low temperature.
run_high(rng) runs the high temperature dynamics from the basin to the
next escape and returns (dt, event), the time and a label of the escape;
after it the system is back in the basin. barrier(event) returns E_a.
Returns (event, t_low, t_high, escapes, seen): the accepted event, its
low temperature time (the advance of the low temperature clock), the
total high temperature time, the number of escapes, and a dict from
each event seen to its extrapolated time.
"""
t_high = 0.0 # @line L1
t_short, best, t_stop = math.inf, None, math.inf
log_inv = math.log(1.0 / delta)
seen = {}
escapes = 0
while t_high < t_stop: # @line L2
if escapes >= max_escapes:
raise RuntimeError("temperature_accelerated_dynamics: max_escapes exceeded")
dt, event = run_high(rng) # @line L3
escapes += 1
if t_high + dt >= t_stop:
t_high = t_stop
break
t_high += dt
if event in seen:
continue
e_a = barrier(event) # @line L4
t_low = t_high * math.exp(e_a * (1.0 / kT_low - 1.0 / kT_high)) # @line L5
seen[event] = t_low
if t_low < t_short: # @line L6
t_short, best = t_low, event
t_stop = (log_inv / nu_min) * (nu_min * t_short / log_inv) ** (kT_low / kT_high) # @line L7
return best, t_short, t_high, escapes, seen # @line L8
def catalog_high_temperature_run(events, kT_high):
"""Return run_high(rng) for a catalog {event: (nu, E_a)} of HTST events.
The escape at T_high is the first of independent Poisson processes with
the rates nu exp(-E_a / kT_high), the model that TAD assumes. This stands
in for molecular dynamics in tests and examples.
"""
labels = list(events)
rates = [events[e][0] * math.exp(-events[e][1] / kT_high) for e in labels]
total = sum(rates)
def run_high(rng):
dt = rng.expovariate(total)
u = rng.random() * total
for e, r in zip(labels, rates):
u -= r
if u < 0.0:
return dt, e
return dt, labels[-1]
return run_high
test_temperature_accelerated_dynamics.py 96 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/temperature-accelerated-dynamics/. The authors are listed in prov/FJ0MZ4.jsonl.
import math
import random
import pytest
from temperature_accelerated_dynamics import catalog_high_temperature_run, temperature_accelerated_dynamics
K_B = 8.617333262e-5 # eV / K
KT_LOW = K_B * 300.0
KT_HIGH = K_B * 600.0
# event: (prefactor in 1/ps, barrier in eV)
EVENTS = {"a": (1.0, 0.50), "b": (5.0, 0.55), "c": (10.0, 0.60)}
def barrier(event):
return EVENTS[event][1]
def low_temperature_law():
rates = {e: nu * math.exp(-ea / KT_LOW) for e, (nu, ea) in EVENTS.items()}
total = sum(rates.values())
return {e: r / total for e, r in rates.items()}, 1.0 / total
class Scripted:
def __init__(self, escapes):
self.escapes = list(escapes)
def __call__(self, rng):
return self.escapes.pop(0)
def test_extrapolation_and_stop_time_by_hand():
# kT_low = 1, kT_high = 2, nu_min = 1, ln(1/delta) = 1.
run = Scripted([(1.0, "a"), (0.5, "b"), (9.0, "a")])
energies = {"a": 2.0, "b": 0.4}
event, t_low, t_high, escapes, seen = temperature_accelerated_dynamics(
run, energies.get, 1.0, 2.0, 1.0, math.exp(-1.0), None)
# a at t_high = 1: t_low = e; t_stop = e^(1/2) = 1.6487.
assert seen["a"] == pytest.approx(math.e)
# b at t_high = 1.5: t_low = 1.5 e^0.2 = 1.83210; t_stop = 1.35355 < 1.5, stop.
assert seen["b"] == pytest.approx(1.5 * math.exp(0.2))
assert event == "b" and t_low == pytest.approx(1.832104, abs=1e-6)
assert t_high == 1.5 and escapes == 2
assert run.escapes == [(9.0, "a")]
def test_repeated_events_keep_the_first_time():
run = Scripted([(1.0, "a"), (1.0, "a"), (1.0, "b"), (100.0, "b")])
energies = {"a": 6.0, "b": 6.0}
event, t_low, t_high, escapes, seen = temperature_accelerated_dynamics(
run, energies.get, 1.0, 2.0, 1.0, math.exp(-1.0), None)
# a first at t_high = 1: t_low = e^3, t_stop = e^1.5 = 4.48. The second a
# is ignored. b at t_high = 3 has t_low = 3 e^3, which is longer.
assert event == "a" and t_low == pytest.approx(math.exp(3.0))
assert seen == {"a": pytest.approx(math.exp(3.0)), "b": pytest.approx(3.0 * math.exp(3.0))}
assert t_high == pytest.approx(math.exp(1.5)) and escapes == 4
def test_low_temperature_law_is_reproduced():
fractions, mean_time = low_temperature_law()
run = catalog_high_temperature_run(EVENTS, KT_HIGH)
rng = random.Random(4)
n = 1000
counts = {e: 0 for e in EVENTS}
times = []
for _ in range(n):
event, t_low, _, _, _ = temperature_accelerated_dynamics(run, barrier, KT_LOW, KT_HIGH, 1.0, 1e-3, rng)
counts[event] += 1
times.append(t_low)
for e, p in fractions.items():
assert abs(counts[e] / n - p) < 3.0 * math.sqrt(p * (1.0 - p) / n)
mean = sum(times) / n
se = math.sqrt(sum((v - mean) ** 2 for v in times) / (n - 1) / n)
assert abs(mean - mean_time) < 3.0 * se
def test_a_wrong_minimum_prefactor_breaks_the_law():
# nu_min = 100 is above every prefactor, so the run stops too early and
# misses the slow event a, which has the lowest barrier.
fractions, _ = low_temperature_law()
run = catalog_high_temperature_run(EVENTS, KT_HIGH)
rng = random.Random(4)
n = 1000
to_a = sum(temperature_accelerated_dynamics(run, barrier, KT_LOW, KT_HIGH, 100.0, 1e-3, rng)[0] == "a"
for _ in range(n))
assert fractions["a"] == pytest.approx(0.5177, abs=1e-4)
assert to_a / n < 0.4
def test_max_escapes():
run = catalog_high_temperature_run(EVENTS, KT_HIGH)
with pytest.raises(RuntimeError):
temperature_accelerated_dynamics(run, barrier, KT_LOW, KT_HIGH, 1.0, 1e-3, random.Random(1), max_escapes=1)
History
Sorensen and Voter gave temperature accelerated dynamics in 2000, as the third of Voter's accelerated molecular dynamics methods after hyperdynamics in 1997 and parallel replica dynamics in 1998. The review of Voter, Montalenti and Germann in 2002 compares the three methods.
References
- Mads R. Sorensen and Arthur F. Voter, Temperature-accelerated dynamics for simulation of infrequent events, The Journal of Chemical Physics 112(21), 2000, 9599-9606, the extrapolation of the event times, the stop time with the minimum prefactor and the confidence level, and the reflection back into the basin
- 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 section on temperature accelerated dynamics and its assumptions
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 FJ0MZ4 Edit this page History Report an error Markdown