VASP Tools

Peter’s collection of small, but useful, VASP scripts. Some of these may be found on NSC’s computers by loading the “vasptools” module.

vaspcheck

The “vaspcheck” script scans your input files and looks for common errors such as: forgetting to copy CONTCAR to POSCAR, misspelled INCAR tags, and various inconsistent configurations such as having N atoms but only N-x magnetic moments specified. If you supply it with information about the intended number of cpu cores and nodes that you will run on, it will also check the NPAR and KPAR values and warn if they are unreasonable.

An alpha version is available in the “vasptools” module on Triolith, and once the script has become more robust, I will make a version available for download here. The idea is to integrate it with the queue system in the future, so that your VASP jobs will be automatically checked when running the “sbatch” command.

Install: Click here to download to the Python script. Install it by putting it in a folder in your $PATH (such as~/bin) and then do:

mv vaspcheck-standalone.py vaspcheck
chmod u+x vaspcheck

This should allow you to write “vaspcheck” in any job folder.

grad2

The gradient program is used to quickly get an overview of VASP geometry optimization runs. It also works for molecular dynamics. It parses the OUTCAR file and writes a one-line summary per ionic step, including average forces and run-time per step. The output looks like this:

$ grad2 OUTCAR
Step   1  Energy: -42.794090  Log|dE|: +1.631  Avg|F|: 1.720176  Max|F|: 2.710237  SCF:  15  Time: 0.52m
Step   2  Energy: -43.336931  Log|dE|: -0.265  Avg|F|: 0.513256  Max|F|: 0.696803  SCF:   9  Time: 0.32m
Step   3  Energy: -43.384337  Log|dE|: -1.324  Avg|F|: 0.095940  Max|F|: 0.178813  SCF:   7  Time: 0.24m
Step   4  Energy: -43.387267  Log|dE|: -2.533  Avg|F|: 0.050399  Max|F|: 0.071963  SCF:   6  Time: 0.20m
Step   5  Energy: -43.388250  Log|dE|: -3.007  Avg|F|: 0.043184  Max|F|: 0.061866  SCF:   4  Time: 0.13m
Step   6  Energy: -43.390384  Log|dE|: -2.671  Avg|F|: 0.030630  Max|F|: 0.047413  SCF:   5  Time: 0.18m
Step   7  Energy: -43.392498  Log|dE|: -2.675  Avg|F|: 0.003760  Max|F|: 0.005849  SCF:   6  Time: 0.20m
Step   8  Energy: -43.392509  Log|dE|: -4.959  Avg|F|: 0.001285  Max|F|: 0.001861  SCF:   3  Time: 0.09m

The Log\|dE\| is the base-10 logarithm of the absolute value of the energy difference between steps, essentially the number of “stable” decimals in the total energy, i.e. for a VASP run with EDIFF=1.0E-5, Log\|dE\| should approach -5 for convergence.

If your terminal has colors, each line will be color-coded with red color signalling convergence problems, and green color corresponding to energy convergence having been reached (as judged by the EDIFF tag in the INCAR file.)

Install: Click here to download to the Python script (version 2012-01-07). Install it by putting it in a folder in your $PATH (such as~/bin) and then do:

mv grad2.py grad2
chmod u+x grad2

This should allow you to write “grad2 OUTCAR” in any job folder.

vasp2cif

The vasp2cif program creates a CIF-file from a POSCAR/CONTCAR file, which can be used for visualization in graphical applications, such as VESTA. Note that it will not preserve symmetries from VASP – the output CIF is always in P1 symmetry. If there is no POTCAR file available, the script has a flag (“–elements”) whereby you can specify the atomic species.

Install: Click here to download to the Python script (version 2012-12-15). Install it by putting it in a folder in your $PATH (such as~/bin) and then do:

mv vasp2cif.py vasp2cif
chmod u+x vasp2cif

This should allow you to write e.g. “vasp2cif CONTCAR” in any job folder.

cif2vasp

For CIF to VASP input conversion, a recommend a program by Torbjörn Björkman called cif2cell, which can generate input from CIF files for many ab initio programs, including VASP.

If anyone is interested in doing high-performance CIF to VASP conversion with optimized C code, I can provide source code to a CIF lexer written with the Ragel state machine compiler and CIF parser written with Lemon. Unfortunately, the tool I built to do CIF to VASP with this framework does not compile correctly anymore on recent platforms, so I cannot put up any binaries for download. You can email me at pla@nsc.liu.se if you want to give it a try.

supersize

Yet another script to make supercells out of VASP’s POSCAR/CONTCAR files. It is basically a wrapper around the corresponding feature in ASE.

It works like this:

$ supersize POSCAR 4x4x4

And you get a new POSCAR file called “POSCAR.4x4x4” containing the supercell repeated 4 times in a,b,c directions. You can achieve the same effect with three lines of Python code in ASE:

import ase.io.vasp
cell = ase.io.vasp.read_vasp("POSCAR")
ase.io.vasp.write_vasp("POSCAR.4x4x4",cell*(4,4,4), label='444supercell',direct=True,sort=True)

The script is a little bit more elaborate, however, since it includes error checks.