Next: 2.6 Compilation Up: 2 Installation Previous: 2.4 Libraries Contents
Subsections

- 2.5.1 Linking in QUANTUM ESPRESSO
  - 2.5.1.1 Note for version 5.0.0:
- 2.5.2 Usage
- 2.5.3 Differences between Libxc and internal functionals
- 2.5.4 Special cases
  - 2.5.4.1 External parameters.
  - 2.5.4.2 Hybrid functionals.
  - 2.5.4.3 Functionals with partial output.
  - 2.5.4.4 Other functionals.
- 2.5.5 XC test

## 2.5 Libxc library

QUANTUM ESPRESSO is compatible with `libxc` version 4.3.0 or later (compatibility with older versions is not guaranteed).
The `libxc` functionals are available for LDA, GGA and metaGGA, however, not all of them are straightforwardly usable. Some of them may depend on specific external parameters and some others may provide as output the energy or the potential, but not both. Therefore some attention has to be paid when using `libxc`. Warning messages should appear in the output when particular cases whose correct operation in QUANTUM ESPRESSO is not guaranteed are chosen.

### 2.5.1 Linking in QUANTUM ESPRESSO

Once installed `libxc`, the linking with QUANTUM ESPRESSO can be enabled directly through the configuration script by adding the two switches `–with-libxc` and `–with-libxc-prefix`, e.g.:

    ./configure --with-libxc --with-libxc-prefix='/path/to/libxc/'

By adding the first switch only an automatic search for the libxc folder will be attempted, but its success is not guaranteed. It is always preferable to specify the second switch too. Optionally, a third switch can be added, namely `–with-libxc-include='/path/to/libxc/include'`, which specifies the path to the Fortran headers (usually it is not necessary).

Alternatively, the link to `libxc` can be activated after the configuration of QUANTUM ESPRESSO by modifying the `make.inc` file in the main folder in this way:

- add `-D__LIBXC` to `DFLAGS`
- add `-I/path/to/libxc/include/` to `IFLAGS`
- set `LD_LIBS=-L/path/to/libxc/lib/ -lxcf90 -lxc`

Then QUANTUM ESPRESSO can be compiled as usual. If the version of `libxc` is older than 5.0.0, the last point must be replaced by:

- set `LD_LIBS=-L/path/to/libxc/lib/ -lxcf03 -lxc`

#### 2.5.1.1 Note for version 5.0.0:

the `f03` interfaces are no longer available in `libxc` 5.0.0. They have been reintroduced in the current develop version. Version 5.0.0 is still usable, but, before compiling QUANTUM ESPRESSO, a string replacement is necessary, namely ``xc_f03`' must be repalced with ``xc_f90`' everywhere in the following files: `funct.f90`, `xc_lda_lsda_drivers.f90`, `xc_gga_drivers.f90`, `xc_mgga_drivers.f90`, `dmxc_drivers.f90` and `dgcxc_drivers.f90` in `Modules` folder and `xctest_qe_libxc.f90` in `PP/src` folder.

### 2.5.2 Usage

In order to use `libxc` functionals, you must enforce them from input by including the `input_dft` string in the `system` namelist. For example, to use the `libxc` version of the PBE functionals (both exchange and correlation):

    input_dft = `gga_x_pbe gga_c_pbe'

Capital or lowercase is not relevant, neither the separation between one name and the other. The complete list of `libxc` functionals is available at:

    https://www.tddft.org/programs/libxc/functionals/

Combinations of QUANTUM ESPRESSO and `libxc` functionals are allowed in `PW`, but some attention has to be paid to their reciprocal compatibility (see section below). In these cases, again, the functionals must be enforced from input. For example, the exchange term of PBE in QUANTUM ESPRESSO together with the correlation term of PBE in `libxc` is obtained by putting:

    input_dft = `sla pbe gga_c_pbe'

Note that when using GGA functionals of QUANTUM ESPRESSO you must always specify the LDA term too, while it is not the case for the `libxc` ones.
Outside `PW` (`PHonon`, `PP`, etc.), `libxc` functionals are still usable, but in these cases it is highly recommended to avoid combinations of QE and `libxc` functionals together, since, at present, they may lead to some issues in the dft detection.

