Learn

Molecular dynamics

MD solves Newton's equations for every particle, one small time step at a time. Most of the skill lies in four choices. You have to decide how to step forward in time, how far to compute forces, what to do at the edges of the box, and how to hold the temperature.

    Stepping forward in time

    The simplest idea, Euler's method, updates positions with the old velocity and velocities with the old force. It looks fine for one step but adds a little energy every time, so the orbit spirals outward.

    Velocity Verlet splits the velocity update into two halves around the position update. It is time-reversible and keeps the energy bounded, which is why almost every MD code uses it, or its close relative, the leapfrog scheme.

    v(t + dt/2) = v(t) + (dt/2m) F(t)
    x(t + dt) = x(t) + dt v(t + dt/2)
    v(t + dt) = v(t + dt/2) + (dt/2m) F(t + dt)

    Try: raise dt. Euler blows up quickly, while Verlet stays on a slightly distorted ellipse until dt gets close to 2/ω, where it also becomes unstable. In real systems, the fastest motion, often an X-H bond vibration, sets dt (1 to 2 fs).

    Cutting off the interactions

    Computing every pair costs O(N2). Short-range forces such as Lennard-Jones are therefore cut at a distance rc, usually 2.5σ or about 1 to 1.2 nm, and neighbor lists keep track of which particles are close.

    A plain cut makes the energy jump when a pair crosses rc, which spoils energy conservation. Shifting the potential fixes the energy, but the force still jumps. Force-shifted or switched potentials make both smooth. Long-range electrostatics are not cut at all, but handled with Ewald sums or PME.

    Try: switch between the three kinds at a short cutoff, such as 1.3, and look at what happens at rc.

    Periodic boundaries

    A simulation box holds thousands of particles, far fewer than a real sample, and a large share of them would sit at a surface. Periodic boundaries remove this surface. The box is surrounded by copies of itself, and a particle that leaves one side comes back on the other.

    Each particle only interacts with the nearest copy of every other particle, which is called the minimum image. This is also why the cutoff must be less than half the box length.

    dx = xj − xi
    dx = dx − L · round(dx / L)

    Try: click a particle near an edge. Some of its neighbors are on the far side of the box.

    Holding the temperature

    Plain MD conserves energy (the NVE ensemble). To simulate at a fixed temperature, a thermostat adds or removes kinetic energy. The temperature itself comes from the kinetic energy, which in 2D gives kBT = Σ m v2 / 2N.

    • Berendsen rescales velocities toward the target. It is smooth and quick, but it suppresses fluctuations, so it does not give a correct canonical ensemble. It is fine for equilibration.
    • Langevin adds friction and random kicks to each particle. It samples the canonical ensemble correctly, but it disturbs the dynamics.
    • Nosé-Hoover and the velocity-rescaling thermostat of Bussi et al. are the usual choices for production runs.

    Try: start with no thermostat and watch T drift as the lattice melts. Then, switch on Berendsen and Langevin, and compare the size of the fluctuations.

    Newton's equations and the thermostats added to them

    Plain MD solves Newton's equations of motion, m dv/dt = F. They keep the total energy constant, so the temperature is whatever the energy allows (the NVE ensemble). To hold the temperature at a set value, a thermostat changes the equations. Here, the same starting configuration is copied six times. The first two copies follow Newton's equations with two different time-step rules. The other four add a thermostat, or, in the Brownian case, drop inertia.

    • Newton with Euler steps uses the naive update. The energy grows every step until the system blows up. The equations are right, but the time-step rule is not.
    • Newton with velocity Verlet is plain Newtonian dynamics done right. The energy wobbles but does not drift, and the temperature settles wherever energy conservation puts it.
    • Langevin dynamics adds friction and random kicks on every particle. The temperature is correct, but momentum is not conserved, so hydrodynamic flow is damped.
    • Brownian dynamics is the overdamped limit, with no velocities at all. It is good for slow colloids and for polymers in implicit solvent, and it is the cheapest.
    • In DPD, friction and noise act on pairs, along the line between them, so momentum is conserved and flow behaves properly.
    • In Nosé-Hoover dynamics, one extra variable acts as a friction that turns positive when the system is too hot and negative when it is too cold. The method is deterministic, and the energy, including the thermostat, is conserved.
    Newton: m dv/dt = F
    Langevin: m dv/dt = F − γmv + √(2γmkT) ξ(t)
    Brownian: γ dx/dt = F + √(2γkT) ξ(t)
    Nosé-Hoover: m dv/dt = F − ζmv, dζ/dt = (T/T0 − 1)/τ2

    Try: push dt up and watch Euler fail first, and then everything else. If you change the target T, the two Newton copies ignore it, while the thermostats follow. If you raise γ, the Langevin and Brownian copies slow down, while DPD still flows.