In this tutorial, we will do a geometrical optimization of the compound ZnO using the SinglePoint task by optimizing the lattice parameter a and the ration c/a and finding the optimized values of the lattice parameters a and c. We can refine the calculation of the ratio c/a to get the more optimized values of lattice parameters.

In the ZnO.cell file we need to use the lattice parameters as follows:

%BLOCK LATTICE_ABC
[units]
a b c
alpha beta gamma
%ENDBLOCK LATTICE_ABC


We need a param file and 2 scripts: one for doing optimization and another for doing plotting. The cell file is created by the script of optimization.

ZnO.param

task       SinglePoint           ! The TASK keyword instructs CASTEP what to do
xc_functional LDA ! Which exchange-correlation functional to use.
cut_off_energy 500 eV !
opt_strategy speed ! Choose algorithms for best speed

Script for optimization: hexcell-opt.sh and script for plotting: plot-EV-coa.sh

You may download the 2 scripts using the command line

$ wget https://raw.githubusercontent.com/jazairdz/Castep/refs/heads/main/hexcell-opt.sh

$ wget https://raw.githubusercontent.com/jazairdz/Castep/refs/heads/main/plot-EV-coa.sh

 

Execution

$ bash hexcell-opt.sh
running ratio= 1.5
running a= 3.00
running a= 3.05
.
.
.

finished with results in ZnO_ratio.dat

This calculation gives 5 files: ZnO_1.5.dat, ZnO_1.55.dat, ZnO_1.60.dat, ZnO_1.65.dat, ZnO_1.70.dat

 

$ python plot-EV-coa.sh

 This gives the script fit.Burch.py and the following figure:

 


 From the figure, we can see that the optimized ratio is c/a= 1.6 and we need to look for the optimized of lattice parameter value of a corresponding to this ratio. The results are in the file ZnO_fit.out file which contains the volume corresponding to c/a=1.60 (V0 =    45.6467 ang^3).

Results for c/a= 1.60
Burch-Murnaghan fit parameters:
E0 = -4451.6781 eV
B0 = 0.9216 eV.ang^-3
B' = 4.7735
V0 = 45.6467 ang^3

Bulk modulus = 147.6431 GPa

Graph of data and fit saved as BMM_curve.png - please check all is OK

 

Now we can use another script cal_lattice.sh to get the lattice parameters' values.

You may download the script using the command line

$ wget https://raw.githubusercontent.com/jazairdz/Castep/refs/heads/main/cal_lattice.sh


$ sh cal_lattice.sh
Enter optimized volume corresponding to optimized ratio (ang^3): 45.6467
Enter optimized value of c/a: 1.6

we get the results in the file ZnO_lattice.out

Lattice parameters

a = 3.605 ang c = 5.768 ang

c/a = 1.6 Volume = 45.6467 ang^3