MADNESS 0.10.1
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
madness::GFit< T, NDIM > Class Template Reference

#include <gfit.h>

Public Member Functions

 GFit ()=default
 default ctor does nothing
 
 GFit (const GFit &other)=default
 copy constructor
 
 GFit (OperatorInfo info)
 
Tensor< T > coeffs () const
 return the coefficients of the fit
 
Tensor< T > exponents () const
 return the exponents of the fit
 
GFit & operator= (const GFit &other)
 assignment operator
 

Static Public Member Functions

static GFit BSHFit (double mu, double lo, double hi, double eps, bool prnt=false)
 return a fit for the bound-state Helmholtz function
 
static GFit CoulombFit (double lo, double hi, double eps, bool prnt=false)
 return a fit for the Coulomb function
 
static GFit F12Fit (double gamma, double lo, double hi, double eps, bool prnt=false)
 return a fit for the F12 correlation factor
 
static GFit F12sqFit (double gamma, double lo, double hi, double eps, bool prnt=false)
 return a fit for the F12^2 correlation factor
 
static GFit F2GFit (double gamma, double lo, double hi, double eps, bool prnt=false)
 return a fit for the F2G function
 
static GFit FGFit (double gamma, double lo, double hi, double eps, bool prnt=false)
 return a fit for the FG function
 
static GFit GaussFit (double gamma, double lo, double hi, double eps, bool prnt=false)
 return a (trivial) fit for a single Gauss function
 
static GFit GeneralFit ()
 return a fit for a general isotropic function
 
static void prune_small_coefficients (const double eps, const double lo, const double hi, Tensor< double > &coeff, Tensor< double > &expnt, const long first_prunable=1)
 
static GFit SlaterFit (double gamma, double lo, double hi, double eps, bool prnt=false)
 return a fit for the Slater function
 
static void truncate_mixed_expansion (Tensor< double > &c, Tensor< double > &e, const std::array< LatticeRange, NDIM > &lattice_ranges, const Tensor< double > &cell_width, double lo, double hi_fin, double eps)
 Truncate the fit of a kernel that is lattice-summed along some axes.
 

Private Member Functions

template<typename funcT >
 GFit (const funcT &f)
 ctor taking an isotropic function
 
template<typename opT >
void print_accuracy (opT op, const double lo, const double hi) const
 print coefficients and exponents, and values and errors
 

Static Private Member Functions

static void bsh_fit (double mu, double lo, double hi, double eps, Tensor< double > &pcoeff, Tensor< double > &pexpnt, bool prnt, bool fix_interval)
 fit the function exp(-mu r)/r
 
static void bsh_fit_ndim (int ndim, double mu, double lo, double hi, double eps, Tensor< double > &pcoeff, Tensor< double > &pexpnt, bool prnt)
 
static void bsh_spherical_moments (double mu, double R, Tensor< double > &q)
 
static void f12_fit (double gamma, double lo, double hi, double eps, Tensor< double > &pcoeff, Tensor< double > &pexpnt, bool prnt)
 fit a correlation factor (1- exp(-mu r))
 
static void f12sq_fit (double gamma, double lo, double hi, double eps, Tensor< double > &pcoeff, Tensor< double > &pexpnt, bool prnt)
 fit a correlation factor f12^2 = (1- exp(-mu r))^2 = 1 - 2 exp(-mu r) + exp(-2 mu r)
 
static void gaussian_spherical_moments (double alpha, double R, Tensor< double > &q)
 
static void slater_fit (double gamma, double lo, double hi, double eps, Tensor< double > &pcoeff, Tensor< double > &pexpnt, bool prnt)
 fit a Slater function using a sum of Gaussians
 

Private Attributes

Tensor< T > coeffs_
 the coefficients of the expansion f(x) = \sum_m coeffs[m] exp(-exponents[m] * x^2)
 
Tensor< T > exponents_
 the exponents of the expansion f(x) = \sum_m coeffs[m] exp(-exponents[m] * x^2)
 

Constructor & Destructor Documentation

◆ GFit() [1/4]

template<typename T , std::size_t NDIM>
madness::GFit< T, NDIM >::GFit ( )
default

default ctor does nothing

