Using VASP for density functional theory (DFT)

Handy Terminal Commands

Login: ssh [username]@[serverIP]

Password: [password]

Copying a file from your local machine to the destination server: scp ~/[local file path] [username]@[serverIP]:~

Before You Start: Creating the Necessary Files

POSCAR file

  1. Open CIF files with VESTA, which you can download here.
  2. Export structure as fractional coordinate (rename the files as POSCAR in a folder with whatever naming convention you prefer)
    • On Macbook, it can only saved as POSCAR.vasp so you can't just delete it. You can only remove the .vasp with the command mv POSCAR.vasp POSCAR
  3. Move POSCAR files from local computer to your folder on the destination server with terminal/powershell using the above keys
  4. I name the first folder as [composition-structure] and will have the specific composition named as composition or structure type, depending on what I’m doing, such as CeRuSi2-CeNiSi2. However, everyone works their own way, just make sure to keep detailed notes.

POTCAR file

  1. Check order of POSCAR molecules for the potcreate command
    • For example: potcreate Si Fe Ce in command line, which matches the order of molecules in the POSCAR file
  2. Check available element potentials like this: potshow Si
  3. You can also generate POTCAR files using VASPKIT:
    • Type vaspkit in the terminal
    • Type 01 for VASP Input-Files Generator
    • Type 103 to generate POTCAR file with default settings
    • Note: Your PBE directory must be set up correctly when installing VASP

INCAR file

  1. Copy the INCAR from this template below, or download it here.

KPOINTS file

  1. Generate the file using VASPKIT, as seen in the video here .
  2. You can also use VASPKIT by typing vaspkit in the terminal, then 01 for VASP Input-Files Generator, and 102 for KPOINTS file.
  3. This file is an attempt to solve Schrodinger's equation… which is technically an infinite attempt as you have a guess and set up the cutoff and wanted precision in POSCAR file
    • K-Points: This line indicates the type of k-points generation scheme being used. In this case, it's set to "Gamma", meaning a single k-point at the center of the Brillouin zone.
    • 0: This value typically denotes the number of k-points to be generated. Here, "0" implies a single k-point.
    • Gamma: Specifies the center of the Brillouin zone where the k-point is placed.
    • 8 2 8: Defines the mesh size, i.e., the number of k-points along each reciprocal lattice vector direction. "8 2 8" indicates 8 k-points along the first lattice vector, 2 along the second, and 8 along the third.
    • 0 0 0: Specifies any fractional shifts applied to the k-point grid. In this example, there are no shifts applied.

Installing VASPKIT

VASPKIT Installation Tutorial Thumbnail
Installation instructions
  1. Visit the VASPKIT installation page for step-by-step instructions for Linux, macOS, and Windows.
  2. Follow the guide to download, compile, and set up VASPKIT on your system.
  3. For a visual walkthrough, see the tutorial video above.
  4. Once installed, you can run VASPKIT by typing vaspkit in your terminal.

Geometry Optimization

Structure Optimization for DFT with VASP YouTube Thumbnail
Tutorial video
  1. Note: mpirun is a command used to launch parallel programs written using the Message Passing Interface (MPI) standard.
  2. The Oliynyk lab uses SLURM for job scheduling, so you need a job file. See the template here.
  3. Once all the above files are created, you’re ready to go with optimizing. You MUST do this before anything else. It is pertinent to start any calculations with an optimized and most thermodynamically stable geometry.
  4. To run with SLURM, use:
    • sbatch job
    • Check status: sq
    • Cancel a job: scancel [job no.] (job number shown by sq)
    • Tip: Change the job name in your job file for each run so cancelling is easy.
  5. type mpirun -np 16 vasp_std>1& (Oliynyk lab - use sbatch job after setting job file) in the command line while in the directory of the folder with your files. "1" indicates the first run, "2" indicates the second, and "3" indicates the third. I do this to keep track of everything, but you can just repeat the same command after copying CONTCAR to POSCAR.
  6. Can view status of calculation/warnings with the following command:
    • Vim + 1
    • tail 1 (only displays last couple of lines)
  7. Can view energy with the following command:
    • grep TOTEN OUTCAR
  8. If ‘reached required accuracy - stopping structural energy minimisation’ is displayed at the bottom of file 1, this indicates it has reached your threshold of accuracy, indicated by EDIFF in the INCAR file. Copy the optimized structure to the structure input file with:
    • cp CONTCAR POSCAR
  9. Continue with the second run:
    • mpirun -np 4 vasp_std>2& (Oliynyk lab - use sbatch job after setting job file)
  10. If ‘reached required accuracy - stopping structural energy minimisation’ is displayed at the bottom of file 2, copy the optimized structure to the structure input file with:
    • cp CONTCAR POSCAR
  11. Continue with the third run:
    • mpirun -np 4 vasp_std>3& (Oliynyk lab - use sbatch job after setting job file)
  12. If ‘reached required accuracy - stopping structural energy minimisation’ is displayed at the bottom of file 3, copy the optimized structure to the structure input file with:
    • cp CONTCAR POSCAR

