Header Ads Widget

Ab initio Calculations Using Q-Espresso Code

Last Posts

10/recent/ticker-posts

How to do the lattice parameter optimization 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 an optimization of the lattice parameter of Silicon using the package PWTK package. We need 2 files (input file pw.scf.silicon.in and pseudopotential si_pbe_v1.uspp.F.UPF ) and a script pwtk si_scf_alat.pwtk for automatic calculation.

 

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_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_alat.pwtk

load_fromPWI pw.scf.silicon.in

# please uncomment & insert value as determined in the "ecutwfc" exercise
SYSTEM { ecutwfc = 30 }

# please uncomment & insert values as determined in the "kpoints" exercise
K_POINTS automatic { 6 6 6 1 1 1 }


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

foreach alat { 9.7 9.8 9.9 10.0 10.1 10.2 10.3 10.4 10.5 10.6 10.7 } {

set name si_scf_alat-$alat

SYSTEM "celldm(1) = $alat"
runPW $name.in

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

close $fid

To do the calculation we run the following command:

/Si-cutoff-pwtk$ pwtk si_scf_alat.pwtk

We get the file  etot_vs_alat.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_alat.dat we use the script silicon-scf-alat.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 alat')
plt.xlabel('alat (Bohr)')
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-alat.py
/Si-cutoff-pwtk$ python3 silicon-scf-alat.py


We get the following picture:

 


 

 

 

Post a Comment

0 Comments