The Wang and Landau algorithm, proposed by Fugao Wang and David P. Landau, is a Monte Carlo method designed to calculate the density of states of a system. The method performs a non-Markovian random walk to build the density of states by quickly visiting all the available energy spectrum. The Wang and Landau algorithm is an important method to obtain the density of states required to perform a multicanonical simulation.
Contents
The Wang–Landau algorithm can be applied to any system which is characterized by a cost (or energy) function. For instance, it has been applied to the solution of numerical integrals and the folding of proteins. The Wang-Landau sampling is related to the metadynamics algorithm.
Overview
The Wang and Landau algorithm is used to obtain the density of states of a system characterized by a cost function. It uses a non-Markovian stochastic process which asymptotically converges to a multicanonical ensemble. (I.e. to a Metropolis-Hastings algorithm with sampling distribution inverse to the density of states.) The major consequence is that this sampling distribution leads to a simulation where the energy barriers are invisible. This means that the algorithm visits all the accessible states (favorable and less favorable) much faster than a Metropolis algorithm.
Algorithm
Consider a system defined on a phase space
Given this discrete spectrum, the algorithm is initialized by:
The algorithm then performs a multicanonical ensemble simulation: a Metropolis-Hastings random walk in the phase space of the system with a probability distribution given by
- proposing a state
r ′ ∈ Ω according to the arbitrary proposal distributiong ( r → r ′ ) - accept/refuse the proposed state according to
After each proposal-acceptance step, the system transits to some value
This is the crucial step of the algorithm, and it is what makes the Wang and Landau algorithm non-Markovian: the stochastic process now depends on the history of the process. Hence the next time there is a proposal to a state with that particular energy
It was later shown that updating the f by constantly dividing by two can lead to saturation errors. A small modification to the Wang and Landau method to avoid this problem is to use the f factor proportional to
Test system
We want to obtain the DOS for the harmonic oscillator potential.
The analytical DOS is given by,
by performing the last integral we obtain
In general, the DOS for a multidimensional harmonic oscillator will be given by some power of E, the exponent will be a function of the dimension of the system.
Hence, we can use a simple harmonic oscillator potential to test the accuracy of Wang–Landau algorithm because we know already the analytic form of the density of states. Therefore, we compare the density of states
Sample code
The following is a sample code of the Wang–Landau algorithm in Python, where we assume that a symmetric proposal distribution g is used:
The code considers a "system" which is the underlying system being studied.
Wang and Landau molecular dynamics
It should be noted that the Wang and Landau algorithm can be implemented not only in a Monte Carlo simulation but also in a molecular dynamics simulation. To do this would require an escalation of the temperature of the system as follows:
where