Referenced by madness::GFit< T, NDIM >::GeneralFit().

◆ GFit() [2/4]

template<typename T , std::size_t NDIM>
madness::GFit< T, NDIM >::GFit ( OperatorInfo  info)
inline

◆ GFit() [3/4]

template<typename T , std::size_t NDIM>
madness::GFit< T, NDIM >::GFit ( const GFit< T, NDIM > &  other)
default

copy constructor

◆ GFit() [4/4]

template<typename T , std::size_t NDIM>
template<typename funcT >
madness::GFit< T, NDIM >::GFit ( const funcT &  f)
inlineprivate

ctor taking an isotropic function

the function will be represented with a uniform error on a uniform grid

Parameters
[in]fa 1d-function that implements T operator()

Member Function Documentation

◆ bsh_fit()

template<typename T , std::size_t NDIM>
static void madness::GFit< T, NDIM >::bsh_fit ( double  mu,
double  lo,
double  hi,
double  eps,
Tensor< double > &  pcoeff,
Tensor< double > &  pexpnt,
bool  prnt,
bool  fix_interval 
)
inlinestaticprivate

fit the function exp(-mu r)/r

formulas taken from G. Beylkin and L. Monzon, On approximation of functions by exponential sums, Appl Comput Harmon A, vol. 19, no. 1, pp. 17-48, Jul. 2005. and R. J. Harrison, G. I. Fann, T. Yanai, and G. Beylkin, Multiresolution Quantum Chemistry in Multiwavelet Bases, Lecture Notes in Computer Science, vol. 2660, p. 103, 2003.

References madness::GFit< T, NDIM >::bsh_spherical_moments(), e(), madness::GFit< T, NDIM >::gaussian_spherical_moments(), madness::gesv(), h(), lo, mu, madness::constants::pi, madness::print(), madness::GFit< T, NDIM >::prune_small_coefficients(), and q().

Referenced by madness::GFit< T, NDIM >::BSHFit(), madness::GFit< T, NDIM >::F2GFit(), and madness::GFit< T, NDIM >::FGFit().

◆ bsh_fit_ndim()

template<typename T , std::size_t NDIM>
static void madness::GFit< T, NDIM >::bsh_fit_ndim ( int  ndim,
double  mu,
double  lo,
double  hi,
double  eps,
Tensor< double > &  pcoeff,
Tensor< double > &  pexpnt,
bool  prnt 
)
inlinestaticprivate

◆ bsh_spherical_moments()

template<typename T , std::size_t NDIM>
static void madness::GFit< T, NDIM >::bsh_spherical_moments ( double  mu,
double  R,
Tensor< double > &  q 
)
inlinestaticprivate

◆ BSHFit()

template<typename T , std::size_t NDIM>
static GFit madness::GFit< T, NDIM >::BSHFit ( double  mu,
double  lo,
double  hi,
double  eps,
bool  prnt = false 
)
inlinestatic

return a fit for the bound-state Helmholtz function

the BSH function is defined by f(r) = 1/ (4 pi) exp(-\mu r)/r

Parameters
[in]muthe exponent of the BSH
[in]lothe smallest length scale that needs to be precisely represented
[in]hithe largest length scale that needs to be precisely represented
[in]epsthe precision threshold @parma[in] prnt print level

References madness::GFit< T, NDIM >::bsh_fit(), madness::GFit< T, NDIM >::bsh_fit_ndim(), exact, fit(), lo, mu, NDIM, madness::constants::pi, and madness::print().

Referenced by madness::GFit< T, NDIM >::GFit(), madness::BSHOperatorPtr3D(), madness::GFit< T, NDIM >::CoulombFit(), madness::BSHFunctionInterface::fit(), madness::GradBSHOperator(), and GradBSHOperator_Joel().

◆ coeffs()

template<typename T , std::size_t NDIM>
Tensor< T > madness::GFit< T, NDIM >::coeffs ( ) const
inline

return the coefficients of the fit

References madness::GFit< T, NDIM >::coeffs_.

Referenced by madness::GFit< T, NDIM >::F2GFit(), and madness::GFit< T, NDIM >::FGFit().

◆ CoulombFit()

template<typename T , std::size_t NDIM>
static GFit madness::GFit< T, NDIM >::CoulombFit ( double  lo,
double  hi,
double  eps,
bool  prnt = false 
)
inlinestatic

◆ exponents()

template<typename T , std::size_t NDIM>
Tensor< T > madness::GFit< T, NDIM >::exponents ( ) const
inline

◆ f12_fit()

template<typename T , std::size_t NDIM>
static void madness::GFit< T, NDIM >::f12_fit ( double  gamma,
double  lo,
double  hi,
double  eps,
Tensor< double > &  pcoeff,
Tensor< double > &  pexpnt,
bool  prnt 
)
inlinestaticprivate

fit a correlation factor (1- exp(-mu r))

use the Slater fit with an additional term: 1*exp(-0 r^2)

References madness::_(), lo, madness::BaseTensor::size(), and madness::GFit< T, NDIM >::slater_fit().

Referenced by madness::GFit< T, NDIM >::F12Fit().

◆ F12Fit()

template<typename T , std::size_t NDIM>
static GFit madness::GFit< T, NDIM >::F12Fit ( double  gamma,
double  lo,
double  hi,
double  eps,
bool  prnt = false 
)
inlinestatic

return a fit for the F12 correlation factor

the Slater function is defined by f(r) = 1/(2 gamma) * (1 - exp(-\gamma r))

Parameters
[in]gammathe exponent of the Slater function
[in]lothe smallest length scale that needs to be precisely represented
[in]hithe largest length scale that needs to be precisely represented
[in]epsthe precision threshold @parma[in] prnt print level

References exact, madness::GFit< T, NDIM >::f12_fit(), fit(), lo, and madness::print().

Referenced by madness::GFit< T, NDIM >::GFit(), and madness::SlaterF12Interface::fit().

◆ f12sq_fit()

template<typename T , std::size_t NDIM>
static void madness::GFit< T, NDIM >::f12sq_fit ( double  gamma,
double  lo,
double  hi,
double  eps,
Tensor< double > &  pcoeff,
Tensor< double > &  pexpnt,
bool  prnt 
)
inlinestaticprivate

fit a correlation factor f12^2 = (1- exp(-mu r))^2 = 1 - 2 exp(-mu r) + exp(-2 mu r)

no factor 1/(2 mu) or square of it included! use the Slater fit with an additional term: 1*exp(-0 r^2)

References madness::_(), lo, MADNESS_CHECK, madness::BaseTensor::size(), and madness::GFit< T, NDIM >::slater_fit().

Referenced by madness::GFit< T, NDIM >::F12sqFit().

◆ F12sqFit()

template<typename T , std::size_t NDIM>
static GFit madness::GFit< T, NDIM >::F12sqFit ( double  gamma,
double  lo,
double  hi,
double  eps,
bool  prnt = false 
)
inlinestatic

return a fit for the F12^2 correlation factor

the Slater function square is defined by f(r) = [ 1/(2 gamma) * (1 - exp(-\gamma r)) ] ^2

Parameters
[in]gammathe exponent of the Slater function
[in]lothe smallest length scale that needs to be precisely represented
[in]hithe largest length scale that needs to be precisely represented
[in]epsthe precision threshold @parma[in] prnt print level

References exact, madness::GFit< T, NDIM >::f12sq_fit(), fit(), lo, and madness::print().

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

◆ F2GFit()

template<typename T , std::size_t NDIM>
static GFit madness::GFit< T, NDIM >::F2GFit ( double  gamma,
double  lo,
double  hi,
double  eps,
bool  prnt = false 
)
inlinestatic

return a fit for the F2G function

f2g = (1/(2 mu) * (1 - exp(-gamma r12)))^2 / r12 = 1/(4 mu^2) * [ 1/r12 - 2 exp(-gamma r12)/r12) + exp(-2 gamma r12)/r12 ]

Parameters
[in]gammathe exponent of the Slater function
[in]lothe smallest length scale that needs to be precisely represented
[in]hithe largest length scale that needs to be precisely represented
[in]epsthe precision threshold @parma[in] prnt print level

