c2x and VASP

c2x is able to read CHG, CHGCAR, POSCAR and CONTCAR files in VASP 5.x format. (Earlier formats omitted any indication of atomic species from these files.) From version 2.30, c2x will also read WAVECAR files (spinors excepted), and from 2.34d it can also read LOCPOT files.

In order to calculate dipole moments, electrostatic potentials, etc, c2x needs to know the atomic pseudocharges. For these it needs to read the associated POTCAR file, and this ability was introduced in c2x version 2.34d.

It can write CHG and CHGCAR files, which are almost identical apart from in the precision with which they are written.

If run with the --vasp flag, c2x will produce POSCAR output, i.e. unit cell and atomic positions only. If -c is added, the charge density will be included, producing a CHG file. The single flag --chgcar is a convenient shorthand for --vasp -c and increases the precision as expected for a CHGCAR file. To include spin density as well (if present), the -s flag is also required.

Note: when reading CHG or CHGCAR files, unless a density is requested reading will stop after the header. If the input contains data on initial magnetic moment, and there is a desire to retain that data, then the -s flag must be given in order for this to be read. In other words

  c2x -s CHGCAR out.cell

will preserve initial magnetic moments when writing to a .cell file, whereas without the -s flag the reading of the CHGCAR file will stop before the magnetic moments are found.

As c2x can write CHG and CHGCAR files, it can turn densities in .check, .cube, .xsf, .den_fmt and similar files into something which can be read by VASP-compatible viewers and analysers.

Note too that versions of c2x prior to 2.34b may change the order of the atomic species in a POSCAR file. The output will be correct, but will require changes to any associated POTCAR file.

Note that c2x's author does not enjoy good access to VASP, so VASP support is likely to be poorer as a result.

VASP's WAVECAR format

Those working with VASP's WAVECAR files may wish to be aware of a few quirks of the format.

Firstly, the wavefunctions are stored in single precision by default. This is not unreasonable: if energies are converged to double precision accuracy, then wavefunctions are converged to approximately single precision accuracy.

Secondly whilst a WAVECAR file stores arrays of g-vector co-efficients as expected, it does not store the mapping of the components of that array to particular g-vectors. Rather it is assumed that one transverses the possible g-vectors in a particular order, including those within the cut-off sphere and excluding those outside it. Reproducing this involves a floating-point comparision between a kinetic energy of a g-vector expressed in reciprocal Angstroms, and a cut-off in eV. Fortunately the WAVECAR file contains the cut-off energy, and the basis, in double precision. Unfortunately there remain a lot of floating point operations, both multiply and add, including an imprecisely-known scaling factor, to convert the g-vector to a kinetic energy. If different codes do this slightly differently, or with slightly different rounding, there is a small chance of the mapping changing as components at the cut-off boundary move slightly. The chance is quite small, but it would not surprise me if c2x (or any other independent reader) sometimes fails to reproduce VASP's mapping.

Finally there are several versions of WAVECAR file. One can choose at VASP compile time whether it stores the wavefunctions as single precision (the default) or double precision. And VASP version 5 uses a more space efficient storage than version 4 if an inequality such as 3*nbands+4>(max number of plane waves per band and k-point) holds (with the right hand side doubled if using double precision storage). Version 2.30 of c2x reads both single-precision formats. Version 2.34 of c2x can convert between the formats, provided spinors are not used.