### 2.5.3 Differences between Libxc and internal functionals

There are some differences between QUANTUM ESPRESSO functionals and `libxc` ones. In QUANTUM ESPRESSO the LDA and the GGA terms are separated and must be specified independently. In `libxc` the GGA functionals already include the LDA part (Slater exchange and Perdew&Wang correlation in most of the cases with the exception, for example, of Lee Yang Parr functionals).
The `libxc` metaGGA functionals may or may not need the LDA and GGA terms, depending on the cases, therefore a good check of the chosen functionals is recommended before doing expensive runs.
Some functionals in `libxc` incorporate the exchange part and the correlation one into one term only (e.g. the ones that include the ``_xc`' label in their name). In these cases the whole functional is formally treated as `exchange only' by QUANTUM ESPRESSO. This does not imply any loss of information.

### 2.5.4 Special cases

A number of `libxc` functional routines need extra information on input and/or provide only partial information on output (e.g. the energy or the potential only). In these cases the use of such functionals may not be straightforward and, depending on the cases, may require some work on the QUANTUM ESPRESSO source code.

#### 2.5.4.1 External parameters.

Several functionals in `libxc` depend on one or more external parameters. Some of these can be recovered inside QUANTUM ESPRESSO, some others are not directly available. In all these cases a direct intervention on the QUANTUM ESPRESSO source code is necessary in order to be able to properly use such functionals.
The `libxc` routine `xc_f03_func_set_ext_params` allows to set the value of the external parameters, which are contained in a single array. A trace for the usage of this routine is present, among the comments, in the XC-drivers of QUANTUM ESPRESSO (in `Modules` folder: `xc_lda_lsda_drivers.f90`, `xc_gga_drivers.f90`, etc.).
Without setting the external parameters inside the code, their default value will be assumed. This could lead to results different from the expectations. To get the default values, the `xc_f03_func_info_get_ext_params_default_value` routine is available in `libxc`. For more details we refer to the official documentation of `libxc`.
In any case, when external parameters are needed by the chosen functionals, a warning message will appear in the output of QUANTUM ESPRESSO.

#### 2.5.4.2 Hybrid functionals.

The hybrid functionals of `libxc` are allowed, but, as in the previous case, their correct operation is not guaranteed by default. It is important to ensure that the `exx_fraction` in QUANTUM ESPRESSO assumes the desired value when the XC routines are called. To do this you need to act on the external parameters of the functionals, as explained previously. Moreover it is important to ensure that the starting value of the variable `exx_fraction` in QUANTUM ESPRESSO , which is set in the `matching_libxc` routine in `Modules/funct.f90`, is the desired one (`exx_fraction` may not always coincide with the `exx_coef` of `libxc`).

#### 2.5.4.3 Functionals with partial output.

A few `libxc` functional routines provides the energy and some others the potential only, but not both of them. At present, QUANTUM ESPRESSO, assumes that both the energy and the potential are provided when a XC-functional routine is called, therefore, in order to use these functionals, some modifications on the code will be necessary.

#### 2.5.4.4 Other functionals.

Besides exchange (`_x`), correlation (`_c`) and exchange plus correlation (`_xc`), a fourth kind of functionals is available in `libxc`, the kinetic functionals (`_k`). At present, they are not usable in QUANTUM ESPRESSO.

### 2.5.5 XC test

A simple testing program, `xctest_qe_libxc.f90`, for the XC part of QUANTUM ESPRESSO is available in the `PP/src` folder.
The program tests the output (energies and potentials) of the XC-driver routines by comparing the results obtained with the QUANTUM ESPRESSO internal library of XC functionals with those obtained with the `libxc` library.
It also tests the XC-derivative part (mainly used in PHonon) by comparing the QE derivative of the XC potential (for LDA and GGA) with the `libxc` one.

Next: 2.6 Compilation Up: 2 Installation Previous: 2.4 Libraries Contents