ergo
fun-cam.c File Reference
#include <assert.h>
#include <math.h>
#include <ctype.h>
#include <string.h>
#include <strings.h>
#include <stdio.h>
#include <stdlib.h>
#include "functionals.h"

Classes

struct  RGFirstDrv
 
struct  RGSecondDrv
 
struct  RGThirdDrv
 
struct  RGFourthDrv
 
struct  FunctionalList
 

Macros

#define __CVERSION__
 
#define ELEMENTS(arr)   (sizeof(arr)/sizeof(arr[0]))
 
#define THR   1e-40
 
#define BECKE88_CORR_WEIGHT   1
 
#define LYP_WEIGHT   0.81
 
#define VWN_WEIGHT   0.19
 
#define SQRT_PI   1.77245385090552
 
#define MAX_LARGE_COEFS   5
 
#define FAC   M_SQRT2
 
#define EVALUATOR(a, type)
 

Functions

static int camb3lyp_read (const char *conf_line)
 
static void camb3lyp_report (void)
 
static int cam_isgga (void)
 
static int cam_read (const char *conf_line)
 Read the configuration. More...
 
static void cam_report (void)
 
static real cam_energy (const FunDensProp *dp)
 
static void cam_first (FunFirstFuncDrv *ds, real factor, const FunDensProp *dp)
 
static void cam_second (FunSecondFuncDrv *ds, real factor, const FunDensProp *dp)
 
static void cam_third (FunThirdFuncDrv *ds, real factor, const FunDensProp *dp)
 
static void cam_fourth (FunFourthFuncDrv *ds, real factor, const FunDensProp *dp)
 
static int hse_read (const char *conf_line)
 
static struct FunctionalListnewFunc (Functional *f, real weight, struct FunctionalList *next)
 
static void cam_free_config (void)
 
static int parse_table (const char *func, const char *str, int cnt, const char *keywords[], double *weights)
 
static real fun_a (real rho, real ex)
 
static void fun_a_first (real rho, real a, real ex, RGFirstDrv *fun1, RGFirstDrv *res)
 
static void fun_a_second (real rho, real a, real ex, RGSecondDrv *f2, RGSecondDrv *res)
 
static void fun_a_third (real rho, real a, real ex, RGThirdDrv *f3, RGThirdDrv *res)
 
static void fun_a_fourth (real rho, real a, real ex, RGFourthDrv *f4, RGFourthDrv *res)
 
static real cam_b_energy_small (real a)
 
static real cam_b_first_small (real a)
 
static real cam_b_energy_large (real a)
 
static real cam_b_first_large (real a)
 
static real cam_b_energy_medium (real a)
 
static real cam_b_first_medium (real a)
 
static real evaluate_series (int n, const real *coefs, real lambda)
 
static real cam_b_second_medium (real a)
 
static real cam_b_third_medium (real a)
 
static real cam_b_fourth_medium (real a)
 
static real cam_energy_sigma (real rho, real ex)
 
static void cam_first_sigma (real rho, real ex, RGFirstDrv *ds, RGFirstDrv *res)
 
static void cam_second_sigma (real rho, real ex, RGSecondDrv *f2, RGSecondDrv *res)
 
static void cam_third_sigma (real rho, real ex, RGThirdDrv *f3, RGThirdDrv *res)
 
static void cam_fourth_sigma (real rho, real ex, RGFourthDrv *f4, RGFourthDrv *res)
 
int fun_get_cam_param (real *alpha, real *beta, real *mu)
 

Variables

Functional Camb3lypFunctional
 
Functional CamFunctional
 
Functional HseFunctional
 
static struct FunctionalListexchangeFunctionals = NULL
 The module uses program-wide configuration. More...
 
static struct FunctionalListcorrelationFunctionals = NULL
 
static real camAlpha = 0.0
 
static real camBeta = 0.0
 
static real camMu = 0.0
 
static const char * cam_keywords [] = { "alpha", "beta", "mu" }
 
static const real large_coefs [] = { 9, 60, 420, 3240, 27720 }
 
