Header Ads Widget

Ab initio Calculations Using Q-Espresso Code

Last Posts

10/recent/ticker-posts

How to do Convergence Tests of ECUTOFF 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.in and pseudopotential si_pbe_v1.uspp.F.UPF ) and a script pwtk si_scf_ecutoff.pwtk for automatic calculation.

 

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

pw.scf.silicon.in

&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.pz-vbc.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_ecutoff.pwtk

# load the pw.x input from file
load_fromPWI pw.scf.silicon.in

# open a file for writing resulting total energies
set fid [open etot_vs_ecutwfc.dat w]

# loop over different "ecut" values
foreach ecut { 12 16 20 24 28 32 } {

# name of I/O files: $name.in & $name.out
set name si_scf_ecutwfc-$ecut

# set the pw.x "ecutwfc" variable
SYSTEM "ecutwfc = $ecut"

# run the pw.x calculation
runPW $name.in

# extract the "total energy" and write it to file
set Etot [::pwtk::pwo::totene $name.out]
puts $fid "$ecut $Etot"
}

close $fid

 

To do the calculation we run the following command:

Si-cutoff-pwtk$ pwtk si_scf_ecutoff.pwtk

We get the file  etot_vs_ecutwfc.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_ecutwfc.dat we use the script silicon-scf-ecutoff.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 ecutwfc')
plt.xlabel('ecutwfc (Ry)')
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-ecutoff.py
/Si-cutoff-pwtk$ python3 silicon-scf-ecutoff.py


We get the following picture:


Post a Comment

0 Comments