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