Setting up an electronic minimization: Difference between revisions

From VASP Wiki
Line 3: Line 3:
== Step-by-step instructions ==
== Step-by-step instructions ==


'''Step 1''': Create a {{FILE| POSCAR}} file containing the structure for which you want to compute the electronic groundstate. External Python tools like the Atomic Simulation Environment{{cite|ase}} or pymatgen{{cite|pymatgen}} can help with this step.
'''Step 1''': Create a {{FILE| POSCAR}} file containing the structure for which you want to compute the electronic groundstate. External Python tools like the Atomic Simulation Environment (ASE){{cite|ase}} or pymatgen{{cite|pymatgen}} can help with this step.


'''Step 2''': Choose an exchange-correlation (XC) functional appropriate for your material and quantity of interest according to our page recommending how to [[:Category:Exchange-correlation_functionals#Which_exchange-correlation_method_to_choose? | choose an XC method]].
'''Step 2''': Choose an exchange-correlation (XC) functional appropriate for your material and quantity of interest according to our page recommending how to [[:Category:Exchange-correlation_functionals#Which_exchange-correlation_method_to_choose? | choose an XC method]].

Revision as of 10:54, 3 March 2025

Setting up an electronic minimization calculation using density-functional theory requires a few steps. The input files must be created or copied into the execution folder. This includes making a few choices for the k-point sampling and electronic smearing, minimization algorithm, and exchange-correlation functionals. A dry-run can be used to review settings and select appropriate parallelization tags. After running the calculation, the output can be analyzed.

Step-by-step instructions

Step 1: Create a POSCAR file containing the structure for which you want to compute the electronic groundstate. External Python tools like the Atomic Simulation Environment (ASE)[1] or pymatgen[2] can help with this step.

Step 2: Choose an exchange-correlation (XC) functional appropriate for your material and quantity of interest according to our page recommending how to choose an XC method.

Step 3: Create a suitable POTCAR file by following the instructions on our preparing a POTCAR page.

Step 4: Create a KPOINTS file to define the integration mesh in reciprocal space. Starting with a regular meshis typically a good idea. Consult the symmetry reduction section of the KPOINTS page to select the appropriate mesh type.

Step 5: Write an INCAR file. It is recommended to start from a rather minimal file, and only specify the most important tags:

Step 6 (optional): Select the appropriate version of the VASP executable. I.e. vasp_gam if you only want to use the Gamma point for reciprocal space integration, vasp_ncl for noncollinear calculations, or vasp_std for anything else. Then Run a dry-run calculation to validate settings and uncover possible errors.

Step 7 (optional): Inspect the OUTCAR file of your dry-run. Take note of the number of bands, NBANDS, and the number of k-points, NKPTS, especially. Follow the guidelines on the optimizing the parallelization page to set NCORE and/or KPAR in the INCAR file.

Step 8: Run the calculation. If you are new to VASP, or unsure about the calculation setup, monitor the screen output. Once the calculation is finished, you have access to the electronic ground state properties via the output files. If there are problems with the electronic minimization, consult the page about troubleshooting electronic convergence. If you can not solve your problems with these resources, search our [Forum] for posts with similar issues.

Recommendations and advice

Mind: Make sure to specify the lattice vectors and ionic positions in the POSCAR with at least 7 digits of precision to ensure the symmetry analysis can work accurately.
Tip: Add only necessary tags to your INCAR file. Cluttered input is a common source of mismatched settings.
Tip: A larger smearing width SIGMA might be required to converge the calculation if your KPOINTS mesh is sparse.
Tip: ENCUT defaults to the largest ENMAX value found in the POTCAR file. Still, it is always a good idea to include it in the INCAR file to ensure comparability between different calculations.
Tip: Use the dry-run command-line argument or ALGO = None to check the feasibility of your settings and optimize parallelization tags, without wasting computational resources.
Tip: Some warnings are a bit hidden in the header section of the screen output. Redirecting the screen output to a file and saving it can simplify troubleshooting significantly.

Example

We will do a small DFT calculation of GaAs in the zincblende structure, using the local-density approximation (LDA) with the Perdew-Zunger parametrization of Ceperley-Alder Monte Carlo correlation data.[3][4]. Thus our XC functional will be set to XC = CA.

Setting up the POSCAR file

The POSCAR file starts with a comment line and a scaling factor, which in our case corresponds to the lattice parameter of GaAs, around 5.65 Angstrom.

Zincblende GaAs
  5.65000000000

Next we need to define the lattice vectors. Zincblende is a face-centered cubic (fcc) structure with two different elements in the unit cell. We can describe the fcc lattice with three vectors, pointing from the origin to the face-centers of the cube:

     0.0000000000000000  0.5000000000000000  0.5000000000000000
     0.5000000000000000  0.0000000000000000  0.5000000000000000
     0.5000000000000000  0.5000000000000000  0.0000000000000000

Now we define the ion types, and in the line below the number of ions in the structure for each type:

 Ga  As
  1   1

Now we specify the positions of the atoms in direct coordinates, with Ga at the origin and As a quarter along the diagonal of the cube:

Direct
  0.0000000000000000  0.0000000000000000  0.0000000000000000
  0.2500000000000000  0.2500000000000000  0.2500000000000000

We now have a finished POSCAR file:

Zincblende GaAs
  5.65000000000
     0.0000000000000000  0.5000000000000000  0.5000000000000000
     0.5000000000000000  0.0000000000000000  0.5000000000000000
     0.5000000000000000  0.5000000000000000  0.0000000000000000
 Ga  As
  1   1
Direct
  0.0000000000000000  0.0000000000000000  0.0000000000000000
  0.2500000000000000  0.2500000000000000  0.2500000000000000

If you have access to py4vasp, the structure can be visualized with two lines of Python code in a Jupyter notebook.

Visualization of the POSCAR with py4vasp
from py4vasp import calculation

calculation.structure.plot(supercell=2,selection="POSCAR")

If ASE[1] is installed, an equivalent POSCAR file can be created as follows:

from ase.build import bulk
from ase.io.vasp import write_vasp

atoms = bulk("GaAs", crystalstructure="zincblende", a=5.65)
write_vasp("POSCAR", atoms, direct=True, sort=False)

Creating the POTCAR file

We have already decided to use XC = CA, and can create the POTCAR file as discussed on the preparing a POTCAR page.

Creating the KPOINTS file

Since our structure is face-centered cubic, we create a regular Gamma-centered k-point mesh according to the symmetry considerations for KPOINTS files. The first line is a comment, followed by a 0 to turn on automatic regular mesh construction. If the next line starts with an G, a Gamma-centered k mesh is created, a line starting with M would create a Monkhorst-Pack[5] mesh.

 Regular k-point mesh
   0
 Gamma
  7 7 7

Creating the INCAR file

We initially chose a robust and efficient combination of a blocked-Davidson algorithm and the RMM-DIIS algorithm which can be selected with ALGO = Fast.

ALGO = Fast

GaAs is a semiconductor so we could use the tetrahedron method ISMEAR = -5 for our electronic smearing technique. But bandgaps are underestimated systematically by DFT and we might have made a mistake with the choice of functional or lattice parameter. Thus it is safer to select Gaussian smearing and a small smearing width.

ISMEAR = 0
SIGMA = 0.05

For an initial guess of the plane-wave cutoff energy ENCUT we can search for ENMAX in our POTCAR, e.g. by grep ENMAX POTCAR, and find that Ga_d has a larger ENMAX. Accordingly, we set:

ENCUT = 285

For the break condition of the self-consistent loop we select eV:

EDIFF = 1.0E-06

The complete INCAR file thus is:

ALGO = Fast
ISMEAR = 0
SIGMA = 0.05
ENCUT = 285
EDIFF = 1.0E-06

Making a dryrun

We are not doing a noncollinear, nor a Gamma-only calculation, thus we execute a VASP dry-run with the standard executable:

/your/vasp_dir/bin/vasp_std --dry-run

Which will print a warning about the dry-run and some information about the MPI-ranks, and OMP-threads, the VASP version, and the input structure. If mistakes were made in the setup, e.g. if the order of elements in the POSCAR and POTCAR do not match, warnings will be printed here as well.

We can now check the OUTCAR file and find the total number of k-points, 20, and number of bands, 13. This means a relatively low number of bands and a decent number of k-points. If we want to run our calculation on 4 MPI ranks, setting KPAR = 4 is an excellent choice for parallelization.

Running the calculation

After adding KPAR = 4 to the INCAR file, we run the calculation on 4 MPI ranks:

mpirun -np 4 /your/vasp_dir/bin/vasp_std

Consult the page on screen output for details about the information VASP prints out. For this example it should be similar to this:

 running    4 mpi-ranks, with    1 threads/rank, on    1 nodes
 distrk:  each k-point on    1 cores,    4 groups
 distr:  one band on    1 cores,    1 groups
 vasp.6.5.1 dev (build Feb 26 2025 12:50:33) complex                            
  
 POSCAR found type information on POSCAR GaAs
 POSCAR found :  2 types and       2 ions
 scaLAPACK will be used
 LDA part: xc-table for (Slater(with rela. corr.)+CA(PZ))
 , standard interpolation
 POSCAR, INCAR and KPOINTS ok, starting setup
 FFT: planning ... GRIDC
 FFT: planning ... GRID_SOFT
 FFT: planning ... GRID
 WAVECAR not read
 entering main loop
       N       E                     dE             d eps       ncg     rms          rms(c)
DAV:   1     0.623554581675E+02    0.62355E+02   -0.70852E+03   528   0.135E+03
DAV:   2    -0.533869968845E+01   -0.67694E+02   -0.65382E+02   580   0.246E+02
DAV:   3    -0.978648308320E+01   -0.44478E+01   -0.44252E+01   635   0.613E+01
DAV:   4    -0.985351010781E+01   -0.67027E-01   -0.67012E-01   614   0.819E+00
DAV:   5    -0.985490478744E+01   -0.13947E-02   -0.13947E-02   641   0.931E-01    0.301E+00
RMM:   6    -0.966994775594E+01    0.18496E+00   -0.21049E-01   715   0.453E+00    0.175E+00
RMM:   7    -0.962995087362E+01    0.39997E-01   -0.10316E-01   701   0.182E+00    0.574E-01
RMM:   8    -0.962647531739E+01    0.34756E-02   -0.12691E-02   740   0.127E+00    0.937E-02
RMM:   9    -0.962642094759E+01    0.54370E-04   -0.21071E-03   758   0.536E-01    0.594E-02
RMM:  10    -0.962647445785E+01   -0.53510E-04   -0.39196E-04   793   0.212E-01    0.166E-02
RMM:  11    -0.962646307401E+01    0.11384E-04   -0.91587E-05   787   0.105E-01    0.529E-03
RMM:  12    -0.962646461316E+01   -0.15391E-05   -0.17585E-05   736   0.426E-02    0.297E-03
RMM:  13    -0.962646464058E+01   -0.27424E-07   -0.26909E-06   488   0.221E-02
   1 F= -.96264646E+01 E0= -.96264646E+01  d E =-.203235E-08
 writing wavefunctions

Related tags and articles

INCAR, POSCAR, KPOINTS, POTCAR, KSPACING

References