phonopy

Phonopy (http://phonopy.sourceforge.net/index.html) is a python-based tool for calculating phonon band structures and densities of states from VASP and Wien2K calculations.

Usage

Phonopy may be used to do many things including generating displacements for calculating the Hessian, calculating frequencies, calculating phonon band structures or dos and calculating thermal corrections. Feel free to add instructions for any use which has not yet been documented here.

  1. Generating supercells with displacements

Phonopy will create the supercells with the displacements needed, and all you have to do is compute either the FORCES (IBRION=-1) or Hessian/FORCE CONSTANTS (IBRION=-5). To get the VASP POSCARS, create the disp.conf file, for example:

CREATE_DISPLACEMENTS=.TRUE.
DIM  = 2 2 2
DISPLACEMENT_DISTANCE=0.02

Then run it

phonopy disp.conf

This gives you the files POSCAR-XXX, where XXX is the displacement number, and disp.yaml which is needed during the post-processing step. Here is a sample INCAR file for the FORCE calculation, setting IBRION=-1 with tightened convergence thresholds, as recommended in the VASP/phonopy manuals:

ADDGRID=.TRUE.
ISTART = 0 # 0=scratch, 1=read WAVECAR but implement different basis 2=restart with same basis
LWAVE = .TRUE.
LREAL=.FALSE.
ENCUT = 450.000
PREC = Accurate
ISYM = 2
ispin = 2
magmom=8*1 16*0
ALGO=FAST
EDIFF = 1E-7
EDIFFG = -1E-06
NELM = 200
LORBIT = 11
ISMEAR = 1 # 0=gaussian, 1,2=MP
SIGMA= 0.05
NEDOS = 2000
IBRION=-1  #-1 #5 #2=CGA
#Dispersion
LVDW= .TRUE. # the corrected energy should be read from OSZICAR
             # (energies in OUTCAR do not contain the vdW term)
  1. Generating FORCE_CONSTANTS or FORCE_SETS

Most of the time, after a calculation of frequencies in VASP, you need to generate the FORCE_CONSTANTS file which is what phonopy uses to generate its Hessian. This can be generated as follows:

phonopy --fc vasprun.xml

FORCE_SETS can be generated as follows:

phonopy --f vasprun.xml

Typically, I have my vasprun.xml files from calculations with many different displacments, each in its own subdirectory. So, I run phonopy as such:

phonopy -f phon_0{01..12}/vasprun.xml
  1. Generating phonon bandstructure

Once the FORCE_CONSTANTS or FORCE_SETS file has been generated, you can generate a band structure for your phonons. A band structure plot follows a path through the Brillouin zone connecting high symmetry k-points. The path depends on the symmetry of your cell. A reference which gives paths for many different types of cells is this article. The example below

Step 1: Create band.conf

ATOM_NAME=Ni C
EIGENVECTORS=.TRUE.
DIM=2 2 2
BAND=0 0 0  0.5 0 0  0.3333 0.3333 0  0 0 0
BAND_POINTS=101
BAND_LABLES=\Gamma M K \Gamma

Step 2: Run phonopy (choose one of these forms, ignore the parts after the # symbol)

phonopy band.conf        # generates band.yaml which contains the w(k) values
phonopy -p band.conf     # creates the band plot (will fail if it cannot display back to your desktop)
phonopy -p -s band.conf  # creates the band plot and saves it as a pdf file (requires display)

The band.conf file contains all of the options necessary for this calculation. The first line gives the atom labels and should have one entry per atom type in your cell. The second line specifies the dimensions of the supercell. The third line specifies that the FORCE_CONSTANTS file should be read to generate the Hessian. The fourth line contains each high symmetry k-point. The paths will connect each adjacent pair of points in the BAND line unless there is a comma between the two points. The fifth line specifies how many k-points should be used between each high symmetry point including the endpoints (thus each segment of this band structure will have a total of 101 points). Finally the last line specifies the labels for the k-points specified in the BAND entry. Where two segments are joined with a comma in the BAND entry, only one entry should be given.

If you run the first version of the phonopy command, then you will get a band.yaml file. This can then be used the bandplot program (installed to ${HOME}/.local/bin when you installed phonopy) which will read this file and generate the plot. A useful tool of the bandplot program is the ability to generate a text file with the data.

  1. Generating phonon DOS

The phonon density of states plots requires integration over the first Brillouin zone. This involves choosing a k-point density for the frequency calculations (which does not have to be the same as the k-point mesh used to calculate the electronic structure). As a matter of fact, since these calculations are extremely cheap (phonopy takes less than a minute to perform these calculations), it makes sense to test convergence of the phonon DOS as a function of mesh size.

Run phonopy specifying the mesh size (example below uses a 4x4x4 Monkhorst-Pack mesh)

phonopy --mp="4 4 4" -p band.conf

The option –mp=”4 4 4” specifies the mesh size (4x4x4 in this case). The -p option causes a plot to be created. If the -s option is added to the command above, a pdf file of the plot is created along with the file total_dos.dat which can be used to plot the dos with another program. Note that this will require that you are running an X server on your machine so that phonopy has a valid display to use when generating the pdf file (although nothing will actually appear on your screen).

Installation

Phonopy has several prerequisites which must first be installed. To get started, you will need to create a working directory (${HOME}/src) and a system directory (${HOME}/.local) where ${HOME} depends on the user (i.e. /home/<username>). As we continue, some of the software we build will generate ${HOME}/.local/bin, ${HOME}/.local/lib and ${HOME}/.local/lib64 directories. These need to be added to the correct environment variables in order to make everything work.

export PATH=${HOME}/.local/bin:$PATH
export LD_LIBRARY_PATH=${HOME}/.local/lib64:${HOME}/.local/lib:${LD_LIBRARY_PATH}

Throughout the following instructions, we will use python2.6 as a command.

Build and install lxml for python The first prerequisite is the lxml python package. This depends on libxml2 and libxslt. While these libraries are present on sesmae, the development files are not present. As such, we will need to build our own copy.

To build and install libxml2 and libxslt, you need to download, extract, configure and make each of these libraries. Follow the steps below to do this. Note that the -fPIC flag is needed to generate usable shared libraries.

cd ${HOME}/src
wget ftp://xmlsoft.org/libxml2/libxml2-2.7.8.tar.gz
wget ftp://xmlsoft.org/libxml2/libxslt-1.1.26.tar.gz
tar zxvf libxml2-2.7.8.tar.gz
tar zxvf libxslt-1.1.26.tar.gz
cd libxml2-2.7.8
./configure --prefix=${HOME}/.local CFLAGS=-fPIC | tee config.log
make -j4 | tee make.log
make install | tee install.log
cd ..
cd libxslt-1.1.26
./configure --prefix=${HOME}/.local CFLAGS=-fPIC | tee config.log
make -j4 | tee make.log
make install | tee install.log
cd ${HOME}/src
rm -r ${HOME}/src/libxml2-2.7.8*
rm -r ${HOME}/src/libxslt-1.1.26*

Next:

cd ${HOME}/src
wget http://lxml.de/files/lxml-2.3.4.tgz
tar zxvf lxml-2.3.4.tgz
cd lxml-2.3.4
python2.6 setup.py build
python2.6 setup.py install --user
cd ${HOME}/src
rm -r ${HOME}/src/lxml-2.3.4*

This method installs the lxml python package to ${HOME}/.local/lib/python2.6/site-packages/ and will be recognized by python 2.6 next time you run it.

Build and install matplotlib

cd ${HOME}/src
wget http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.1.0/matplotlib-1.1.0.tar.gz
tar zxvf matplotlib-1.1.0.tar.gz
cd matplotlib-1.1.0
python2.6 setup.py build
python2.6 setup.py install --user
cd ${HOME}/src
rm -r matplotlib-1.1.0

Build and install PyYAML

cd ${HOME}/src
wget http://pyyaml.org/download/pyyaml/PyYAML-3.10.tar.gz
tar zxvf PyYAML-3.10.tar.gz
cd PyYAML-3.10
python2.6 setup.py --without-libyaml install --user
cd ${HOME}/src
rm -r PyYAML-3.10*

Build and install Phonopy

cd ${HOME}/src
wget http://sourceforge.net/projects/phonopy/files/latest/download
tar zxvf phonopy-1.3.tar.gz
cd phonopy-1.3
python2.6 setup.py install --user

Cleanup

cd ${HOME}
rm -r ${HOME}/sys
rm -r ${HOME}/src