Pt VASP Tutorial - Computational Materials Group

advertisement
MgO VASP Tutorial
Amy Bengtson 19 May 2006
updated 2 February 2007
updated April 2008
This tutorial gives a brief introduction to VASP (Vienna Ab-initio Simulation Package). The
tutorial will describe the input and output files, teach you how to run a basic calculation, and
teach you what is necessary to get an accurate calculation.
Introduction :
VASP is a pre-packaged code that solves the Schrodinger Equation using appropriate
approximations for the energy and forces. DFT codes like VASP are a very powerful tool for
scientific research. However, you have to learn to frame your research questions around the
outputs that a DFT code will give you. This tutorial will focus on the VASP input and output
files, however the same ideas can be applied to any DFT code although they will have different
input/output. As J. Hafner et al (MRS Bulletin, Vol 31, Sepember 2006) says:
The successful application of DFT to a materials problem involves three distinct steps:
(1) translation of the engineering problem to a computable atomistic model, (2)
computation of the required physicochemical properties, and (3) validation of the
simulation results by confrontation with laboratory experiments.
The fundamental input parameters for VASP are:
 Atomic structure. This can be …
o any crystal structure (FCC, BCC, HCP, etc …) with your desired atoms.
o a bulk or surface.
o a structure including defects, interstitials, etc …
o etc …
 Information about the electronic structure (see details in INCAR, POTCAR in this
document)
 Convergence parameters (see details in INCAR, KPOINTS in this document)
For a given atomic structure, the fundamental outputs from VASP are:
 Energy & force
 Volume
 Magnetic Moment (if you are doing a spin-polarized calculation)
 DOS (Density of States)
There are other outputs, but the above 4 are the most fundamental and important. Here are a few
basic examples of what research questions these 4 outputs will give you:
 Stable structure
o
o


For an atom N (N=any atom in the periodic table), find the most stable crystal structure.
For example: Set up Fe in FCC, BCC, and HCP crystal structure. Compare the final
energies for each structure to find the lowest energy crystal structure.
Can also do as a function of pressure
TMR (tunneling magnetoresistance) values (based on the s-DOS at the Fermi energy)
Formation Energies
Amy Bengtson
2/6/16 Page 1

