VASP tutorial Computer resources This tutorial will guide you to perform first principles calculations using a density functional theory (DFT) based code called VASP. The VASP manual can be found at http://cms.mpi.univie.ac.at/vasp/vasp/vasp.html. All calculations can be performed at the Computational Materials Group’s linux machines. The host name of the machines (located at IMS) are phoebus.ims.uconn.edu and gaanam.ims.uconn.edu (henceforth referred to as phoebus and gaanam). Besides, the supercomputer sgi1.engr.uconn.edu located at the school of engineering and some external resources are available for you (in the future). To log onto these hosts you need an account (userid & password). Please ask the seniors in our group to create an account for you. Once you have logged on to a windows PC, you can log onto phoebus and/or gaanam using a secure shell client called PuTTY (freely available from http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe) or SSH (freely available from http://www.sfsu.edu/~doit/helpdesk/wdevapp.htm ). In our group SSH is used. An instruction for SSH is available from http://www.sfsu.edu/~helpdesk/ssh/ssh329/. Account Setup Once you have logged on to phoebus using the userid & password you are provided, you are all set to do some calculations, provided you follow the instructions below. phoebus uses the linux operating system. If you are not already familiar with the unix/linux operating system, you first need to learn some of the basics, such as how to navigate between directories, edit files, etc. A unix/linux tutorial is available at the end of this document. Once you log in to phoebus, your “command prompt” will be ”userid@phoebus:~>”. Change your default password by typing the command “passwd” at the command prompt, followed by hitting the enter key. Follow the instructions to change your password. In the following you will try a few VASP calculations, which are used as exercises in lab session of the course MMAT320. To do so, you need to copy and unpack a file at your home directory, by issuing the following commands at the command: o userid@phoebus:~> cp /home/rampi/mmat320.tar . o userid@phoebus:~> tar –xf mmat320.tar Note the dot at the end of the copy command; this is intentional. The tar command will create the directory mmat320 in your home directory (you can see this by typing ls and hitting the enter key) and unpack the file mmat320.tar into the directory mmat320. Type the command “chmod 700 mmat320” at the command prompt to restrict access to this directory. Change to the mmat320 directory by using the command “cd mmat320”, and view the contents of this directory (again by using the “ls” command). You should see the following subdirectories: Cl2, Cu-bulk-bcc, Cu-bulk-fcc, Cu-bulksc, Cu-surf-001, and Cu-surf-110, H2. Now, you are really ready to do some calculations. VASP files You will find that each of the subdirectories in mmat320 contains four files. These are the input files that VASP looks for before it starts a calculation. The four files are: POSCAR: lattice vectors, number of atoms, atomic locations, etc. INCAR: type of calculation, level of theory, accuracy desired, etc. POTCAR: pseudopotentials information for all atom types involved KPOINTS: k-points for Brillouin zone sampling Referring to the manual of VASP you will get more insights about these input files. An important note to be made here is that when you start to study a system, you should check k-points sampling to make sure you get converged calculation results. This can be done by gradually increasing the number of k-points and checking difference in the energy of the system. When the energy difference is within 0.005-0.01 eV per atom, you have obtained converged results. A rule of thumb is that when the size of your unit cell become larger (in some direction, say x- direction), you need fewer k-points in this direction. If you have a slab in your system along x-y plane and have a vacuum on top of your slab, you only need one k-point along z- direction. You can check out the KPOINTS files for the following exercises. If your system contains more than one type of atom, you will have to make a POTCAR from several POTCARs. The POTCARs for our group are located under directory /home/rampi/VASP on gaanam. Now suppose you want to make a PAW-GGA type POTCAR for ZnO at his home directory (you can move it to your working directory later). You can do it like this: tang@master:/home/rampi/VASP/potpaw_GGA> cp Zn/POTCAR.Z ~/Zn.Z (copy file POTCAR.Z under directory “Zn” to your home directory “~”) tang@master:/home/rampi/VASP/potpaw_GGA> cp O/POTCAR.Z ~/O.Z tang@master:/home/rampi/VASP/potpaw_GGA> cd (move to home directory) tang@master:~> gunzip Zn.Z (unzip Zn.Z, which creates file Zn) tang@master:~> gunzip O.Z tang@master:~> cat Zn O > POTCAR (output contents of files Zn and O to file POTCAR. Note Zn is the first, and O is the second. This defines the order of atom type in your POSCAR.) In the above, the blue parts are the commands, and the brown parts are comments. Some resources for DFT: Our group focuses on DFT-based computational materials science. It is quite necessary for a Ph.D. student who does DFT calculations to have a good grasp of this theory. Some introduction-level references of DFT are as follows: K. Burke et al, The ABC of DFT, 2003 K. Capelle, A Bird’s-Eye View of Density-Functional Theory, 2005 M. J. Gillan, Contemporary Physics, 38, 115, (1997) M. C. Payne et al, Reviews of Modern Physics, 64, 1045, (1992) The above references can be downloaded from http://raagam.uconn.edu/dftintroduction.htm . Important note: For the purpose of this tutorial session, you will need to modify/edit only the POSCAR file (modify the other files at your own risk!!!). Exercise 1: Calculate the equilibrium bond length of the Cl2 dimer molecule. From within the mmat320 directory, change to the Cl2 directory by issuing the command “cd Cl2” [Note that linux is case sensitive] Make sure that you have the four necessary files (POSCAR, INCAR, POTCAR and KPOINTS) by issuing the command “ls” Open the POSCAR file (say using the pico editor, by issuing the command “pico POSCAR”; feel free to use other editors of your choice). The POSCAR file should look like this: Cl2 molecule: 1.0 10.0 0.0 0.0 0.0 10.0 0.0 0.0 0.0 10.0 2 cartesian 0.00 0.00 0.00 1.97 0.00 0.00 Note the following: o The first line of this file is a dummy line that contains some information about the system you want to study. o The next line contains the length unit in Å. The lattice vectors that follow this line are multiplied by this parameter. o Lines 3-5 contain the three components of each of the three lattice vectors of the system. Note that regardless of whether we are studying an atom, a molecule, a periodic or a non-periodic solid, VASP will place the system in a “supercell” that will repeat in 3-dimensional space. For this problem, since we want to study a Cl2 dimer, we would like to place the molecule in a large box so that the dimer does not “see” its periodic image. A rule of thumb is that a distance of about 8 Å between one end of a system and the nearest end of its periodic image is sufficient to ensure isolation; hence the choice of 10 Å for each of the lattice vectors is reasonable. o Line 6 lists the number of atoms in the system [note that in this case, we have only one type of atom; if our system contains more than one type of atom, then the number of each type of atom will be listed in line 6 separated by spaces, and the order of atomic types should be consist with that in POTCAR.] o Line 7 contains a description of the format used for the atomic coordinates o Lines 8-9 contain the (x,y,z) location of each of the two atoms of our system (note that for this dimer example, only one internal coordinate, namely, the bond length, is relevant) We can use VASP to calculate the total energy of this system as a function of the bond length, from which we can determine the equilibrium bond length. To do a VASP calculation for the given POSCAR file, type “vasp-serial” at the command prompt and hit the enter key. (Here we assume you use phoebus. How to use VASP command on gaanam and how to use parallel VASP command will discussed at the end this set of exercises.) A bunch of stuff gets printed out, and ultimately, you will see a line with a value for E0 (in eV). This is the total energy (-3.3478 eV) for the initial choice of bond length of 1.97 Å. Record this value. Now, edit the POSCAR file, and change the x-coordinate of the second Cl atom to 1.99, save the file, exit the editor, and redo the VASP calculation by again issuing the command “vasp-serial”. Record the E0 value for this case. Repeat the calculation for successive increases of the bond length up to 2.07 Å. Below is a table of bond length (d, Å) versus total energy (E0, eV). d (A) 1.97 1.99 2.01 2.03 2.05 2.07 E0 (eV) -3.3478 -3.3661 -3.3754 -3.3771 -3.3705 -3.3571 A plot of E0 versus d (shown below) yields a parabola with a minimum at 2.02 Å. The experimental value for the Cl2 equilibrium bond length is 2.01 Å. -3.345 1.96 -3.35 1.98 -3.355 E0 (eV) -3.36 2 2.02 2.04 2.06 2.08 y = 9.9152x2 - 40.145x + 37.258 R2 = 0.9992 -3.365 -3.37 -3.375 -3.38 d (Angstroms) Exercise 1b: Calculate the equilibrium bond length of the H2 dimer molecule. [Experimental value of the bond length is 0.74 Å] -6.68 0.68 -6.69 -6.7 -6.71 -6.72 -6.73 -6.74 -6.75 0.7 0.72 0.74 0.76 0.78 0.8 Exercise 2: Calculate the lattice constant of Cu in the face centered cubic (FCC) phase. Change to the Cu-bulk-fcc directory by issuing the command “cd ../Cu-bulk-fcc” Make sure that you have the four necessary files (POSCAR, INCAR, POTCAR and KPOINTS) by issuing the command “ls” Open the POSCAR file (say using the pico editor, by issuing the command “pico POSCAR”; feel free to use other editors of your choice). The POSCAR file should look like this: fcc: 3.55 0.5 0.5 0.0 0.0 0.5 0.5 0.5 0.0 0.5 1 cartesian 000 Again, note the following: o The first line of this file is a dummy line that contains some information about the system you want to study. o The next line contains the length unit in Å. The lattice vectors that follow this line are multiplied by this parameter. Note that for bulk calculations, it is convenient to use the lattice constant in this line. o Lines 3-5 contain the three components of each of the three lattice vectors of the system. Note that we are using the primitive lattice vectors for a FCC lattice. o Line 6 lists the number of atoms in the system. Note that within the primitive unit cell, we have only one atom. o Line 7 contains a description of the format used for the atomic coordinates o Line 8 contains the (x,y,z) location of the atom of our system. Note that we chose to place this atom at the origin; the lattice vectors will translate this atom, and create the infinite FCC lattice. We can use VASP to calculate the total energy of this system as a function of the lattice constant, from which we can determine the equilibrium lattice constant. Again, to do a VASP calculation for the given POSCAR file, type “vasp-serial” at the command prompt and hit the enter key. A bunch of stuff gets printed out, and ultimately, you will see a line with a value for E0 (in eV). This is the total energy per unit cell which contains one atom for the initial choice of the lattice constant of 3.55 Å. Record this value. Now, edit the POSCAR file, and change the lattice constant (line 2) to 3.60, save the file, exit the editor, and redo the VASP calculation by again issuing the command “vasp-serial”. Record the E0 value for this case. Repeat the calculation for successive increases of the bond length up to 3.70 Å. Below are the table of lattice constant (a, Å) versus total energy (E0, eV), and a plot of E0 versus a. a (Ang) 3.55 3.6 3.65 3.7 E0 (eV) -3.6577 -3.6834 -3.6882 -3.676 -3.655 -3.66 3.5 -3.665 E0, eV -3.67 3.55 3.6 3.65 3.7 3.75 y = 3.79x2 - 27.597x + 46.548 R2 = 0.9986 -3.675 -3.68 -3.685 -3.69 -3.695 a, Angstroms The equilibrium lattice constant is the one that corresponds to the minimum, which in our case is 3.64 Å. The experimental value for FCC Cu is 3.61 Å. Exercise 3: Calculate the surface energy of the (001) surface of FCC Cu. Change to the Cu-surf-001 directory by issuing the command “cd ../Cu-surf-001” Open the POSCAR file. This file contains the supercell lattice vectors and atomic coordinates for a Cu(001) slab with 7 layers. The POSCAR file should look like this: fcc-(001) surface: 1.00 1.82 -1.82 0.0 1.82 1.82 0.0 0.0 0.0 18.2 7 Cartesian 0.00000000 0.00000000 0.00000000 1.82000000 0.00000000 1.82000000 0.00000000 0.00000000 3.64000000 1.82000000 0.00000000 5.46000000 0.00000000 0.00000000 7.28000000 1.82000000 0.00000000 9.10000000 0.00000000 0.00000000 10.92000000 Note the following: o Again, the first line of this file is a dummy line that contains some information about the system you want to study. o The next line contains the length unit in Å; we have used a unit of 1.0 Å, as we are not going to vary the lattice constant anymore. o Pay attention to the lattice vectors in lines 3-5. The lattice vectors are determined for the equilibrium lattice constant of 3.64 Å. Below is a picture of a (001) surface. Note that we have chosen the primitive lattice vectors for a1 and a2 along the surface plane (so that we have just one atom per surface unit cell), instead of the cubic lattice vectors (Question: what happens if we choose the cubic vectors? Answer: we will end up having 2 atoms for each surface plane, which translates to longer computational time!) Also, note that along the z-direction, i.e., the [001] direction, we have chosen a large lattice vector. This is done to ensure that the surface planes on adjacent “image” slabs do not “see” each other. 3.64 A a2 a1 x y o Line 6 lists the number of atoms in the system. Note that, since we have only one atom per surface plane, we have a total of 7 atoms for the 7-layer slab. o Line 7 contains a description of the format used for the atomic coordinates o Lines 8-14 contain the (x,y,z) location of all 7 atoms of our slab system. Pay careful attention to the atomic coordinates. o Make sure you understand the POSCAR file for this case; you can use the same idea to perform a (110) surface energy calculation. VASP can calculate the total energy of this slab. The INCAR file has been set up for this calculation so that the surface planes can move about and relax to satisfy coordinate unsaturations (of course, you do not have to mess with the INCAR file at all). Again, type “vasp-serial” at the command prompt followed by hitting the enter key, and VASP will begin the computation. This will take a while (about 5 minutes) as there are significantly more atoms, and we are performing geometry optimization as well. Record the E0 value at the end of the calculation, which should be -24.6499 eV. This is the total energy of a 7-atom slab; let’s call it E_surf. To determine the surface energy we need to know the energy of the perfect system. Let E_perf be the total energy of a perfect bulk crystal with 7 atoms. We can get this energy from the parabolic fit we obtained in Exercise 2. The minimum energy (corresponding to the equilibrium lattice constant of 3.64 Å) is 3.6891 eV per atom. Therefore, E_perf = -3.6891*7 = -25.8237 eV. Surface energy of (001) Cu surface = [-24.6499 – (-25.8237)]/(2*(3.64)2/2) = 0.0886 eV/ Å2 = 1.42 J/m2 Note that “2” exists before “*” in the denominator because two surfaces are created. To summarize, for Cu: Lattice constant (Å) (001) surface energy (J/m2) (110) surface energy (J/m2) Vacancy formation energy (eV) Pair Potential fit 2.86 2.53 3.49 * Surface energy averaged over several surfaces. DFT 3.64 1.42 HW #3 1.28 Experiment 3.61 ~ 1.7* ~ 1.7* 1.29 VASP commands on phoebus and gaanam clusters 1) on phoebus serial VASP: vasp-serial (standard command) vasp-serial > log (stuff printed out will be redirected to file “log”) vasp-serial > log & (“&” will run VASP in the background.) nohup vasp-serial > log & (“nohup”: VASP still runs even if you disconnect your terminal (your PC) with the cluster.) parallel VASP: When your system contains a lot of atoms the calculation using serial VASP will take long time. In such a case it is desirable to use parallel VASP. The command can be as follows: nohup /usr/local/mpich2/bin/mpirun -np 2 /usr/local/bin/vasp-parallel < /dev/null > log & In the above command, “2” following “-np” defines how many processors (CPUs) you want to use at the same time (two in this case). If you think this command is too long, you can write a file, for example, with name 2nd.sh, which contains the above command content. This can be done by first issuing command “cd ~/bin” and then “pico 2nd.sh”. Now issue command “chmod 755 2nd.sh”, which makes file “2nd.sh” a command. Next time when you run a parallel VASP calculation, all you need to do is just to type 2nd.sh and then hit the enter key (in your current working directory, i.e., the one containing VASP input files). Similarly you can create files 4nd.sh, etc. 2) on gaanam serial VASP nohup vasp > log & (this is the suggested command. Of course you can just use “vasp”) parallel VASP The structure of gaanam cluster is different from that of phoebus and so the usage of parallel VASP is a bit different. Gaanam consists of 12 nodes, each of the first 8 nodes (master node and nodes 2-8) having 2 processors, and each of nodes 9-12 having 4 processors. A parallel VASP command can be like this: nohup mpirun -v -nolocal -machinefile machinefile -np 4 /usr/bin/vaspmpi < /dev/null > log & In the above command the setting “-nolocal” enables you to submit jobs to nodes 2-12 rather than the master node. Since master node is in charge of the intercommunication among the slave nodes (nodes 2-12), too much load on the master will detriment the performance of the whole cluster. So submitting jobs to the master node is discouraged. In the above command, 4 processors (-np 4) are used. Parameter “machinefile” is a file (located in the current working directory) that defines which processors to be used. Some example machinefiles are: node11:4 (this will use 4 processors of node 11) node9 node10:2 (this will use 1 processor of node 9 and 2 processors of node 10) Following the procedure mentioned above you can put the parallel VASP command in a file named 4nd.sh in your bin directory (~/bin) to simplify your job submission. UNIX Tutorial UNIX systems are prompt based. This tutorial will explain the basic commands needed to navigate between directories, make new files/directories, copy/rename/delete files, use an editor, and execute commands. List of common UNIX commands and their usage Command Pwd mkdir directory rmdir directory cd directory cd .. Ls cp file1 file2 mv file1 file2 rm file1 Using directories for cp, mv cp file1 ./directory/. mv file1 ./directory/. cp file1 ./directory/file2 * Ps Top kill jobID Ctrl C Ctrl Z & cat file1 file2 > file1 Editor Pico pico file1 Ctrl X Ctrl O UNIX is cap sensitive Usage list current directory create a directory by name directory deletes directory change to directory directory go back one directory list all the files in the current directory make a copy of file1 and name it file2 rename file1 to file2 delete file1 copy file1 into directory (name stays the same) move file1 into directory copy file1 into directory and name file2 wildcard- can be used with ls, cp, mv, and rm shows your current jobs shows usage of the machine terminates a process of jobID terminates a job suspends a job runs process in background concatenate file1 and file2 write output to file1 opens editor opens file1 in editor (if file doesn’t exist, file is blank) exit pico editor write out file