3.36 Interface to LibRPA
LibRPA (https://srlive1201.github.io/LibRPA) provides low-scaling implementations of Green’s-function-based many-body perturbation theory based on the local resolution-of-identity (LRI) approximation. In FHI-aims, LibRPA can be used in two distinct ways:
-
•
through a file-based workflow, in which FHI-aims writes an input dataset for the standalone LibRPA driver, and
-
•
through an in-program API backend, in which FHI-aims passes the required data directly to the LibRPA library and obtains the MBPT result within the same FHI-aims run.
The two workflows are alternatives. output librpa and mbpt_backend librpa must not be used in the same control.in.
The FHI-aims–LibRPA interface is available for periodic calculations. Accordingly, lattice_vector must be specified in geometry.in and k_grid in control.in. Finite systems can be treated by placing them in a sufficiently large simulation cell.
Both workflows use the minimax time-frequency grid expected by LibRPA. If freq_grid_type is not set, FHI-aims switches it to minimax for LibRPA calculations. If a non-minimax grid is set explicitly, the input is rejected. For GW calculations, anacon_type must still be provided, as for the native periodic GW workflow. The keyword frequency_points sets the number of LibRPA frequency points; for the minimax grid, use one of the supported even values 6, 8, …, 34. Use of the minimax grid requires FHI-aims to be built with GreenX support, controlled by the CMake option USE_GREENX.
File-based workflow: output librpa
The file-based interface is enabled by the tag output librpa in control.in. It is used when FHI-aims prepares input files for a separate LibRPA driver calculation. This export mode requires one of the standard MBPT requests
-
•
total_energy_method rpa, or
-
•
qpe_calc gw_expt.
When this tag is present, FHI-aims writes the structure, Brillouin-zone sampling, Kohn-Sham eigenvalues and eigenvectors, LRI triple coefficients, Coulomb matrices, and, for GW calculations, the exchange-correlation matrix elements and dielectric-function data required by the LibRPA driver. The optional subtag version:<n> selects the dataset format. version:0 is the default and writes the legacy LibRPA file formats. version:1 writes the LibRPA reader-v1 formats for the LRI triple coefficients, SCF Kohn-Sham eigenvectors, and Coulomb matrices. In this mode FHI-aims writes binary v1 Cs_data* files, binary KS_eigenvector_<rank>.dat files, and one Coulomb file per q-point, coulomb_mat_<iq>.dat and, for GW, coulomb_cut_<iq>.dat. LibRPA will detect output formats to choose the correct readers detects v1 files from their header. version:-1, or the compatibility alias legacy_v030, selects the old v0.3.0 layout. The real-space LRI coefficients are folded to the Born-von Karman cell by default; the old fold_C subtag is accepted only as a deprecated compatibility alias.
For periodic GW calculations along a band path, also specify output band; FHI-aims then exports the band-path eigenvalues, eigenvectors, and exchange-correlation matrix elements read by the LibRPA g0w0_band and exx_band driver tasks. If include_spin_orbit is used, FHI-aims exports the perturbatively spin-orbit-coupled spinor wave functions; the corresponding LibRPA driver input must then set use_spinor_wfc = t.
If the structure, basis, and k-point sampling are unchanged and only the exchange-correlation functional is modified, the subtag ks_only can be added to output librpa. This is a convenience alias for noC and noV: the real-space LRI triple coefficients and Coulomb matrices are suppressed, while the Kohn-Sham-dependent files, the dielectric function, and any requested band-path data are exported as usual.
For periodic GW calculations with KS_method serial, the subtags mommat and mommat:ks write momentum matrices in the Kohn–Sham basis, while mommat:nao writes the corresponding full Bloch-NAO matrices. The selectors are independent and may be specified together. Both representations contain matrix elements of the gradient operator,
| (3.132) |
without the factor needed to form the physical momentum operator. They are related by . With spin–orbit coupling, the NAO matrix is spin-independent and represents .
For each k-point, the KS selector writes mommat_ks_kpt_######.dat. Its unformatted stream starts with the six default-integer values i_k_point, n_state_min, n_state_max, ld, n_spin, and 3, followed by the complex*16 packed lower triangle for every spin and Cartesian direction. The NAO selector writes mommat_nao_kpt_######.dat. Its header contains the four default-integer values i_k_point, n_basis, n_basis*n_basis, and 3, followed by the full complex*16 , , and matrices in Fortran column-major order.
For example, both representations can be requested with
output librpa mommat:ks mommat:nao
Running the standalone driver
A typical file-based calculation proceeds as follows:
- 1.
-
2.
Create a librpa.in file in the directory where the driver will be launched. Set input_dir to the directory containing the exported FHI-aims files.
-
3.
Run the standalone driver, for example
mpirun -np <nprocs> /path/to/LibRPA/build/chi0_main.exe
The bundled LibRPA library built through USE_LIBRPA is linked into FHI-aims for the API backend and does not build the standalone driver. For the file-based workflow, build LibRPA separately with its driver enabled, or use an existing LibRPA driver executable.
Examples
Example control.in fragment for exporting an RPA dataset:
xc pbe relativistic atomic_zora scalar occupation_type gaussian 0.001 basis_threshold 1.e-5 total_energy_method rpa frequency_points 16 k_grid 3 3 3 output librpa version:1 # [insert species data below]
A matching librpa.in for the LibRPA driver is:
task = rpa input_dir = . parallel_routing = libri tfgrids_type = minimax nfreq = 16
Example control.in fragment for exporting an one-shot band-structure dataset:
xc pbe relativistic atomic_zora scalar occupation_type gaussian 0.001 basis_threshold 1.e-5 qpe_calc gw_expt frequency_points 16 anacon_type pade k_grid 3 3 3 output band 0.00000 0.00000 0.00000 0.50000 0.00000 0.50000 13 G X output librpa version:1 # [insert species data below]
A matching librpa.in is:
task = g0w0_band input_dir = . parallel_routing = libri tfgrids_type = minimax nfreq = 16 replace_w_head = t option_dielect_func = 0 use_qpe_adaptive_damp = t # Optional screening thresholds libri_chi0_threshold_C = 1e-3 libri_exx_threshold_C = 1e-4 libri_g0w0_threshold_C = 1e-4
Keep nfreq consistent with frequency_points in the FHI-aims export run. If the FHI-aims run used include_spin_orbit, add
use_spinor_wfc = t
to librpa.in. If the dielectric head replacement is not wanted, omit replace_w_head.
In-program workflow: mbpt_backend librpa
LibRPA can also be called directly through its API from within FHI-aims. In this mode, FHI-aims passes the required data to LibRPA in memory and retrieves the computed quantities within the same run. No intermediate LibRPA dataset or librpa.in file is needed.
The API backend currently covers direct RPA correlation energies and periodic calculations on the regular k-grid and, when output band is requested, on band-path k-points. For GW band output, FHI-aims writes GW_band1xxx.out files using the same band-path convention as the native periodic GW workflow. If output gw_nscf_exx_only_band is also set, the non-self-consistent EXX-only band correction is written to Non-SCF_EXX_only_band1xxx.out.
Building FHI-aims with LibRPA
To use the LibRPA API backend, FHI-aims must be compiled and linked against LibRPA. Exactly one of the following CMake options should be enabled:
-
•
USE_LIBRPA: build and link the bundled LibRPA library shipped with FHI-aims. This requires USE_GREENX.
-
•
USE_EXTERNAL_LIBRPA: link against an externally built LibRPA installation.
For the bundled library, enable USE_LIBRPA in the CMake initial cache. The bundled build enables LibRI routing and the LibRPA Fortran bindings needed by FHI-aims.
To use an external LibRPA build instead, enable USE_EXTERNAL_LIBRPA and specify either the LibRPA build directory or install directory:
set(USE_EXTERNAL_LIBRPA ON CACHE BOOL "" FORCE)
set(EXTERNAL_LIBRPA_BUILD_DIR "$ENV{HOME}/LibRPA/build" CACHE STRING "" FORCE)
or
set(USE_EXTERNAL_LIBRPA ON CACHE BOOL "" FORCE)
set(EXTERNAL_LIBRPA_INSTALL_DIR "$ENV{HOME}/LibRPA/install" CACHE STRING "" FORCE)
The external LibRPA build must provide the Fortran bindings and the LibRI support used by the FHI-aims API wrapper.
Running MBPT with the LibRPA backend
To delegate an MBPT calculation to LibRPA, use the standard MBPT-related input in control.in and additionally set mbpt_backend to librpa. For example, a one-shot G0W0 calculation with regular-k-grid and band output reads:
xc pbe relativistic atomic_zora scalar occupation_type gaussian 0.001 basis_threshold 1.e-5 qpe_calc gw_expt frequency_points 16 anacon_type pade k_grid 3 3 3 output gw_regular_kgrid output k_eigenvalue 10000 output gw_nscf_exx_only_band output band 0.00000 0.00000 0.00000 0.50000 0.00000 0.50000 13 G X mbpt_backend librpa librpa_thres_chi0 C:1e-3 librpa_thres_nlex C:1e-4 librpa_thres_sigc C:1e-4 # [insert species data below]
For perturbative spin-orbit-coupled G0W0 calculations, add include_spin_orbit. The current LibRPA API spinor workflow does not support ScaLAPACK eigenvectors; use a non-ScaLAPACK Kohn-Sham eigenvector workflow for such calculations, see KS_method.
Keywords specific to the LibRPA backend
The two LVL batching keywords below apply to both LibRPA file export and the direct LibRPA API backend.
Tag: librpa_lvl_ap_batches(control.in)
Usage: librpa_lvl_ap_batches value
Purpose: Divide the atom-pair range used to construct the real-space LVL
coefficients into value balanced batches. All MPI tasks
process one batch at a time. Increasing this value lets more tasks
cooperate on the Bravais vectors of each atom pair and therefore
reduces per-task memory, at the cost of additional communicator
creation and reductions. The value must be positive and defaults
to 1, which disables atom-pair batching. Requests larger
than the total number of atom pairs are clamped to that number.
Tag: librpa_lvl_r_batches(control.in)
Usage: librpa_lvl_r_batches value
Purpose: Divide each MPI task’s local Bravais-vector range into
value balanced batches when constructing real-space LVL
coefficients. Increasing this value reduces the temporary arrays
passed to the pair-coefficient calculation, at the cost of more
calls to that calculation. The value must be positive and defaults
to 1, which disables local R-vector batching. This is a
number of batches for each task’s local R-vector interval, not a
global R-vector count; requests larger than a local interval are
clamped so that no empty coefficient call is made.
For a large calculation, a possible reduced-memory setup is
librpa_lvl_ap_batches 13 librpa_lvl_r_batches 4
The useful values depend on the atom count, number of Bravais cells, MPI task count, and the largest species-resolved orbital and auxiliary basis dimensions. Both settings apply to folded and non-folded coefficients, legacy and reader-v1 file export, the direct LibRPA API, threshold filtering, and force derivatives.
The following remaining keywords are relevant when mbpt_backend is set to librpa.
Tag: mbpt_backend(control.in)
Usage: mbpt_backend str
Purpose: Select the backend used for many-body perturbation theory
calculations.
str: native or librpa; default is
native.
-
•
native: use the MBPT implementation built into FHI-aims.
-
•
librpa: use the LibRPA API backend described in Sec. 3.36.
Tag: librpa_thres_chi0(control.in)
Usage: librpa_thres_chi0 [C:<value> G:<value>]
Purpose: Set screening thresholds for atom-pair-block quantities used
in the evaluation of the non-interacting response function
in LibRPA.
This keyword is active only when mbpt_backend is
librpa.
All thresholds default to 0.0.
Options:
-
•
C: threshold for real-space RI coefficients.
-
•
G: threshold for real-space Green’s functions.
In practice, a setting such as
librpa_thres_chi0 C:1e-3
can substantially reduce the cost of the evaluation, but the user should always verify that the chosen thresholds are sufficiently accurate for the system under study.
Tag: librpa_thres_nlex(control.in)
Usage: librpa_thres_nlex [C:<value> D:<value> V:<value>]
Purpose: Set screening thresholds for atom-pair-block quantities used
in the evaluation of the non-local exchange operator in LibRPA.
This keyword is active only when mbpt_backend is
librpa.
All thresholds default to 0.0.
Options:
-
•
C: threshold for real-space RI coefficients.
-
•
D: threshold for real-space density matrices.
-
•
V: threshold for real-space Coulomb matrices.
Tag: librpa_thres_sigc(control.in)
Usage: librpa_thres_sigc [C:<value> G:<value> W:<value>]
Purpose: Set screening thresholds for atom-pair-block quantities used
in the evaluation of the G0W0 correlation self-energy in LibRPA.
This keyword is active only when mbpt_backend is
librpa.
All thresholds default to 0.0.
Options:
-
•
C: threshold for real-space RI coefficients.
-
•
G: threshold for the real-space Green’s function.
-
•
W: threshold for the correlation part of the real-space screened Coulomb interaction.
For example,
librpa_thres_sigc C:1e-4
may provide a useful starting point, but the effect of the threshold on the final results should always be checked.
Tag: output_librpa_process(control.in)
Usage: output_librpa_process bool
Purpose: Control whether LibRPA writes per-process output files during the
API-backed workflow.
Options: bool, with default .true.
Additional notes
LibRPA band structures are obtained by interpolation from regular-k-grid quantities to the requested band path. Increasing the number of k-points along the band path, or adding more path segments, therefore has only a small additional cost compared with the main regular-k-grid G0W0 calculation. Current LibRPA band interpolation uses Wigner-Seitz Born-von Karman remapping by default.