Localized Orbital Scaling Correction (LOSC) C library
curvature.h File Reference

The C interface for LOSC curvature matrix. More...

#include <c_losc/matrix.h>
#include <stddef.h>

Go to the source code of this file.

Classes

struct  LoscCurvatureBase
 The C interface for LOSC curvature base class. More...
 
struct  LoscCurvatureV1
 The C interface for LOSC curvature class of version 1. More...
 
struct  LoscCurvatureV2
 The C interface for LOSC curvature class of version 2. More...
 

Macros

#define losc_dfa_info_free(ptr)   _losc_DFAInfo_free(&(ptr))
 Free a LoscDFAInfo struct. More...
 
#define losc_curvature_v1_free(ptr)   _losc_curvature_v1_free(&(ptr))
 Free a struct LoscCurvatureV1. More...
 
#define losc_curvature_v2_free(ptr)   _losc_curvature_v2_free(&(ptr))
 Free a struct LoscCurvatureV2. More...
 

Typedefs

typedef struct LoscDFAInfo LoscDFAInfo
 The DFA information. More...
 
typedef struct LoscCurvatureBase LoscCurvatureBase
 The C interface for LOSC curvature base class. More...
 
typedef struct LoscCurvatureV1 LoscCurvatureV1
 The C interface for LOSC curvature class of version 1. More...
 
typedef struct LoscCurvatureV2 LoscCurvatureV2
 The C interface for LOSC curvature class of version 2. More...
 

Functions

LoscDFAInfolosc_dfa_info_create (double gga_x, double hf_x, const char *name)
 Create a struct LoscDFAInfo. More...
 
LoscCurvatureV1losc_curvature_v1_create (const LoscDFAInfo *dfa, const losc_matrix *df_pii, const losc_matrix *df_Vpq_inv, const losc_matrix *grid_lo, const double *grid_weight)
 Create a struct LoscCurvatureV1. More...
 
LoscCurvatureV2losc_curvature_v2_create (const LoscDFAInfo *dfa, const losc_matrix *df_pii, const losc_matrix *df_Vpq_inv, const losc_matrix *grid_lo, const double *grid_weight)
 Constructor of LoscCurvatureV2. More...
 

Detailed Description

The C interface for LOSC curvature matrix.

Macro Definition Documentation

#define losc_curvature_v1_free (   ptr)    _losc_curvature_v1_free(&(ptr))

Free a struct LoscCurvatureV1.

Parameters
[in,out]ptra pointer with type LoscCurvatureV1 *. At exit, ptr is set to null.
#define losc_curvature_v2_free (   ptr)    _losc_curvature_v2_free(&(ptr))

Free a struct LoscCurvatureV2.

Parameters
[in,out]ptra pointer with type LoscCurvatureV1 *. At exit, ptr is set to null.
#define losc_dfa_info_free (   ptr)    _losc_DFAInfo_free(&(ptr))

Free a LoscDFAInfo struct.

Parameters
[in,out]ptra pointer with type LoscDFAInfo *. At exit, ptr is set to null.

Typedef Documentation

The C interface for LOSC curvature base class.

Note
This struct exports all the functions for LOSC curvature base class. This struct servers as helper class to avoid code duplication for the implementation of C interface. There is no need for C users to create a such struct in practice.

The C interface for LOSC curvature class of version 1.

