Next: 2.7 Compilation
Up: 2 Installation
Previous: 2.5 Libraries
Contents
Subsections
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.
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/ -lxcf03 -lxc
Then QUANTUM ESPRESSO can be compiled as usual.
if the version of libxc is 5.0.0, the last point must be replaced by:
- set LD_LIBS=-L/path/to/libxc/lib/ -lxcf90 -lxc
since the f03 interfaces are no longer available. They have been restored in following releases. Version 5.0.0 is still usable, but, before compiling QUANTUM ESPRESSO, a string replacement is necessary, namely `xc_f03' must be replaced with `xc_f90' everywhere in the XClib folder.
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.
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' kind 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.
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.
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 might be necessary in order to be able to properly use such functionals. However two routines have been defined in the XC library of QUANTUM ESPRESSO that ease the task of setting and recovering the external parameters in libxc:
- get_libxc_ext_param: this function receives as input the ID of the libxc functional and the index of the chosen parameter and returns its value. If the parameter has not been set before it returns its default value.
- set_libxc_ext_param: this routine receives as input the index of the functional family-type (from 1 to 6: lda-exch, lda-corr, gga-exch, ...), the index of the chosen libxc parameter and the value to set it to.
In order to see the available parameters for a given libxc functional and their corresponding indexes, the dft_info test is available as an option of the xclib_test.x program in XClib folder. For more details see Sec. 2.6.5.
The two routines can be called almost anywhere in QUANTUM ESPRESSO, however, as any other XClib setting routine, they must be declared through the xc_lib module.
Without setting the external parameters inside the code, their default value will be assumed. This could lead to results different from the expectations.
In any case, when external parameters are needed by the chosen functionals, a warning message will appear in the output of QUANTUM ESPRESSO.
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).
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.
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.6.5 XC test
A testing program, xclib_test.x, for the XClib library of QUANTUM ESPRESSO is available. Three options:
- dft-info: infos on the input dft are provided. If the functionals are from libxc the external parameters, when present, are listed with a brief description and their default value.
- exe-benchmark (gen-benchmark): the program gets a data file generated previously as input (by running the same program with the gen-benchmark option) and compares the output data, namely energy and potential on a selected number of grid points. It also compares total energy and potential summed up on a large grid in order to better span the input domain. This option shoud be used to test modifications in the XClib library or to check the output matching among different parallelization schemes.
- dft-comparison: comparison between two different dfts on a large grid of points. Max, min and average percentage difference between the two dft outputs (energy and potential) are provided and the points of the grid where the two output differ are shown. This option can be used, for example, to find differences between internal QUANTUM ESPRESSO functionals and the libxc ones.
The testing program is available for LDA, GGA and MGGA functionals. It also tests the potential derivatives for LDA (dmxc) and GGA (dgcxc).
Next: 2.7 Compilation
Up: 2 Installation
Previous: 2.5 Libraries
Contents