NWChem

From Predictive Chemistry
Revision as of 09:44, 5 November 2013 by David M. Rogers (talk | contribs)

Jump to: navigation, search

When in doubt, check the Documentation, and test!

Running NWChem

First, login to a system (e.g. circe) with nwchem installed.

Next, load the NWChem module and set up a working dir. <source lang="bash"> module load apps/nwchem/6.1.1 mkdir nw-test cd nw-test </source>

Then create a molecule (you can download an sdf file from the PDB ligand structure database listed in the course reference material (Search by molecule name -> Download Links (on left panel) -> Ideal Molfile).

Next, paste the molecule into a file, e.g. <source lang="bash"> cat >start.sdf <<. FOR.sdf

 -ISIS-            3D
 4  3  0  0  0  0  0  0  0  0  0 V2000
   0.6070    0.0000    0.0000 C   0  0  0  0  0
  -0.6000    0.0000    0.0000 O   0  0  0  0  0
   1.1470    0.9350    0.0020 H   0  0  0  0  0
   1.1470   -0.9350    0.0020 H   0  0  0  0  0
 1  2  2  0  0  0
 1  3  1  0  0  0
 1  4  1  0  0  0

M END $$$$ . </source>

You'll also need to paste one of the templates below (they work without changes) into an NWChem control file called en_scf.nw. Use the 'cat' command to paste into the file as above.

Finally, convert start.sdf to an xyz format for NWChem and run nwchem. <source lang="bash"> babel start.sdf start.xyz nwchem en_scf.nw >en_scf.log </source>

All your output will be in en_scf.log (scp/download it to your local system). In the future, use the batch queue system with <source lang="bash"> cat >en_job.sh <<.

  1. $ -N a-test-job
  2. $ -cwd
  3. $ -o job-$JOB_ID.out
  4. $ -e job-$JOB_ID.err
  5. $ -l pcpus=4,h_rt=06:00:00

module load apps/nwchem/6.1.1 cd $HOME/nw-test mpirun `which nwchem` en_scf.nw >en_scf.log . </source>

This runs on 4 cpus in parallel, so it will be faster than running (as before) directly on the login node. Of course, you'll also want to change some options in the run file eventually (especially the basis set). You can also manually edit the xyz file and scan the energy vs some coordinate. See the templates below for more ideas.

Note that you can also edit the files on your system and transfer, or edit locally on circe using your favorite linux editor. Nano is easy to use. <source lang="bash"> nano en_scf.nw </source>

Energy Calculation

A simple SCF energy calculation on the input file start.xyz can be done with:

start en_scf
title "Pople SCF energy"

geometry units angstrom
  load start.xyz
end
basis
#   * library cc-pvdz
#   * library 6-31G*
   * library 3-21G
end

task scf energy

Geometry Optimization

Running a geometry optimization just requires replacing the task directive. Here, we've also added a block of parameters controlling the minimization algorithm.

start opt_scf
title "Pople SCF geometry optimization"

geometry units angstrom
  load start.xyz
end
basis
#   * library cc-pvdz
#   * library 6-31G*
   * library 3-21G
end

driver
   loose
   maxiter 150
   xyz opt
end
task scf optimize

DFT

You can also use DFT rather than HF (SCF) by changing the appropriate keywords and adding a DFT block to specify its functional:

start opt_dft

title "Pople DFT geometry optimization"

geometry units angstrom
  load start.xyz
end
basis
#  * library cc-pvdz
#  * library 6-31G*
  * library 3-21G
end
dft
  xc xpbe96 1.0 \
  pw91lda local 1.0 \
  cpbe96 nonlocal 1.0
  direct
  iterations 150
  grid fine
  disp vdw 2
end

driver
  loose
  maxiter 150
  xyz opt
end
task dft optimize

The "xyz opt" causes NWChem to write out coordinate files, e.g. opt-001.xyz, ... as the optimization is proceeding.

Specifying Charge and Spin

Of course, we need to be able to specify the charge and total spin for most systems as well. Here's an input example appropriate for Fe3+ (5 spin-up electrons making up a half-filled d-shell):

start en_scf
title "Pople SCF energy"

geometry start units angstrom
  load start.xyz
end
basis
#   Fe  library "Ahlrichs pVDZ" # better basis
    * library 3-21G
end

set geometry start
charge 3
scf
  sextet
end

task scf energy

Vibrational Frequencies

At a minimum, the second derivatives of the potential energy surface with respect to the nuclear coordinates make up a 3Nx3N matrix. The eigenvectors represent vibrational 'modes,' and the eigenvalues represent their force constants. Analyzing each mode as a harmonic oscillator leads to a set of vibrational frequencies, which give thermochemical information on the molecule as well as IR spectroscopic information.

From a minimized set of coordinates, all you should require is to add the appropriate task (and optionally a block of parameters)

task scf frequencies