by Ute Werner & Pasquale Pavone for exciting neon
(Jupyter notebook by Mara Voiculescu & Martin Kuban)
Purpose: In this tutorial, you will learn how to use different exchange-correlation (XC) functionals and the libxc library. As an example, the optimal volume and bulk modulus of silicon are calculated.
Table of Contents
2. Directly Implemented Functionals
Read the following paragraphs before starting with the rest of this tutorial!
Before running any Jupyter tutorials, please refer to the 00_before_starting.md
document on how to correctly set up the environment. This only needs to be done once. After which, the venv can be (re)activated from exciting
's root directory:
source tools/excitingjupyter/venv/excitingvenv/bin/activate
As a first step, you may create a running directory for the notebook.
%%bash
mkdir -p run_tutorial_xc_functionals
In this tutorial, we use ideas and scripts which are fully described in the tutorial Volume optimization for cubic systems. Here, we will use these scripts to compare XC functionals, without going into the details of the scripts. The comparison of results obtained for the equilibrium volume and bulk modulus for different XC functionals gives information on the validity and applicability of the functionals.
In this tutorial, we consider as an example the calculation of the energy-vs-volume curves for silicon in the fcc cubic structure. Inside the running directory, we create the file input.xml corresponding to a SCF calculation at a reference lattice constant. The input file employing the experimental lattice constant could look like the following.
<input>
<title>Silicon</title>
<structure speciespath="$EXCITINGROOT/species">
<crystal scale="10.261">
<basevect> 0.0 0.5 0.5 </basevect>
<basevect> 0.5 0.0 0.5 </basevect>
<basevect> 0.5 0.5 0.0 </basevect>
</crystal>
<species speciesfile="Si.xml">
<atom coord="0.00 0.00 0.00" />
<atom coord="0.25 0.25 0.25" />
</species>
</structure>
<groundstate
ngridk="8 8 8"
swidth="0.01"
rgkmax="8.0"
xctype="LDA_PW">
</groundstate>
</input>
The parameter xctype
specifies the XC functional that will be used in the calculation. In this example, the local spin density approximation (LDA_PW) is used. For further details and pararmeters see Input Reference.
Before starting the calculation, create a subdirectory called LDA_PW.
%%bash
cd run_tutorial_xc_functionals
mkdir -p LDA_PW
cd ..
The next step is writing the complete input as a string and saving it in your working directory as input.xml.
Set the correct path for the exciting
root directory ($EXCITINGROOT) to the one pointing to the place where the exciting
directory is placed.
%%bash
cd run_tutorial_xc_functionals/LDA_PW
python3 -m excitingscripts.setup.excitingroot
cd ../..
Using the input file created above, you can perform calculations at different volumes for the xctype
= "LDA_PW" functional, as you learn more in details in the tutorial Volume optimization for cubic systems. For a given exchenge-correlation functional, the recommended number of volume values for which a calculation should be done is 11.
%%bash
cd run_tutorial_xc_functionals/LDA_PW
python3 -m excitingscripts.setup.volume_optimization 11
cd ../..
To execute the calculations, run
%%bash
cd run_tutorial_xc_functionals/LDA_PW
python3 -m excitingscripts.execute.volume_optimization 11
cd ../..
After completing the calculation for the LDA_PW functional, you can investigate other functionals. For instance, you can change in the input file input.xml the value of the attribute xctype
to "GGA_PBE_SOL" (general gradient approximation, GGA). Then, you can run exciting
as above but changing the directory name to GGA_PBE_SOL, etc.
%%bash
cd run_tutorial_xc_functionals
mkdir -p GGA_PBE_SOL
cd ..
%%bash
cd run_tutorial_xc_functionals/GGA_PBE_SOL
python3 -m excitingscripts.setup.excitingroot
cd ../..
%%bash
cd run_tutorial_xc_functionals/GGA_PBE_SOL
python3 -m excitingscripts.setup.volume_optimization 11
cd ../..
%%bash
cd run_tutorial_xc_functionals/GGA_PBE_SOL
python3 -m excitingscripts.execute.volume_optimization 11
cd ../..
In order to compare the different XC functionals, you may calculate the lattice constant and the bulk modulus by entering the directory related to the exchange-correlation functional you choose and running there the script excitingscripts.plot.newbrich
.
%%bash
cd run_tutorial_xc_functionals/LDA_PW
python3 -m excitingscripts.plot.newbirch
cd ../..
Compare your results to the experimental values, which you can obtain, e.g., from the WebElements site. You can also use the Python script excitingscripts.plot.volumecurves
for a graphical comparison of the energy-versus-volume values for different functionals.
%%bash
cd run_tutorial_xc_functionals
python3 -m excitingscripts.plot.volumecurves -r LDA_PW GGA_PBE_SOL
cd ..
Using the given example you will obtain the following plot.
For a better comparison, the minima of the energy-vs-volume values are shifted to zero.
In order to use a wider variety of XC functionals or to combine different functionals for exchange and correlation, the libxc library can be used. For this purpose, the element libxc
can be added to the groundstate
element in the exciting
input. The XC functional can then be chosen with the attributes xc
or exchange
and correlation
, as described in detail in Input Reference.
Remarks:
Repeat the calculation for silicon from the previous section, but this time employing the libxc library. For this purpose, use the previous input file and replace the groundstate element with the following lines.
...
<groundstate
ngridk="8 8 8"
swidth="0.01"
rgkmax="8.0">
<libxc
correlation="XC_GGA_C_PBE"
exchange="XC_GGA_X_PBE">
</libxc>
</groundstate>
...
%%bash
cd run_tutorial_xc_functionals
mkdir -p libxc_functional
cd ..
%%bash
cd run_tutorial_xc_functionals/libxc_functional
python3 -m excitingscripts.setup.excitingroot
cd ../..
%%bash
cd run_tutorial_xc_functionals/libxc_functional
python3 -m excitingscripts.setup.volume_optimization 11
cd ../..
%%bash
cd run_tutorial_xc_functionals/libxc_functional
python3 -m excitingscripts.execute.volume_optimization 11
cd ../..
If you plot your new results together with the previous results from LDA_PW and GGA_PBE_SOL using the script excitingscripts.plot.volumecurves
, you will obtain the following plot:
%%bash
cd run_tutorial_xc_functionals
python3 -m excitingscripts.plot.volumecurves -r LDA_PW GGA_PBE_SOL libxc_functional
cd ..