static const real large_coefs1 [] = { 4.5, 15, 70, 405 }
 
static const real ENERGY_THR = 1e-13
 

Detailed Description

General CAM functional.

Often called a range-separated exchange method.

Pawel Salek, 2004.06, Himmelbjerg - initial implementation.

Macro Definition Documentation

◆ __CVERSION__

#define __CVERSION__

◆ BECKE88_CORR_WEIGHT

#define BECKE88_CORR_WEIGHT   1

◆ ELEMENTS

#define ELEMENTS (   arr)    (sizeof(arr)/sizeof(arr[0]))

◆ EVALUATOR

#define EVALUATOR (   a,
  type 
)
Value:
((a<0.14) ? cam_b_ ## type ## _small(a) : \
((a<4.25) ? cam_b_ ## type ## _medium(a) : \
cam_b_ ## type ## _large(a)))

◆ FAC

#define FAC   M_SQRT2

◆ LYP_WEIGHT

#define LYP_WEIGHT   0.81

◆ MAX_LARGE_COEFS

#define MAX_LARGE_COEFS   5

◆ SQRT_PI

#define SQRT_PI   1.77245385090552

◆ THR

#define THR   1e-40

◆ VWN_WEIGHT

#define VWN_WEIGHT   0.19

Function Documentation

◆ cam_b_energy_large()

static real cam_b_energy_large ( real  a)
static

References large_coefs, and MAX_LARGE_COEFS.

◆ cam_b_energy_medium()

static real cam_b_energy_medium ( real  a)
static

References ERF, EXP, and SQRT_PI.

◆ cam_b_energy_small()

static real cam_b_energy_small ( real  a)
static

References SQRT_PI.

◆ cam_b_first_large()

static real cam_b_first_large ( real  a)
static

References large_coefs1, and MAX_LARGE_COEFS.

◆ cam_b_first_medium()

static real cam_b_first_medium ( real  a)
static

References ERF, EXP, POW, and SQRT_PI.

◆ cam_b_first_small()

static real cam_b_first_small ( real  a)
static

References EXP, and SQRT_PI.

◆ cam_b_fourth_medium()

static real cam_b_fourth_medium ( real  a)
static

◆ cam_b_second_medium()

static real cam_b_second_medium ( real  a)
static

◆ cam_b_third_medium()

static real cam_b_third_medium ( real  a)
static

◆ cam_energy()

◆ cam_energy_sigma()

static real cam_energy_sigma ( real  rho,
real  ex 
)
static

References EVALUATOR, and fun_a().

Referenced by cam_energy().

◆ cam_first()

◆ cam_first_sigma()

static void cam_first_sigma ( real  rho,
real  ex,
RGFirstDrv ds,
RGFirstDrv res 
)
static

◆ cam_fourth()

◆ cam_fourth_sigma()

◆ cam_free_config()

static void cam_free_config ( void  )
static

◆ cam_isgga()

static int cam_isgga ( void  )
static

◆ cam_read()

static int cam_read ( const char *  conf_line)
static

Read the configuration.

The configuration consists of three types of terms that follow general pattern:

(p|x|c):(FUNCTIONAL)=(weight)

p prefix is followed by either 'alpha', 'beta' or 'mu' parameters and corresponding weights. x prefix defines an exchange functional

  • no actual check is performed! c allows to add an additive functional, usually a correlation one.

Example configuration for CAM-B3LYP is:

CAM p:alpha=0.19 p:beta=0.46 p:mu=0.33 x:slater=1 x:becke=1 c:lyp=0.81 c:vwn5=0.19

We obviously need to carefully exclude the recursive case of cam functional built from another cam functional....

Returns
0 on failure, 1 on success.

References available_functionals, cam_free_config(), camAlpha, camBeta, CamFunctional, camMu, correlationFunctionals, ELEMENTS, exchangeFunctionals, fun_printf, newFunc(), and FunctionalList::weight.

Referenced by hse_read().

◆ cam_report()

◆ cam_second()

◆ cam_second_sigma()

static void cam_second_sigma ( real  rho,
real  ex,
RGSecondDrv f2,
RGSecondDrv res 
)
static

◆ cam_third()

◆ cam_third_sigma()

◆ camb3lyp_read()

◆ camb3lyp_report()

static void camb3lyp_report ( void  )
static

References camAlpha, camBeta, camMu, and fun_printf.

◆ evaluate_series()

static real evaluate_series ( int  n,
const real coefs,
real  lambda 
)
static

◆ fun_a()

static real fun_a ( real  rho,
real  ex 
)
static

◆ fun_a_first()

static void fun_a_first ( real  rho,
real  a,
real  ex,
RGFirstDrv fun1,
RGFirstDrv res 
)
static

References RGFirstDrv::df01, RGFirstDrv::df10, FABS, and THR.

Referenced by cam_first_sigma().

◆ fun_a_fourth()

◆ fun_a_second()

static void fun_a_second ( real  rho,
real  a,
real  ex,
RGSecondDrv f2,
RGSecondDrv res 
)
static

◆ fun_a_third()

◆ fun_get_cam_param()

int fun_get_cam_param ( real alpha,
real beta,
real mu 
)

◆ hse_read()

static int hse_read ( const char *  conf_line)
static

References cam_read().

◆ newFunc()

static struct FunctionalList* newFunc ( Functional f,
real  weight,
struct FunctionalList next 
)
static

◆ parse_table()

static int parse_table ( const char *  func,
const char *  str,
int  cnt,
const char *  keywords[],
double *  weights 
)
static

References fun_printf, and FunctionalList::func.

Referenced by camb3lyp_read().

Variable Documentation

◆ cam_keywords

const char* cam_keywords[] = { "alpha", "beta", "mu" }
static

Referenced by camb3lyp_read().

◆ camAlpha

◆ Camb3lypFunctional

Functional Camb3lypFunctional

◆ camBeta

◆ CamFunctional

Functional CamFunctional

◆ camMu

◆ correlationFunctionals

◆ ENERGY_THR

const real ENERGY_THR = 1e-13
static

◆ exchangeFunctionals

struct FunctionalList* exchangeFunctionals = NULL
static

The module uses program-wide configuration.

It uses following range separation of the HF exchange: HF_RS_Exch = (alpha + beta*erf(mu*r))*HF_exchange

This means that the DFT exchange becomes: 1 - HF_RS_Exch

Referenced by cam_energy(), cam_first(), cam_fourth(), cam_free_config(), cam_read(), cam_report(), cam_second(), cam_third(), and camb3lyp_read().

◆ HseFunctional

Functional HseFunctional

◆ large_coefs

const real large_coefs[] = { 9, 60, 420, 3240, 27720 }
static

◆ large_coefs1

const real large_coefs1[] = { 4.5, 15, 70, 405 }
static

Referenced by cam_b_first_large().

cam_third
static void cam_third(FunThirdFuncDrv *ds, real factor, const FunDensProp *dp)
Definition: fun-cam.c:1094
cam_second
static void cam_second(FunSecondFuncDrv *ds, real factor, const FunDensProp *dp)
Definition: fun-cam.c:973
cam_isgga
static int cam_isgga(void)
Definition: fun-cam.c:80
camb3lyp_report
static void camb3lyp_report(void)
Definition: fun-cam.c:259
cam_read
static int cam_read(const char *conf_line)
Read the configuration.
Definition: fun-cam.c:289
hse_read
static int hse_read(const char *conf_line)
Definition: fun-cam.c:405
cam_first
static void cam_first(FunFirstFuncDrv *ds, real factor, const FunDensProp *dp)
Definition: fun-cam.c:884
camb3lyp_read
static int camb3lyp_read(const char *conf_line)
Definition: fun-cam.c:224
cam_energy
static real cam_energy(const FunDensProp *dp)
Definition: fun-cam.c:825
cam_report
static void cam_report(void)
Definition: fun-cam.c:391
cam_fourth
static void cam_fourth(FunFourthFuncDrv *ds, real factor, const FunDensProp *dp)
Definition: fun-cam.c:1274