Header Ads Widget

Ab initio Calculations Using Q-Espresso Code

Last Posts

10/recent/ticker-posts

How to do Convergence Tests of KPOINTS parameter using the PWTK package

 

To download and install the PWTK package click on the following link:

 How to download and install PWTK package

 

We will do convergence tests for ECUTOFF and KPOINTS parameters. For every calculation, we need 2 files (input file pw.scf.silicon and pseudopotentialsi_pbe_v1.uspp.F.UPF ) and a script pwtk si_scf_kpoints.pwtk for automatic calculation.

 

To do the ECUTOFF convergence test, we need the following files and script:

pw.scf.silicon

&CONTROL
! we want to perform self consistent field calculation
calculation = 'scf',

! prefix is reference to the output files
prefix = 'silicon',

! output directory. Note that it is deprecated.
outdir = './tmp/'

! directory for the pseudo potential directory
pseudo_dir = './'

! verbosity high will give more details on the output file
verbosity = 'high'
/

&SYSTEM
! Bravais lattice index, which is 2 for FCC structure
ibrav = 2,

! Lattice constant in BOHR
celldm(1) = 10.26,

! number of atoms in an unit cell
nat = 2,

! number of different types of atom in the cell
ntyp = 1,

! kinetic energy cutoff for wavefunction in Ry
ecutwfc = 30

! number of bands to calculate
nbnd = 8
/

&ELECTRONS
! Mixing factor used in the self-consistent method
mixing_beta = 0.6
/

ATOMIC_SPECIES
Si 28.086 si_pbe_v1.uspp.F.UPF

ATOMIC_POSITIONS (alat)
Si 0.0 0.0 0.0
Si 0.25 0.25 0.25

K_POINTS (automatic)
6 6 6 0 0 0

 si_scf_kpoints.pwtk

load_fromPWI pw.scf.silicon.in

set fid [open etot-vs-kpoint.dat w]

foreach k { 2 4 6 8 } {

set name si_scf_kpoints-$k

K_POINTS automatic "$k $k $k 1 1 1"
runPW $name.in

set Etot [::pwtk::pwo::totene $name.out]
puts $fid "$k $Etot"
}

close $fid

 

To do the calculation we run the following command:

/Si-cutoff-pwtk$ pwtk si_scf_kpoints.pwtk

We get the file  etot_vs_kpoints.dat

 

To the plot the data, we use the matplotlib package which is developed with python language.

To install the package we run the following command:

sudo apt-get install python3-matplotlib


To the plot the file etot_vs_kpoints.dat we use the script silicon-scf-kpoints.py

#!/usr/bin/env python3

import matplotlib.pyplot as plt
from matplotlib import rcParamsDefault
import numpy as np
#%matplotlib inline
plt.rcParams["figure.dpi"]=150
plt.rcParams["figure.facecolor"]="white"


file_name = input("Enter the file name:")
x, y = np.loadtxt(file_name, delimiter=' ', unpack=True)
plt.plot(x, y, "o-", markersize=5, label='Etot vs kpoints')
plt.xlabel('kpoints)')
plt.ylabel('Etot (Ry)')
plt.legend(frameon=False)
plt.show()
)


To execute the script we run the following commands:

/Si-cutoff-pwtk$ chmod +x silicon-scf-kpoints.py
/Si-cutoff-pwtk$ python3 silicon-scf-kpoints.py


We get the following picture:

 


 

 

Post a Comment

0 Comments