Header Ads Widget

Ab initio Calculations Using Vasp Code

Last Posts

10/recent/ticker-posts

Modified package (vaspup2.0) for Kpoint and Encutoff Convergence tests

To do convergence tests for Kpoints and Energy cutoff there is a package named vaspup2.0 which I made some modification for do convergence tests automatically.

we can download the package we use the following command:

git clone https://github.com/kavanase/vaspup2.0

First of all we need to add the path to the  ~/.bashrc  file

#--------vasprun2----------
VASPUP2BIN=/home/abderrahmane/abinitio/vaspup2.0/bin
export PATH=$PATH:$VASPUP2BIN
#-------------------------------------------------

The package contains the following:

abderrahmane@abderrahmane-Inspiron-3521:~/abinitio/vaspup2.0$ ls
bin  CITATION.cff  Dielectric_Constants_Convergence.ipynb  Examples  generate-converge  input 
 LICENSE  README.md

We need only the folders bin and input

We need only 3 scripts in the bin folder :

data-converge  data-converge-magnetic  generate-converge

I have modified the script generate-converge as follows:

#!/bin/bash
# vaspup2.0 - Seán Kavanagh (sean.kavanagh.19@ucl.ac.uk), 2023
# Check all needed files exist

[ ! -f input/CONFIG ] && echo "CONFIG file not found in ./input/ directory" && exit
[ ! -f input/INCAR ] && echo "INCAR file not found in ./input/ directory" && exit
[ ! -f input/POTCAR ] && echo "POTCAR file not found in ./input/ directory" && exit
[ ! -f input/KPOINTS ] && echo "KPOINTS file not found in ./input/ directory" && exit
[ ! -f input/POSCAR ] && echo "POSCAR file not found in ./input/ directory" && exit


# Read CONFIG file to get parameters
source input/CONFIG

# Converge ENCUT
if [ "$conv_encut" -eq "1" ]; then
mkdir cutoff_converge
cd cutoff_converge
for i in $(eval echo "{$encut_start..$encut_end..$encut_step}"); do
if [ "$i" -gt 999 ]; then
dirname="e_$i" # Add underscore to ensure correct ordering for data-converge
else
dirname="encut$i"
fi
mkdir "$dirname"
cd "$dirname"
cp ../../input/KPOINTS .
cp ../../input/INCAR .
cp ../../input/POTCAR .
cp ../../input/POSCAR .

sed -i "s/ENMAX .*$/ENMAX = $i eV/g" INCAR
sed -i "s/ENCUT .*$/ENCUT = $i eV/g" INCAR


[ "$run_vasp" -eq "1" ] && mpirun -np $np vasp_std
cd ..
done
cd ..
fi

# Converge k-points
if [ "$conv_kpoint" -eq "1" ]; then
mkdir "kpoint_converge"
cd "kpoint_converge"
n=1;

