In this tutorial, we will take the example of Aluminum Al. We need the param file and a script to create the cell file with different values of cutoff energy.
Al.param
task SinglePoint ! The TASK keyword instructs CASTEP what to do
xc_functional LDA ! Which exchange-correlation functional to use.
cut_off_energy 700 !
opt_strategy speed ! Choose algorithms for best speedkpoint-conv.sh
#!/bin/sh
NAME=Al
rm -f ${NAME}.castep
rm -f ${NAME}_KPOINT.dat
for K in 3 4 5 6 7 8 9 10 12 14 16
do
cat > ${NAME}.cell << EOF
%BLOCK LATTICE_ABC
2.86 2.86 2.86
60 60 60
%ENDBLOCK LATTICE_ABC
%BLOCK POSITIONS_ABS
Al 0 0 0
%ENDBLOCK POSITIONS_ABS
kpoint_mp_grid $K $K $K
symmetry_generate
EOF
echo ${NAME}_${K}_${K}_${K}
mpirun -np 4 castep.mpi ${NAME}
done
#analyse the runs and extract the values we need into a single results file
grep 'MP grid size for SCF calculation is ' ${NAME}.castep | awk '{print $8}' > K
grep 'Final energy' ${NAME}.castep | awk '{print $5}' > E
paste K E >> ${NAME}_KPOINT.dat
rm K E
echo ' '
echo 'finished with results in '${NAME}_KPOINT.dat
Execution
$ sh kpoint-conv.shAl_3_3_3
Al_4_4_4
Al_5_5_5
Al_6_6_6
Al_7_7_7
Al_8_8_8
Al_9_9_9
Al_10_10_10
Al_12_12_12
Al_14_14_14
Al_16_16_16
finished with results in Al_KPOINT.dat
finished with results in Al_KPOINT.dat
The content of the file Al_KPOINT.dat is :
3 -109.1831853078
4 -109.7184971323
5 -109.7164492004
6 -109.7672338408
7 -109.8214800225
8 -109.7791609360
9 -109.7447828790
10 -109.7778457064
12 -109.7731871378
14 -109.7726274274
16 -109.7748461704
Plotting
To plot the results we need to use the following python script:
kpoint-conv.py
import matplotlib.pyplot as plt
from matplotlib import rcParamsDefault
import numpy as np
plt.rcParams["figure.dpi"]=150
plt.rcParams["figure.facecolor"]="white"
x, y = np.loadtxt('Al_KPOINT.dat', delimiter=' ', unpack=True)
plt.plot(x, y, "o-", markersize=5, label='Etot vs kpoints')
plt.xlabel('# kpoints')
plt.ylabel('Etot (eV)')
plt.legend(frameon=False)
plt.show()Before running the script we need to install matplotlib tool for plotting
$ sudo apt-get install python3-matplotlib $ python kpoint-conv.py
We get the following picture

0 Comments