For hybrid calculations

  1. If a certain potential cannot converge no matter what, you need to enable the section for the hybrid calculations in the INCAR file. The optimization will take much longer, up to weeks in some cases.
  2. In case there’s a problem with convergence, the way to fix that would be changing TIME = 0.2 to 0.1 in the INCAR file.
  3. Setting an easier convergence criterion, namely 10^-6 and 10^-5 for electronic and ionic loop respectively may help with stubborn structures.

Data Accrual

  1. For free energy:
    • While in the structure directory, type grep TOTEN OUTCAR to see the final energy of the optimized structure, which is the last iterated value at the bottom.
    • Looks like this:
    • Free Energy Image Placeholder
  2. For optimized parameters:
    • While in the structure directory, type vim POSCAR
    • This is why we type cp CONTCAR POSCAR at the end of our third optimization iteration.
    • One can also just type vim CONTCAR, but we want to export POSCAR later for further calculations – so it’s best to do the first command in 1.
    • Looks like this:
    • Optimized Parameters Image Placeholder
    • After opening the file in the vim editor, you will see the optimized parameters as displayed in the image above.
    • Where the first line with values indicates parameter A, second indicates B, and third indicates C (in Angstroms).
      • In this case, we have a matrix representation of a non-orthogonal unit cell. It is monoclinic. You will notice that there are more than one value in each line.
      • Optimized Parameters Matrix Image Placeholder
      • To deal with this and convert it to appropriate parameters as well as angles, import the optimized POSCAR to VESTA and report the A, B and C cell parameters as well as the β Angle (°) in the summary section.
        VESTA Summary Image Placeholder

Density of States - DOSCAR

DOSCAR Analysis YouTube Thumbnail
Tutorial video
  1. Uncomment DOS & band structure and General Parameters (never LWAVE = .FALSE.) in INCAR as we need the WAVECAR file for this.
  2. Non-spin polarized DOSCAR
  3. Spin-Polarized and Non-Spin-Polarized :
    • ISPIN=1 (non-spin-polarized) and ISPIN=2 (spin-polarized) calculations.
  4. Atomic orbital contribution settings:
  5. Run with mpirun -np 16 vasp_std>Dos1& (Oliynyk lab - use sbatch job after setting job file)
  6. Copy DOSCAR files to local desktop for analysis when converged
  7. Plotting DOSCAR:
    • You can plot the exported POSCAR and DOSCAR files using DOSCAR-GUI.
    • More information and settings can be found on GitHub.

Magnetic Moment Calculation

  1. Spin-polarized DOSCAR (only if magnetism is expected here, otherwise you can ignore this)
    • Add the following to the INCAR:
      • ISPIN = 2
      • MAGMOM = ie.) 4*0 4*1 OR 0 0 0 0 1 1 1 1
        • This can only be full integers
        • This is your prediction, the OUTCAR file will give you the software's guess
    • Run with mpirun -np 8 vasp_std>Dos2& (Oliynyk lab - use sbatch job after setting job file)
      • Rerun until the OUTCAR charges are the same as your input MAGMOM prediction, as it gets better with better predictions
        • As in they’re all positive numbers or negative numbers with respect to your entry. The output does not have to match besides it being positive or negative, usually.
    • Retrieve DOSCAR file when converged
    • From there, plot the same elemental contributions in wxDragon like before

Electron Localization Function - ELFCAR

ELFCAR + Bader CHG Calculation YouTube Thumbnail
Tutorial video
  1. Uncomment Bader Charge and Electron localization function and General Parameters in INCAR
  2. Run with mpirun -np 16 vasp_std>Elf& (Oliynyk lab - use sbatch job after setting job file)
  3. Import ELFCAR file into local computer and drag into VESPA to view

Bader Charges

