librpa.hpp Source File

librpa.hpp Source File#

LibRPA: librpa.hpp Source File
LibRPA
librpa.hpp
Go to the documentation of this file.
1#pragma once
16
17#include "librpa_enums.h"
18#include "librpa_options.h"
19#include "librpa_handler.h"
20
21#include <vector>
22#include <complex>
23
27namespace librpa
28{
29
30/* Enums */
36
38
40
42
44
45
46/* Options */
58{
59public:
62
69};
70
71
72/* Global environment functions */
73
79const char* get_build_info(void);
80
87
94
101
112void init_global(Switch switch_redirect_stdout = LIBRPA_SWITCH_OFF, const char *redirect_path = "stdout",
113 Switch switch_process_output = LIBRPA_SWITCH_ON);
114
122
127void test(void);
128
133void print_profile(void);
134
135/* C++ handler definition, input and compute methods declarations */
136
159{
160private:
161 LibrpaHandler *h_ = nullptr;
162public:
164 Handler(): h_(nullptr) {};
165
170 Handler(MPI_Comm comm);
171
173 const LibrpaHandler *get_c_handler() const { return h_; }
174
179 void init(MPI_Comm comm);
180
184 void free();
185
192
193 /* Input (set) functions */
194
196 void set_scf_dimension(int nspins, int nkpts, int nstates, int nbasis);
197
199 void set_wg_ekb_efermi(int nspins, int nkpts, int nstates, const double *wg, const double *ekb,
200 double efermi);
201
203 void set_wfc(int ispin, int ik, int nstates_local, int nbasis_local, const double *wfc_real,
204 const double *wfc_imag);
205
207 void set_wfc_packed(int ispin, int ik, int nstates_local, int nbasis_local,
208 const std::complex<double> *wfc);
209
211 void set_ao_basis_wfc(const std::vector<size_t> &nbs_wfc);
212
214 void set_ao_basis_aux(const std::vector<size_t> &nbs_aux);
215
217 void set_latvec_and_G(const double lat_mat[9], const double G_mat[9]);
218
220 void set_atoms(const std::vector<int> &types, const std::vector<double> &pos_cart);
221
223 void set_kgrids_kvec(int nk1, int nk2, int nk3, const double *kvecs);
224
226 void set_ibz_mapping(const std::vector<int> &map_ibzk);
227
229 void set_lri_coeff(LibrpaParallelRouting routing, int I, int J, int nbasis_i, int nbasis_j,
230 int naux_mu, const int R[3], const double *Cs_in);
231
233 void set_aux_bare_coulomb_k_atom_pair(int ik, int I, int J, int naux_mu, int naux_nu,
234 const double *Vq_real_in, const double *Vq_imag_in,
235 double vq_threshold);
236
238 void set_aux_cut_coulomb_k_atom_pair(int ik, int I, int J, int naux_mu, int naux_nu,
239 const double *Vq_real_in, const double *Vq_imag_in,
240 double vq_threshold);
241
243 void set_aux_bare_coulomb_k_2d_block(int ik, int mu_begin, int mu_end, int nu_begin, int nu_end,
244 const double *Vq_real_in, const double *Vq_imag_in);
245
247 void set_aux_cut_coulomb_k_2d_block(int ik, int mu_begin, int mu_end, int nu_begin, int nu_end,
248 const double *Vq_real_in, const double *Vq_imag_in);
249
251 void set_dielect_func_imagfreq(const std::vector<double> &omegas_imag,
252 const std::vector<double> &dielect_func);
253
255 void set_band_kvec(int n_kpts_band, const double *kfrac_band);
256
258 void set_band_occ_eigval(int n_spins, int n_kpts_band, int n_states, const double *occ,
259 const double *eig);
260
262 void set_wfc_band(int ispin, int ik_band, int nstates_local, int nbasis_local,
263 const double *wfc_real, const double *wfc_imag);
264
266 void set_wfc_band_packed(int ispin, int ik_band, int nstates_local, int nbasis_local,
267 const std::complex<double> *wfc);
268
271
272 /* Compute (build/get) functions */
273
276 std::vector<double> &omegas, std::vector<double> &weights);
277
285 std::vector<std::complex<double>> &rpa_corr_ibzk_contrib);
286
291 void build_exx(const Options &opts);
292
302 std::vector<double>
303 get_exx_pot_kgrid(const Options &opts, const int n_spins, const std::vector<int> &iks_this,
304 int i_state_low, int i_state_high);
305
316 std::vector<double>
317 get_exx_pot_band_k(const Options &opts, const int n_spins, const std::vector<int> &iks_band_this,
318 int i_state_low, int i_state_high);
319
324 void build_g0w0_sigma(const Options &opts);
325
338 std::vector<std::complex<double>>
339 get_g0w0_sigc_kgrid(const Options &opts, const int n_spins, const std::vector<int> &iks_this,
340 int i_state_low, int i_state_high, const std::vector<double> &vxc, const std::vector<double> &vexx);
341
354 std::vector<std::complex<double>>
355 get_g0w0_sigc_band_k(const Options &opts, const int n_spins, const std::vector<int> &iks_band_this,
356 int i_state_low, int i_state_high, const std::vector<double> &vxc_band, const std::vector<double> &vexx_band);
357
358 /* Utility functions */
359};
360
361}
void set_ao_basis_aux(const std::vector< size_t > &nbs_aux)
Set auxiliary atomic orbital basis size.
void set_latvec_and_G(const double lat_mat[9], const double G_mat[9])
Set lattice vectors and reciprocal lattice vectors.
void set_ao_basis_wfc(const std::vector< size_t > &nbs_wfc)
Set atomic orbital basis size for wavefunctions.
void set_wfc_packed(int ispin, int ik, int nstates_local, int nbasis_local, const std::complex< double > *wfc)
Set wavefunction coefficients (packed complex array).
void set_ibz_mapping(const std::vector< int > &map_ibzk)
Set mapping from full k-point grid to irreducibleBZ.
double get_rpa_correlation_energy(const Options &opts, std::vector< std::complex< double > > &rpa_corr_ibzk_contrib)
Compute RPA correlation energy.
void set_wfc(int ispin, int ik, int nstates_local, int nbasis_local, const double *wfc_real, const double *wfc_imag)
Set wavefunction coefficients (separated real/imag arrays).
void set_dielect_func_imagfreq(const std::vector< double > &omegas_imag, const std::vector< double > &dielect_func)
Set dielectric function on imaginary frequency axis.
void reset_band_data()
Reset band structure data.
void set_aux_cut_coulomb_k_atom_pair(int ik, int I, int J, int naux_mu, int naux_nu, const double *Vq_real_in, const double *Vq_imag_in, double vq_threshold)
Set truncated Coulomb matrix elements (atom-pair format).
void get_imaginary_frequency_grids(const Options &opts, std::vector< double > &omegas, std::vector< double > &weights)
Construct and return frequency grids.
void init(MPI_Comm comm)
Initialize handler with given MPI communicator.
std::vector< std::complex< double > > get_g0w0_sigc_kgrid(const Options &opts, const int n_spins, const std::vector< int > &iks_this, int i_state_low, int i_state_high, const std::vector< double > &vxc, const std::vector< double > &vexx)
Get G0W0 correlation self-energy for k-grid states.
~Handler()
Defatul destructor - automatically frees handler if not already freed.
void set_atoms(const std::vector< int > &types, const std::vector< double > &pos_cart)
Set atom types and Cartesian coordinates.
void set_lri_coeff(LibrpaParallelRouting routing, int I, int J, int nbasis_i, int nbasis_j, int naux_mu, const int R[3], const double *Cs_in)
Set local RI coefficients.
void set_scf_dimension(int nspins, int nkpts, int nstates, int nbasis)
Set SCF wavefunction dimension (numbers of spins, k-points, states, basis).
void set_aux_bare_coulomb_k_atom_pair(int ik, int I, int J, int naux_mu, int naux_nu, const double *Vq_real_in, const double *Vq_imag_in, double vq_threshold)
Set bare Coulomb matrix elements (atom-pair format).
void set_aux_cut_coulomb_k_2d_block(int ik, int mu_begin, int mu_end, int nu_begin, int nu_end, const double *Vq_real_in, const double *Vq_imag_in)
Set truncated Coulomb matrix elements (2D block format).
void set_wfc_band(int ispin, int ik_band, int nstates_local, int nbasis_local, const double *wfc_real, const double *wfc_imag)
Set wavefunction for band k-point (separated real/imag).
std::vector< std::complex< double > > get_g0w0_sigc_band_k(const Options &opts, const int n_spins, const std::vector< int > &iks_band_this, int i_state_low, int i_state_high, const std::vector< double > &vxc_band, const std::vector< double > &vexx_band)
Get G0W0 correlation self-energy for band k-points.
void set_kgrids_kvec(int nk1, int nk2, int nk3, const double *kvecs)
Set k-point grid vectors.
void build_g0w0_sigma(const Options &opts)
Build G0W0 self-energy matrix in real space.
void set_wfc_band_packed(int ispin, int ik_band, int nstates_local, int nbasis_local, const std::complex< double > *wfc)
Set wavefunction for band k-point (packed complex).
std::vector< double > get_exx_pot_kgrid(const Options &opts, const int n_spins, const std::vector< int > &iks_this, int i_state_low, int i_state_high)
Get exact-exchange potential for k-grid states.
void build_exx(const Options &opts)
Build exact-exchange matrix in real space.
const LibrpaHandler * get_c_handler() const
Get underlying C handler (for internal use).
Definition librpa.hpp:173
void set_wg_ekb_efermi(int nspins, int nkpts, int nstates, const double *wg, const double *ekb, double efermi)
Set occupation numbers, eigenvalues, and Fermi level.
void set_aux_bare_coulomb_k_2d_block(int ik, int mu_begin, int mu_end, int nu_begin, int nu_end, const double *Vq_real_in, const double *Vq_imag_in)
Set bare Coulomb matrix elements (2D block format).
void set_band_kvec(int n_kpts_band, const double *kfrac_band)
Set k-points for band structure calculations.
void free()
Free handler and release resources.
Handler()
Default constructor (creates null handler).
Definition librpa.hpp:164
std::vector< double > get_exx_pot_band_k(const Options &opts, const int n_spins, const std::vector< int > &iks_band_this, int i_state_low, int i_state_high)
Get exact-exchange potential for band k-points.
Handler(MPI_Comm comm)
Construct and initialize handler with MPI communicator.
void set_band_occ_eigval(int n_spins, int n_kpts_band, int n_states, const double *occ, const double *eig)
Set occupation numbers and eigenvalues for band k-points.
C++ wrapper for runtime options.
Definition librpa.hpp:58
Options()
Construct with default options.
Definition librpa.hpp:61
void set_output_dir(const char *output_dir)
Set output directory.
Definition librpa.hpp:68
Enumeration types and constants for LibRPA.
int LibrpaKind
Type of DFT code (reserved for future use).
Definition librpa_enums.h:99
int LibrpaSwitch
Boolean switch type.
Definition librpa_enums.h:91
#define LIBRPA_SWITCH_OFF
Switch value for disabled/off state (equivalent to false).
Definition librpa_enums.h:23
#define LIBRPA_SWITCH_ON
Switch value for enabled/on state (equivalent to true).
Definition librpa_enums.h:26
int LibrpaVerbose
Verbosity level for runtime output.
Definition librpa_enums.h:107
LibrpaParallelRouting
Parallel routing strategy for distributed memory calculations.
Definition librpa_enums.h:58
LibrpaTimeFreqGrid
Type of time or frequency grid for integration.
Definition librpa_enums.h:76
Handler management for LibRPA instances.
Runtime options for LibRPA calculations.
void librpa_set_output_dir(LibrpaOptions *opts, const char *output_dir)
Set the output directory for LibRPA results.
void librpa_init_options(LibrpaOptions *opts)
Initialize runtime options to default values.
Main namespace for LibRPA C++ API.
Definition librpa.hpp:28
const char * get_build_info(void)
Get build information string.
void print_profile(void)
Print profiling information.
int get_minor_version(void)
Get minor version number.
void init_global(Switch switch_redirect_stdout=LIBRPA_SWITCH_OFF, const char *redirect_path="stdout", Switch switch_process_output=LIBRPA_SWITCH_ON)
Initialize the global LibRPA environment.
void finalize_global(void)
Finalize the global LibRPA environment.
LibrpaParallelRouting ParallelRouting
Parallel routing strategy (C++ alias).
Definition librpa.hpp:35
LibrpaKind Kind
DFT code kind type (C++ alias, reserved)
Definition librpa.hpp:41
void test(void)
Run internal self-tests.
int get_patch_version(void)
Get patch version number.
LibrpaVerbose Verbose
Verbosity level type (C++ alias)
Definition librpa.hpp:43
LibrpaTimeFreqGrid TimeFreqGrid
Time/frequency grid type (C++ alias)
Definition librpa.hpp:37
int get_major_version(void)
Get major version number.
LibrpaSwitch Switch
Boolean switch type (C++ alias)
Definition librpa.hpp:39
Opaque handle to a LibRPA instance.
Definition librpa_handler.h:26
Runtime options structure for LibRPA calculations.
Definition librpa_options.h:34
char output_dir[LIBRPA_MAX_STRLEN]
Output directory.
Definition librpa_options.h:39