Exchange-Correlation Functionals

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

0. Before Starting

1. Introduction

2. Directly Implemented Functionals

  • Preparation of the Input File
  • Execute Calculations at Different Volumes
  • Post Processing: Comparison of XC Functionals

3. Use of libxc

  • Example Calculation

4. Exercises

5. Literature


0. Before Starting

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.

In [1]:
%%bash
mkdir -p run_tutorial_xc_functionals


1. Introduction

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.


2. Directly Implemented Functionals

i) Preparation of the Input File

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.

In [2]:
%%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.

In [5]:
%%bash
cd run_tutorial_xc_functionals/LDA_PW
python3 -m excitingscripts.setup.excitingroot
cd ../..

ii) Execute Calculations at Different Volumes

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.

In [6]:
%%bash
cd run_tutorial_xc_functionals/LDA_PW
python3 -m excitingscripts.setup.volume_optimization 11
cd ../..

To execute the calculations, run

In [7]:
%%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.

In [8]:
%%bash
cd run_tutorial_xc_functionals
mkdir -p GGA_PBE_SOL
cd ..
In [11]:
%%bash
cd run_tutorial_xc_functionals/GGA_PBE_SOL
python3 -m excitingscripts.setup.excitingroot
cd ../..
In [12]:
%%bash
cd run_tutorial_xc_functionals/GGA_PBE_SOL
python3 -m excitingscripts.setup.volume_optimization 11
cd ../..
In [13]:
%%bash
cd run_tutorial_xc_functionals/GGA_PBE_SOL
python3 -m excitingscripts.execute.volume_optimization 11
cd ../..

iii) Post Processing: Comparison of XC Functionals

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.

In [14]:
%%bash
cd run_tutorial_xc_functionals/LDA_PW
python3 -m excitingscripts.plot.newbirch 
cd ../..
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     V0        B0         Bp        a-sc       a-bcc      a-fcc     log(chi)
  266.07236    96.128     4.272     6.4318     8.1036    10.2099      -5.87
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

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.

In [22]:
%%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.


3. Use of libxc

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:

  • Not every functional, especially not every combination of exchange and correlation, may give stable results. For more details on the validity and applicability of different functionals, please look at the tables shown here.
  • Further details concerning different functionals can be found in the libxc wiki.

Example Calculation

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>
...
In [25]:
%%bash
cd run_tutorial_xc_functionals
mkdir -p libxc_functional
cd ..
In [33]:
%%bash
cd run_tutorial_xc_functionals/libxc_functional
python3 -m excitingscripts.setup.excitingroot
cd ../..
In [1]:
%%bash
cd run_tutorial_xc_functionals/libxc_functional
python3 -m excitingscripts.setup.volume_optimization 11
cd ../..
In [2]:
%%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:

In [3]:
%%bash
cd run_tutorial_xc_functionals
python3 -m excitingscripts.plot.volumecurves -r LDA_PW GGA_PBE_SOL libxc_functional
cd ..


4. Exercises

  • Repeat the example of silicon for different XC functionals and try to find the best agreement with the experimental values.
  • Investigate the influence of different combinations of exchange and correlation functionals on calculations performed for another material, e.g., silver.


5. Literature

  • LDA_PW: J. P. Perdew and Y. Wang, Phys. Rev. B 23, 5048 (1981); D.M. Ceperly and B.J. Alder, Phys. Rev. Lett. 45, 566 (1980)
  • GGA_PBE_SOL: J. P. Perdew, A. Ruzsinszky, G. I. Csonka, O. A. Vydrov, G. E. Scuseria, L. A. Constantin, X. Zhou, and K. Burke, Phys. Rev. Lett. 100, 136406 (2008); Erratum: Phys. Rev. Lett. 102, 039902 (2009)
  • GGA_PBE: J. P. Perdew, K. Burke, and M. Ernzerhof, Phys. Rev. Lett. 77, 3865 (1996)