Example of Wang-Landau for NH3 adsorption : Monte Carlo method
Download test_wl_nh3-v3c2.py
and NH3-V3C2
model
from susmost import *
from susmost import mc
import numpy as np
lt = load_lattice_task('models/nh3-v3c2', precission=1)
lt.set_ads_energy('nh3-atop-v3c2', -0.5)
T = 600. # arbitrary value - not used in Wang-Landau simulations
k_B = 0.000086 # Boltzmann constant, implies eV energy units
L = 12 # Lattice size
m = mc.make_metropolis(lt, L, [T], k_B)
emin = -15.0 # minimal energy for Wang-Landau histogram
emax = 10.0 # maximal energy for Wang-Landau histogram
bincnt = 1000 # number of bins for Wang-Landau histogram
mc.wl_setup(m, emin, emax, bincnt) # set Wang-Landau options
# do 100M Wang-Landau Monte Carlo sweeps without relaxation
mc.run(m, 100, 1000*1000, relaxation_steps=0, log_callback=lambda m: print (m.curE.sum()))
U_list = []
T_list = range(100, 1000+1, 10)
for T in T_list:
a = mc.wl_analysis(m, T)
U_list += [a.U]
print ("Temperature = ", T)
print ("Mean Energy = ", a.U)
print ("Entropy = ", a.S)
print ("Free energy = ", a.F)
print ("Heat capacity = ", a.C)
print ("\n")
import pylab as pl
pl.plot(T_list, U_list)
pl.show()