**by****Ute Werner****for****exciting****carbon**

** Purpose:** In this tutorial, you will learn how to use different exchange-correlation (

`) functionals and the`

**XC**`library. As an example, the optimal volume and bulk modulus of silicon are calculated.`

**libxc**### 1. Introduction

We assume you are already familiar with the ideas and the scripts shown in ` Volume optimization for cubic systems`. Here, we will use these scripts to compare

`functionals. 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.`

**XC**### 2. Directly implemented functionals

##### i) Preparation of the input file

The first step is to create a directory for the system that you want to investigate.

```
$ mkdir XC-functionals
$ cd XC-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 directory ` XC-functionals`, we create the file

**corresponding to a**

`input.xml``calculation at a reference lattice constant. The input file employing the experimental lattice constant could look like the following.`

**SCF**<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

`functional that will be used in the calculation. In this example, the local spin density approximation (`

**XC**`) is used. For further details and perarmeters see`

**LDA_PW**`. Set the correct path for the`

**Input Reference**`root directory (`

**exciting**`) to the one pointing to the place where the`

**$EXCITINGROOT**`directory is placed.`

**exciting**`$ SETUP-excitingroot.sh`

##### ii) Execute the calculations

Using the input file created above, you can perform the calculations for the ` xctype` =

`functional, as you have already learned in the tutorial`

**"LDA_PW"**`. Since you will run several sets of calculations, it is recommended to decrease the number of volume values,`

**Volume optimization for cubic systems***e.g.*, to

**7**.

```
$ SETUP-volume-optimization.py workdir_LDA
Enter the number of volume values >>>> 7
$
```

To execute the calculations, run

```
$ EXECUTE-volume-optimization.sh workdir_LDA
...
```

After completing the calculation for the ` LDA` functional, you can investigate other functionals. For instance, you can change in the input file

`the value of the attribute`

**input.xml**`to`

**xctype**`(general gradient approximation,`

**"GGA_PBE_SOL"**`). Then, you can run`

**GGA**`as above but changing the directory name to`

**exciting**`,`

**workdir_PBE_SOL***etc.*

##### iii) Post processing: Comparison of XC functionals

In order to compare the different ` XC` functionals, calculate the lattice constant and the bulk modulus with the script

`(`

**CHECKFIT-energy-vs-volume.py***cf*.

`). Compare them to the experimental values, which you can obtain,`

**Volume optimization for cubic systems***e.g.*, from the

`site. You can also use the Python script`

**WebElements**`for a graphical comparison of the fitted energy-versus-volume curves for different functionals. The script will produce the following output on the screen.`

**PLOT-volumecurves.py**```
$ PLOT-volumecurves.py
################################################
Enter list of working directories
Entering "Quit" will terminate the input
################################################
directory name: workdir_LDA
directory name: workdir_PBE_SOL
directory name: Quit
$
```

In this example, the input entry is preceded by ` "directory name: "`. The entry values must be typed on the screen and must be the name of the directories which contain your results for different

`functionals. In the example, the first entry contains results obtained using the`

**XC**`exchange-correlation functional and the second the ones corresponding to`

**LDA_PW**`calculation. If you enter`

**GGA_PBE_SOL**`, the input will be terminated. The script`

**Quit**`produces a PostScript (`

**PLOT-volumecurves.py**`) and a`

**XC.eps**`(`

**PNG**`) output file, as well as an image on the screen. Using the given example you will obtain the following plot.`

**XC.png**For a better comparison, the minima of the energy curves 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

`library can be used. For this purpose, the element`

**libxc**`can be added to the`

**libxc**`element in the`

**groundstate**`input. The`

**exciting**`functional can then be chosen with the attributes`

**XC****or**

`xc`**and**

`exchange`**, as described in detail in**

`correlation``.`

**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> ...

If you plot your new results together with the previous results from ` LDA_PW` and

`using the script`

**GGA_PBE_SOL**`(see above), you will obtain the following plot:`

**PLOT-volumecurves.py**### 4. Exercises

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

### 5. Literature

: J. P. Perdew and Y. Wang,`LDA_PW`*Phys. Rev. B***23**, 5048 (1981); D.M. Ceperly and B.J. Alder,*Phys. Rev. Lett.***45**, 566 (1980): J. P. Perdew, A. Ruzsinszky, G. I. Csonka, O. A. Vydrov, G. E. Scuseria, L. A. Constantin, X. Zhou, and K. Burke,`GGA_PBE_SOL`*arXiv:***0707.2088v1**(2007): J. P. Perdew, K. Burke, and M. Ernzerhof,`GGA_PBE`*Phys. Rev. Lett.***77**, 3865 (1996)