IFS=',' read -ra ADDR <<< "$kpoints" # Split the kpoints by comma
for i in "${ADDR[@]}"; do
firstk=$(echo $i | head -n1 | awk '{print $1;}')
sub=${i//[ ]/,}
if [ "$firstk" -gt 19 ]; then
sub="__$sub" # Add double underscore for >19 to ensure correct ordering for data-converge

elif [ "$firstk" -gt 9 ]; then
sub="_$sub" # Add underscore for >9 to ensure correct ordering for data-converge
fi

mkdir "k$sub"
cd "k$sub"
cp ../../input/KPOINTS .
cp ../../input/INCAR .
cp ../../input/POTCAR .
cp ../../input/POSCAR .


sed -i "4s/.*/${i}/" KPOINTS

[ "$run_vasp" -eq "1" ] && mpirun -np $np vasp_std
let n=n+1
cd ..
done
cd ..
fi

And I have also modified the config file as fommows:

# vaspup2.0 - Seán Kavanagh (sean.kavanagh.19@ucl.ac.uk), 2023
# This is the default config for automating convergence.
# Works for ground-state energy convergence and DFPT convergence.
# Make sure to rename to CONFIG before running.

conv_encut="1" # 1 for ON, 0 for OFF (ENCUT Convergence Testing)
encut_start="300" # Value to start ENCUT calcs from.
encut_end="900" # Value to end ENCUT calcs on.
encut_step="50" # ENCUT increment.

conv_kpoint="0" # 1 for ON, 0 for OFF (KPOINTS Convergence Testing)
kpoints="3 3 3,4 4 4,5 5 5,6 6 6,7 7 7,8 8 8,9 9 9" # All the kpoints meshes
# you want to try, separated by a comma

np="4" # number of processors used

run_vasp="1" # Run VASP after generating the files? (1 for ON, 0 for OFF)

Implementation

Ground-State Energy Convergence

To quickly set up a ground-state energy convergence test, the following steps are required:

  • Create a folder named input, containing INCAR, KPOINTS, POSCAR, and POTCAR VASP input files, a jobscript file (job) and a CONFIG file. Example CONFIG and INCAR files are provided in the input directory named CONFIG and energy_INCAR respectively. (Note: Rename energy_INCAR to INCAR, and set ISPIN = 1 if your system is non-magnetic for faster calculations). The directory structure should match the below:
./<Convergence Testing Directory (run script from here)>
    ./input
        /INCAR
        /KPOINTS
        /POSCAR
        /POTCAR
        /CONFIG
        
  • Customise the CONFIG file as you wish (specifying ENCUT and k-point convergence parameters and (optionally) the name to append to each jobname).

  • Run the generate-converge executable from the directory above the input directory. A series of folders will be created, with the folder names matching the calculation settings. For example, the cutoff_converge/encut450 folder will contain the ENCUT = 450 eV calculation and the kpoint_converge/k666 folder will contain the calculation with a k-mesh of 6 × 6 × 6 .

Note that vaspup2.0 uses the SGE qsub job submission command by default, but this can easily be modified in the bash scripts.

  • Once the calculations have finished running, the data-converge script can be used to extract the total energies from the VASP output. This script will print the convergence data to the terminal (as shown below) as well as saving to a file named Convergence_Data. The data-converge script should be run separately within the folders named kpoint_converge and cutoff_converge.

Execution

 This is the INCAR file used:

ALGO = Normal
EDIFF = 1e-07
ENCUT = 300 # Need ENCUT/ENMAX included in the INCAR for vaspup2.0 to converge-test this parameter
IBRION = -1 # singleshot calcs
ISMEAR = 0 # Note that ISMEAR = -5 will give better DOS convergence wrt kpoints (but won't work with 1x1x1 grid)
ISPIN = 2 # can be removed if system is non-magnetic
LORBIT = 11 # lm-projected DOS info
LREAL = False
NEDOS = 2000
NELM = 100
NSW = 0
PREC = Accurate
SIGMA = 0.05

# Parallelisation settings:
KPAR = 2

 

We need the input files

 abderrahmane@abderrahmane-Inspiron-3521:~/abinitio/vasp-tutorials/Si-testconv/input$ ls

 CONFIG  INCAR  KPOINTS  POSCAR  POTCAR

 abderrahmane@abderrahmane-Inspiron-3521:~/abinitio/vasp-tutorials/Si-testconv$ generate-converge

 abderrahmane@abderrahmane-Inspiron-3521:~/abinitio/vasp-tutorials/Si-testconv/kpoint_converge$ ls

k3,3,3  k4,4,4  k5,5,5  k6,6,6  k7,7,7  k8,8,8  k9,9,9

 encut300  encut350  encut400  encut450  encut500  encut550  encut600  encut650  encut700  encut750  encut800  encut850  encut900

abderrahmane@abderrahmane-Inspiron-3521:~/abinitio/vasp-tutorials/Si-testconv/kpoint_converge$ data-converge

Example output from data-converge: kpoint

Directory:     Total Energy/eV: (per atom): Difference (meV/atom): Average Force Difference (meV/â„«):
k3,3,3        -5.18222689    -5.1822268
k4,4,4        -4.82271891    -4.8227189      -359.5079            0.0000
k5,5,5        -4.77660086    -4.7766008      -46.1181            0.0000
k6,6,6        -4.86743413    -4.8674341      90.8333            0.0000
k7,7,7        -4.86110679    -4.8611067      -6.3274            0.0000
k8,8,8        -4.87499507    -4.8749950      13.8883            0.0000
k9,9,9        -4.90100508    -4.9010050      26.0100            0.0000

Example output from data-converge: encutoff

 Directory:     Total Energy/eV: (per atom): Difference (meV/atom): Average Force Difference (meV/â„«):
encut300        -4.88916593    -4.8891659
encut350        -4.89335168    -4.8933516      4.1857            0.0000
encut400        -4.89499212    -4.8949921      1.6405            0.0000
encut450        -4.89519834    -4.8951983      0.2062            0.0000
encut500        -4.89516619    -4.8951661      -0.0322            0.0000
encut550        -4.89514693    -4.8951469      -0.0192            0.0000
encut600        -4.89517434    -4.8951743      0.0274            0.0000
encut650        -4.89519533    -4.8951953      0.0210            0.0000
encut700        -4.89520711    -4.8952071      0.0118            0.0000
encut750        -4.89519952    -4.8951995      -0.0076            0.0000
encut800        -4.89519478    -4.8951947      -0.0048            0.0000
encut850        -4.89519606    -4.8951960      0.0013            0.0000
encut900        -4.89520249    -4.8952024      0.0064            0.0000



Reference: https://github.com/kavanase/vaspup2.0

Post a Comment

0 Comments