MADNESS 0.10.1
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
madness::XCfunctional Class Reference

Simplified interface to XC functionals. More...

#include <xcfunctional.h>

Public Types

enum  xc_arg {
  enum_rhoa =0 , enum_rhob =1 , enum_rho_pt =2 , enum_saa =10 ,
  enum_sab =11 , enum_sbb =12 , enum_sigtot =13 , enum_sigma_pta_div_rho =14 ,
  enum_sigma_ptb_div_rho =15 , enum_zetaa_x =16 , enum_zetaa_y =17 , enum_zetaa_z =18 ,
  enum_zetab_x =19 , enum_zetab_y =20 , enum_zetab_z =21 , enum_chi_aa =22 ,
  enum_chi_ab =23 , enum_chi_bb =24 , enum_ddens_ptx =25 , enum_ddens_pty =26 ,
  enum_ddens_ptz =27
}
 

Public Member Functions

 XCfunctional ()
 Default constructor is required.
 
 ~XCfunctional ()
 Destructor.
 
madness::Tensor< double > exc (const std::vector< madness::Tensor< double > > &t) const
 Computes the energy functional at given points.
 
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
 
double get_ggatol () const
 return the binary munging threshold for the final result in the GGA potential/kernel
 
double get_rhotol () const
 return the munging threshold for the density
 
bool has_fxc () const
 Returns true if the second derivative of the functional is available (not yet supported)
 
bool has_kxc () const
 Returns true if the third derivative of the functional is available (not yet supported)
 
double hf_exchange_coefficient () const
 Returns the value of the hf exact exchange coefficient.
 
void initialize (const std::string &input_line, bool polarized, World &world, const bool verbose=false)
 Initialize the object from the user input data.
 
bool is_dft () const
 Returns true if there is a DFT functional (false probably means Hatree-Fock exchange only)
 
bool is_gga () const
 Returns true if the potential is gga (needs first derivatives)
 
bool is_lda () const
 Returns true if the potential is lda.
 
bool is_meta () const
 Returns true if the potential is meta gga (needs second derivatives ... not yet supported)
 
bool is_spin_polarized () const
 Returns true if the functional is spin_polarized.
 
void plot () const
 Crude function to plot the energy and potential functionals.
 
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.
 

Static Public Member Functions

static double munge_old (double rho)
 

Static Public Attributes

static const int number_xc_args =28
 max number of intermediates
 

Protected Member Functions

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
 

Static Protected Member Functions

static void polyn (const double x, double &p, double &dpdx)
 Smoothly switches between constant (x<xmin) and linear function (x>xmax)
 

Protected Attributes

double ggatol
 See initialize and munge*.
 
double hf_coeff
 Factor multiplying HF exchange (+1.0 gives HF)
 
int nderiv
 the number of xc kernel derivatives (lda: 0, gga: 1, etc)
 
double rhomin
 
double rhotol
 See initialize and munge*.
 
bool spin_polarized
 True if the functional is spin polarized.
 

Private Member Functions

double binary_munge (double rho, double refrho, const double thresh) const
 munge rho if refrho is small
 
double munge (double rho) const
 simple munging for the density only (LDA)
 

Detailed Description

Simplified interface to XC functionals.

Member Enumeration Documentation

◆ xc_arg

The ordering of the intermediates is fixed, but the code can handle non-initialized functions, so if e.g. no GGA is requested, all the corresponding vector components may be left empty.

Note the additional quantities $ \zeta $ and $ \chi $, which are defined as

\[
\rho = \exp(\zeta)
\]

and thus the derivative of rho is given by

\[
\nabla_x\rho = \exp(\zeta)\nabla_x\zeta = \rho \nabla_x\zeta
\]

The reduced gradients \sigma may then be expressed as

\[
  \sigma = |\nabla\rho|^2 = |\rho|^2 |\nabla\zeta|^2 = |\rho|^2 \chi
\]

Enumerator
enum_rhoa 

alpha density $ \rho_\alpha $

enum_rhob 

beta density $ \rho_\beta $

enum_rho_pt 

perturbed density (CPHF, TDKS) $ \rho_{pt} $

enum_saa 

$ \sigma_{aa} = \nabla \rho_{\alpha}.\nabla \rho_{\alpha} $

enum_sab 

$ \sigma_{ab} = \nabla \rho_{\alpha}.\nabla \rho_{\beta} $

enum_sbb 

$ \sigma_{bb} = \nabla \rho_{\beta}.\nabla \rho_{\beta} $

enum_sigtot 

$ \sigma = \nabla \rho.\nabla \rho $

enum_sigma_pta_div_rho 

$ \zeta_{\alpha}.\nabla\rho_{pt} $

