MADNESS 0.10.1
xcfunctional.h
Go to the documentation of this file.
1#ifndef MADNESS_CHEM_XCFUNCTIONAL_H__INCLUDED
2#define MADNESS_CHEM_XCFUNCTIONAL_H__INCLUDED
3
5
6MADNESS_PRAGMA_GCC(diagnostic push)
7MADNESS_PRAGMA_GCC(diagnostic ignored "-Wcomment")
8MADNESS_PRAGMA_CLANG(diagnostic push)
9MADNESS_PRAGMA_CLANG(diagnostic ignored "-Wcomment")
10
11/// \file moldft/xcfunctional.h
12/// \brief Defines interface for DFT XC functionals
13/// \ingroup chemistry
14
15#include <madness/tensor/tensor.h>
16#include <vector>
17#include <algorithm>
18#include <utility>
19#include <madness/mra/key.h>
22
23#ifdef MADNESS_HAS_LIBXC
24#include <xc.h>
25#endif
26
27namespace madness {
28/// Compute the spin-restricted LDA potential using unaryop (only for the initial guess)
31
32 void operator()(const Key<3> & key, Tensor<double>& t) const
33 {
34 int x_rks_s__(const double *r__, double *f, double * dfdra);
35 int c_rks_vwn5__(const double *r__, double *f, double * dfdra);
36 double* rho = t.ptr();
37 for (int i=0; i<t.size(); i++) {
38 double r = std::max(rho[i],1e-12);
39 double q, dq1, dq2;
40 x_rks_s__(&r, &q, &dq1);
41 c_rks_vwn5__(&r, &q, &dq2);
42 rho[i] = dq1 + dq2;
43 }
44 }
45};
46
47/// Simplified interface to XC functionals
49public:
50
51 /// The ordering of the intermediates is fixed, but the code can handle
52 /// non-initialized functions, so if e.g. no GGA is requested, all the
53 /// corresponding vector components may be left empty.
54 ///
55 /// Note the additional quantities \f$ \zeta \f$ and \f$ \chi \f$, which are defined as
56 /// \f[
57 /// \rho = \exp(\zeta)
58 /// \f]
59 /// and thus the derivative of rho is given by
60 /// \f[
61 /// \nabla_x\rho = \exp(\zeta)\nabla_x\zeta = \rho \nabla_x\zeta
62 /// \f]
63 /// The reduced gradients \sigma may then be expressed as
64 /// \f[
65 /// \sigma = |\nabla\rho|^2 = |\rho|^2 |\nabla\zeta|^2 = |\rho|^2 \chi
66 /// \f]
67 enum xc_arg {
68 enum_rhoa=0, ///< alpha density \f$ \rho_\alpha \f$
69 enum_rhob=1, ///< beta density \f$ \rho_\beta \f$
70 enum_rho_pt=2, ///< perturbed density (CPHF, TDKS) \f$ \rho_{pt} \f$
71 enum_taua=3, ///< alpha kinetic energy density \f$ \tau_\alpha = \frac{1}{2}\sum_i|\nabla\psi_{i\alpha}|^2 \f$
72 enum_taub=4, ///< beta kinetic energy density \f$ \tau_\beta \f$
73 enum_saa=10, ///< \f$ \sigma_{aa} = \nabla \rho_{\alpha}.\nabla \rho_{\alpha} \f$
74 enum_sab=11, ///< \f$ \sigma_{ab} = \nabla \rho_{\alpha}.\nabla \rho_{\beta} \f$
75 enum_sbb=12, ///< \f$ \sigma_{bb} = \nabla \rho_{\beta}.\nabla \rho_{\beta} \f$
76 enum_sigtot=13, ///< \f$ \sigma = \nabla \rho.\nabla \rho \f$
77 enum_sigma_pta_div_rho=14, ///< \f$ \zeta_{\alpha}.\nabla\rho_{pt} \f$
78 enum_sigma_ptb_div_rho=15, ///< \f$ \zeta_{\beta}.\nabla\rho_{pt} \f$
79 enum_zetaa_x=16, ///< \f$ \zeta_{a,x}=\partial/{\partial x} \ln(\rho_a) \f$
80 enum_zetaa_y=17, ///< \f$ \zeta_{a,y}=\partial/{\partial y} \ln(\rho_a) \f$
81 enum_zetaa_z=18, ///< \f$ \zeta_{a,z}=\partial/{\partial z} \ln(\rho_a) \f$
82 enum_zetab_x=19, ///< \f$ \zeta_{b,x} = \partial/{\partial x} \ln(\rho_b) \f$
83 enum_zetab_y=20, ///< \f$ \zeta_{b,y} = \partial/{\partial y} \ln(\rho_b) \f$
84 enum_zetab_z=21, ///< \f$ \zeta_{b,z} = \partial/{\partial z} \ln(\rho_b) \f$
85 // Slots 22-24 held chi_st = zeta_s.zeta_t as three separately represented
86 // functions. They are gone: a projected product is not pointwise consistent
87 // with the zeta components it is built from, so the sigma matrix handed to
88 // libxc was not the Gram matrix of the density gradients -- chi_aa, a sum of
89 // squares, could come out negative near the nuclear cusp, and the total sigma
90 // followed it. make_libxc_args contracts zeta pointwise instead. Left as a
91 // hole rather than reused, so the surviving indices keep their meaning.
92 enum_ddens_ptx=25, ///< \f$ \nabla\rho_{pt}\f$
93 enum_ddens_pty=26, ///< \f$ \nabla\rho_{pt}\f$
94 enum_ddens_ptz=27 ///< \f$ \nabla\rho_{pt}\f$
95 };
96 const static int number_xc_args=28; ///< max number of intermediates
97
98 /// return the munging threshold for the density
99 double get_rhotol() const {return rhotol;}
100
101 /// return the binary munging threshold for the final result in the GGA potential/kernel
102
103 /// the GGA potential will be munged based on the smallness of the original
104 /// density, which we call binary munging
105 double get_ggatol() const {return ggatol;}
106
107 /// return the floor for the kinetic energy density
108
109 /// meta-gga functionals build the iso-orbital indicators alpha and z with tau
110 /// in the denominator, so tau needs a floor well above libxc's own 1e-20
111 /// default for a real-space code, where tau is a numerical derivative
112 double get_tautol() const {return tautol;}
113
114protected:
115
116 bool spin_polarized; ///< True if the functional is spin polarized
117 double hf_coeff; ///< Factor multiplying HF exchange (+1.0 gives HF)
118 double rhomin, rhotol; ///< See initialize and munge*
119 double ggatol; ///< See initialize and munge*
120 double tautol; ///< floor for the kinetic energy density, see initialize
121
122#ifdef MADNESS_HAS_LIBXC
123 std::vector< std::pair<xc_func_type*,double> > funcs;
124#endif
125
126 /// convert the raw density (gradient) data to be used by the xc operators
127
128 /// Involves mainly munging of the densities and multiplying with 2
129 /// if the calculation is spin-restricted.
130 /// Response densities and density gradients are munged based on the
131 /// value of the ground state density, since they may become negative
132 /// and may also be much more diffuse.
133 /// dimensions of the output tensors are for spin-restricted and unrestricted
134 /// (with np the number of grid points in the box):
135 /// rho(np) or rho(2*np)
136 /// sigma(np) sigma(3*np)
137 /// rho_pt(np)
138 /// sigma_pt(2*np)
139 /// @param[in] t input density (gradients)
140 /// @param[out] rho ground state (spin) density, properly munged
141 /// @param[out] sigma ground state (spin) density gradients, properly munged
142 /// @param[out] tau ground state (spin) kinetic energy density, properly munged
143 /// @param[out] rho_pt response density, properly munged (no spin)
144 /// @param[out] sigma_pt response (spin) density gradients, properly munged
145 /// @param[out] drho density derivative, constructed from rho and zeta
146 /// @param[out] drho_pt response density derivative directly from xc_args
147 /// @param[in] need_response flag if rho_pt and sigma_pt need to be calculated
148 void make_libxc_args(const std::vector< madness::Tensor<double> >& t,
154 std::vector<madness::Tensor<double> >& drho,
155 std::vector<madness::Tensor<double> >& drho_pt,
156 const bool need_response) const;
157
158 /// the number of xc kernel derivatives (lda: 0, gga: 1, etc)
160
161
162 /// Smoothly switches between constant (x<xmin) and linear function (x>xmax)
163
164 /// \f[
165 /// f(x,x_{\mathrm{min}},x_{\mathrm{max}}) = \left\{
166 /// \begin{array}{ll}
167 /// x_{\mathrm{min}} & x < x_{\mathrm{min}} \\
168 /// p(x,x_{\mathrm{min}},x_{\mathrm{max}}) & x_{\mathrm{min}} \leq x_{\mathrm{max}} \\
169 /// x & x_{\mathrm{max}} < x
170 /// \end{array}
171 /// \right.
172 /// \f]
173 /// where \f$p(x)\f$ is the unique quintic polynomial that
174 /// satisfies \f$p(x_{min})=x_{min}\f$, \f$p(x_{max})=x_{max}\f$,
175 /// \f$dp(x_{max})/dx=1\f$, and
176 /// \f$dp(x_{min})/dx=d^2p(x_{min})/dx^2=d^2p(x_{max})/dx^2=0\f$.
177 static void polyn(const double x, double& p, double& dpdx) {
178 // All of the static const stuff is evaluated at compile time
179
180 static const double xmin = 1.e-6; // <<<< MINIMUM VALUE OF DENSITY
181 static const double xmax = 5.e-5; // <<<< DENSITY SMOOTHLY MODIFIED BELOW THIS VALUE
182
183 static const double xmax2 = xmax*xmax;
184 static const double xmax3 = xmax2*xmax;
185 static const double xmin2 = xmin*xmin;
186 static const double xmin3 = xmin2*xmin;
187 static const double r = 1.0/((xmax-xmin)*(-xmin3+(3.0*xmin2+(-3.0*xmin+xmax)*xmax)*xmax));
188 static const double a0 = xmax3*xmin*(xmax-4.0*xmin)*r;
189 static const double a = xmin2*(xmin2+(-4.0*xmin+18.0*xmax)*xmax)*r;
190 static const double b = -6.0*xmin*xmax*(3.0*xmax+2.0*xmin)*r;
191 static const double c = (4.0*xmin2+(20.0*xmin+6.0*xmax)*xmax)*r;
192 static const double d = -(8.0*xmax+7.0*xmin)*r;
193 static const double e = 3.0*r;
194
195 if (x > xmax) {
196 p = x;
197 dpdx = 1.0;
198 }
199 else if (x < xmin) {
200 p = xmin;
201 dpdx = 0.0;
202 }
203 else {
204 p = a0+(a+(b+(c+(d+e*x)*x)*x)*x)*x;
205 dpdx = a+(2.0*b+(3.0*c+(4.0*d+5.0*e*x)*x)*x)*x;
206 }
207 }
208public:
209 static double munge_old(double rho) {
210 double p, dpdx;
211 polyn(rho, p, dpdx);
212 return p;
213 }
214
215private:
216
217 /// simple munging for the density only (LDA)
218 double munge(double rho) const {
219 if (rho <= rhotol) rho=rhomin;
220 return rho;
221 }
222
223 /// munge rho if refrho is small
224
225 /// special case for perturbed densities, which might be negative and diffuse.
226 /// Munge rho (e.g. the perturbed density) if the reference density refrho
227 /// e.g. the ground state density is small. Only where the reference density
228 /// is large enough DFT is numerically well-defined.
229 /// @param[in] rho number to be munged
230 /// @param[in] refrho reference value for munging
231 /// @param[in] thresh threshold for munging
232 double binary_munge(double rho, double refrho, const double thresh) const {
233 if (refrho<thresh) rho=rhomin;
234 return rho;
235 }
236
237public:
238 /// Default constructor is required
239 XCfunctional();
240
241 /// Initialize the object from the user input data
242
243 /// @param[in] input_line User input line (without beginning XC keyword)
244 /// @param[in] polarized Boolean flag indicating if the calculation is spin-polarized
245 void initialize(const std::string& input_line, bool polarized, World& world,
246 const bool verbose=false);
247
248 /// Destructor
250
251 /// Returns true if the potential is lda
252 bool is_lda() const;
253
254 /// Returns true if the potential is gga (needs first derivatives)
255 bool is_gga() const;
256
257 /// Returns true if the potential is meta gga (needs the kinetic energy density)
258 bool is_meta() const;
259
260 /// Returns true if the functional needs the reduced density gradients sigma
261
262 /// True for gga AND meta-gga -- a meta-gga needs the density gradients as
263 /// well as the kinetic energy density. Use this, not is_gga(), to decide
264 /// whether the gradient intermediates have to be computed.
265 bool needs_sigma() const;
266
267 /// Returns true if the functional needs the kinetic energy density tau
268 bool needs_tau() const;
269
270 /// Returns true if there is a DFT functional (false probably means Hatree-Fock exchange only)
271 bool is_dft() const;
272
273 /// Returns true if the functional is spin_polarized
274 bool is_spin_polarized() const
275 {
276 return spin_polarized;
277 }
278
279 /// Returns true if the second derivative of the functional is available (not yet supported)
280 bool has_fxc() const;
281
282 /// Returns true if the third derivative of the functional is available (not yet supported)
283 bool has_kxc() const;
284
285 /// Returns the value of the hf exact exchange coefficient
287 {
288 return hf_coeff;
289 }
290
291 /// Computes the energy functional at given points
292
293 /// This uses the convention that the total energy is
294 /// \f$ E[\rho] = \int \epsilon[\rho(x)] dx\f$
295 /// Any HF exchange contribution must be separately computed. Items in the
296 /// vector argument \c t are interpreted similarly to the xc_arg enum.
297 /// @param[in] t The input densities and derivatives as required by the functional
298 /// @return The exchange-correlation energy functional
299 madness::Tensor<double> exc(const std::vector< madness::Tensor<double> >& t) const;
300
301 /// Computes components of the potential (derivative of the energy functional) at np points
302
303 /// Any HF exchange contribution must be separately computed. Items in the
304 /// vector argument \c t are interpreted similarly to the xc_arg enum.
305 ///
306 /// We define \f$ \sigma_{\mu \nu} = \nabla \rho_{\mu} . \nabla \rho_{\nu} \f$
307 /// with \f$ \mu, \nu = \alpha\f$ or \f$ \beta \f$.
308 ///
309 /// For unpolarized GGA, matrix elements of the potential are
310 /// \f[
311 /// < \phi | \hat V | \psi > = \int \left( \frac{\partial \epsilon}{\partial \rho} \phi \psi
312 /// + \left( 2 \frac{\partial \epsilon}{\partial \sigma} \right)
313 /// \nabla \rho \cdot \nabla \left( \phi \psi \right) \right) dx
314 /// \f]
315 ///
316 /// For polarized GGA, matrix elements of the potential are
317 /// \f[
318 /// < \phi_{\alpha} | \hat V | \psi_{\alpha} > = \int \left( \frac{\partial \epsilon}{\partial \rho_{\alpha}} \phi \psi
319 /// + \left( 2 \frac{\partial \epsilon}{\partial \sigma_{\alpha \alpha}} \nabla \rho_{\alpha}
320 /// + \frac{\partial \epsilon}{\partial \sigma_{\alpha \beta}} \nabla \rho_{\beta} \right) . \nabla \left( \phi \psi \right) \right) dx
321 /// \f]
322 ///
323 /// Integrating the above by parts and assuming free-space or periodic boundary conditions
324 /// we obtain that the local multiplicative form of the GGA potential is
325 /// \f[
326 /// V_{\alpha} = \frac{\partial \epsilon}{\partial \rho_{\alpha}}
327 /// - \left(\nabla . \left(2 \frac{\partial \epsilon}{\partial \sigma_{\alpha \alpha}} \nabla \rho_{\alpha}
328 /// + \frac{\partial \epsilon}{\partial \sigma_{\alpha \beta}} \nabla \rho_{\beta} \right) \right)
329 /// \f]
330 ///
331 /// Return the following quantities for RHF: (see Yanai2005, Eq. (12))
332 /// \f{eqnarray*}{
333 /// \mbox{result[0]} &:& \qquad \frac{\partial \epsilon}{\partial \rho} \\
334 /// \mbox{result[1-3]} &:& \qquad 2 \rho \frac{\partial \epsilon}{\partial \sigma} \nabla\rho
335 /// \f}
336 /// and for UHF same-spin and other-spin quantities
337 /// \f{eqnarray*}{
338 /// \mbox{result[0]} &:& \qquad \frac{\partial \epsilon}{\partial \rho_{\alpha}} \\
339 /// \mbox{result[1-3]} &:& \qquad \rho_\alpha \frac{\partial \epsilon}{\partial \sigma_{\alpha \alpha}} \nabla\rho_\alpha\\
340 /// \mbox{result[4-6]} &:& \qquad \rho_\alpha \frac{\partial \epsilon}{\partial \sigma_{\alpha \beta}} \nabla\rho_\beta
341 /// \f}
342 /// @param[in] t The input densities and derivatives as required by the functional
343 /// @param[in] ispin Specifies which component of the potential is to be computed as described above
344 /// @return the requested quantity, based on ispin (0: same spin, 1: other spin)
345 std::vector<madness::Tensor<double> > vxc(const std::vector< madness::Tensor<double> >& t,
346 const int ispin) const;
347
348
349 /// compute the second derivative of the XC energy wrt the density and apply
350
351 /// Return the following quantities (RHF only) (see Yanai2005, Eq. (13))
352 /// \f{eqnarray*}{
353 /// \mbox{result[0]} &:& \qquad \frac{\partial^2 \epsilon}{\partial \rho^2} \rho_\mathrm{pt}
354 /// + 2.0 * \frac{\partial^2 \epsilon}{\partial \rho\partial\sigma}\sigma_\mathrm{pt}\\
355 /// \mbox{result[1-3]} &:& \qquad 2.0 * \frac{\partial\epsilon}{\partial\sigma}\nabla\rho_\mathrm{pt}
356 /// + 2.0 * \frac{\partial^2\epsilon}{\partial\rho\partial\sigma} \rho_\mathrm{pt}\nabla\rho
357 /// + 4.0 * \frac{\partial^2\epsilon}{\partial^2\sigma} \sigma_\mathrm{pt}\nabla\rho
358 /// \f}
359 /// @param[in] t The input densities and derivatives as required by the functional,
360 /// as in the xc_arg enum
361 /// @param[in] ispin not referenced since only RHF is implemented, always 0
362 /// @return a vector of Functions containing the contributions to the kernel apply
363 std::vector<madness::Tensor<double> > fxc_apply(
364 const std::vector< madness::Tensor<double> >& t, const int ispin) const;
365
366
367 /// Crude function to plot the energy and potential functionals
368 void plot() const {
369 long npt = 1001;
370 double lo=1e-6, hi=1e+1, s=std::pow(hi/lo, 1.0/(npt-1));
371
373 for (int i=0; i<npt; i++) {
374 rho[i] = lo;
375 lo *= s;
376 }
377 std::vector< madness::Tensor<double> > t(13);
378 t[enum_rhoa]=(rho);
379 if (is_spin_polarized()) t[enum_rhob]=(rho);
380// if (is_gga()) t[enum_saa]=madness::Tensor<double>(npt); // sigma_aa=0
381 if (needs_sigma()) t[enum_saa]=0.5*rho; // sigma_aa=0
382 if (needs_tau()) t[enum_taua]=0.5*rho;
383 madness::Tensor<double> f = exc(t); //pending UGHHHHH
384 std::vector<madness::Tensor<double> > va = vxc(t,0);
385 for (long i=0; i<npt; i++) {
386 printf("%.3e %.3e %.3e\n", rho[i], f[i], va[0][i]);
387 }
388 }
389};
390
391/// Class to compute the energy functional
394
396
398 const std::vector< madness::Tensor<double> >& t) const {
400 return xc->exc(t);
401 }
402};
403
404
405/// Class to compute terms of the potential
408 const int ispin;
409
411 {}
412
413 std::size_t get_result_size() const {
414 // local terms, same spin
415 if (xc->is_lda()) return 1;
416 // local term + 3x semilocal terms (x,y,z), same spin
417 std::size_t result_size=4;
418 // 3x semilocal terms (x,y,z) for the opposite spin
419 if (xc->is_spin_polarized()) result_size+=3;
420 // de/dtau, same spin -- the non-multiplicative meta-gga term
421 if (xc->needs_tau()) result_size+=1;
422 return result_size;
423 }
424
425 std::vector<madness::Tensor<double> > operator()(const madness::Key<3> & key,
426 const std::vector< madness::Tensor<double> >& t) const {
428 std::vector<madness::Tensor<double> > r = xc->vxc(t, ispin);
429 return r;
430 }
431};
432
433
434/// Class to compute terms of the kernel
437 const int ispin;
439
441 cdata(FunctionCommonData<double,3>::get(FunctionDefaults<3>::get_k())) {
442 MADNESS_ASSERT(ispin==0); // closed shell only!
443 }
444
445 std::size_t get_result_size() const {
446 // all spin-restricted
447 if (xc->is_gga()) return 4; // local terms, 3x semilocal terms (x,y,z)
448 return 1; // local terms only
449 }
450
451 std::vector<madness::Tensor<double> > operator()(const madness::Key<3> & key,
452 const std::vector< madness::Tensor<double> >& t) const {
454 std::vector<madness::Tensor<double> > r = xc->fxc_apply(t, ispin);
455 return r;
456 }
457};
458
459}
460
461MADNESS_PRAGMA_CLANG(diagnostic pop)
462MADNESS_PRAGMA_GCC(diagnostic pop)
463
464#endif
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:100
Key is the index for a node of the 2^NDIM-tree.
Definition key.h:70
A tensor is a multidimensional array.
Definition tensor.h:318
T * ptr()
Returns a pointer to the internal data.
Definition tensor.h:1841
A parallel world class.
Definition world.h:134
Simplified interface to XC functionals.
Definition xcfunctional.h:48
bool has_fxc() const
Returns true if the second derivative of the functional is available (not yet supported)
Definition xcfunctional_ldaonly.cc:81
bool is_dft() const
Returns true if there is a DFT functional (false probably means Hatree-Fock exchange only)
Definition xcfunctional_ldaonly.cc:77
double get_tautol() const
return the floor for the kinetic energy density
Definition xcfunctional.h:112
double rhomin
Definition xcfunctional.h:118
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:133
bool is_lda() const
Returns true if the potential is lda.
Definition xcfunctional_ldaonly.cc:57
double get_ggatol() const
return the binary munging threshold for the final result in the GGA potential/kernel
Definition xcfunctional.h:105
double get_rhotol() const
return the munging threshold for the density
Definition xcfunctional.h:99
static const int number_xc_args
max number of intermediates
Definition xcfunctional.h:96
void plot() const
Crude function to plot the energy and potential functionals.
Definition xcfunctional.h:368
madness::Tensor< double > exc(const std::vector< madness::Tensor< double > > &t) const
Computes the energy functional at given points.
Definition xcfunctional_ldaonly.cc:91
bool is_spin_polarized() const
Returns true if the functional is spin_polarized.
Definition xcfunctional.h:274
xc_arg
Definition xcfunctional.h:67
@ enum_zetab_y
Definition xcfunctional.h:83
@ enum_zetab_z
Definition xcfunctional.h:84
@ enum_ddens_pty
Definition xcfunctional.h:93
@ enum_zetaa_y
Definition xcfunctional.h:80
@ enum_sigtot
Definition xcfunctional.h:76
@ enum_zetab_x
Definition xcfunctional.h:82
@ enum_taua
alpha kinetic energy density
Definition xcfunctional.h:71
@ enum_taub
beta kinetic energy density
Definition xcfunctional.h:72
@ enum_rho_pt
perturbed density (CPHF, TDKS)
Definition xcfunctional.h:70
@ enum_sbb
Definition xcfunctional.h:75
@ enum_saa
Definition xcfunctional.h:73
@ enum_rhob
beta density
Definition xcfunctional.h:69
@ enum_zetaa_x
Definition xcfunctional.h:79
@ enum_sab
Definition xcfunctional.h:74
@ enum_zetaa_z
Definition xcfunctional.h:81
@ enum_sigma_pta_div_rho
Definition xcfunctional.h:77
@ enum_sigma_ptb_div_rho
Definition xcfunctional.h:78
@ enum_ddens_ptx
Definition xcfunctional.h:92
@ enum_rhoa
alpha density
Definition xcfunctional.h:68
@ enum_ddens_ptz
Definition xcfunctional.h:94
bool is_meta() const
Returns true if the potential is meta gga (needs the kinetic energy density)
Definition xcfunctional_ldaonly.cc:65
static double munge_old(double rho)
Definition xcfunctional.h:209
bool is_gga() const
Returns true if the potential is gga (needs first derivatives)
Definition xcfunctional_ldaonly.cc:61
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:181
~XCfunctional()
Destructor.
Definition xcfunctional_ldaonly.cc:55
double hf_exchange_coefficient() const
Returns the value of the hf exact exchange coefficient.
Definition xcfunctional.h:286
void make_libxc_args(const std::vector< madness::Tensor< double > > &t, madness::Tensor< double > &rho, madness::Tensor< double > &sigma, madness::Tensor< double > &tau, 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:186
double hf_coeff
Factor multiplying HF exchange (+1.0 gives HF)
Definition xcfunctional.h:117
bool needs_sigma() const
Returns true if the functional needs the reduced density gradients sigma.
Definition xcfunctional_ldaonly.cc:69
bool needs_tau() const
Returns true if the functional needs the kinetic energy density tau.
Definition xcfunctional_ldaonly.cc:73
double ggatol
See initialize and munge*.
Definition xcfunctional.h:119
static void polyn(const double x, double &p, double &dpdx)
Smoothly switches between constant (x<xmin) and linear function (x>xmax)
Definition xcfunctional.h:177
bool has_kxc() const
Returns true if the third derivative of the functional is available (not yet supported)
Definition xcfunctional_ldaonly.cc:86
double tautol
floor for the kinetic energy density, see initialize
Definition xcfunctional.h:120
bool spin_polarized
True if the functional is spin polarized.
Definition xcfunctional.h:116
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:24
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:232
int nderiv
the number of xc kernel derivatives (lda: 0, gga: 1, etc)
Definition xcfunctional.h:159
double munge(double rho) const
simple munging for the density only (LDA)
Definition xcfunctional.h:218
double rhotol
See initialize and munge*.
Definition xcfunctional.h:118
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_PRAGMA_CLANG(x)
Definition madness_config.h:200
#define MADNESS_PRAGMA_GCC(x)
Definition madness_config.h:205
#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:2622
int x_rks_s__(const double *r__, double *f, double *dfdra)
Definition lda.cc:58
static XNonlinearSolver< std::vector< Function< T, NDIM > >, T, vector_function_allocator< T, NDIM > > nonlinear_vector_solver(World &world, const long nvec)
Definition nonlinsol.h:371
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:392
xc_functional(const XCfunctional &xc)
Definition xcfunctional.h:395
madness::Tensor< double > operator()(const madness::Key< 3 > &key, const std::vector< madness::Tensor< double > > &t) const
Definition xcfunctional.h:397
const XCfunctional * xc
Definition xcfunctional.h:393
Class to compute terms of the kernel.
Definition xcfunctional.h:435
const FunctionCommonData< double, 3 > & cdata
Definition xcfunctional.h:438
const int ispin
Definition xcfunctional.h:437
std::size_t get_result_size() const
Definition xcfunctional.h:445
std::vector< madness::Tensor< double > > operator()(const madness::Key< 3 > &key, const std::vector< madness::Tensor< double > > &t) const
Definition xcfunctional.h:451
const XCfunctional * xc
Definition xcfunctional.h:436
xc_kernel_apply(const XCfunctional &xc, int ispin)
Definition xcfunctional.h:440
Compute the spin-restricted LDA potential using unaryop (only for the initial guess)
Definition xcfunctional.h:29
void operator()(const Key< 3 > &key, Tensor< double > &t) const
Definition xcfunctional.h:32
xc_lda_potential()
Definition xcfunctional.h:30
Class to compute terms of the potential.
Definition xcfunctional.h:406
xc_potential(const XCfunctional &xc, int ispin)
Definition xcfunctional.h:410
std::size_t get_result_size() const
Definition xcfunctional.h:413
const XCfunctional * xc
Definition xcfunctional.h:407
std::vector< madness::Tensor< double > > operator()(const madness::Key< 3 > &key, const std::vector< madness::Tensor< double > > &t) const
Definition xcfunctional.h:425
const int ispin
Definition xcfunctional.h:408
void e()
Definition test_sig.cc:75