Stable magnetic ordering
Amy Bengtson
2/6/16 Page 2
The POSCAR file:
The POSCAR file defines your crystal structure. Create a POSCAR file based on the known
crystal structure and lattice parameters. You can get crystal structure information from
experiments or other calculations. I like to use http://cst-www.nrl.navy.mil/lattice/ .
MgO has the ROCKSALT (NaCl) structure http://cst-www.nrl.navy.mil/lattice/struk/b1.html
We can use the information given on the website to set up the crystal structure. For now, we
guess at the lattice parameter based on the information available. VASP will relax the structure
and find the lowest energy lattice parameter in the calculation.
[amy@head ]$ cat POSCAR
MgO
5.63
0.0 0.5 0.5
0.5 0.0 0.5
0.5 0.5 0.0
11
Direct
0.0 0.0 0.0
0.5 0.5 0.5
Line 1 - Title. Not read in by VASP
Line 2 - lattice parameter (in Angstroms)
Lines 3,4,&5 - lattice vectors that describe the FCC structure. Make sure you can draw out
these lattice vectors and understand how it forms the Rocksalt lattice.
Line 6 - Describes how many atoms of each type there are. Here there is 1 atom of type 1
and 1 atom of type 2. The type is defined the POTCAR file.
Here, type 1 =Mg and type 2 =Oxygen.
Line 7 - Specify Direct or Cartesian coordinates
Line 8 - Atomic position for the first atom (on line 6). This atom is at 0 0 0.
The position on line 8 is translated by the vectors given on lines 3,4&5.
Line 9 - Atomic position for the second atom atom (on line 6). This atom is at 0.5 0.5 0.5.
Make sure you understand how the POSCAR file creates the Rocksalt structure!
To visualize this file you can create an xyz file and look at it in a visualization program.
First, name each atom in the POSCAR file:
convasp -numnames Mg O < POSCAR > POSCAR.n
Now create an xyz file:
convasp -xyz 4 4 4 < POSCAR.n > POSCAR.xyz
Then import POSCAR.xyz into a visualizer.
Amy Bengtson
2/6/16 Page 3
To set up a different structure, you create a different POSCAR file for that structure. For
example, if you had two atoms - both of different types, the basic idea of the POSCAR file
would look like:
name of file
lattice parameter
lattice vector 1
lattice vector 2
lattice vector 3
11
Direct
starting position for atom 1 (of type 1)
starting position for atom 2 (of type 2)
Note: VASP has periodic boundary conditions, so even though we are only specifying 2 atoms
above, VASP views it as a bulk sample. In order to make a surface, you have to add space for
vacuum into your POSCAR file.
Extra Practice:
To gain familiarity with POSCAR files, create the following POSCAR files:
1. FCC Iron
2. BCC Iron
3. BCC Co Fe with 25% Fe
4. BCC CoFe with 50% Fe using ABAB stacking along the 1 0 0 direction.
5. BCC CoFe with 50% Fe using AABB stacking along the 1 0 0 direction.
6. An FCC surface (for any atom you choose).
Any other group member that uses DFT codes will be able to tell you if your POSCAR files are
correct.
Amy Bengtson
2/6/16 Page 4
The POTCAR file:
In order to tell VASP what atoms are in the POSCAR file, you need to create a POTCAR file.
The POTCAR file holds the pseudopotentials for all of the different atoms. A pseudopotential is
a modified expression for the potential that makes it possible to solve the Schrödinger equation.
(Google pseudopotential to see a visual of what this means).
From the pseudopotential library, you create a POTCAR file that has the pseudopotentials for all
of the atoms in your calculation. For this calculation, we need the pseudopotential files for Mg
and O. The order of the pseudopotential files match the order you set in the POSCAR file.
First copy the POTCAR files for each type of atom in your POSCAR to your working directory:
Copy the Mg pseudopotential:
cp /export/apps/vasp_pseudopotentials/paw/PBE/Mg_pv/POTCAR.Z .
Unzip the POTCAR.Z file:
gunzip POTCAR.Z
Rename the POTCAR:
mv POTCAR POTCAR.Mg_pv
Copy the O pseudopotential, unzip it and rename it:
cp /export/apps/vasp_pseudopotentials/paw/PBE/O_s/POTCAR.Z .
gunzip POTCAR.Z
mv POTCAR POTCAR.O_s
VASP only reads files called POTCAR (Not POTCAR.*). You need to create one POTCAR file
with both Mg and O in it:
cat POTCAR.Mg_pv POTCAR.O_s > POTCAR
Now check that both types are in the POTCAR:
grep TITEL POTCAR
And you should see:
TITEL = PAW_PBE Mg_pv 06Sep2000
TITEL = PAW_PBE O_s 07Sep2000
There is a lot of quantum mechanics in the POTCAR file that you will learn as time goes on. For
more details about using POTCAR.*_pv vs POTCAR.* files and soft vs. hard pseudopotentials,
please see the wiki.
Reminder: The order of the pseudopotentials in VASP must MATCH the order of the atoms
in the POSCAR file.
Amy Bengtson
2/6/16 Page 5
The INCAR file:
The INCAR file describes the other electronic constraints you want to put on your calculation.
The comments in the file describe what each tag means. Both Mg and O are non-magnetic,
therefore this is a non-spin polarized calculation. At the end of the Tutorial I will show you how
to modify the INCAR to do a spin-polarized calculation.
This is the current INCAR file:
System = MgO
PREC = Accurate #cutoff + wrap around errors.
IBRION= 2 #conj. grad. relaxation.
NSW= 191 #numberof ionic steps taken in minimization. Make it odd.
ISIF= 3 #Allows the cell to fully relax.
ENCUT = 425 #cutoff energy for planewave basis set
ISMEAR = 1 #BZ integration method (for relaxation).
SIGMA = 0.2 #smearing width in eV (keep TS<1meV/atom)
RWIGS= 1 1 # Given for each atom type
NPAR = 1 # Necessary to get all information when running in parallel.
To choose the value for ENCUT, you need to use the ENMAX from the POTCAR. First, find
the ENMAX:
[amy@curie input_files]$ grep ENMAX POTCAR
ENMAX = 265.574; ENMIN = 199.180 eV
ENMAX = 282.841; ENMIN = 212.131 eV
Choose to use ENCUT = 1.5*(Max ENMAX )= 1.5* 282.841= 425
Note: Every time you use a new atom type, you have to check the ENMAX to make sure you
choose a large enough value.
Amy Bengtson
2/6/16 Page 6
The KPOINTS file:
The KPOINTS file describes how the calculation is divided over reciprocal space. Usually the
higher the k-points, the more accurate the calculation, but also the longer the calculation takes.
You want to find a balance between calculation time and accuracy, which is why we do k-point
convergence tests to find a balance between speed and acuracy.
[amy@curie input_files]$ cat KPOINTS
MgO
0
M
444
000
Amy Bengtson
2/6/16 Page 7
How to run a calculation to find the relaxed lattice parameters:
1. Create a directory that has the 4 input files (POSCAR, POTCAR, INCAR, KPOINTS)
and choose a conservative KPOINT choice (the Tutorial comes with a 4x4x4 Kpoint
mesh – this is fine to start with). These files should all be in
MgO_VASP_Tutorial/input_files
2. If you have all 4 input files: POSCAR, POTCAR, INCAR, KPOINTS, all you need to
run VASP is the VASP executable. In theory, you would execute the VASP executable
in your current working directory (call the directory “relax”). However, we have a queue
system, so the next steps outline running VASP through a submission script.
3. Put the VASP executable in your /home/USER/bin directory (see your system
administrator or software person for details on where the vasp executable is located).
Note: if you are running over ethernet you need VASP compiled for ethernet and if you
are running over infiniband you need VASP compiled for infiniband. On Curie VASP
does not scale well over Ethernet for more than 4 processors. If you need to run on
more than 4 processors, run over Infiniband.
4. Edit your parallel submission script to include the correct vasp executable for the correct
networking (see system administrator for questions on executables and queues to run on).
Copy the parallel submission scrip to your current working directory (called relax) with
the VASP input files.
5. Run the calculation. To run, use the submission script parallel.sh (see your system
administrator for details on submission scripts).
a. to submit type (in your current working directory): qsub parallel.sh
b. to view the job in the queue, type: qstat and look for your user name.
6. Run the input files given to you in the executable (do not change anything). You will
know the job is done when the end of your OUTCAR file looks something like this:
User time (sec):
System time (sec):
Elapsed time (sec):
11.573
0.247
12.545
Maximum memory used (kb):
Average memory used (kb):
0.
0.
Minor page faults:
22173
Major page faults:
12
Voluntary context switches:
956
Congratulations! You have just run your first VASP run!
NOTE: You are running the calculation to get the energy and relaxed lattice parameters of the
MgO structure. In order to use VASP to do scientific research, you will compare the energy of
MgO compares to something else. But before you can compare MgO’s
energies/volumes/magnetic moment, you have to get the correct relaxed structure, with
converged lattice parameters, which the next sections outline.
Amy Bengtson
2/6/16 Page 8
Analyze the Output Files:
7. When the VASP run is finished, the main outputs you will analyze are OUTCAR,
OSZICAR, CONTCAR. Typically when a run is finished, you should check the
following:
a. Make sure the calculation is finished running:
tail OUTCAR and cat OUTCAR. You should see something like:
User time (sec):
System time (sec):
Elapsed time (sec):
11.573
0.247
12.545
Maximum memory used (kb):
Average memory used (kb):
0.
0.
Minor page faults:
22173
Major page faults:
12
Voluntary context switches:
956
b. Look at the energies for each iteration and check your final energy (E0) and the
change in energy (dE) for each iteration:
grep E0 OSZICAR
You should see something like:
[amy@curie relax]$ grep E0 OSZICAR
1 F= -.83999076E+01 E0= -.84042268E+01 d E =-.839991E+01
2 F= -.11221178E+02 E0= -.11222856E+02 d E =-.282127E+01
3 F= 0.17310991E+02 E0= 0.17310750E+02 d E =0.257109E+02
4 F= -.11506800E+02 E0= -.11508030E+02 d E =-.310689E+01
c. Look at the volumes for each iteration:
grep vol OUTCAR
You should see something like:
[amy@curie relax]$ grep vol OUTCAR
volume/ion in A,a.u.
= 22.31
150.53
volume of cell :
44.61
volume of cell :
44.61
volume of cell :
27.03
volume of cell :
5.94
volume of cell :
25.15
volume of typ
1: 16.7 %
volume of typ
2: 16.7 %
d. Look at the pressures for each iteration (mostly to make sure nothing weird
happened). grep pressure OUTCAR
[amy@curie relax]$ grep pressure OUTCAR
external pressure = -229.03 kB Pullay stress =
external pressure = -259.23 kB Pullay stress =
external pressure = 18566.56 kB Pullay stress =
What happens
during a calculation:
external pressure = -238.66 kB Pullay stress =
0.00 kB
0.00 kB
0.00 kB
0.00 kB
Amy Bengtson
2/6/16 Page 9
On the previous page, you see that the energy, volume and pressure are printed out for a number
of steps. VASP is printing out the energy, volume and pressure for each iteration of solving the
Schrodinger Equation (from quantum mechanics). VASP will iterate until it reaches some
tolerance parameter set in the INCAR file. For all the details on the quantum mechanics behind
VASP, see Dane’s notes from his class, especially: QMIII_Details.pdf
OUTCAR file:
The OUTCAR file contains the main output information including volume (in cubic Angstroms)
and pressure (in kBar - divide by 10 to get in units of GPa).
You will want to examine how volume and pressure change with each iteration:
[amy@curie relax]$ grep vol OUTCAR
volume/ion in A,a.u.
= 22.31
volume of cell :
44.61
volume of cell :
44.61
volume of cell :
27.03
volume of cell :
5.94
volume of cell :
25.15
volume of typ
1: 16.7 %
volume of typ
2: 16.7 %
150.53
[amy@curie relax]$ grep pressure OUTCAR
external pressure = -229.03 kB Pullay stress =
external pressure = -259.23 kB Pullay stress =
external pressure = 18566.56 kB Pullay stress =
external pressure = -238.66 kB Pullay stress =
0.00 kB
0.00 kB
0.00 kB
0.00 kB
Here you see the volume of the cell started at 44.61 Ang3 but ends at 25.15 Ang3. This make
sense because the lattice parameters given were for NaCl, not MgO, so we expect them to be too
large at the start, and VASP will relax to the lowest energy lattice parameters.
Notice that the pressure starts and ends slightly expanded.
Beware: In the second to last iteration the volume of the cell drops to 5.94 Ang3 and the
pressure increases to 1856 GPa!! (This is about 10 times greater than the pressures at the center
of the Earth!). Something weird happened in the relaxation here. You will want to restart from
the CONTCAR and re-relax the cell (see Rerunning from the CONTCAR file for details).
Amy Bengtson
2/6/16 Page 10
OSZICAR file:
The OSZICAR contains information about the energy of the cell at each iteration. You want to
make sure that the change in energy from one step to another is converging (dE). Notice that at
the second to last iteration dE increases drastically. This is another warning sign that we have to
run a second convergence run.
[amy@curie relax]$ grep E0 OSZICAR
1 F= -.83999076E+01 E0= -.84042268E+01 d E =-.839991E+01
2 F= -.11221178E+02 E0= -.11222856E+02 d E =-.282127E+01
3 F= 0.17310991E+02 E0= 0.17310750E+02 d E =0.257109E+02
4 F= -.11506800E+02 E0= -.11508030E+02 d E =-.310689E+01
CONTCAR file:
The CONTCAR is the final positions and is written out after each iteration. At the end of the
calculation, the CONTCAR will give the final relaxed positions and lattice parameters. Notice
how CONTCAR and POSCAR have essentially the same format. You can restart a calculation
from a CONTCAR file in order to further converge a calculation, which we are going to do in
the section Rerunning from the CONTCAR file.
You may want to visualize the CONTCAR (using similar methods as you would to visualize the
POSCAR file) to make sure it is still the same structure Rocksalt structure.
Another useful command is: convasp -data < CONTCAR
All CONTCAR information is in Angstroms.
CHG* files:
Contains the charge densities. You need these to run a density of states calculation (see wiki for
details).
DOSCAR files:
Contains the occupation information (for plotting DOS). See the wiki for details.
Amy Bengtson
2/6/16 Page 11
Rerunning from the CONTCAR file:
8. As we noticed above, grep vol OUTCAR shows that the final volume changes by ~ 50%
from the first iteration. This is because we are starting with a guess for our lattice
parameters. Because our lattice parameters changed by more than 10% in the calculation,
we need to re-relax from the final positions and lattice parameters (CONTCAR). We
also saw that the second to last iteration volume was not consistent with the other
changes. This tells us we need to rerun our calculation to make sure the cell is fully
relaxed.
9. To run second relaxation. To do this, create a new directory (relax2 would be a good
choice for a name) by copying the original directory.
cp -r relax/ relax2
cd relax2/
10. Start from the final lattice parameters and atom positions by using the CONTCAR:
cp CONTCAR POSCAR
11. Remove all files except for the 4 input files. The script “cvf” makes this really easy:
cvf
12. Submit your job to the queue using the submission script. When it has finished, recheck
the same output we checked before. You should see that the volumes and energies
change much less between the initial and final iterations. Notice this final energy (E0)
should be lower than the E0 in your first relaxation run.
13. If your volume still changes by more than 10%, you will want to rerun again from the
CONTCAR file.
14. The CONTCAR file should now have the final relaxed lattice parameters and atom
positions in it. The OUTCAR will have the volume, and the OSZICAR will have the
total energy.
Ok! Now we have a relaxed structure, but we still need to do a kpoint convergence to make sure
our energies and volume are accurate.
Amy Bengtson
2/6/16 Page 12
Kpoint Convergence:
The more kpoints you have, the more accurate your calculation will be; however it will also be
slower. You want to make sure you are using a large enough kpoint mesh that your calculation
is accurate but can still run in a timely manner, which is why we do a kpoint convergence test.
Let’s use integration by parts as an analogy to explain how the kpoints work:
In integration by parts, the smaller boxes that you use to estimate the area under a curve the more
accurate your area estimation will be. It is the same idea with Kpoints – the more kpoints, the
more accurate.
We are going to do a kpoint convergence with respect to Energy (E0) and volume. You should
also do a kpoint convergence with respect to any final quantity that you want.
Use the relaxed structure that we found above (in directory relax2) to do a relaxation with higher
kpoints in a new directory (kpoints5 would be a good choice for a directory name):
1. Set up your input files:
cp -r relax2/ kpoints5
cd kpoints5/
cp CONTCAR POSCAR (to start from the relaxed structure)
vi KPOINTS
change 4 4 4 to 5 5 5
cvf (remove all VASP files except for the input files)
Submit your submission script.
2. Repeat this for KPOINTS files with meshes from 2 2 2 up to 20 20 20.
3. Submit all the jobs to the queue.
4. When the jobs are finished, get the total energy, volume, and CPU time from the output
files for each kpoint mesh.
5. To get the total energy type: grep E0 OSZICAR and take the last E0 that is listed.
6. To get the total volume type: grep vol OUTCAR and take the last volume that is listed.
7. CPU time: cat the OUTCAR and look for "Total CPU time used". This is for you to see
the time difference between kpoint meshes.
8. In Excel, plot the energy vs. kpoint mesh (in eV/atom units) and volume vs. kpoint mesh.
For hints on setup, see the excel sheet attached with the tutorial.
Amy Bengtson
2/6/16 Page 13
9. For kpoint mesh vs. energy, find the kpoint mesh where the energy/atom changes less
than 1meV from the higher kpoint mesh. This is your converged kpoint mesh with
respect to energy.
10. For the kpoint mesh vs. volume, find the mesh where the volume/atom changes less than
0.01 Angstroms from the higher kpoint mesh. This is your converged kpoint mesh
with respect to volume.
11. Are these convergedc kpoint meshes the same? If not, use the larger mesh for the most
accuracy.
12. Using your plots, think through what the consequences would be for using a kpoint mesh
that was not converged and talk through your thoughts with another group member that
uses DFT codes.
13. Show your plots of energy vs. kpoint mesh and volume vs. kpoint mesh to another group
member that uses DFT to make sure they make sense.
Note: As a rule of thumb, if the structure is cubic (like Rocksalt), the 3 kpoint values must all be
the same. If the structure is not cubic, then the kpoints should be the opposite of the ratios of the
sides of the unit cell – please ask me or any other group member if you run into this situation.
Dane’s convasp routine has a very useful tool for determining kpoint meshes vs. lattice
parameter: convasp -kmesh kptdens POSCAR (kptdens = total number of kpoints you want).
Note: after I find the correct KPOINT mesh, I usually use the CONTCAR from it and run a final
3rd relaxation run.
SUMMARY: You should always use the k-point mesh that gives you converged energies and
volumes. If you do not do a k-point convergence, you risk having inaccurate outputs (energies,
volumes), which could cause you to make false conclusions in your research.
NOTE: If you are interested in another value besides energy or volume (for example: TMR),
you should also do a k-point convergence vs. TMR value.
NOTE: After you have done k-point convergence, you may also want to do a ENCUT
convergence (sometimes you will need an ENCUT > 1.5*ENMAX, but not often).
TAKE IT FURTHER: If you really want to go above and beyond, find an experimental paper
on MgO and compare those lattice parameters to the lattice parameters you calculated with your
converged kpoint mesh. How close are the values?
Amy Bengtson
2/6/16 Page 14
Spin Polarized Calculation:
The above tutorial focuses on MgO, which is non-magnetic. I am telling you it is non-magnetic
based on what I know experimentally about MgO. However, you can use VASP to convince
yourself it is non-magnetic by running a spin polarized calculation and looking at the final
moments.
To do a spin-polarized calculation, add these lines to the INCAR file:
ISPIND = 2 #makes spin-polarized calc. possible
ISPIN = 2 #does spin-polarized calc.
MAGMOM= 5 1 #initial mag. mom. of each atom.
MAGMOM=moment on each atom (it should match the order in your POSCAR and POTCAR
files). Here, we are guessing that Mg has a moment of ~ 5 and O has a moment of ~ 1. These
moments will fully relax in the calculation.
Run the VASP calculation as before. (Use your relaxed lattice parameters and converged
kpoints that you found above).
Look at the energy grep E0 OSZICAR:
3 F= -.12029471E+02 E0= -.12029805E+02 d E =-.543298E+00 mag=
0.0000
Now you see that there is an extra column: mag = *** *
mag = the total moment of the cell.
Look at the magnetic moment on each atom. cat OUTCAR
Just below the final output you will see:
magnetization (x)
# of ion s
p
d
tot
---------------------------------------1
0.000 0.000 0.000 0.000
2
0.000 0.000 0.000 0.000
-----------------------------------------------tot
0.00 0.00 0.00 0.00
You can see there is no magnetic moment on atom 1 or 2, therefore it is non-magnetic.
Amy Bengtson
2/6/16 Page 15
Future Work:
Now that you have see the basics of how to run VASP, here are some future exercises to get
more comfortable with VASP.
1. Run FeO as a spin polarized calculation. Find the relaxed lattice parameters for FeO and
the magnetic moment on each atom.
a. Fe is magnetic, so you will do a spin polarized calculation.
b. You can probably use the same converged kpoint mesh you found for MgO
c. Use the same input files but change them to be FeO and spin polarized.
d. You want the relaxed lattice parameters and magnetic moment on Fe and O.
2. Repeat the entire calculation with the LDA pseudopotentials instead of GGA. How do
your energies and volumes change? Why is this?
3. ???
Scripts/Command we use and what they mean:
Note: There are a lot of scripts/details we have developed to make using VASP quicker and
easier. After you have learned the basics, please talk with Amy or any other VASP user to make
sure you know all of our tricks for running as quickly as possible. Examples include: cvf, fcvf,
convasp, EVP extract scripts, directory creation scripts, kpoint scripts, DOS information, and
much much more …
Amy Bengtson
2/6/16 Page 16
Download