1#ifndef MADNESS_CHEM_XCFUNCTIONAL_H__INCLUDED
2#define MADNESS_CHEM_XCFUNCTIONAL_H__INCLUDED
18#ifdef MADNESS_HAS_LIBXC
29 int x_rks_s__(
const double *r__,
double *
f,
double * dfdra);
30 int c_rks_vwn5__(
const double *r__,
double *
f,
double * dfdra);
31 double* rho = t.
ptr();
32 for (
int i=0; i<t.
size(); i++) {
33 double r = std::max(rho[i],1
e-12);
103#ifdef MADNESS_HAS_LIBXC
104 std::vector< std::pair<xc_func_type*,double> > funcs;
135 const bool need_response)
const;
156 static void polyn(
const double x,
double&
p,
double& dpdx) {
159 static const double xmin = 1.e-6;
160 static const double xmax = 5.e-5;
162 static const double xmax2 = xmax*xmax;
163 static const double xmax3 = xmax2*xmax;
164 static const double xmin2 = xmin*xmin;
165 static const double xmin3 = xmin2*xmin;
166 static const double r = 1.0/((xmax-xmin)*(-xmin3+(3.0*xmin2+(-3.0*xmin+xmax)*xmax)*xmax));
167 static const double a0 = xmax3*xmin*(xmax-4.0*xmin)*r;
168 static const double a = xmin2*(xmin2+(-4.0*xmin+18.0*xmax)*xmax)*r;
169 static const double b = -6.0*xmin*xmax*(3.0*xmax+2.0*xmin)*r;
170 static const double c = (4.0*xmin2+(20.0*xmin+6.0*xmax)*xmax)*r;
171 static const double d = -(8.0*xmax+7.0*xmin)*r;
172 static const double e = 3.0*r;
183 p = a0+(
a+(
b+(
c+(
d+
e*x)*x)*x)*x)*x;
184 dpdx =
a+(2.0*
b+(3.0*
c+(4.0*
d+5.0*
e*x)*x)*x)*x;
224 void initialize(
const std::string& input_line,
bool polarized,
World& world,
225 const bool verbose=
false);
315 const int ispin)
const;
332 std::vector<madness::Tensor<double> >
fxc_apply(
339 double lo=1
e-6, hi=1
e+1, s=std::pow(hi/
lo, 1.0/(npt-1));
342 for (
int i=0; i<npt; i++) {
346 std::vector< madness::Tensor<double> > t(13);
352 std::vector<madness::Tensor<double> > va =
vxc(t,0);
353 for (
long i=0; i<npt; i++) {
354 printf(
"%.3e %.3e %.3e\n", rho[i],
f[i], va[0][i]);
396 std::vector<madness::Tensor<double> > r =
xc->
vxc(t,
ispin);
double q(double t)
Definition DKops.h:18
This header should include pretty much everything needed for the parallel runtime.
long size() const
Returns the number of elements in the tensor.
Definition basetensor.h:138
FunctionCommonData holds all Function data common for given k.
Definition function_common_data.h:52
FunctionDefaults holds default paramaters as static class members.
Definition funcdefaults.h:204
Key is the index for a node of the 2^NDIM-tree.
Definition key.h:66
A tensor is a multidimension array.
Definition tensor.h:317
T * ptr()
Returns a pointer to the internal data.
Definition tensor.h:1824
A parallel world class.
Definition world.h:132
Simplified interface to XC functionals.
Definition xcfunctional.h:43
bool has_fxc() const
Returns true if the second derivative of the functional is available (not yet supported)
Definition xcfunctional_ldaonly.cc:71
bool is_dft() const
Returns true if there is a DFT functional (false probably means Hatree-Fock exchange only)
Definition xcfunctional_ldaonly.cc:67
double rhomin
Definition xcfunctional.h:100
std::vector< madness::Tensor< double > > vxc(const std::vector< madness::Tensor< double > > &t, const int ispin) const
Computes components of the potential (derivative of the energy functional) at np points.
Definition xcfunctional_ldaonly.cc:119
bool is_lda() const
Returns true if the potential is lda.
Definition xcfunctional_ldaonly.cc:55
double get_ggatol() const
return the binary munging threshold for the final result in the GGA potential/kernel
Definition xcfunctional.h:94
double get_rhotol() const
return the munging threshold for the density
Definition xcfunctional.h:88
static const int number_xc_args
max number of intermediates
Definition xcfunctional.h:85
void plot() const
Crude function to plot the energy and potential functionals.
Definition xcfunctional.h:337
madness::Tensor< double > exc(const std::vector< madness::Tensor< double > > &t) const
Computes the energy functional at given points.
Definition xcfunctional_ldaonly.cc:81
bool is_spin_polarized() const
Returns true if the functional is spin_polarized.
Definition xcfunctional.h:243
xc_arg
Definition xcfunctional.h:62
@ enum_zetab_y
Definition xcfunctional.h:76
@ enum_zetab_z
Definition xcfunctional.h:77
@ enum_ddens_pty
Definition xcfunctional.h:82
@ enum_zetaa_y
Definition xcfunctional.h:73
@ enum_sigtot
Definition xcfunctional.h:69
@ enum_zetab_x
Definition xcfunctional.h:75
@ enum_rho_pt
perturbed density (CPHF, TDKS)
Definition xcfunctional.h:65
@ enum_chi_aa
Definition xcfunctional.h:78
@ enum_sbb
Definition xcfunctional.h:68
@ enum_saa
Definition xcfunctional.h:66
@ enum_rhob
beta density
Definition xcfunctional.h:64
@ enum_zetaa_x
Definition xcfunctional.h:72
@ enum_sab
Definition xcfunctional.h:67
@ enum_zetaa_z
Definition xcfunctional.h:74
@ enum_sigma_pta_div_rho
Definition xcfunctional.h:70
@ enum_chi_ab
Definition xcfunctional.h:79
@ enum_chi_bb
Definition xcfunctional.h:80
@ enum_sigma_ptb_div_rho
Definition xcfunctional.h:71
@ enum_ddens_ptx
Definition xcfunctional.h:81
@ enum_rhoa
alpha density
Definition xcfunctional.h:63
@ enum_ddens_ptz
Definition xcfunctional.h:83
bool is_meta() const
Returns true if the potential is meta gga (needs second derivatives ... not yet supported)
Definition xcfunctional_ldaonly.cc:63
static double munge_old(double rho)
Definition xcfunctional.h:188
bool is_gga() const
Returns true if the potential is gga (needs first derivatives)
Definition xcfunctional_ldaonly.cc:59
std::vector< madness::Tensor< double > > fxc_apply(const std::vector< madness::Tensor< double > > &t, const int ispin) const
compute the second derivative of the XC energy wrt the density and apply
Definition xcfunctional_ldaonly.cc:163
~XCfunctional()
Destructor.
Definition xcfunctional_ldaonly.cc:53
double hf_exchange_coefficient() const
Returns the value of the hf exact exchange coefficient.
Definition xcfunctional.h:255
double hf_coeff
Factor multiplying HF exchange (+1.0 gives HF)
Definition xcfunctional.h:99
void make_libxc_args(const std::vector< madness::Tensor< double > > &t, madness::Tensor< double > &rho, madness::Tensor< double > &sigma, madness::Tensor< double > &rho_pt, madness::Tensor< double > &sigma_pt, std::vector< madness::Tensor< double > > &drho, std::vector< madness::Tensor< double > > &drho_pt, const bool need_response) const
convert the raw density (gradient) data to be used by the xc operators
Definition xcfunctional_ldaonly.cc:168
double ggatol
See initialize and munge*.
Definition xcfunctional.h:101
static void polyn(const double x, double &p, double &dpdx)
Smoothly switches between constant (x<xmin) and linear function (x>xmax)
Definition xcfunctional.h:156
bool has_kxc() const
Returns true if the third derivative of the functional is available (not yet supported)
Definition xcfunctional_ldaonly.cc:76
bool spin_polarized
True if the functional is spin polarized.
Definition xcfunctional.h:98
void initialize(const std::string &input_line, bool polarized, World &world, const bool verbose=false)
Initialize the object from the user input data.
Definition xcfunctional_ldaonly.cc:23
XCfunctional()
Default constructor is required.
Definition xcfunctional_ldaonly.cc:19
double binary_munge(double rho, double refrho, const double thresh) const
munge rho if refrho is small
Definition xcfunctional.h:211
int nderiv
the number of xc kernel derivatives (lda: 0, gga: 1, etc)
Definition xcfunctional.h:138
double munge(double rho) const
simple munging for the density only (LDA)
Definition xcfunctional.h:197
double rhotol
See initialize and munge*.
Definition xcfunctional.h:100
char * p(char *buf, const char *name, int k, int initial_level, double thresh, int order)
Definition derivatives.cc:72
const double sigma
Definition dielectric.cc:185
static double lo
Definition dirac-hatom.cc:23
Multidimension Key for MRA tree and associated iterators.
Macros and tools pertaining to the configuration of MADNESS.
#define MADNESS_EXCEPTION(msg, value)
Macro for throwing a MADNESS exception.
Definition madness_exception.h:119
#define MADNESS_ASSERT(condition)
Assert a condition that should be free of side-effects since in release builds this might be a no-op.
Definition madness_exception.h:134
Namespace for all elements and tools of MADNESS.
Definition DFParameters.h:10
NDIM & f
Definition mra.h:2416
int x_rks_s__(const double *r__, double *f, double *dfdra)
Definition lda.cc:58
int c_rks_vwn5__(const double *r__, double *f, double *dfdra)
Definition lda.cc:116
static const double b
Definition nonlinschro.cc:119
static const double d
Definition nonlinschro.cc:121
static const double a
Definition nonlinschro.cc:118
static const double c
Definition relops.cc:10
static const double thresh
Definition rk.cc:45
Class to compute the energy functional.
Definition xcfunctional.h:360
xc_functional(const XCfunctional &xc)
Definition xcfunctional.h:363
madness::Tensor< double > operator()(const madness::Key< 3 > &key, const std::vector< madness::Tensor< double > > &t) const
Definition xcfunctional.h:365
const XCfunctional * xc
Definition xcfunctional.h:361
Class to compute terms of the kernel.
Definition xcfunctional.h:403
const FunctionCommonData< double, 3 > & cdata
Definition xcfunctional.h:406
const int ispin
Definition xcfunctional.h:405
std::size_t get_result_size() const
Definition xcfunctional.h:413
std::vector< madness::Tensor< double > > operator()(const madness::Key< 3 > &key, const std::vector< madness::Tensor< double > > &t) const
Definition xcfunctional.h:419
const XCfunctional * xc
Definition xcfunctional.h:404
xc_kernel_apply(const XCfunctional &xc, int ispin)
Definition xcfunctional.h:408
Compute the spin-restricted LDA potential using unaryop (only for the initial guess)
Definition xcfunctional.h:24
void operator()(const Key< 3 > &key, Tensor< double > &t) const
Definition xcfunctional.h:27
xc_lda_potential()
Definition xcfunctional.h:25
Class to compute terms of the potential.
Definition xcfunctional.h:374
xc_potential(const XCfunctional &xc, int ispin)
Definition xcfunctional.h:378
std::size_t get_result_size() const
Definition xcfunctional.h:381
const XCfunctional * xc
Definition xcfunctional.h:375
std::vector< madness::Tensor< double > > operator()(const madness::Key< 3 > &key, const std::vector< madness::Tensor< double > > &t) const
Definition xcfunctional.h:393
const int ispin
Definition xcfunctional.h:376
Defines and implements most of Tensor.
void e()
Definition test_sig.cc:75