The Wang and Landau algorithm, proposed by Fugao Wang and David P. Landau, is a Monte Carlo method designed to estimate 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. 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 an estimate for 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 Ω, and a cost function, E (the energy), bounded on a spectrum E∈Γ=[Emin,Emax]. E has an associated density of states, ρ(E), which is to be estimated. The estimator is ρ̂(E)≡exp(S(E)). Because Wang and Landau algorithm works in discrete spectra, the spectrum Γ is divided in N discrete values with a difference between them of Δ, such that
Δ=Emax−EminN. Given this discrete spectrum, the algorithm is initialized by:
setting all entries of the microcanonical entropy to zero, S(Ei)=0 i=1,2,...,N initializing f=1 and initializing the system randomly, by putting in a random configuration 𝒓∈Ω. 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 P(𝒓)=1/ρ̂(E(𝒓))=exp(−S(E(𝒓))) and a probability of proposing a new state given by a probability distribution g(𝒓→𝒓′). A histogram H(E) of visited energies is stored. Like in the Metropolis–Hastings algorithm, a proposal-acceptance step is performed, and consists in (see Metropolis–Hastings algorithm overview):
proposing a state 𝒓′∈Ω according to the arbitrary proposal distribution g(𝒓→𝒓′) accept/refuse the proposed state according to A(𝒓→𝒓′)=min(1,eS−S′g(𝒓′→𝒓)g(𝒓→𝒓′)) where S=S(E(𝒓)) and S′=S(E(𝒓′)). After each proposal-acceptance step, the system transits to some value Ei, H(Ei) is incremented by one and the following update is performed:
S(Ei)←S(Ei)+f. 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 Ei, that proposal is now more likely refused; in this sense, the algorithm forces the system to visit all of the spectrum equally. The consequence is that the histogram H(E) is more and more flat. However, this flatness depends on how well-approximated the calculated entropy is to the exact entropy, which naturally depends on the value of f. To better and better approximate the exact entropy (and thus histogram's flatness), f is decreased after M proposal-acceptance steps:
f←f/2. 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 1/t, where t is proportional to the number of steps of the simulation.
Test system We want to obtain the DOS for the harmonic oscillator potential.
E(x)=x2, The analytical DOS is given by,
ρ(E)=∫δ(E(x)−E)dx=∫δ(x2−E)dx, by performing the last integral we obtain
ρ(E)∝{E−1/2,for x∈ℝ1const,for x∈ℝ2E1/2,for x∈ℝ3 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 estimated density of states ρ̂(E) obtained by the Wang–Landau algorithm with ρ(E).
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:
g(𝒙′→𝒙)=g(𝒙→𝒙′) The code considers a "system" which is the underlying system being studied.
Parallel Implementations The Wang–Landau algorithm lends itself to parallelisation (utilising multiple CPU and/or GPU cores to improve simulation performance) in three key ways. First is that the energy domain may be divided into several smaller energy sub-domains, with an independent Wang–Landau walker gathering statistics in each sub-domain. (In this case, the global DOS is periodically recovered from the local DOS.) These energy sub-domains may be chosen to be non-uniform in size, to ensure a higher concentration of walkers in regions where the density of states is most challenging to converge. Second is that, in a given energy domain, multiple independent Wang–Landau walkers may gather statistics which are later combined. Third is that, in the case that multiple energy sub-domains are used, an overlap between energy sub-domains facilitates replica exchange, i.e. swapping of walkers from one energy sub-domain to another, which can improve exploration of the configuration space.
… excerpt ends here. Continue reading the full article.