top of page

 

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:

 

$ 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. 

 

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.

 

$ cat KPOINTS

MgO

 0

M

4 4 4

0 0 0

 

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).

    1. to submit type (in your current working directory): qsub parallel.sh

    2. to view the job in the queue, type: qstat and look for your user name.

 

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):       11.573

System time (sec):        0.247

Elapsed time (sec):       12.545

 

Maximum memory used (kb):           0.

Average memory used (kb):           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.

Analyze the Output Files:                                                                                 

 

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:

 Make sure the calculation is finished running:
tail OUTCAR and cat OUTCAR.  You should see something like:

 

User time (sec):       11.573

System time (sec):        0.247

Elapsed time (sec):       12.545

 

Maximum memory used (kb):           0.

Average memory used (kb):           0.

 

Minor page faults:        22173

Major page faults:           12

Voluntary context switches:          956

 

  1. 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:

$ 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

 

$ 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 %

 

Look at the volumes for each iteration:

grep vol OUTCAR
You should see something like:

 

 

  1. Look at the pressures for each iteration (mostly to make sure nothing weird happened).  grep pressure OUTCAR

 

 

$ grep pressure OUTCAR

  external pressure =     -229.03 kB  Pullay stress =        0.00 kB

  external pressure =     -259.23 kB  Pullay stress =        0.00 kB

  external pressure =    18566.56 kB  Pullay stress =        0.00 kB

  external pressure =     -238.66 kB  Pullay stress =        0.00 kB

 

What happens during a calculation:                                                                          

 

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:

 

 

$ 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 %

 

$ grep pressure OUTCAR

  external pressure =     -229.03 kB  Pullay stress =        0.00 kB

  external pressure =     -259.23 kB  Pullay stress =        0.00 kB

  external pressure =    18566.56 kB  Pullay stress =        0.00 kB

  external pressure =     -238.66 kB  Pullay stress =        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).

 

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. 

 

$ 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.  

 

 

Rerunning from the CONTCAR file:                                                             

 

  1. 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.

 

  1. 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/

 

  1. Start from the final lattice parameters and atom positions by using the CONTCAR:
    cp CONTCAR POSCAR

 

  1. Remove all files except for the 4 input files.  The script “cvf” makes this really easy:
    cvf

 

  1. 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.

 

  1. If your volume still changes by more than 10%, you will want to rerun again from the CONTCAR file.

 

  1. 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. 

 

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.

 

  1. Repeat this for KPOINTS files with meshes from 2 2 2 up to 20 20 20.

  2. Submit all the jobs to the queue. 

  3. When the jobs are finished, get the total energy, volume, and CPU time from the output files for each kpoint mesh.

  4. To get the total energy type: grep E0 OSZICAR and take the last E0 that is listed.

  5. To get the total volume type: grep vol OUTCAR and take the last volume that is listed. 

  6. CPU time: cat the OUTCAR and look for "Total CPU time used".  This is for you to see the time difference between kpoint meshes. 

  7. 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.

  8. 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.

  9. 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.

  10. Are these convergedc kpoint meshes the same?  If not, use the larger mesh for the most accuracy.

  11. 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.

  12. 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? 
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.

 

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. 

    1. Fe is magnetic, so you will do a spin polarized calculation.

    2. You can probably use the same converged kpoint mesh you found for MgO

    3. Use the same input files but change them to be FeO and spin polarized.

    4. You want the relaxed lattice parameters and magnetic moment on Fe and O.

 

  1. Repeat the entire calculation with the LDA pseudopotentials instead of GGA. How do your energies and volumes change?  Why is this?

 

  1. ???

 

 

 

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 …

 

Reference: Amy Bengtson 19 May 2006 updated 2 February 2007 updated April 2008

 

 

Quantum Materials for Energy Conversion Lab
School of Energy and Chemical Engineering, Ulsan National Institute of Science and Technology

반도체 ALD 박막 증착, DRAM 및 NAND 소자 제작,

DFT 시뮬레이션 관심 있는 대학원생 모집합니다

Contact : junhee@unist.ac.kr

Catalyst

Battery

Semiconductor

Hydrogen production

bottom of page