Atomsk

The Swiss-army knife of atomic simulations

Tutorial: working with VASP

This tutorial explains how to use Atomsk to produce data files for VASP, and to read VASP output files. It is recommended to be already familiar with VASP to proceed with this tutorial.

VASP is a code performing density functional theory (DFT) calculations. A VASP calculation requires no less than four input files:

  1. a file named INCAR that contains the parameters for the calculation (type of calculation, cut-offs, etc.);
  2. a file named KPOINTS specifying the k-points mesh;
  3. a file named POTCAR containing the pseudopotential information;
  4. finally, a file named POSCAR that contains the cell vectors and atom positions.

Atomsk only deals with the latter, i.e. the POSCAR file containing atom positions. If you wish to run an actual simulation with VASP, it is up to you to produce the three other files.

Note: Atomsk only handles the simulation box vectors and the positions of atoms -and not the electronic structure or any other information!

1. Producing a POSCAR file

For the sake of example, let us create a unit cell of fcc aluminium, and write it in a POSCAR file:

atomsk --create fcc 4.046 Al POSCAR

Alternatively you can just write "vasp" as output format, and Atomsk will know what it means:

atomsk --create fcc 4.046 Al vasp

In both cases, Atomsk will produce a POSCAR file that looks like the following:

POSCAR

# Fcc Al oriented X=[100], Y=[010], Z=[001].
1.000000
4.04600000 0.00000000 0.00000000
0.00000000 4.04600000 0.00000000
0.00000000 0.00000000 4.04600000
4
Cartesian
0.00000000 0.00000000 0.00000000
2.02300000 2.02300000 0.00000000
0.00000000 2.02300000 2.02300000
2.02300000 0.00000000 2.02300000

This file is ready for a VASP calculation. Of course, you will need to prepare the other files (INCAR, KPOINTS, POTCAR) in order to run an actual calculation.

2. Using reduced coordinates

If you prefer to work with reduced coordinates, it is possible to tell Atomsk to do so, with the option "-fractional":

atomsk --create fcc 4.046 Al -fractional vasp

In this case, the POSCAR file will indeed contain reduced coordinates:

POSCAR

# Fcc Al oriented X=[100], Y=[010], Z=[001].
1.000000
4.04600000 0.00000000 0.00000000
0.00000000 4.04600000 0.00000000
0.00000000 0.00000000 4.04600000
4
Direct
0.00000000 0.00000000 0.00000000
0.50000000 0.50000000 0.00000000
0.00000000 0.50000000 0.50000000
0.50000000 0.00000000 0.50000000

3. Packing atom types

VASP requires that all atoms of the same species are contiguous, and in an order that is consistent with the pseudopotential file POTCAR. This is not an issue if there is only ont type of atom in the system, however it is an important point if there are two or more different types of atoms.

To illustrate this point, let us create a unit cell of copper-nickel, and duplicate it twice along the Z direction:

atomsk --create fcc 3.6 Cu Ni -duplicate 1 1 2 xsf

If you open the file "CuNi.xsf" produced by Atomsk, you will notice that it contains an alternance of Cu and Ni atoms:

CuNi.xsf

# Fcc CuNi alloy oriented X=[100], Y=[010], Z=[001].
CRYSTAL
PRIMVEC
3.60000000 0.00000000 0.00000000
0.00000000 3.60000000 0.00000000
0.00000000 0.00000000 7.20000000
CONVVEC
3.60000000 0.00000000 0.00000000
0.00000000 3.60000000 0.00000000
0.00000000 0.00000000 7.20000000
PRIMCOORD
8 1
29 0.00000000 0.00000000 0.00000000
29 1.80000000 1.80000000 0.00000000
28 0.00000000 1.80000000 1.80000000
28 1.80000000 0.00000000 1.80000000
29 0.00000000 0.00000000 3.60000000
29 1.80000000 1.80000000 3.60000000
28 0.00000000 1.80000000 5.40000000
28 1.80000000 0.00000000 5.40000000

This is not a problem for visualization, but it is for VASP. If we use the command above to produce a POSCAR file, it will not be suited for a VASP calculation, because atoms of the same species are not contiguous.

Atomsk can pack atoms to comply with this requirement from VASP, thanks to the option "-sort species pack". When producing VASP files, it is recommended to always use this option, to ensure that atoms of the same species are indeed contiguous in the POSCAR file:

atomsk --create fcc 3.6 Cu Ni -duplicate 1 1 2 -sort species pack vasp

Even so, you will have to make sure that atoms are sorted in a way that is consistent with the pseudopotential file POTCAR.

4. Freeze some atoms

The POSCAR file can contain additional flags, specifying if atoms are "frozen" along each Cartesian direction. It is possible to choose which atoms to freeze with Atomsk, with the option "-fix". For instance, building on the previous aluminium example, let us freeze completely the atoms that have a Z coordinate smaller than 4.05 Å:

atomsk --create fcc 4.046 Al -duplicate 1 1 2 -fix all below 4.05 Z vasp

Alternatively, if we want to freeze these atoms only along the Y direction, use the following:

atomsk --create fcc 4.046 Al -duplicate 1 1 2 -fix Y below 4.05 Z vasp

This time, Atomsk writes the appropriate flags ("T" or "F") after each atom:

POSCAR

# Fcc Al oriented X=[100], Y=[010], Z=[001].
1.000000
4.04600000 0.00000000 0.00000000
0.00000000 4.04600000 0.00000000
0.00000000 0.00000000 8.09200000
8
Selective dynamics
Cartesian
0.00000000 0.00000000 0.00000000 T F T
2.02300000 2.02300000 0.00000000 T F T
0.00000000 2.02300000 2.02300000 T F T
2.02300000 0.00000000 2.02300000 T F T
0.00000000 0.00000000 4.04600000 T F T
2.02300000 2.02300000 4.04600000 T F T
0.00000000 2.02300000 6.06900000 T T T
2.02300000 0.00000000 6.06900000 T T T

It is also possible to use the option "-select" to pick atoms according to various criteria. For instance, this option allows to select atoms within a certain range of index, or atoms inside a box, sphere or cylinder. After selecting atoms, the option "-fix" will freeze only the selected atoms, along the given direction.

As an example, assuming an initial atomic system "Al.xsf", select atoms inside a cylinder along the Z axis of radius 20 Å, and fix them along the Y direction:

atomsk Al.xsf -select in cylinder Z 0.5*box 0.5*box 20 -fix Y POSCAR

This way it is possible to select more complex patterns of atoms.

5. Convert CONTCAR files

During a calculation, VASP writes atom positions into a file named CONTCAR. This file follows exactly the same format as the input POSCAR file. It is quite simple to convert an CONTCAR file into another format with Atomsk. For instance, running the following command:

atomsk CONTCAR cfg

will produce a file named "CONTCAR.cfg", suitable for visualization with Atomeye or OVITO. If some atoms are frozen, then Atomsk also saves this information as an auxiliary property, so that it is transferred to other file formats.

An important point is that the CONTCAR file does not contain any information about the atom species. However, if the folder containing the CONTCAR file also contains a pseudopotential file POTCAR (which should be the case if the calculation was run in this folder), then Atomsk will use that POTCAR file to recognize the atom species.

If there is no POTCAR file in the current folder, Atomsk will assume that atoms of the first type are hydrogen, those of type 2 helium, and so on. It is possible to modify the atom species, thanks to the option "-substitute". For instance, if the CONTCAR file contains atoms of Cu and Ni, Atomsk will interpret them as H and He. Then, use the option "-substitute" to replace H by Cu, and He by Ni:

atomsk CONTCAR -substitute 1 Cu -substitute 2 Ni cfg