Algorithmadvanced
QM/MM method
Also called hybrid quantum mechanics molecular mechanics.
Treats a small reactive region by quantum mechanics and the rest by a molecular mechanics force field, with coupling terms between them.
- Time
- O(q^3 + N) worst
- Space
- O(q^2 + N) extra
- Where
- N = the number of atoms; q = the number of sites in the QM model system
- Model
- Real RAM
- Properties
- deterministicnot exactnot iterativenot randomized
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Arieh Warshel, Michael Levitt, 1976
The QM/MM method computes the energy and forces of a large molecular system by treating a small region, where bonds break or electrons move, with quantum mechanics (QM), and everything else with a molecular mechanics force field (MM). Quantum calculations cost at least the cube of the size of the region, while force fields cost about linear time, so the split makes reactions in enzymes, in solution and in materials possible to model. The two regions are coupled by bonded terms across the boundary, by electrostatics and by van der Waals terms, and bonds cut by the boundary are capped with link atoms. With these energies and forces, the system can be optimized or moved by molecular dynamics in the spirit of Born-Oppenheimer molecular dynamics for the QM part.
In plain words
Think of an enzyme with thousands of atoms. Only a few of them take part in the chemical reaction; the rest hold the stage. Computing the electrons of all atoms would take far too long, so you compute the electrons only for the small group at the center, and treat all other atoms as balls on springs.
Where the two parts meet, a chemical bond is cut in two. To keep the small group chemically sensible, you put a stand-in atom, usually hydrogen, on the cut bond. The forces on the stand-in are passed back to the two real atoms of the bond. There are two ways to add up the energies: add the small group and the rest, taking care not to count anything twice, or compute the whole system cheaply and replace the cheap energy of the center by the accurate one.
The problem
The input is the positions of atoms, a QM region of atoms, a QM method that gives the energy and the forces of a small molecule, and an MM force field for the whole system. The output is a total energy and forces on all atoms, so that geometry optimization and molecular dynamics can use them. The model system is the QM region with a link atom on each cut bond , , , placed on the bond at
with a fixed ratio (for a carbon-hydrogen link that replaces a carbon-carbon bond, is near the ratio of the two bond lengths). The additive energy is
where couples the regions. The subtractive energy (IMOMM, ONIOM) is
In mechanical embedding, the coupling is the MM terms between QM and MM atoms. In electrostatic embedding, the MM charges also enter the QM Hamiltonian, so the electrons of the QM region are polarized by the environment.
The algorithm
QMMM-ADDITIVE(positions y, QM region Q, ratio g)- 1
build the model system: the atoms of Q, and a link atom at y_L = y_a + g (y_b - y_a) on each cut bond (a, b) - 2
(E_Q, F_Q) ← QM energy and forces of the model system - 3
for each link atom L on the cut bond (a, b): F_a ← F_a + (1 - g) F_L, F_b ← F_b + g F_L, then drop L - 4
(E_M, F_M) ← MM energy and forces of every term with at least one atom outside Q - 5
return E = E_Q + E_M and F = F_Q + F_M
The link atom is not a real atom: its position is a function of and , so its force must be passed to them by the chain rule, which is line L3. Line L4 takes the coupling terms (bonds, angles and dihedrals across the boundary, and the van der Waals terms between the regions) from the force field, which is mechanical embedding; in electrostatic embedding the MM charges also go into the QM calculation of line L2, and the MM terms of line L4 leave out the electrostatics between the regions, because the QM calculation already contains them.
The implementation is a toy. The QM method is a Hückel tight-binding model of a chain on a line, with hopping , one electron per site and the energy . The matrix is diagonalized by the Jacobi eigenvalue algorithm, and the forces follow from the Hellmann-Feynman formula. The MM part is harmonic bonds . The parameters , , , , , and are choices that make the numbers simple. The code also has the subtractive scheme.
Example
By hand. Three atoms sit at and atom is the QM region. The cut bond is , so line L1 puts the link atom at , and the model system is a dimer of length . Its hopping is and its repulsion is . The dimer has one bonding orbital with eigenvalue and two electrons, so line L2 gives , and
So the force on atom is and the force on the link atom is . Line L3 gives half of the link force to atom and half to atom : the QM forces on the real atoms are . Line L4 adds the cut bond, stretched by , with energy and forces on atoms and ; bond is at rest. The total is with .
Subtractive. For the same atoms, ONIOM gives : the MM energy of the real system is the cut bond, , and in the model system the link bond gets the MM parameters , so its MM energy is as well. The two schemes differ by the MM energy of the cut bonds, a fact that the proofs file proves for any chain with this choice of link parameters.
Dynamics. On a chain of 8 atoms with the QM region of atoms to (two link atoms, a model system of 6 sites), velocity Verlet over 5 time units keeps the total energy to within at and at for the additive scheme, and and for ONIOM. The ratio is close to , the second order of the integrator, which shows that the forces are the gradient of the energy (measurement).
Correctness
The proofs file shows, for the toy, that the forces are the exact negative gradient of the energy. The model system of an even number of sites on a chain always has a gap between the occupied and the empty orbitals, because the spectrum is symmetric about and is not an eigenvalue; with the gap, the derivative of the sum of the occupied eigenvalues is the Hellmann-Feynman expression . The link atom position is linear in the positions of and , so line L3 is the chain rule. The proof also shows that the forces sum to zero, that both schemes give the pure QM energy when contains all atoms, and that the additive minus the subtractive energy is the MM energy of the cut bonds.
For a real QM method, the same argument needs a converged self-consistent field: the Hellmann-Feynman forces are the gradient only at the variational minimum, and with a basis of atom-centered functions they need the Pulay terms as well. The quality of the result, how close is to the energy of a full QM calculation, is not a theorem: it depends on the size of the QM region, the boundary and the embedding, and is checked by tests that enlarge the region.
Proof: The toy QM/MM forces are the exact gradient of the QM/MM energy, and the energy has the right limitsfull
Setup. Atoms sit at on a line. The QM region is the block . Each cut bond , with and a neighbor of , gets a link atom at with a fixed . The model system is the ordered list of sites: the left link atom if there is one, the atoms of , and the right link atom if there is one. Each site position is with fixed weights (line L1). For sites with bond lengths and , the tight-binding matrix has and zeros elsewhere, and
with the eigenvalues and even. The additive energy is , where sums over all bonds with at least one atom outside . We assume exact arithmetic and an exact eigensolver.
Lemma 1 (a gap at half filling). If is even and every , then .
Proof. has a zero diagonal and the sites form a path, so the matrix satisfies , and the spectrum is symmetric about . Expanding the determinant of a tridiagonal matrix with zero diagonal along the first row gives , so , and is not an eigenvalue. A symmetric spectrum without has exactly negative eigenvalues.
Lemma 2 (Hellmann-Feynman for the occupied sum). Let be orthonormal eigenvectors of the occupied eigenvalues. Under the gap of Lemma 1,
Proof. Let , the projector onto the occupied space, so . Because of the gap, is a smooth function of (it is the Riesz projector, a contour integral of the resolvent around the negative eigenvalues). Differentiate: . From we get , so and . Hence . Since commutes with , , and the same holds for the other term. So . Only depend on , with derivative , so . Summing over and multiplying by gives the formula.
Lemma 3 (the QM site forces). Function qm_chain returns .
Proof. By Lemma 2 and , the code computes as de_dr. Since , bond contributes to and to . The code adds the negatives of these: de_dr to and minus de_dr to .
Lemma 4 (the link atom forces). Line L3 returns for each atom .
Proof. is linear, so . Function _spread adds for every site and every atom in it. For a link atom of the cut bond this gives to and to .
Theorem (correctness). (i) Lines L1 to L5 return and exactly. (ii) . (iii) If contains all atoms, the additive and the subtractive energies both equal . (iv) If a bond to a link atom gets the MM parameters in the model system, then is the MM energy of the cut bonds.
Proof. (i) Lemmas 3 and 4 for the QM part; for the MM part, and the code adds to and subtracts it from . (ii) depends on the positions only through differences, because the rows of sum to , so and . (iii) With equal to all atoms there are no cut bonds, and every bond has both atoms in , so and . In ONIOM, the model system is the real system and has the same MM bonds, so . (iv) For a cut bond , the link bond has length , so its MM energy in the model is , the MM energy of the cut bond. So is the MM energy of the bonds inside plus that of the cut bonds, and is plus the MM energy of the bonds with both atoms outside . The additive energy is plus the MM energy of all bonds with at least one atom outside , which also counts the cut bonds.
Remark. Statement (i) is what makes molecular dynamics with these forces conserve the total energy up to the error of the integrator, which the tests measure. In real QM/MM programs, the QM energy comes from a self-consistent method, and the Hellmann-Feynman step of Lemma 2 needs the self-consistent solution to be converged; a partly converged solution gives forces that are not the exact gradient.
Complexity
In the real RAM model, the toy costs per sweep of the Jacobi method on the by matrix of the model system, with a capped number of sweeps, and for the bonds of the MM part, so an energy and force evaluation is with memory. In real programs, the QM part dominates: Hartree-Fock and density functional methods cost between the cube and the fourth power of the number of basis functions, and correlated methods more, while the MM part costs with particle mesh Ewald electrostatics. Electrostatic embedding adds the MM charges to the QM Hamiltonian, at a cost linear in per QM matrix element of the external potential.
Properties
- Consistent forces. With a converged QM calculation and the chain rule for link atoms, the forces are the gradient of a single energy, so dynamics conserve energy and optimizations converge (theorem for the toy, Lemma 2 and Lemma 4 of the proofs file).
- Correct limits. If the QM region is the whole system, both schemes give the QM energy (theorem). If the QM method is replaced by the MM method, the subtractive scheme gives the MM energy of the real system exactly (theorem, from the form of the formula).
- Additive versus subtractive. The subtractive scheme needs no special coupling terms and works with any pair of methods, but needs MM parameters for the model system, including the QM region. The additive scheme needs no MM parameters inside the QM region, which matters when bonds change.
- Approximate. The result depends on the choice of the QM region, the link atoms and the embedding, and must be checked by enlarging the QM region (heuristic).
- Translation invariance. The energy depends only on the relative positions, so the forces sum to zero (theorem).
Variants and improvements
- Electrostatic embedding. The MM point charges enter the QM Hamiltonian, which polarizes the QM region. This is the common choice for reactions in proteins and solution. Charges next to the link atom are often removed, shifted or smeared, to avoid an overpolarization of the boundary.
- Polarizable embedding. The MM region has induced dipoles or fluctuating charges, which respond to the QM region in turn.
- Other boundary treatments. Instead of link atoms, the cut bond can be capped by frozen localized orbitals or by a boundary atom with special parameters (pseudopotentials).
- Several layers. ONIOM uses three or more layers, each with its own method, by repeating the subtraction.
- Adaptive QM/MM. Atoms enter and leave the QM region as they move, for example water molecules near a solute, with a smooth switching to keep the energy continuous.
- Machine learning potentials. A Behler-Parrinello or other learned potential can replace the QM method, or the MM region, at a much lower cost.
When to use it
Use QM/MM when a chemical event (a bond that breaks, a change of charge, an excited state) takes place in a small part of a large system, and the rest acts through its shape and its electrostatics. Use a plain molecular mechanics force field when no bonds change. Use a full QM method, as in Born-Oppenheimer or Car-Parrinello molecular dynamics, when the system is small enough or when the chemistry is spread out, for example in a metal. Use the quasicontinuum method for the analogous split between atoms and a continuum in solids.
Pitfalls
- The link force is dropped. Leaving out line L3, or giving all of to atom , gives forces that are not the gradient of the energy, and molecular dynamics drifts in energy. Write line L3 with the chain rule weights for and for .
- Terms counted twice. In the additive scheme, line L4 must leave out the MM terms with all atoms in , because already contains them; in the subtractive scheme, must use the same terms as for the model atoms. Write line L4 over the terms with at least one atom outside .
- Odd electron counts. A link atom adds one electron per cut bond. The toy raises an error when the model system has an odd number of electrons; a real calculation must set the charge and spin of the model system on purpose.
- Overpolarization at the boundary. In electrostatic embedding, an MM charge on atom sits very close to the link atom and pulls the QM electrons too strongly. Remove, shift or smear the charges next to the boundary.
- Cuts through polar or conjugated bonds. A link atom on a polar bond, or on a bond of a conjugated system, changes the electronic structure of the QM region. Cut nonpolar single bonds, two or three bonds away from the reacting atoms.
- A QM region too small. Results can change much with the size of the QM region. Check convergence by enlarging the region.
- Unconverged QM forces. A loose convergence of the self-consistent field gives forces that are not the gradient of the energy. Tighten the convergence for dynamics.
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/qm-mm-method/. The authors are listed in prov/CDM80T.jsonl.
"""A toy QM/MM calculation on a chain of atoms in one dimension.
This is a toy. The "QM" part is a Hueckel tight-binding model, not a real
electronic structure method, and the "MM" part is a chain of harmonic
bonds. The code shows the parts that every QM/MM program has: the split
into a QM region and an MM region, the link atoms that cap the cut bonds,
the transfer of the link atom forces onto the real atoms, and the two ways
to add the energies (additive and subtractive, also called ONIOM).
Atoms 0 .. n-1 sit at positions y[0] < y[1] < ... on a line, with a bond
between each pair of neighbors. The QM region is the block of atoms
q0 .. q1-1. Each bond (a, b) with a in the QM region and b outside it is
cut and gets a link atom at y_a + g (y_b - y_a).
QM model (for a chain of sites s_0 < s_1 < ... with bond lengths r_i):
H_{i,i+1} = -t(r_i), t(r) = t0 exp(-beta (r - r0)), one orbital per site,
one electron per site, each occupied orbital holds two electrons,
E_QM = 2 (sum of the occupied eigenvalues) + sum_i A exp(-2 beta (r_i - r0)).
MM model: E_MM = sum over bonds of (k / 2) (r - d0)^2.
"""
import math
from dataclasses import dataclass
from typing import Sequence
@dataclass(frozen=True)
class Params:
t0: float = 1.0 # hopping at r = r0
beta: float = math.log(2.0) # decay rate of the hopping
rep: float = 1.0 # repulsion A; with A = t0 the QM dimer has its minimum at r0
r0: float = 1.0
k: float = 10.0 # MM bond stiffness
d0: float = 2.0 # MM bond rest length
g: float = 0.5 # link atom placed at the fraction g of the cut bond
def jacobi_eigen(a: Sequence[Sequence[float]], tol: float = 1e-14,
max_sweeps: int = 60) -> tuple[list[float], list[list[float]]]:
"""Cyclic Jacobi method for a symmetric matrix.
Returns the eigenvalues in increasing order and the eigenvectors as rows
(vecs[k] belongs to vals[k]).
"""
n = len(a)
m = [list(map(float, row)) for row in a]
v = [[1.0 if i == j else 0.0 for j in range(n)] for i in range(n)]
scale = sum(m[i][j] ** 2 for i in range(n) for j in range(n)) or 1.0
for _ in range(max_sweeps):
off = sum(m[i][j] ** 2 for i in range(n) for j in range(n) if i != j)
if off <= tol * tol * scale:
break
for p in range(n - 1):
for q in range(p + 1, n):
if m[p][q] == 0.0:
continue
theta = (m[q][q] - m[p][p]) / (2.0 * m[p][q])
t = math.copysign(1.0, theta) / (abs(theta) + math.sqrt(theta * theta + 1.0))
c = 1.0 / math.sqrt(t * t + 1.0)
s = t * c
for r in range(n): # columns p and q
mrp, mrq = m[r][p], m[r][q]
m[r][p] = c * mrp - s * mrq
m[r][q] = s * mrp + c * mrq
for r in range(n): # rows p and q
mpr, mqr = m[p][r], m[q][r]
m[p][r] = c * mpr - s * mqr
m[q][r] = s * mpr + c * mqr
for r in range(n):
vrp, vrq = v[r][p], v[r][q]
v[r][p] = c * vrp - s * vrq
v[r][q] = s * vrp + c * vrq
else:
raise ArithmeticError("Jacobi method did not converge")
order = sorted(range(n), key=lambda i: m[i][i])
return [m[i][i] for i in order], [[v[r][i] for r in range(n)] for i in order]
def qm_chain(s: Sequence[float], p: Params) -> tuple[float, list[float]]:
"""Energy and forces of the tight-binding chain with sites at s (sorted)."""
n = len(s)
if n % 2 != 0:
raise ValueError("the model system needs an even number of sites (closed shell)")
r = [s[i + 1] - s[i] for i in range(n - 1)]
t = [p.t0 * math.exp(-p.beta * (ri - p.r0)) for ri in r]
h = [[0.0] * n for _ in range(n)]
for i in range(n - 1):
h[i][i + 1] = h[i + 1][i] = -t[i]
vals, vecs = jacobi_eigen(h)
occ = vecs[:n // 2]
energy = 2.0 * sum(vals[:n // 2])
f = [0.0] * n
for i in range(n - 1):
bond_order = 2.0 * sum(c[i] * c[i + 1] for c in occ)
phi = p.rep * math.exp(-2.0 * p.beta * (r[i] - p.r0))
energy += phi
# Hellmann-Feynman: dE_el/dr = 2 P dH/dr = 2 P beta t; dphi/dr = -2 beta phi
de_dr = 2.0 * bond_order * p.beta * t[i] - 2.0 * p.beta * phi
f[i] += de_dr
f[i + 1] -= de_dr
return energy, f
def mm_bonds(y: Sequence[float], bonds: Sequence[tuple[int, int, float, float]],
n: int) -> tuple[float, list[float]]:
"""Harmonic bonds (i, j, k, d0) with energy (k / 2) (y_j - y_i - d0)^2."""
energy = 0.0
f = [0.0] * n
for i, j, k, d0 in bonds:
stretch = (y[j] - y[i]) - d0
energy += 0.5 * k * stretch * stretch
f[i] += k * stretch
f[j] -= k * stretch
return energy, f
def model_sites(n: int, q0: int, q1: int, g: float) -> list[list[tuple[int, float]]]:
"""Each site of the model system as a list of (atom, weight); a link atom has two."""
if not 0 <= q0 < q1 <= n:
raise ValueError("the QM region must be a nonempty block of atoms")
sites = []
if q0 > 0:
sites.append([(q0, 1.0 - g), (q0 - 1, g)]) # cut bond (q0 - 1, q0)
sites.extend([[(i, 1.0)] for i in range(q0, q1)])
if q1 < n:
sites.append([(q1 - 1, 1.0 - g), (q1, g)]) # cut bond (q1 - 1, q1)
return sites
def _spread(site_forces: Sequence[float], sites: Sequence[Sequence[tuple[int, float]]],
n: int) -> list[float]:
"""Chain rule: a site at sum_w w y_atom passes the force w F_site to each atom."""
f = [0.0] * n
for fs, site in zip(site_forces, sites):
for atom, w in site:
f[atom] += w * fs
return f
def additive(y: Sequence[float], q0: int, q1: int, p: Params = Params()) -> tuple[float, list[float]]:
"""Additive QM/MM with link atoms and mechanical embedding."""
n = len(y)
sites = model_sites(n, q0, q1, p.g) # @line L1
s = [sum(w * y[a] for a, w in site) for site in sites]
e_qm, f_sites = qm_chain(s, p) # @line L2
f = _spread(f_sites, sites, n) # @line L3
mm = [(i, i + 1, p.k, p.d0) for i in range(n - 1) if not (q0 <= i and i + 1 < q1)]
e_mm, f_mm = mm_bonds(y, mm, n) # @line L4
return e_qm + e_mm, [a + b for a, b in zip(f, f_mm)] # @line L5
def oniom(y: Sequence[float], q0: int, q1: int, p: Params = Params()) -> tuple[float, list[float]]:
"""Subtractive QM/MM (ONIOM): E_MM(real) + E_QM(model) - E_MM(model).
In the model system, a bond to a link atom gets the MM parameters
(k / g^2, g d0), so that its MM energy equals that of the cut bond.
"""
n = len(y)
sites = model_sites(n, q0, q1, p.g)
s = [sum(w * y[a] for a, w in site) for site in sites]
e_real, f_real = mm_bonds(y, [(i, i + 1, p.k, p.d0) for i in range(n - 1)], n)
e_qm, f_qm = qm_chain(s, p)
model_bonds = []
for i in range(len(sites) - 1):
link = len(sites[i]) == 2 or len(sites[i + 1]) == 2
k, d0 = (p.k / p.g ** 2, p.g * p.d0) if link else (p.k, p.d0)
model_bonds.append((i, i + 1, k, d0))
e_low, f_low = mm_bonds(s, model_bonds, len(sites))
f_model = _spread([a - b for a, b in zip(f_qm, f_low)], sites, n)
return e_real + e_qm - e_low, [a + b for a, b in zip(f_real, f_model)]
def velocity_verlet(y: list[float], v: list[float], h: float, steps: int, q0: int, q1: int,
scheme=additive, p: Params = Params()) -> list[float]:
"""NVE run with unit masses; returns the total energy after each step."""
e, f = scheme(y, q0, q1, p)
energies = []
for _ in range(steps):
for i in range(len(y)):
v[i] += 0.5 * h * f[i]
y[i] += h * v[i]
e, f = scheme(y, q0, q1, p)
for i in range(len(y)):
v[i] += 0.5 * h * f[i]
energies.append(e + 0.5 * sum(vi * vi for vi in v))
return energies
test_qm_mm_method.py 99 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/qm-mm-method/. The authors are listed in prov/CDM80T.jsonl.
import math
import random
import pytest
from qm_mm_method import Params, additive, jacobi_eigen, model_sites, oniom, qm_chain, velocity_verlet
def chain(n, seed, jitter=0.1):
rng = random.Random(seed)
return [2.0 * i + rng.uniform(-jitter, jitter) for i in range(n)]
def test_jacobi_matches_the_eigenvalues_of_a_uniform_chain():
n = 6
h = [[-1.0 if abs(i - j) == 1 else 0.0 for j in range(n)] for i in range(n)]
vals, vecs = jacobi_eigen(h)
exact = sorted(-2.0 * math.cos(k * math.pi / (n + 1)) for k in range(1, n + 1))
assert vals == pytest.approx(exact, abs=1e-12)
for lam, c in zip(vals, vecs):
hc = [sum(h[i][j] * c[j] for j in range(n)) for i in range(n)]
assert hc == pytest.approx([lam * ci for ci in c], abs=1e-12)
def test_dimer_by_hand():
# Two sites at the distance r0: t = 1, E = -2 t + A = -1 and no force.
e, f = qm_chain([0.0, 1.0], Params())
assert e == pytest.approx(-1.0, abs=1e-14)
assert f == pytest.approx([0.0, 0.0], abs=1e-14)
def test_three_atom_example_by_hand():
# Atom 0 is QM; the link atom sits at 0 + 0.5 * 2.2 = 1.1.
y = [0.0, 2.2, 4.2]
t, phi = 2.0 ** -0.1, 2.0 ** -0.2
e_qm = -2.0 * t + phi
de_dr = 2.0 * math.log(2.0) * (t - phi)
e, f = additive(y, 0, 1)
assert e == pytest.approx(e_qm + 0.5 * 10.0 * 0.2 ** 2, abs=1e-12)
assert f == pytest.approx([2.0 + de_dr / 2, -2.0 - de_dr / 2, 0.0], abs=1e-12)
e2, f2 = oniom(y, 0, 1)
assert e2 == pytest.approx(e_qm, abs=1e-12)
assert f2 == pytest.approx([de_dr / 2, -de_dr / 2, 0.0], abs=1e-12)
@pytest.mark.parametrize("scheme", [additive, oniom])
@pytest.mark.parametrize("region", [(0, 3), (2, 6), (5, 8), (0, 8)])
def test_forces_are_minus_the_gradient(scheme, region):
y = chain(8, 1)
_, f = scheme(y, *region)
eps = 1e-6
for i in range(len(y)):
up, down = list(y), list(y)
up[i] += eps
down[i] -= eps
fd = -(scheme(up, *region)[0] - scheme(down, *region)[0]) / (2 * eps)
assert fd == pytest.approx(f[i], abs=1e-7)
assert abs(sum(f)) < 1e-12
def test_whole_system_in_the_qm_region_gives_the_qm_energy():
y = chain(6, 3)
e_qm, _ = qm_chain(y, Params())
assert additive(y, 0, 6)[0] == pytest.approx(e_qm, abs=1e-12)
assert oniom(y, 0, 6)[0] == pytest.approx(e_qm, abs=1e-12)
def test_additive_minus_subtractive_is_the_mm_energy_of_the_cut_bonds():
p = Params()
y = chain(8, 4, jitter=0.3)
cut = [(1, 2), (5, 6)]
e_cut = sum(0.5 * p.k * (y[j] - y[i] - p.d0) ** 2 for i, j in cut)
assert additive(y, 2, 6)[0] - oniom(y, 2, 6)[0] == pytest.approx(e_cut, abs=1e-12)
def test_link_atoms_and_odd_model_systems():
assert model_sites(5, 1, 3, 0.5) == [[(1, 0.5), (0, 0.5)], [(1, 1.0)], [(2, 1.0)], [(2, 0.5), (3, 0.5)]]
with pytest.raises(ValueError):
additive(chain(5, 0), 1, 2) # one QM atom and two link atoms: three electrons
with pytest.raises(ValueError):
additive(chain(5, 0), 3, 3)
@pytest.mark.parametrize("scheme", [additive, oniom])
def test_energy_is_conserved_to_second_order(scheme):
def drift(h):
rng = random.Random(2)
y = chain(8, 2)
v = [rng.gauss(0.0, 0.3) for _ in y]
mean = sum(v) / len(v)
v = [x - mean for x in v]
energies = velocity_verlet(y, v, h, round(5.0 / h), 2, 6, scheme)
return max(abs(e - energies[0]) for e in energies)
coarse, fine = drift(0.02), drift(0.01)
assert coarse < 1e-3
assert 3.0 < coarse / fine < 5.0
History
Warshel and Levitt built the first QM/MM model in 1976, for the reaction of the enzyme lysozyme, with a semiempirical quantum treatment of the reacting atoms inside a classical model of the protein and its dielectric. Field, Bash and Karplus gave in 1990 a general QM/MM potential with link atoms and electrostatic coupling, built into a molecular dynamics program. Maseras and Morokuma introduced the subtractive IMOMM scheme in 1995, and Svensson, Morokuma and coworkers generalized it to the multilayer ONIOM method in 1996. Karplus, Levitt and Warshel received the Nobel Prize in Chemistry in 2013 for multiscale models of complex chemical systems. Senn and Thiel reviewed the methods for biomolecular systems in 2009.
References
- A. Warshel and M. Levitt, Theoretical studies of enzymic reactions: dielectric, electrostatic and steric stabilization of the carbonium ion in the reaction of lysozyme, Journal of Molecular Biology 103(2), 1976, 227-249, the first combined model, with a quantum region inside a classical protein
- Martin J. Field, Paul A. Bash and Martin Karplus, A combined quantum mechanical and molecular mechanical potential for molecular dynamics simulations, Journal of Computational Chemistry 11(6), 1990, 700-733, the additive QM/MM Hamiltonian with link atoms and electrostatic coupling, used for molecular dynamics
- Feliu Maseras and Keiji Morokuma, IMOMM: A new integrated ab initio + molecular mechanics geometry optimization scheme of equilibrium structures and transition states, Journal of Computational Chemistry 16(9), 1995, 1170-1179, the subtractive combination of an ab initio model system with molecular mechanics for the whole system
- Mats Svensson, Stephane Humbel, Robert D. J. Froese, Toshiaki Matsubara, Stefan Sieber and Keiji Morokuma, ONIOM: A multilayered integrated MO + MM method for geometry optimizations and single point energy predictions, The Journal of Physical Chemistry 100(50), 1996, 19357-19363, the ONIOM extrapolation with several layers
- Hans Martin Senn and Walter Thiel, QM/MM methods for biomolecular systems, Angewandte Chemie International Edition 48(7), 2009, 1198-1229, a review of additive and subtractive schemes, mechanical and electrostatic embedding, and the treatment of the boundary
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 CDM80T Edit this page History Report an error Markdown