lkwagner edited this page Mar 18, 2015 · 2 revisions

(Note, this tutorial uses several new features that are only available in versions 0.96.3 and later. Also, note that some familiarity with the ideas of quantum Monte Carlo are assumed; the purpose of this tutorial is to teach the mechanics of QWalk)


$ cd qwalk/src
$ make 
$ make install

The binaries will then be in qwalk/bin. Put this directory in your PATH; for example, in your .bashrc put

export PATH=${PATH}:~/qwalk/bin

or wherever the QWalk directory is in your setup.

For more involved installs using MPI or LAPACK routines, please see the README file in the distribution.

CH4 molecule: conversion

Download the examples set from the downloads directory on the website. Change to the directory examples/gamess/ch4. There you should see the results of a GAMESS run: ch4.inp ch4.pun, and ch4.out. Type:

$ gamess2qmc ch4

It will produce several files:

ch4.sys: The Hamiltonian and boundary conditions being simulated. You will most likely not touch this file.

ch4.slater: The Slater wave function

ch4.jast2: This is the Jastrow correlation factor that we'll add onto the Slater determinant.

ch4.jast3: A more complicated Jastrow factor including 3-body correlation terms.

CH4: Hartree-Fock wave function

We'll first evaluate the energy of the Hartree-Fock wave function using the variational Monte Carlo technique. Create a new file 'ch4.hf' and enter the following:

method { VMC }
include ch4.sys
trialfunc { include ch4.slater }

now run

$ qwalk ch4.hf

It should take a little while and perhaps print out a few diagnostic lines. There should be three new files:

  • ch4.hf.o: Information about the run. This file is overwritten every time QWalk is run.
  • ch4.hf.log: The log of the run for statistical analysis. This file is not overwritten, but is appended to when QWalk is rerun on ch4.hf.
  • ch4.hf.config: The checkfile for the run. This file is overwritten every time QWalk is run and every averaging block.

Look at ch4.hf.o. There should be lots of information about the system, like where the atoms are, what type of wave function you used, etc. Near the bottom, after 'Starting VMC', is where the run starts. It prints out the values of the energy, kinetic energy, potential energy and pseudopotential energy (nonlocal energy) on the first line, and the standard deviation of each on the second line.

To get the averages, run

$ gosling ch4.hf.log

You should get something like

vmc:  100 total blocks reblocked into 100
Threw out the first 2 blocks in the averaging.
total_energy0         -7.843243648 +/-   0.01364379687 (sigma     1.17532426 ) 
kinetic0               6.533578317 +/-   0.06412492696 (sigma     3.635779487 ) 
potential0            -14.79932262 +/-   0.08166890819 (sigma     4.287535753 ) 
nonlocal0             0.4225006577 +/-   0.04207629862 (sigma     2.605797067 ) 
weight0                          1 +/- 8.971956907e-17 (sigma               0 ) 

The average energy with an error bar is printed out. This should match the GAMESS input within one error bar about 66 percent of the time, and within two error bars about 90 percent of the time. If you want to reduce the error bar, you need to run longer.

Let's reduce the error bar by rerunning QWalk. Note that 100 blocks were performed. If we want to reduce the error bar by a factor of 2, we need to perform 400 total blocks. Thus, edit ch4.hf so it looks like this:

method { VMC nblock 300 } 
include ch4.sys
trialfunc { ch4.slater } 

and run

$ qwalk ch4.hf


$ gosling ch4.hf.log

to get the new average and error bars, which should look like this:

vmc:  400 total blocks reblocked into 400
Threw out the first 2 blocks in the averaging.
total_energy0         -7.828916215 +/-  0.007224912422 (sigma     1.201653534 ) 
kinetic0               6.473482374 +/-   0.03431546469 (sigma     3.510279933 ) 
potential0             -14.7356489 +/-    0.0396554966 (sigma     4.011434204 ) 
nonlocal0             0.4332503088 +/-   0.01579636687 (sigma     2.191167933 ) 
weight0                          1 +/- 3.728580264e-16 (sigma               0 ) 

Note that there are 400 total blocks, 100 from the first VMC run and 300 from the second one.

You can also use gosling to check on the progress of a long run, even as QWalk is running!

Optimize the correlation factor

So far, we have only evaluated the Slater determinant wave function from GAMESS. We will now optimize the Jastrow correlation factor using variance minimization. Create a new file named ch4.opt and put the following inside:

method { OPTIMIZE
   nconfig 500

include ch4.sys

trialfunc { slater-jastrow
  wf1 { include ch4.slater }
  wf2 { include ch4.jast2 }


$ qwalk ch4.opt 

This will produce two files:

ch4.opt.o A summary of the run.

ch4.opt.wfout The optimized wave function.

In ch4.opt.o, you should see that the dispersion is decreasing. In my run, it decreased from 0.86 to 0.34 Hartrees.

Energy with the optimized correlation factor

Make an input file named ch4.vmc as follows:

method { VMC }
include ch4.sys
trialfunc { include ch4.opt.wfout }

You can evaluate the properties of this wave function in the same way as we did for ch4.hf, by running

$ qwalk ch4.vmc 

and then

$ gosling ch4.vmc.log 

The energy obtained using the optimized wave function should be lower and the sigma (standard deviation) of the energy should be half or less of the Slater determinant wave function. Note that for the exact ground state wave function, the total energy is minimized and sigma is zero. The lower sigma and the total energy are, the closer we are to the exact ground state!

Diffusion Monte Carlo

We can further refine the results by using diffusion Monte Carlo. Make an input file ch4.dmc:

method { DMC timestep .01
include ch4.sys
trialfunc { include ch4.opt.wfout }

Note the additional parameter 'timestep'. This controls the accuracy of the calculation. As the timestep tends to zero, the calculation becomes more accurate, but less efficient. Practical calculations are performed at several timesteps and extrapolated to zero.

Other than the timestep parameter, the DMC runs are performed the same as VMC. Perform the run using

$ qwalk ch4.dmc 

and then

$ gosling ch4.dmc.log

You can run longer by changing 'nblock' in DMC.