Bader Charges Tutorial YouTube Thumbnail
Tutorial video
  1. Uncomment Bader Charge and Electron localization function and General Parameters in INCAR, comment out KPAR
  2. Run with -np 8 vasp_std>Bader& (Oliynyk lab - use sbatch job after setting job file)
  3. When converged run chgsum.pl AECCAR0 AECCAR2
    • This combines core and valence electrons
  4. type bader CHGCAR -ref CHGCAR_sum
    • Looks like this:
    • Bader Charges Image Placeholder
  5. Import ACF.dat to local machine or just view it in the terminal with vim command
  6. Run grep ZVAL POTCAR
    • Looks like this:
    • Bader Charges Image Placeholder
  7. Run vim POSCAR if you forget the order of the molecules to determine which charge is which molecule
  8. Use above values as the initial charge, see the VASP output in ACF.dat to determine difference, or actual charge

Crystal Orbital Hamiltonian/Overlap Populations (COHP/COOP)

COHP/COOP Tutorial YouTube Thumbnail
Tutorial video
  1. Uncomment COHP Analysis (via LOBSTER) and General Parameters in INCAR
  2. Copy the lobsterin file from this template below, or download it here. Note that you can only have a maximum of four interactions in one calculation. You can also add the lobsterin file after your calculation. lobsterin is not needed for the VASP calculation to run. Only for lobster to run.
  3. ! First, enter the energetic window in eV (relative to the Fermi level):
    COHPstartEnergy -10
    COHPendEnergy 5
    !
    ! Then, specify which types of valence orbitals to use:
    includeorbitals s p d
    ! You can also specify the basis functions per element manually, e.g.:
    ! basisfunctions Ga 4s 4p
    ! basisfunctions Sr 5s 4s 4p ! Sr_sv potential
    !
    ! Now define the pairs for which COHP analysis etc. should be done.
    ! The atoms are numbered as per order in the PAW-code control file.
    !cohpbetween atom 1 atom 10
    !
    ! If you are interested in single orbital COHPs, you can get all the pairs ! like s-s, s-p_x, ..., p_z-p_z. Uncomment this line to switch it on:
    ! cohpbetween atom 1 atom 2 orbitalwise
    !
    ! If you want to generate the COHPPairs automatically, use this to include ! all pairs in a given distance range (in Angstrom, not in atomic units):
    cohpGenerator from 1 to 2.5 type Si type Fe
    cohpGenerator from 1 to 3.3 type Gd type Si
    cohpGenerator from 1 to 3.3 type Gd type Fe
    cohpGenerator from 1 to 2.6 type Si type Si
    ! and in the latter case only between the specified elements
    - of course adjust accordingly to your atomic interactions and optimized structure's bond distances.
    - I like using VESTA to visualize this
  4. type mpirun -np 20 vasp_std>COHP& (Oliynyk lab - use sbatch job after setting job file)
  5. type lobster
  6. Note: If you do not set NBANDS or set it too low, you may see an NBANDS error in the output file. Check the required value, then set NBANDS to that value plus 20 for reliable results.
  7. Import COOPCAR.lobster, COHPCAR.lobster, to local machine as needed for plotting
  8. To plot COHP/COOP, save the files (COOPCAR.lobster, COHPCAR.lobster, etc.) in a .zip archive and upload to COHP-COOP-GUI.
  9. See GitHub for more info and settings.

Band Structure

Band Structure Tutorial YouTube Thumbnail
Tutorial video
  1. Uncomment DOS & band structure and General Parameters (never LWAVE = .FALSE.) in INCAR as we need the WAVECAR file for this.
  2. Then we need to use VASPKIT to create a new KPOINTS using the symmetry. Follow these steps:

Work function

    Check back soon!

Phonons

    Check back soon!

Processor Considerations

  1. More processors doesn’t necessarily mean faster computations!

Troubleshooting errors

  1. ERROR FEXCP: supplied exchange-correlation table is too small, maximal index: 5536
    • Solved by adding the following to the INCAR:
      • IBRION=1
      • ISIF=2
  2. internal error in FOCK_FCC: number of k-points incorrect 5 18 2 2 2
    • Solved by ensuring KPOINTS are divisible by the grid reduction factors:
      • NKREDX = 2
      • NKREDY = 2
      • NKREDZ = 2
    • For example, a 5 x 5 x 5 mesh will not work. Use 4 x 4 x 4, etc.
    • Solution found here.

Further debugging resources

  • To calculate NBANDS: