Learn

Monte Carlo

Molecular dynamics is one way to sample the Boltzmann distribution. Monte Carlo is the other way. Instead of following the forces, it makes random moves and accepts them with the right probability. It has no time, but it can make moves that no trajectory could make.

    The Metropolis rule

    Propose a random change. If the energy goes down, accept it. If it goes up by ΔU, accept it with probability e−ΔU/kT. That is all. The resulting chain of states follows the Boltzmann distribution exactly, because the rule satisfies detailed balance.

    Pacc(old → new) = min(1, e−(Unew − Uold)/kT)

    The step size is the only tuning knob. If it is too small, nearly every move is accepted, but the walker barely moves. If it is too large, nearly every move is rejected. What matters is not the acceptance rate but how many independent samples you get, which the autocorrelation time τ measures.

    Try: compare δ = 0.05, 1.5, and 5. Both extremes give a long τ. The best value here is around 1.5, with an acceptance rate well below 50%.

    Same ensemble, different route

    MD at constant temperature and Metropolis MC sample the same canonical ensemble, so all static averages must agree, such as energies, g(r), and densities. Dynamic quantities, such as diffusion coefficients, exist only in MD.

    MC wins when there are clever moves that MD cannot make, for example swapping two particles, regrowing a polymer chain, inserting a molecule, or flipping a spin. MD wins for dense, complex systems where good moves are hard to design, and it runs efficiently in parallel.

    Try: wait for the two averages to settle. They agree to about 1%, and the rest is statistical noise and the finite MD time step, although the two boxes never look alike frame by frame.

    Phase transitions and the Ising model

    The Ising model has spins that point up or down on a lattice, and each spin prefers to align with its neighbors. Below the critical temperature, Tc = 2.269, one direction wins, and above it, the order melts. The Ising model is the standard example of a phase transition, and it maps directly onto lattice gases and binary mixtures.

    Near Tc, the domains come in all sizes and the fluctuations are huge, so the heat capacity and susceptibility peak. Single spin flips also become very slow there (critical slowing down), which is why cluster algorithms such as Wolff were invented. Finite boxes round off the transition, so the true Tc comes from comparing several box sizes.

    Try: T = 2.0, 2.27, and 2.6. At 2.27, the pattern never settles. Drag on the lattice to paint an island, and see whether it survives.

    Chemical potential by insertion

    The chemical potential tells you how much a system wants another molecule. It decides solubility, partitioning between phases, and adsorption. Widom's method measures it by inserting a ghost particle at random and averaging its Boltzmann factor, without ever really adding the particle.

    μex = −kT ln <e−ΔU/kT>

    It works well for small molecules in fluids that are not too dense. In a dense liquid, almost every insertion overlaps with a particle, and the average is decided by the rare lucky ones. Then, the estimate converges slowly, and it is better to use free energy perturbation in steps or thermodynamic integration instead.

    Try: at density 0.1, the estimate converges almost at once. At 0.7, only a tiny fraction of the ghosts fit, and the running value jumps around for a long time.