enum_sigma_ptb_div_rho 

$ \zeta_{\beta}.\nabla\rho_{pt} $

enum_zetaa_x 

$ \zeta_{a,x}=\partial/{\partial x} \ln(\rho_a)  $

enum_zetaa_y 

$ \zeta_{a,y}=\partial/{\partial y} \ln(\rho_a)  $

enum_zetaa_z 

$ \zeta_{a,z}=\partial/{\partial z} \ln(\rho_a)  $

enum_zetab_x 

$ \zeta_{b,x} = \partial/{\partial x} \ln(\rho_b)  $

enum_zetab_y 

$ \zeta_{b,y} = \partial/{\partial y} \ln(\rho_b)  $

enum_zetab_z 

$ \zeta_{b,z} = \partial/{\partial z} \ln(\rho_b)  $

enum_chi_aa 

$ \chi_{aa} = \nabla \zeta_{\alpha}.\nabla \zeta_{\alpha} $

enum_chi_ab 

$ \chi_{ab} = \nabla \zeta_{\alpha}.\nabla \zeta_{\beta} $

enum_chi_bb 

$ \chi_{bb} = \nabla \zeta_{\beta}.\nabla \zeta_{\beta} $

enum_ddens_ptx 

$ \nabla\rho_{pt}$

enum_ddens_pty 

$ \nabla\rho_{pt}$

enum_ddens_ptz 

$ \nabla\rho_{pt}$

Constructor & Destructor Documentation

◆ XCfunctional()

madness::XCfunctional::XCfunctional ( )

Default constructor is required.

References e(), rhomin, and rhotol.

◆ ~XCfunctional()

madness::XCfunctional::~XCfunctional ( )

Destructor.

Member Function Documentation

◆ binary_munge()

double madness::XCfunctional::binary_munge ( double  rho,
double  refrho,
const double  thresh 
) const
inlineprivate

munge rho if refrho is small

special case for perturbed densities, which might be negative and diffuse. Munge rho (e.g. the perturbed density) if the reference density refrho e.g. the ground state density is small. Only where the reference density is large enough DFT is numerically well-defined.

Parameters
[in]rhonumber to be munged
[in]refrhoreference value for munging
[in]threshthreshold for munging

References rhomin, and thresh.

◆ exc()

madness::Tensor< double > madness::XCfunctional::exc ( const std::vector< madness::Tensor< double > > &  t) const

Computes the energy functional at given points.

This uses the convention that the total energy is $ E[\rho] = \int \epsilon[\rho(x)] dx$ Any HF exchange contribution must be separately computed. Items in the vector argument t are interpreted similarly to the xc_arg enum.

Parameters
[in]tThe input densities and derivatives as required by the functional
Returns
The exchange-correlation energy functional

References madness::c_rks_vwn5__(), madness::c_uks_vwn5__(), madness::f, std::isnan(), munge(), madness::print(), madness::Tensor< T >::ptr(), madness::BaseTensor::size(), spin_polarized, madness::x_rks_s__(), madness::x_uks_s__(), and madness::xf().

Referenced by madness::xc_functional::operator()(), plot(), and test_lda().

◆ fxc_apply()

std::vector< madness::Tensor< double > > madness::XCfunctional::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

Return the following quantities (RHF only) (see Yanai2005, Eq. (13))

\begin{eqnarray*}
    \mbox{result[0]}    &:& \qquad \frac{\partial^2 \epsilon}{\partial \rho^2} \rho_\mathrm{pt}
                            + 2.0 * \frac{\partial^2 \epsilon}{\partial \rho\partial\sigma}\sigma_\mathrm{pt}\\
    \mbox{result[1-3]}  &:& \qquad 2.0 * \frac{\partial\epsilon}{\partial\sigma}\nabla\rho_\mathrm{pt}
                            + 2.0 * \frac{\partial^2\epsilon}{\partial\rho\partial\sigma} \rho_\mathrm{pt}\nabla\rho
                            + 4.0 * \frac{\partial^2\epsilon}{\partial^2\sigma} \sigma_\mathrm{pt}\nabla\rho
\end{eqnarray*}

Parameters
[in]tThe input densities and derivatives as required by the functional, as in the xc_arg enum
[in]ispinnot referenced since only RHF is implemented, always 0
Returns
a vector of Functions containing the contributions to the kernel apply

References MADNESS_EXCEPTION.

Referenced by madness::xc_kernel_apply::operator()().

◆ get_ggatol()

double madness::XCfunctional::get_ggatol ( ) const
inline

return the binary munging threshold for the final result in the GGA potential/kernel

the GGA potential will be munged based on the smallness of the original density, which we call binary munging

References ggatol.