References madness::GFit< T, NDIM >::bsh_fit(), madness::GFit< T, NDIM >::coeffs(), madness::GFit< T, NDIM >::coeffs_, exact, madness::GFit< T, NDIM >::exponents(), madness::GFit< T, NDIM >::exponents_, lo, MADNESS_CHECK, madness::constants::pi, madness::print(), madness::GFit< T, NDIM >::print_accuracy(), and madness::GFit< T, NDIM >::prune_small_coefficients().

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

◆ FGFit()

template<typename T , std::size_t NDIM>
static GFit madness::GFit< T, NDIM >::FGFit ( double  gamma,
double  lo,
double  hi,
double  eps,
bool  prnt = false 
)
inlinestatic

return a fit for the FG function

fg = 1/(2 mu) * (1 - exp(-gamma r12)) / r12 = 1/(2 mu) *( 1/r12 - exp(-gamma r12)/r12) = 1/(2 mu) * (coulomb - bsh)

Parameters
[in]gammathe exponent of the Slater function
[in]lothe smallest length scale that needs to be precisely represented
[in]hithe largest length scale that needs to be precisely represented
[in]epsthe precision threshold @parma[in] prnt print level

References madness::GFit< T, NDIM >::bsh_fit(), madness::GFit< T, NDIM >::coeffs(), madness::GFit< T, NDIM >::coeffs_, exact, madness::GFit< T, NDIM >::exponents(), madness::GFit< T, NDIM >::exponents_, lo, MADNESS_CHECK, madness::constants::pi, madness::print(), madness::GFit< T, NDIM >::print_accuracy(), and madness::GFit< T, NDIM >::prune_small_coefficients().

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

◆ GaussFit()

template<typename T , std::size_t NDIM>
static GFit madness::GFit< T, NDIM >::GaussFit ( double  gamma,
double  lo,
double  hi,
double  eps,
bool  prnt = false 
)
inlinestatic

return a (trivial) fit for a single Gauss function

the Gauss function is defined by f(r) = exp(-\gamma r^2)

Parameters
[in]gammathe exponent of the Gauss function
[in]lothe smallest length scale that needs to be precisely represented
[in]hithe largest length scale that needs to be precisely represented
[in]epsthe precision threshold @parma[in] prnt print level

References madness::GFit< T, NDIM >::coeffs_, exact, fit(), lo, and madness::print().

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

◆ gaussian_spherical_moments()

template<typename T , std::size_t NDIM>
static void madness::GFit< T, NDIM >::gaussian_spherical_moments ( double  alpha,
double  R,
Tensor< double > &  q 
)
inlinestaticprivate

◆ GeneralFit()

template<typename T , std::size_t NDIM>
static GFit madness::GFit< T, NDIM >::GeneralFit ( )
inlinestatic

return a fit for a general isotropic function

note that the error is controlled over a uniform grid, the boundaries will be poorly represented in general. Following Beylkin 2005

References madness::GFit< T, NDIM >::GFit(), and MADNESS_EXCEPTION.

◆ operator=()

template<typename T , std::size_t NDIM>
GFit & madness::GFit< T, NDIM >::operator= ( const GFit< T, NDIM > &  other)
inline

◆ print_accuracy()

template<typename T , std::size_t NDIM>
template<typename opT >
void madness::GFit< T, NDIM >::print_accuracy ( opT  op,
const double  lo,
const double  hi 
) const
inlineprivate

print coefficients and exponents, and values and errors

Parameters
[in]opthe exact function, e.g. 1/r, exp(-mu r), etc
[in]lolower bound for the range r
[in]hihigher bound for the range r

References madness::GFit< T, NDIM >::coeffs_, exact, madness::GFit< T, NDIM >::exponents_, lo, op(), pow(), and test().

Referenced by madness::GFit< T, NDIM >::F2GFit(), and madness::GFit< T, NDIM >::FGFit().

◆ prune_small_coefficients()

template<typename T , std::size_t NDIM>
static void madness::GFit< T, NDIM >::prune_small_coefficients ( const double  eps,
const double  lo,
const double  hi,
Tensor< double > &  coeff,
Tensor< double > &  expnt,
const long  first_prunable = 1 
)
inlinestatic

Fold the most diffuse Gaussians of a fit into their neighbours while the fit stays accurate to eps on [lo, hi]. Works from the tail inwards and stops at the first term that cannot be merged; terms before first_prunable are never merged into (so first_prunable - 1 and everything before it keep their coefficients).

References std::abs(), lo, and madness::BaseTensor::size().

Referenced by madness::GFit< T, NDIM >::bsh_fit(), madness::GFit< T, NDIM >::F2GFit(), madness::GFit< T, NDIM >::FGFit(), and madness::GFit< T, NDIM >::truncate_mixed_expansion().

◆ slater_fit()

template<typename T , std::size_t NDIM>
static void madness::GFit< T, NDIM >::slater_fit ( double  gamma,
double  lo,
double  hi,
double  eps,
Tensor< double > &  pcoeff,
Tensor< double > &  pexpnt,
bool  prnt 
)
inlinestaticprivate

fit a Slater function using a sum of Gaussians

formula inspired by the BSH fit, with the roles of r and mu exchanged see also Eq. (A3) in S. Ten-no, Initiation of explicitly correlated Slater-type geminal theory, Chem. Phys. Lett., vol. 398, no. 1, pp. 56-61, 2004.

References e(), exact, h(), lo, MADNESS_CHECK, madness::constants::pi, pow(), and test().

Referenced by madness::GFit< T, NDIM >::f12_fit(), madness::GFit< T, NDIM >::f12sq_fit(), and madness::GFit< T, NDIM >::SlaterFit().

◆ SlaterFit()

template<typename T , std::size_t NDIM>
static GFit madness::GFit< T, NDIM >::SlaterFit ( double  gamma,
double  lo,
double  hi,
double  eps,
bool  prnt = false 
)
inlinestatic

return a fit for the Slater function

the Slater function is defined by f(r) = exp(-\gamma r)

Parameters
[in]gammathe exponent of the Slater function
[in]lothe smallest length scale that needs to be precisely represented
[in]hithe largest length scale that needs to be precisely represented
[in]epsthe precision threshold @parma[in] prnt print level

References exact, fit(), lo, madness::print(), and madness::GFit< T, NDIM >::slater_fit().

Referenced by madness::GFit< T, NDIM >::GFit(), madness::SlaterFunctionInterface::fit(), and madness::GradSlaterOperator().

◆ truncate_mixed_expansion()

template<typename T , std::size_t NDIM>
static void madness::GFit< T, NDIM >::truncate_mixed_expansion ( Tensor< double > &  c,
Tensor< double > &  e,
const std::array< LatticeRange, NDIM > &  lattice_ranges,
const Tensor< double > &  cell_width,
double  lo,
double  hi_fin,
double  eps 
)
inlinestatic

Truncate the fit of a kernel that is lattice-summed along some axes.

Along an axis with an infinite lattice sum, a Gaussian with exponent below tcut = 0.25/L^2 (L the largest such cell width) has a lattice sum that is flat to exp(-4 pi^2) over the cell: a gauge constant. If every axis is summed, those terms are dropped (all but the first, as before). If some axes are not summed, the same terms are not flat along them and carry real potential there – so they are kept as far as the finite axes need them: the tail is folded into its neighbours while the fit stays accurate to eps on [lo, hi_fin], where hi_fin is the largest distance the finite axes can reach. The first term below tcut is never merged into a term above it, whose lattice sum is not flat.

Parameters
[in,out]ccoefficients of the fit; truncated (and possibly rescaled) on return
[in,out]eexponents of the fit, in decreasing order
[in]lattice_rangeslattice range of each axis
[in]cell_widthwidth of each axis of the cell
[in]losmallest distance the fit must represent accurately
[in]hi_finlargest distance the finite (non-infinite) axes must represent accurately
[in]epsaccuracy of the fit on [lo, hi_fin]

References b, c, d, e(), lo, NDIM, and madness::GFit< T, NDIM >::prune_small_coefficients().

Member Data Documentation

◆ coeffs_

template<typename T , std::size_t NDIM>
Tensor<T> madness::GFit< T, NDIM >::coeffs_
private

◆ exponents_

template<typename T , std::size_t NDIM>
Tensor<T> madness::GFit< T, NDIM >::exponents_
private

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