ergo
|
General CAM functional. More...
#include <assert.h>
#include <math.h>
#include <ctype.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "functionals.h"
Classes | |
struct | RGFirstDrv |
struct | RGSecondDrv |
struct | RGThirdDrv |
struct | RGFourthDrv |
struct | FunctionalList |
Defines | |
#define | _XOPEN_SOURCE 500 |
#define | _XOPEN_SOURCE_EXTENDED 1 |
#define | _BSD_SOURCE 1 |
#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. | |
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 FunctionalList * | newFunc (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 FunctionalList * | exchangeFunctionals = NULL |
The module uses program-wide configuration. | |
static struct FunctionalList * | correlationFunctionals = 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 |
General CAM functional.
Often called a range-separated exchange method.
Pawel Salek, 2004.06, Himmelbjerg - initial implementation.
#define __CVERSION__ |
#define _BSD_SOURCE 1 |
#define _XOPEN_SOURCE 500 |
#define _XOPEN_SOURCE_EXTENDED 1 |
#define BECKE88_CORR_WEIGHT 1 |
Referenced by camb3lyp_read().
#define ELEMENTS | ( | arr | ) | (sizeof(arr)/sizeof(arr[0])) |
Referenced by camb3lyp_read(), cam_read(), cam_b_second_medium(), cam_b_third_medium(), and cam_b_fourth_medium().
#define EVALUATOR | ( | a, | |
type | |||
) |
((a<0.14) ? cam_b_ ## type ## _small(a) : \ ((a<4.25) ? cam_b_ ## type ## _medium(a) : \ cam_b_ ## type ## _large(a)))
Referenced by cam_energy_sigma(), cam_first_sigma(), cam_second_sigma(), cam_third_sigma(), and cam_fourth_sigma().
#define FAC M_SQRT2 |
#define LYP_WEIGHT 0.81 |
Referenced by camb3lyp_read().
#define MAX_LARGE_COEFS 5 |
Referenced by cam_b_energy_large(), and cam_b_first_large().
#define SQRT_PI 1.77245385090552 |
Referenced by fun_a(), cam_b_energy_small(), cam_b_first_small(), cam_b_energy_medium(), cam_b_first_medium(), and cam_b_fourth_medium().
#define THR 1e-40 |
Referenced by fun_a_first(), fun_a_second(), cam_b_second_medium(), cam_b_third_medium(), cam_energy(), cam_first(), cam_second(), cam_third(), and cam_fourth().
#define VWN_WEIGHT 0.19 |
Referenced by camb3lyp_read().
References MAX_LARGE_COEFS, and large_coefs.
References MAX_LARGE_COEFS, and large_coefs1.
References large_coefs, evaluate_series(), ELEMENTS, POW, EXP, and SQRT_PI.
Referenced by cam_fourth_sigma().
References FABS, THR, large_coefs, evaluate_series(), ELEMENTS, EXP, and POW.
Referenced by cam_second_sigma(), cam_third_sigma(), and cam_fourth_sigma().
References FABS, THR, large_coefs, evaluate_series(), ELEMENTS, POW, and EXP.
Referenced by cam_third_sigma(), and cam_fourth_sigma().
static real cam_energy | ( | const FunDensProp * | dp | ) | [static] |
References fun_a(), and EVALUATOR.
Referenced by cam_energy().
static void cam_first | ( | FunFirstFuncDrv * | ds, |
real | factor, | ||
const FunDensProp * | dp | ||
) | [static] |
References camAlpha, FunDensProp_::rhoa, FunDensProp_::rhob, FunDensProp_::grada, FunDensProp_::gradb, FunDensProp_::gradab, FunctionalList::next, FunctionalList::func, Functional_::func, FunctionalList::weight, Functional_::first, ENERGY_THR, RGFirstDrv::df10, FunFirstFuncDrv::df1000, RGFirstDrv::df01, FunFirstFuncDrv::df0010, cam_first_sigma(), FABS, THR, FunFirstFuncDrv::df0100, and FunFirstFuncDrv::df0001.
static void cam_first_sigma | ( | real | rho, |
real | ex, | ||
RGFirstDrv * | ds, | ||
RGFirstDrv * | res | ||
) | [static] |
References fun_a(), camBeta, EVALUATOR, fun_a_first(), RGFirstDrv::df10, and RGFirstDrv::df01.
Referenced by cam_first().
static void cam_fourth | ( | FunFourthFuncDrv * | ds, |
real | factor, | ||
const FunDensProp * | dp | ||
) | [static] |
References camAlpha, FunDensProp_::rhoa, FunDensProp_::rhob, FunDensProp_::grada, FunDensProp_::gradb, FunDensProp_::gradab, FunctionalList::next, FunctionalList::func, Functional_::func, FunctionalList::weight, Functional_::fourth, ENERGY_THR, RGFourthDrv::df10, FunFourthFuncDrv::df1000, RGFourthDrv::df20, FunFourthFuncDrv::df2000, RGFourthDrv::df30, FunFourthFuncDrv::df3000, RGFourthDrv::df01, FunFourthFuncDrv::df0010, RGFourthDrv::df02, FunFourthFuncDrv::df0020, RGFourthDrv::df03, FunFourthFuncDrv::df0030, RGFourthDrv::df11, FunFourthFuncDrv::df1010, RGFourthDrv::df21, FunFourthFuncDrv::df2010, RGFourthDrv::df12, FunFourthFuncDrv::df1020, RGFourthDrv::df40, FunFourthFuncDrv::df4000, RGFourthDrv::df31, FunFourthFuncDrv::df3010, RGFourthDrv::df22, FunFourthFuncDrv::df2020, RGFourthDrv::df13, FunFourthFuncDrv::df1030, RGFourthDrv::df04, FunFourthFuncDrv::df0040, cam_fourth_sigma(), FABS, THR, FunFourthFuncDrv::df0100, FunFourthFuncDrv::df0200, FunFourthFuncDrv::df0300, FunFourthFuncDrv::df0001, FunFourthFuncDrv::df0002, FunFourthFuncDrv::df0003, FunFourthFuncDrv::df0101, FunFourthFuncDrv::df0201, FunFourthFuncDrv::df0102, FunFourthFuncDrv::df0400, FunFourthFuncDrv::df0301, FunFourthFuncDrv::df0202, FunFourthFuncDrv::df0103, and FunFourthFuncDrv::df0004.
static void cam_fourth_sigma | ( | real | rho, |
real | ex, | ||
RGFourthDrv * | f4, | ||
RGFourthDrv * | res | ||
) | [static] |
References fun_a(), camBeta, EVALUATOR, cam_b_second_medium(), cam_b_third_medium(), cam_b_fourth_medium(), fun_a_fourth(), RGFourthDrv::df10, RGFourthDrv::df01, RGFourthDrv::df20, RGFourthDrv::df11, RGFourthDrv::df02, RGFourthDrv::df30, RGFourthDrv::df21, RGFourthDrv::df12, RGFourthDrv::df03, RGFourthDrv::df40, RGFourthDrv::df31, RGFourthDrv::df22, RGFourthDrv::df13, and RGFourthDrv::df04.
Referenced by cam_fourth().
static void cam_free_config | ( | void | ) | [static] |
References FunctionalList::next.
Referenced by camb3lyp_read(), and cam_read().
static int cam_isgga | ( | void | ) | [static] |
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
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....
References camAlpha, camBeta, camMu, cam_free_config(), fun_printf, ELEMENTS, exchangeFunctionals, correlationFunctionals, available_functionals, FunctionalList::weight, and newFunc().
Referenced by hse_read().
static void cam_report | ( | void | ) | [static] |
References fun_printf, camAlpha, camBeta, camMu, FunctionalList::next, FunctionalList::func, Functional_::name, and FunctionalList::weight.
static void cam_second | ( | FunSecondFuncDrv * | ds, |
real | factor, | ||
const FunDensProp * | dp | ||
) | [static] |
References camAlpha, FunDensProp_::rhoa, FunDensProp_::rhob, FunDensProp_::grada, FunDensProp_::gradb, FunDensProp_::gradab, FunctionalList::next, FunctionalList::func, Functional_::func, FunctionalList::weight, Functional_::second, ENERGY_THR, RGSecondDrv::df10, FunSecondFuncDrv::df1000, RGSecondDrv::df20, FunSecondFuncDrv::df2000, RGSecondDrv::df01, FunSecondFuncDrv::df0010, RGSecondDrv::df02, FunSecondFuncDrv::df0020, RGSecondDrv::df11, FunSecondFuncDrv::df1010, cam_second_sigma(), FABS, THR, FunSecondFuncDrv::df0100, FunSecondFuncDrv::df0200, FunSecondFuncDrv::df0001, FunSecondFuncDrv::df0002, and FunSecondFuncDrv::df0101.
static void cam_second_sigma | ( | real | rho, |
real | ex, | ||
RGSecondDrv * | f2, | ||
RGSecondDrv * | res | ||
) | [static] |
References RGSecondDrv::df10, RGSecondDrv::df01, RGSecondDrv::df20, RGSecondDrv::df11, RGSecondDrv::df02, fun_a(), camBeta, EVALUATOR, cam_b_second_medium(), and fun_a_second().
Referenced by cam_second().
static void cam_third | ( | FunThirdFuncDrv * | ds, |
real | factor, | ||
const FunDensProp * | dp | ||
) | [static] |
References camAlpha, FunDensProp_::rhoa, FunDensProp_::rhob, FunDensProp_::grada, FunDensProp_::gradb, FunDensProp_::gradab, FunctionalList::next, FunctionalList::func, Functional_::func, FunctionalList::weight, Functional_::third, ENERGY_THR, RGThirdDrv::df10, FunThirdFuncDrv::df1000, RGThirdDrv::df20, FunThirdFuncDrv::df2000, RGThirdDrv::df30, FunThirdFuncDrv::df3000, RGThirdDrv::df01, FunThirdFuncDrv::df0010, RGThirdDrv::df02, FunThirdFuncDrv::df0020, RGThirdDrv::df03, FunThirdFuncDrv::df0030, RGThirdDrv::df11, FunThirdFuncDrv::df1010, RGThirdDrv::df21, FunThirdFuncDrv::df2010, RGThirdDrv::df12, FunThirdFuncDrv::df1020, cam_third_sigma(), FABS, THR, FunThirdFuncDrv::df0100, FunThirdFuncDrv::df0200, FunThirdFuncDrv::df0300, FunThirdFuncDrv::df0001, FunThirdFuncDrv::df0002, FunThirdFuncDrv::df0003, FunThirdFuncDrv::df0101, FunThirdFuncDrv::df0201, and FunThirdFuncDrv::df0102.
static void cam_third_sigma | ( | real | rho, |
real | ex, | ||
RGThirdDrv * | f3, | ||
RGThirdDrv * | res | ||
) | [static] |
References fun_a(), camBeta, EVALUATOR, cam_b_second_medium(), cam_b_third_medium(), fun_a_third(), RGThirdDrv::df10, RGThirdDrv::df01, RGThirdDrv::df20, RGThirdDrv::df11, RGThirdDrv::df02, RGThirdDrv::df30, RGThirdDrv::df21, RGThirdDrv::df12, and RGThirdDrv::df03.
Referenced by cam_third().
static int camb3lyp_read | ( | const char * | conf_line | ) | [static] |
static void camb3lyp_report | ( | void | ) | [static] |
References fun_printf, camAlpha, camBeta, and camMu.
Referenced by cam_b_second_medium(), cam_b_third_medium(), and cam_b_fourth_medium().
References camMu, SQRT, and SQRT_PI.
Referenced by cam_energy_sigma(), cam_first_sigma(), cam_second_sigma(), cam_third_sigma(), and cam_fourth_sigma().
static void fun_a_first | ( | real | rho, |
real | a, | ||
real | ex, | ||
RGFirstDrv * | fun1, | ||
RGFirstDrv * | res | ||
) | [static] |
References FABS, THR, RGFirstDrv::df10, and RGFirstDrv::df01.
Referenced by cam_first_sigma().
static void fun_a_fourth | ( | real | rho, |
real | a, | ||
real | ex, | ||
RGFourthDrv * | f4, | ||
RGFourthDrv * | res | ||
) | [static] |
References FABS, RGFourthDrv::df10, RGFourthDrv::df01, RGFourthDrv::df20, RGFourthDrv::df11, RGFourthDrv::df02, RGFourthDrv::df30, RGFourthDrv::df21, RGFourthDrv::df12, RGFourthDrv::df03, RGFourthDrv::df40, RGFourthDrv::df31, RGFourthDrv::df22, RGFourthDrv::df13, and RGFourthDrv::df04.
Referenced by cam_fourth_sigma().
static void fun_a_second | ( | real | rho, |
real | a, | ||
real | ex, | ||
RGSecondDrv * | f2, | ||
RGSecondDrv * | res | ||
) | [static] |
References FABS, THR, RGSecondDrv::df10, RGSecondDrv::df20, RGSecondDrv::df01, RGSecondDrv::df11, and RGSecondDrv::df02.
Referenced by cam_second_sigma().
static void fun_a_third | ( | real | rho, |
real | a, | ||
real | ex, | ||
RGThirdDrv * | f3, | ||
RGThirdDrv * | res | ||
) | [static] |
References FABS, RGThirdDrv::df10, RGThirdDrv::df01, RGThirdDrv::df20, RGThirdDrv::df11, RGThirdDrv::df02, RGThirdDrv::df30, RGThirdDrv::df21, RGThirdDrv::df12, and RGThirdDrv::df03.
Referenced by cam_third_sigma().
References selected_func, camAlpha, camBeta, and camMu.
Referenced by get_hf_weight_and_cam_params().
static int hse_read | ( | const char * | conf_line | ) | [static] |
References cam_read().
static struct FunctionalList* newFunc | ( | Functional * | f, |
real | weight, | ||
struct FunctionalList * | next | ||
) | [static, read] |
References FunctionalList::func, FunctionalList::weight, and FunctionalList::next.
Referenced by camb3lyp_read(), and cam_read().
static int parse_table | ( | const char * | func, |
const char * | str, | ||
int | cnt, | ||
const char * | keywords[], | ||
double * | weights | ||
) | [static] |
References fun_printf.
Referenced by camb3lyp_read().
const char* cam_keywords[] = { "alpha", "beta", "mu" } [static] |
Referenced by camb3lyp_read().
Referenced by camb3lyp_read(), camb3lyp_report(), cam_read(), cam_report(), cam_energy(), cam_first(), cam_second(), cam_third(), cam_fourth(), and fun_get_cam_param().
{ "Camb3lyp", cam_isgga, camb3lyp_read, camb3lyp_report, cam_energy, cam_first, cam_second, cam_third, cam_fourth }
{ "Cam", cam_isgga, cam_read, cam_report, cam_energy, cam_first, cam_second, cam_third, cam_fourth }
Referenced by camb3lyp_read(), camb3lyp_report(), cam_read(), cam_report(), fun_a(), and fun_get_cam_param().
struct FunctionalList* correlationFunctionals = NULL [static] |
Referenced by cam_read().
const real ENERGY_THR = 1e-13 [static] |
Referenced by cam_energy(), cam_first(), cam_second(), cam_third(), and cam_fourth().
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_read().
{ "HSE", cam_isgga, hse_read, cam_report, cam_energy, cam_first, cam_second, cam_third, cam_fourth }
const real large_coefs[] = { 9, 60, 420, 3240, 27720 } [static] |
Referenced by cam_b_energy_large(), cam_b_second_medium(), cam_b_third_medium(), and cam_b_fourth_medium().
const real large_coefs1[] = { 4.5, 15, 70, 405 } [static] |
Referenced by cam_b_first_large().