◆ get_rhotol()

double madness::XCfunctional::get_rhotol ( ) const
inline

return the munging threshold for the density

References rhotol.

◆ has_fxc()

bool madness::XCfunctional::has_fxc ( ) const

Returns true if the second derivative of the functional is available (not yet supported)

◆ has_kxc()

bool madness::XCfunctional::has_kxc ( ) const

Returns true if the third derivative of the functional is available (not yet supported)

◆ hf_exchange_coefficient()

double madness::XCfunctional::hf_exchange_coefficient ( ) const
inline

Returns the value of the hf exact exchange coefficient.

References hf_coeff.

Referenced by madness::SCF::apply_potential().

◆ initialize()

void madness::XCfunctional::initialize ( const std::string &  input_line,
bool  polarized,
World world,
const bool  verbose = false 
)

Initialize the object from the user input data.

Parameters
[in]input_lineUser input line (without beginning XC keyword)
[in]polarizedBoolean flag indicating if the calculation is spin-polarized

References e(), hf_coeff, rhomin, rhotol, and spin_polarized.

Referenced by MiniDFT::MiniDFT(), madness::SCF::SCF(), madness::Coulomb< double, 3 >::compute_density(), main(), test_lda(), and test_xcfunctional().

◆ is_dft()

bool madness::XCfunctional::is_dft ( ) const

Returns true if there is a DFT functional (false probably means Hatree-Fock exchange only)

References is_gga(), is_lda(), and is_meta().

Referenced by madness::SCF::apply_potential().

◆ is_gga()

bool madness::XCfunctional::is_gga ( ) const

◆ is_lda()

bool madness::XCfunctional::is_lda ( ) const

Returns true if the potential is lda.

References hf_coeff.

Referenced by madness::xc_potential::get_result_size(), and is_dft().

◆ is_meta()

bool madness::XCfunctional::is_meta ( ) const

Returns true if the potential is meta gga (needs second derivatives ... not yet supported)

Referenced by is_dft().

◆ is_spin_polarized()

bool madness::XCfunctional::is_spin_polarized ( ) const
inline

◆ make_libxc_args()

void madness::XCfunctional::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
protected

convert the raw density (gradient) data to be used by the xc operators

Involves mainly munging of the densities and multiplying with 2 if the calculation is spin-restricted. Response densities and density gradients are munged based on the value of the ground state density, since they may become negative and may also be much more diffuse. dimensions of the output tensors are for spin-restricted and unrestricted (with np the number of grid points in the box): rho(np) or rho(2*np) sigma(np) sigma(3*np) rho_pt(np) sigma_pt(2*np)

Parameters
[in]tinput density (gradients)
[out]rhoground state (spin) density, properly munged
[out]sigmaground state (spin) density gradients, properly munged
[out]rho_ptresponse density, properly munged (no spin)
[out]sigma_ptresponse (spin) density gradients, properly munged
[out]drhodensity derivative, constructed from rho and zeta
[out]drho_ptresponse density derivative directly from xc_args
[in]need_responseflag if rho_pt and sigma_pt need to be calculated

References MADNESS_EXCEPTION.

◆ munge()

double madness::XCfunctional::munge ( double  rho) const
inlineprivate

simple munging for the density only (LDA)

References rhomin, and rhotol.

Referenced by exc(), and vxc().

◆ munge_old()

static double madness::XCfunctional::munge_old ( double  rho)
inlinestatic

References p(), and polyn().

◆ plot()

void madness::XCfunctional::plot ( ) const
inline

Crude function to plot the energy and potential functionals.

References e(), enum_rhoa, enum_rhob, enum_saa, exc(), madness::f, is_gga(), is_spin_polarized(), lo, and vxc().

◆ polyn()

static void madness::XCfunctional::polyn ( const double  x,
double &  p,
double &  dpdx 
)
inlinestaticprotected

Smoothly switches between constant (x<xmin) and linear function (x>xmax)

