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.[1]
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.
Consider a system defined on a phase space
\Omega
E\in\Gamma=[Emin,Emax]
\rho(E)
\hat\rho(E)\equiv\exp(S(E))
\Gamma
\Delta
\Delta=
Emax-Emin | |
N |
Given this discrete spectrum, the algorithm is initialized by:
S(Ei)=0 i=1,2,...,N
f=1
\boldsymbol{r}\in\Omega
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(\boldsymbol{r})=1/\hat{\rho}(E(\boldsymbol{r}))=\exp(-S(E(\boldsymbol{r})))
g(\boldsymbol{r} → \boldsymbol{r}')
H(E)
\boldsymbol{r}'\in\Omega
g(\boldsymbol{r} → \boldsymbol{r}')
A(\boldsymbol{r} → \boldsymbol{r}')=min\left(1,eS
g(\boldsymbol{r | |
' → |
\boldsymbol{r})}{g(\boldsymbol{r} → \boldsymbol{r}')}\right)
where
S=S(E(\boldsymbol{r}))
S'=S(E(\boldsymbol{r}'))
After each proposal-acceptance step, the system transits to some value
Ei
H(Ei)
S(Ei)\leftarrowS(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
H(E)
f\leftarrowf/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
t
We want to obtain the DOS for the harmonic oscillator potential.
E(x)=x2,
The analytical DOS is given by,
\rho(E)=\int\delta(E(x)-E)dx=\int\delta(x2-E)dx,
by performing the last integral we obtain
\rho(E)\propto\begin{cases}E-1/2,forx\inR1\\ const,forx\inR2\\ E1/2,forx\inR3\\ \end{cases}
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
\hat\rho(E)
\rho(E)
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(\boldsymbol{x}' → \boldsymbol{x})=g(\boldsymbol{x} → \boldsymbol{x}')
The code considers a "system" which is the underlying system being studied.
while f > epsilon: system.proposeConfiguration # A proposed configuration is proposed proposedEnergy = system.proposedEnergy # The energy of the proposed configuration computed
if random < exp(entropy[currentEnergy] - entropy[proposedEnergy]): # If accepted, update the energy and the system: currentEnergy = proposedEnergy system.acceptProposedConfiguration else: # If rejected system.rejectProposedConfiguration
H[currentEnergy] += 1 entropy[currentEnergy] += f
if isFlat(H): # isFlat tests whether the histogram is flat (e.g. 95% flatness) H[:] = 0 f *= 0.5 # Refine the f parameter
Molecular dynamics (MD) is usually preferable to Monte Carlo (MC), so it is desirable to have a MD algorithm incorporating the basic WL idea for flat energy sampling. That algorithm is Statistical Temperature Molecular Dynamics (STMD), developed by Jaegil Kim et al at Boston University.
An essential first step was made with the Statistical Temperature Monte Carlo (STMC) algorithm. WLMC requires an extensive increase in the number of energy bins with system size, caused by working directly with the density of states. STMC is centered on an intensive quantity, the statistical temperature,
T(E)=1/(dS(E)/dE)
\Omega(E)=eS(E)
kB=1
\prime= | |
\tilde{T} | |
j\pm1 |
\alphaj\pm\tilde{T}j\pm,
where
\alphaj\pm=1/(1\mp\deltaf\tilde{T}j),\deltaf=(lnf/2\DeltaE),\DeltaE
\tilde{T}
The details are given in Ref. With an initial guess for
T(E)
TL
TU
\tilde{T}(E)
S(E)
S(E)
f
f → \sqrt{f}
STMC was compared with WL for the Ising model and the Lennard-Jones liquid. Upon increasing energy bin size, STMC gets the same results over a considerable range, while the performance of WL deteriorates rapidly. STMD can use smaller initial values of
fd=f-1
Now consider the main result, STMD. It is based on the observation that in a standard MD simulation at temperature
T0
E([x])
[x]
-E([x])/T0 | |
e |
W(E)
-W(E([x]))/T0 | |
e |
For flat energy sampling, let the effective potential be
T0S(E)
e-S(E)
e+S(E)
The forces are calculated as
F=(-d/dx)T0S(E)=T0(dS/dE)(-d/dx)E([x])=(T0/T(E))F0
where
F0
(T0/T(E))
STMD starts with an ordinary MD algorithm at constant
T0
\tilde{T}(E)
T(E)
In STMD
T0
T(E)
T(E)
1/T(E)
STMD has been refined by the BU group, and applied to several systems by them and others. It was recognized by D. Stelter that despite our emphasis on working with intensive quantities,
ln(f)
\deltaf=(ln(f)/2\DeltaE)
f → \sqrt{f}
\deltaf
\deltaf
T(E)
STMD is particularly useful for phase transitions. Equilibrium information is impossible to obtain with a canonical simulation, as supercooling or superheating is necessary to cause the transition. However an STMD run obtains flat energy sampling with a natural progression of heating and cooling, without getting trapped in the low energy or high energy state. Most recently it has been applied to the fluid/gel transition in lipid-wrapped nanoparticles.
Replica exchange STMD has also been presented by the BU group.