Curvature version 1 is defined as \( \kappa \) in Eq. 3 in the original LOSC paper (https://doi.org/10.1093/nsr/nwx11).

See also
losc_curvature_v1_create(): create a LosCurvatureV1 object.
losc_curvature_v1_free(): free a LosCurvatureV1 object.

The C interface for LOSC curvature class of version 2.

The curvature matrix is defined as \(\tilde{\kappa}\) in Eq. 8 of the LOSC2 paper (J. Phys. Chem. Lett. 2020, 11, 4, 1528-1535).

See also
losc_curvature_v2_create(): create a LosCurvatureV2 object.
losc_curvature_v2_free(): free a LosCurvatureV2 object.
typedef struct LoscDFAInfo LoscDFAInfo

The DFA information.

Note
This is a incomplete declaration. You can not create a LoscDFAInfo variable by youself.
See also
losc_dfa_info_create(): create a LoscDFAInfo
losc_dfa_info_free(): free a LoscDFAInfo

Function Documentation

LoscCurvatureV1* losc_curvature_v1_create ( const LoscDFAInfo dfa,
const losc_matrix *  df_pii,
const losc_matrix *  df_Vpq_inv,
const losc_matrix *  grid_lo,
const double *  grid_weight 
)

Create a struct LoscCurvatureV1.

Parameters
[in]dfaType of DFA.
[in]df_piiThree-body integral \( \langle p |ii \rangle \) used in density fitting. Index p is for fitbasis and index i is for LOs. The dimension of df_pii is [nfitbasis, nlo].
[in]df_Vpq_invInverse of \( \langle p | 1/\mathbf{r} | q \rangle \) matrix used in density fitting. Index p and q are for LOs. The dimension of df_Vpq_inv is [nfitbasis, nfitbasis].
[in]grid_loLOs' value on grid points with dimension of [npts, nlo].
[in]grid_weightCoefficient vector for numerical integral on grid with size of npts.
Returns
Create a struct LoscCurvatureV1 and return the pointer.
Note
This function requires all the matrices are allocated in advance. This could be memory consuming. For example, the grid_lo matrix can be very large.
LoscCurvatureV2* losc_curvature_v2_create ( const LoscDFAInfo dfa,
const losc_matrix *  df_pii,
const losc_matrix *  df_Vpq_inv,
const losc_matrix *  grid_lo,
const double *  grid_weight 
)

Constructor of LoscCurvatureV2.

Parameters
[in]dfaType of DFA.
[in]df_piiThree-body integral \( \langle p |ii \rangle \) used in density fitting. Index p is for fitbasis and index i is for LOs. The dimension of df_pii is [nfitbasis, nlo].
[in]df_Vpq_invInverse of \( \langle p | 1/\mathbf{r} | q \rangle \) matrix used in density fitting. Index p and q are for LOs. The dimension of df_Vpq_inv is [nfitbasis, nfitbasis].
[in]grid_loLOs' value on grid points with dimension of [npts, nlo].
[in]grid_weightCoefficient vector for numerical integral on grid with size of npts.
Returns
Create a struct LoscCurvatureV2 and return the pointer.
Note
This function requires all the matrices are allocated in advance. This could be memory consuming. For example, the grid_lo matrix can be very large.
LoscDFAInfo* losc_dfa_info_create ( double  gga_x,
double  hf_x,
const char *  name 
)

Create a struct LoscDFAInfo.

Parameters
[in]gga_xThe total weights of all GGA and LDA type exchanges.
[in]hf_xThe total weights of HF exchanges.
[in]nameThe name of the DFA. Default to an empty string.
Example
Taking B3LYP functional as an example. The B3LYP functional is

\[ E^{\rm{B3LYP}}_{\rm{xc}} = E^{\rm{LDA}}_{\rm{x}} + a_0 (E^{\rm{HF}}_{\rm{x}} - E^{\rm{LDA}}_{\rm{x}}) + a_x (E^{\rm{GGA}}_{\rm{x}} - E^{\rm{LDA}}_{\rm{x}}) + E^{\rm{LDA}}_{\rm{c}} + a_c (E^{\rm{GGA}}_{\rm{c}} - E^{\rm{LDA}}_{\rm{c}}), \]

in which exchanges end with suffix _x and correlations end with suffix _c, \( a_0=0.20 \), \( a_x=0.72 \) and \( a_c=0.81 \). Only the exchanges are considered and the correlations are ignored. The GGA and LDA exchanges are viewed as the same type. Therefore, the total weights of GGA and LDA exchanges are \( 1 - a_0 + a_x \times (1 - 1) = 1 - a_0 = 0.80 \), and the total weights of HF exchanges is \( a_0 = 0.20 \). To construct a DFAInfo object for B3LYP functional, one should do the following
1 b3lyp = losc_dfa_info_create(0.80, 0.20, "B3LYP")