\[
f(x,x_{\mathrm{min}},x_{\mathrm{max}}) = \left\{
  \begin{array}{ll}
    x_{\mathrm{min}}                       & x < x_{\mathrm{min}} \\
    p(x,x_{\mathrm{min}},x_{\mathrm{max}}) & x_{\mathrm{min}} \leq x_{\mathrm{max}} \\
    x                                      & x_{\mathrm{max}} < x
  \end{array}
\right.
\]

where $p(x)$ is the unique quintic polynomial that satisfies $p(x_{min})=x_{min}$, $p(x_{max})=x_{max}$, $dp(x_{max})/dx=1$, and $dp(x_{min})/dx=d^2p(x_{min})/dx^2=d^2p(x_{max})/dx^2=0$.

References a, b, c, d, e(), and p().

Referenced by munge_old().

◆ vxc()

std::vector< madness::Tensor< double > > madness::XCfunctional::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.

Any HF exchange contribution must be separately computed. Items in the vector argument t are interpreted similarly to the xc_arg enum.

We define $ \sigma_{\mu \nu} = \nabla \rho_{\mu} . \nabla \rho_{\nu} $ with $ \mu, \nu = \alpha$ or $ \beta $.

For unpolarized GGA, matrix elements of the potential are

\[
  < \phi | \hat V | \psi > = \int \left( \frac{\partial \epsilon}{\partial \rho} \phi \psi
                 +  \left( 2 \frac{\partial \epsilon}{\partial \sigma} \right)
                 \nabla \rho \cdot \nabla \left( \phi \psi \right) \right) dx
\]

For polarized GGA, matrix elements of the potential are

\[
  < \phi_{\alpha} | \hat V | \psi_{\alpha} > = \int \left( \frac{\partial \epsilon}{\partial \rho_{\alpha}} \phi \psi
           +  \left( 2 \frac{\partial \epsilon}{\partial \sigma_{\alpha \alpha}} \nabla \rho_{\alpha}
           + \frac{\partial \epsilon}{\partial \sigma_{\alpha \beta}} \nabla \rho_{\beta}  \right) . \nabla \left( \phi \psi \right) \right) dx
\]

Integrating the above by parts and assuming free-space or periodic boundary conditions we obtain that the local multiplicative form of the GGA potential is

\[
   V_{\alpha} =  \frac{\partial \epsilon}{\partial \rho_{\alpha}}
                 - \left(\nabla . \left(2 \frac{\partial \epsilon}{\partial \sigma_{\alpha \alpha}} \nabla \rho_{\alpha}
                 + \frac{\partial \epsilon}{\partial \sigma_{\alpha \beta}} \nabla \rho_{\beta}  \right)  \right)
\]

Return the following quantities for RHF: (see Yanai2005, Eq. (12))

\begin{eqnarray*}
    \mbox{result[0]}    &:& \qquad \frac{\partial \epsilon}{\partial \rho} \\
    \mbox{result[1-3]}  &:& \qquad 2 \rho \frac{\partial \epsilon}{\partial \sigma} \nabla\rho
\end{eqnarray*}

and for UHF same-spin and other-spin quantities

\begin{eqnarray*}
    \mbox{result[0]}    &:& \qquad \frac{\partial \epsilon}{\partial \rho_{\alpha}} \\
    \mbox{result[1-3]}  &:& \qquad \rho_\alpha \frac{\partial \epsilon}{\partial \sigma_{\alpha \alpha}} \nabla\rho_\alpha\\
    \mbox{result[4-6]}  &:& \qquad \rho_\alpha \frac{\partial \epsilon}{\partial \sigma_{\alpha \beta}} \nabla\rho_\beta
\end{eqnarray*}

Parameters
[in]tThe input densities and derivatives as required by the functional
[in]ispinSpecifies which component of the potential is to be computed as described above
Returns
the requested quantity, based on ispin (0: same spin, 1: other spin)

References madness::c_rks_vwn5__(), madness::c_uks_vwn5__(), madness::f, std::isnan(), munge(), madness::print(), madness::Tensor< T >::ptr(), q(), spin_polarized, madness::x_rks_s__(), madness::x_uks_s__(), and madness::xf().

Referenced by madness::xc_potential::operator()(), plot(), test_lda(), and test_xcfunctional().

Member Data Documentation

◆ ggatol

double madness::XCfunctional::ggatol
protected

See initialize and munge*.

Referenced by get_ggatol().

◆ hf_coeff

double madness::XCfunctional::hf_coeff
protected

Factor multiplying HF exchange (+1.0 gives HF)

Referenced by hf_exchange_coefficient(), initialize(), and is_lda().

◆ nderiv

int madness::XCfunctional::nderiv
protected

the number of xc kernel derivatives (lda: 0, gga: 1, etc)

◆ number_xc_args

const int madness::XCfunctional::number_xc_args =28
static

max number of intermediates

Referenced by madness::XCOperator< T, NDIM >::prep_xc_args().

◆ rhomin

double madness::XCfunctional::rhomin
protected

◆ rhotol

double madness::XCfunctional::rhotol
protected

See initialize and munge*.

Referenced by XCfunctional(), get_rhotol(), initialize(), and munge().

◆ spin_polarized

bool madness::XCfunctional::spin_polarized
protected

True if the functional is spin polarized.

Referenced by exc(), initialize(), is_spin_polarized(), and vxc().


The documentation for this class was generated from the following files: