# Solution LAB1 diamond bulk modulus

### Bulk modulus of diamond

Using the data produced in the previous exercise (total energy as a function of the lattice parameter for a range of ecutwfc values), one can do the following:

• extract etot vs volume for each wfcutfc value into different files;
• fit the data and extract the second derivative in the minimum;
• this can be done using a second (or better higher) order polynomial or other fitting functions (cubic splines, Murnaghan equation of state, ...)
• Evaluate the bulk modulus taking care of unit conversion to international system (B modulus is given in GPa)
• The above steps are coded in the script `./LabQSM/tools/compute_B_modulus.py` for convenience

Results as a function of the kinetic energy cutoff are reported below:

1. ecut [Ry] B modulus [GPa]
```  20         4222.035362534261
30          545.8276696265291
40          577.6525328096515
50          678.313290451693
60          526.4841165649044
80          463.3508978235948
100          471.6781060558174
120          468.6260793219729
140          467.798081344509
160          467.04233495671605
```

Once again, a cutoff of 60-80 Ry (80 better) seems to be sufficient.

A script to automate the calculation can be put together as follows:

``` #!/bin/bash

list=`ls results_*_vol.dat`
fileout=results_BMOD.dat

echo "#  ecut [Ry]     B modulus [GPa]" > \$fileout

for file in \$list
do
filein=\$file
ecut=`echo \$file | cut -d "_" -f2 | sed 's/Ry//'`
bmod=`./compute_B_modulus.py \$file | tail -1 | awk '{print \$(NF-1)}'`
echo \$ecut \$bmod >> \$fileout
done
```