1 #ifndef MADNESS_CHEM_XCFUNCTIONAL_H__INCLUDED
2 #define MADNESS_CHEM_XCFUNCTIONAL_H__INCLUDED
16 #ifdef MADNESS_HAS_LIBXC
27 int x_rks_s__(
const double *r__,
double *
f,
double * dfdra);
28 int c_rks_vwn5__(
const double *r__,
double *f,
double * dfdra);
29 double* rho = t.ptr();
30 for (
int i=0; i<t.size(); i++) {
47 #ifdef MADNESS_HAS_LIBXC
48 std::vector< std::pair<xc_func_type*,double> > funcs;
49 void make_libxc_args(
const std::vector< madness::Tensor<double> >& t,
50 madness::Tensor<double>& rho,
51 madness::Tensor<double>&
sigma)
const;
71 static void polyn(
const double x,
double& p,
double& dpdx) {
74 static const double xmin = 1e-10;
75 static const double xmax = 1e-8;
77 static const double xmax2 = xmax*xmax;
78 static const double xmax3 = xmax2*xmax;
79 static const double xmin2 = xmin*xmin;
80 static const double xmin3 = xmin2*xmin;
81 static const double r = 1.0/((xmax-xmin)*(-xmin3+(3.0*xmin2+(-3.0*xmin+xmax)*xmax)*xmax));
82 static const double a0 = xmax3*xmin*(xmax-4.0*xmin)*r;
83 static const double a = xmin2*(xmin2+(-4.0*xmin+18.0*xmax)*xmax)*r;
84 static const double b = -6.0*xmin*xmax*(3.0*xmax+2.0*xmin)*r;
85 static const double c = (4.0*xmin2+(20.0*xmin+6.0*xmax)*xmax)*r;
86 static const double d = -(8.0*xmax+7.0*xmin)*r;
87 static const double e = 3.0*r;
98 p = a0+(a+(b+(c+(d+e*x)*x)*x)*x)*x;
99 dpdx = a+(2.0*b+(3.0*c+(4.0*d+5.0*e*x)*x)*x)*x;
111 if (rho <= rhotol) rho=
rhomin;
116 if (rho < rhotol) rho=
rhomin;
117 if (rho < rhotol || sigma < sigtol) sigma=
sigmin;
120 void munge5(
double& rhoa,
double& rhob,
double& saa,
double& sab,
double& sbb)
const {
121 if (rhoa < rhotol || rhob < rhotol || sab < sigtol) sab=
sigmin;
123 if (rhoa < rhotol) rhoa=
rhomin;
124 if (rhoa < rhotol || saa < sigtol) saa=
sigmin;
126 if (rhob < rhotol) rhob=
rhomin;
127 if (rhob < rhotol || sbb < sigtol) sbb=
sigmin;
192 madness::Tensor<double>
exc(
const std::vector< madness::Tensor<double> >& t ,
const int ispin)
const;
239 madness::Tensor<double>
vxc(
const std::vector< madness::Tensor<double> >& t,
const int ispin,
const int what)
const;
241 madness::Tensor<double>
fxc(
const std::vector< madness::Tensor<double> >& t,
const int ispin,
const int what)
const;
246 double lo=1e-6, hi=1e+1, s=std::pow(hi/lo, 1.0/(npt-1));
248 madness::Tensor<double> rho(npt);
249 for (
int i=0; i<npt; i++) {
253 std::vector< madness::Tensor<double> > t;
256 madness::Tensor<double>
f =
exc(t,0);
257 madness::Tensor<double> va =
vxc(t,0,0);
258 madness::Tensor<double> vb =
vxc(t,0,1);
259 for (
long i=0; i<npt; i++) {
260 printf(
"%.3e %.3e %.3e %.3e\n", rho[i], f[i], va[i], vb[i]);
271 : xc(&xc), ispin(ispin)
277 return xc->
exc(t,ispin);
288 : xc(&xc), what(what), ispin(ispin)
294 madness::Tensor<double> r = xc->
vxc(t, ispin, what);
306 : xc(&xc), what(what), ispin(ispin)
312 madness::Tensor<double> r = xc->
fxc(t, ispin, what);
int x_rks_s__(const double *r__, double *f, double *dfdra)
Definition: chem/lda.cc:58
void operator()(const Key< 3 > &key, Tensor< double > &t) const
Definition: chem/xcfunctional.h:25
void plot() const
Crude function to plot the energy and potential functionals.
Definition: chem/xcfunctional.h:244
const int what
Definition: chem/xcfunctional.h:302
Compute the spin-restricted LDA potential using unaryop (only for the initial guess) ...
Definition: chem/xcfunctional.h:22
~XCfunctional()
Destructor.
Definition: chem/xcfunctional_ldaonly.cc:55
const double sigma
Definition: dielectric.cc:187
void initialize(const std::string &input_line, bool polarized)
Initialize the object from the user input data.
Definition: chem/xcfunctional_ldaonly.cc:19
bool is_lda() const
Returns true if the potential is lda.
Definition: chem/xcfunctional_ldaonly.cc:57
::std::string string
Definition: gtest-port.h:872
xc_kernel(const XCfunctional &xc, int ispin, int what)
Definition: chem/xcfunctional.h:305
double rhomin
Definition: chem/xcfunctional.h:45
xc_potential(const XCfunctional &xc, int ispin, int what)
Definition: chem/xcfunctional.h:287
static void polyn(const double x, double &p, double &dpdx)
Smoothly switches between constant (xxmax)
Definition: chem/xcfunctional.h:71
const int ispin
Definition: chem/xcfunctional.h:268
NDIM & f
Definition: mra.h:2179
XCfunctional()
Default constructor is required.
Definition: chem/xcfunctional_ldaonly.cc:17
const XCfunctional * xc
Definition: chem/xcfunctional.h:267
Class to compute terms of the potential.
Definition: chem/xcfunctional.h:282
xc_lda_potential()
Definition: chem/xcfunctional.h:23
const int what
Definition: chem/xcfunctional.h:284
madness::Tensor< double > operator()(const madness::Key< 3 > &key, const std::vector< madness::Tensor< double > > &t) const
Definition: chem/xcfunctional.h:274
Defines and implements most of Tensor.
madness::Tensor< double > operator()(const madness::Key< 3 > &key, const std::vector< madness::Tensor< double > > &t) const
Definition: chem/xcfunctional.h:309
#define max(a, b)
Definition: lda.h:53
bool has_kxc() const
Returns true if the third derivative of the functional is available (not yet supported) ...
Definition: chem/xcfunctional_ldaonly.cc:78
bool spin_polarized
True if the functional is spin polarized.
Definition: chem/xcfunctional.h:43
bool has_fxc() const
Returns true if the second derivative of the functional is available (not yet supported) ...
Definition: chem/xcfunctional_ldaonly.cc:73
double munge(double rho) const
Definition: chem/xcfunctional.h:110
FLOAT a(int j, FLOAT z)
Definition: y1.cc:86
xc_functional(const XCfunctional &xc, int ispin)
Definition: chem/xcfunctional.h:270
double hf_coeff
Factor multiplying HF exchange (+1.0 gives HF)
Definition: chem/xcfunctional.h:44
Class to compute terms of the kernel.
Definition: chem/xcfunctional.h:300
static double munge_old(double rho)
Definition: chem/xcfunctional.h:103
void munge5(double &rhoa, double &rhob, double &saa, double &sab, double &sbb) const
Definition: chem/xcfunctional.h:120
const int ispin
Definition: chem/xcfunctional.h:303
double sigmin
Definition: chem/xcfunctional.h:45
madness::Tensor< double > fxc(const std::vector< madness::Tensor< double > > &t, const int ispin, const int what) const
Definition: chem/xcfunctional_ldaonly.cc:150
bool is_meta() const
Returns true if the potential is meta gga (needs second derivatives ... not yet supported) ...
Definition: chem/xcfunctional_ldaonly.cc:65
const int ispin
Definition: chem/xcfunctional.h:285
double hf_exchange_coefficient() const
Returns the value of the hf exact exchange coefficient.
Definition: chem/xcfunctional.h:168
madness::Tensor< double > vxc(const std::vector< madness::Tensor< double > > &t, const int ispin, const int what) const
Computes components of the potential (derivative of the energy functional) at np points.
Definition: chem/xcfunctional_ldaonly.cc:115
const XCfunctional * xc
Definition: chem/xcfunctional.h:283
int c_rks_vwn5__(const double *r__, double *f, double *dfdra)
Definition: chem/lda.cc:116
double sigtol
Definition: chem/xcfunctional.h:45
double rhotol
Definition: chem/xcfunctional.h:45
Class to compute the energy functional.
Definition: chem/xcfunctional.h:266
const XCfunctional * xc
Definition: chem/xcfunctional.h:301
void munge2(double &rho, double &sigma) const
Definition: chem/xcfunctional.h:115
madness::Tensor< double > exc(const std::vector< madness::Tensor< double > > &t, const int ispin) const
Computes the energy functional at given points.
Definition: chem/xcfunctional_ldaonly.cc:83
bool is_gga() const
Returns true if the potential is gga (needs first derivatives)
Definition: chem/xcfunctional_ldaonly.cc:61
Multidimension Key for MRA tree and associated iterators.
Simplified interface to XC functionals.
Definition: chem/xcfunctional.h:41
Holds machinery to set up Functions/FuncImpls using various Factories and Interfaces.
Definition: chem/atomutil.cc:45
bool is_dft() const
Returns true if there is a DFT functional (false probably means Hatree-Fock exchange only) ...
Definition: chem/xcfunctional_ldaonly.cc:69
const double c
Definition: gfit.cc:200
FLOAT b(int j, FLOAT z)
Definition: y1.cc:79
madness::Tensor< double > operator()(const madness::Key< 3 > &key, const std::vector< madness::Tensor< double > > &t) const
Definition: chem/xcfunctional.h:291
Key is the index for a node of the 2^NDIM-tree.
Definition: key.h:69
bool is_spin_polarized() const
Returns true if the functional is spin_polarized.
Definition: chem/xcfunctional.h:156