MADNESS 0.10.1
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
madness::MP2 Class Reference

a class for computing the first order wave function and MP2 pair energies More...

#include <mp2.h>

Inheritance diagram for madness::MP2:
Inheritance graph
[legend]
Collaboration diagram for madness::MP2:
Collaboration graph
[legend]

Classes

struct  Pairs
 POD holding all electron pairs with easy access. More...
 
struct  Parameters
 POD for MP2 keywords. More...
 

Public Member Functions

 MP2 (World &world, const commandlineparser &parser)
 ctor
 
double asymmetry (const real_function_6d &f, const std::string s) const
 
bool check_core_valence_separation () const
 make sure frozen orbitals don't couple with correlated ones – relocalize if necessary
 
double compute_gQf (const int i, const int j, ElectronPair &pair) const
 compute the matrix element <ij | g12 Q12 f12 | phi^0>
 
double compute_gQf_cc2interface (const int i, const int j, const real_function_6d &f) const
 compute the matrix element <ij | g12 Q12 f12 | phi^0>
 
double coord_chksum () const
 return a checksum for the geometry
 
real_function_6d debug_cc2 (const real_function_6d &f, const size_t &i, const size_t &j) const
 
void enforce_core_valence_separation ()
 make sure frozen orbitals don't couple with correlated ones – relocalize if necessary
 
HartreeFockget_hf ()
 return the underlying HF reference
 
real_function_6d get_residue (const real_function_6d &f, const int i, const int j)
 
void increment (ElectronPair &pair, real_convolution_6d &green)
 compute increments: psi^1 = C + GV C + GVGV C + GVGVGV C + ..
 
real_function_6d iterate (const real_function_6d &f) const
 solve the residual equation for electron pair (i,j)
 
template<typename T , size_t NDIM>
void load_function (Function< T, NDIM > &f, const std::string name) const
 load a function
 
std::string name () const
 
template<typename T >
void print_options (const std::string option, const T val) const
 pretty print the options
 
template<typename T , size_t NDIM>
void save_function (const Function< T, NDIM > &f, const std::string name) const
 save a function
 
virtual bool selftest ()
 
double solve_coupled_equations (Pairs< ElectronPair > &pairs, const double econv, const double dconv) const
 solve the coupled MP1 equations (e.g. for local orbitals)
 
void solve_residual_equations (ElectronPair &pair, const double econv, const double dconv) const
 solve the residual equation for electron pair (i,j)
 
double value ()
 return the molecular correlation energy energy (without the HF energy)
 
double value (const Tensor< double > &x)
 return the molecular correlation energy as a function of the coordinates
 
double zeroth_order_energy (const int i, const int j) const
 return the 0th order energy of pair ij (= sum of orbital energies)
 
- Public Member Functions inherited from madness::OptimizationTargetInterface
virtual ~OptimizationTargetInterface ()
 
virtual Tensor< double > gradient (const Tensor< double > &x)
 Should return the derivative of the function.
 
virtual bool provides_gradient () const
 Override this to return true if the derivative is implemented.
 
double test_gradient (Tensor< double > &x, double value_precision, bool doprint=true)
 Numerical test of the derivative ... optionally prints to stdout, returns max abs error.
 
virtual void value_and_gradient (const Tensor< double > &x, double &value, Tensor< double > &gradient)
 Reimplement if more efficient to evaluate both value and gradient in one call.
 

Static Public Member Functions

static void help ()
 
static void print_parameters ()
 

Private Member Functions

void add_local_coupling (const Pairs< ElectronPair > &pairs, Pairs< real_function_6d > &coupling) const
 add the coupling terms for local MP2
 
real_function_6d apply_exchange (const real_function_6d &f, const real_function_3d &orbital_ket, const real_function_3d &orbital_bra, const int particle) const
 apply the exchange operator on f
 
real_function_6d apply_exchange_vector (const real_function_6d &f, const int particle) const
 
double compute_energy (ElectronPair &pair) const
 compute the singlet and triplet energy for a given electron pair
 
void END_TIMER (World &world, const char *msg) const
 
Tensor< double > get_fock_matrix () const
 
void guess_mp1_3 (ElectronPair &pair) const
 compute the first iteration of the residual equations and all intermediates
 
real_function_3d J (const real_function_3d &phi) const
 apply the Coulomb operator a on orbital
 
real_function_6d JK1phi0_on_demand (const int i, const int j, const bool hc=false) const
 return the function (J(1)-K(1)) |phi0> as on-demand function
 
real_function_6d JK2phi0_on_demand (const int i, const int j, const bool hc=false) const
 return the function (J(2)-K(2)) |phi0> as on-demand function
 
real_function_3d K (const real_function_3d &phi, const bool hc=false) const
 apply the exchange operator on an orbital
 
real_function_6d K (const real_function_6d &phi, const bool is_symmetric=false) const
 apply the exchange operator on a pair function
 
std::vector< real_function_3dmake_chi (const real_function_3d &phi, const real_convolution_3d &op, const bool hc=false) const
 make the quantity chi_k
 
real_function_6d make_fKphi0 (const int i, const int j) const
 apply the operator K on the reference and multiply with f; fK |phi^0>
 
real_function_6d make_KffKphi0 (const ElectronPair &pair) const
 return the function [K,f] phi0; load from disk if available
 
ElectronPair make_pair (const int i, const int j) const
 compute some matrix elements that don't change during the SCF
 
real_function_6d make_Uphi0 (ElectronPair &pair) const
 return the function Uphi0; load from disk if available
 
std::vector< real_function_3dmake_xi (const real_function_3d &phi_i, const real_function_3d &phi_j, const real_convolution_3d &op, const bool hc=false) const
 make the quantity xi_k
 
real_function_6d multiply_with_0th_order_Hamiltonian (const real_function_6d &f, const int i, const int j) const
 multiply the given function with the 0th order Hamiltonian, exluding the 0th order energy
 
real_function_6d nemo0_on_demand (const int i, const int j) const
 return the function |F1F2> as on-demand function
 
real_function_6d phi0_on_demand (const int i, const int j) const
 return the function |phi0> as on-demand function
 
void START_TIMER (World &world) const
 

Private Attributes

double coords_sum
 check sum for the geometry
 
double correlation_energy
 the correlation energy
 
CorrelationFactor corrfac
 correlation factor: Slater
 
Tensor< double > fock
 the Fock matrix
 
std::shared_ptr< HartreeFockhf
 our reference
 
std::shared_ptr< NuclearCorrelationFactornuclear_corrfac
 
Pairs< ElectronPairpairs
 pair functions and energies
 
Parameters param
 SCF parameters for MP2.
 
std::shared_ptr< real_convolution_3dpoisson
 
StrongOrthogonalityProjector< double, 3 > Q12
 
double sss
 
double ttt
 
Worldworld
 the world
 

Detailed Description

a class for computing the first order wave function and MP2 pair energies

Constructor & Destructor Documentation

◆ MP2()

madness::MP2::MP2 ( World world,
const commandlineparser parser 
)

Member Function Documentation

◆ add_local_coupling()

void madness::MP2::add_local_coupling ( const Pairs< ElectronPair > &  pairs,
Pairs< real_function_6d > &  coupling 
) const
private

add the coupling terms for local MP2

\sum_{k\neq i} f_ki |u_kj> + \sum_{l\neq j} f_lj |u_il>

Todo:
Verify this doxygen block.
Returns
\sum_{k\neq i} f_ki |u_kj> + \sum_{l\neq j} f_lj |u_il>

References madness::FunctionFactory< T, NDIM >::compressed(), madness::WorldGopInterface::fence(), madness::MP2::Parameters::freeze(), function(), get_fock_matrix(), madness::FunctionDefaults< NDIM >::get_thresh(), madness::World::gop, hf, k, MADNESS_EXCEPTION, pairs, param, madness::print(), madness::World::rank(), madness::swap_particles(), thresh, and world.

Referenced by solve_coupled_equations().

◆ apply_exchange()

real_function_6d madness::MP2::apply_exchange ( const real_function_6d f,
const real_function_3d orbital_ket,
const real_function_3d orbital_bra,
const int  particle 
) const
private

apply the exchange operator on f

if the exchange operator is similarity transformed (R-1 K R) the orbital spaces differ for the orbitals underneath the integral sign R-1 K R = \phi-ket(1) * \int \phi-bra(1') * f(1',2)

Parameters
[in]fthe pair function
[in]orbital_brathe orbital underneath the integral sign (typically R2orbitals)
[in]orbital_ketthe orbital to be pre-multiplied with (typically orbitals)
Returns
the pair function, on which the exchange operator has been applied

References madness::copy(), madness::CoulombOperator(), madness::f, hf, madness::load_balance(), MADNESS_ASSERT, madness::multiply(), op(), madness::Function< T, NDIM >::truncate(), and world.

◆ apply_exchange_vector()

real_function_6d madness::MP2::apply_exchange_vector ( const real_function_6d f,
const int  particle 
) const
private

◆ asymmetry()

double madness::MP2::asymmetry ( const real_function_6d f,
const std::string  s 
) const

◆ check_core_valence_separation()

bool madness::MP2::check_core_valence_separation ( ) const

◆ compute_energy()

double madness::MP2::compute_energy ( ElectronPair pair) const
private

◆ compute_gQf()

double madness::MP2::compute_gQf ( const int  i,
const int  j,
ElectronPair pair 
) const

compute the matrix element <ij | g12 Q12 f12 | phi^0>

scales quartically. I think I can get this down to cubically by setting Q12 = (1 - O1)(1 - O2) = 1- O1(1 - 0.5 O2) - O2 (1 - 0.5 O1) as for the formulas cf the article mra_molecule

Returns
the energy <ij | g Q f | kl>

References a, bsh_eps, corrfac, madness::CoulombOperator(), e(), madness::f, madness::g, hf, madness::ElectronPair::i, madness::inner(), madness::ElectronPair::j, k, lo, make_xi(), madness::matrix_inner(), madness::OT_F12, madness::OT_G12, param, madness::constants::pi, poisson, madness::print(), Q12, madness::World::rank(), madness::CCTimer::reset(), madness::SlaterF12Operator(), madness::Tensor< T >::trace(), and world.

Referenced by compute_gQf_cc2interface(), iterate(), and make_pair().

◆ compute_gQf_cc2interface()

double madness::MP2::compute_gQf_cc2interface ( const int  i,
const int  j,
const real_function_6d f 
) const
inline

compute the matrix element <ij | g12 Q12 f12 | phi^0>

scales quartically. I think I can get this down to cubically by setting Q12 = (1 - O1)(1 - O2) = 1- O1(1 - 0.5 O2) - O2 (1 - 0.5 O1) as for the formulas cf the article mra_molecule

Returns
the energy <ij | g Q f | kl>

References compute_gQf(), madness::ElectronPair::constant_term, madness::copy(), madness::f, and madness::ElectronPair::function.

◆ coord_chksum()

double madness::MP2::coord_chksum ( ) const
inline

return a checksum for the geometry

References coords_sum.

Referenced by value().

◆ debug_cc2()

real_function_6d madness::MP2::debug_cc2 ( const real_function_6d f,
const size_t &  i,
const size_t &  j 
) const
inline

◆ END_TIMER()

void madness::MP2::END_TIMER ( World world,
const char *  msg 
) const
inlineprivate

◆ enforce_core_valence_separation()

void madness::MP2::enforce_core_valence_separation ( )

◆ get_fock_matrix()

Tensor< double > madness::MP2::get_fock_matrix ( ) const
inlineprivate

◆ get_hf()

HartreeFock & madness::MP2::get_hf ( )
inline

return the underlying HF reference

References hf.

◆ get_residue()

real_function_6d madness::MP2::get_residue ( const real_function_6d f,
const int  i,
const int  j 
)
inline

◆ guess_mp1_3()

void madness::MP2::guess_mp1_3 ( ElectronPair pair) const
private

◆ help()

static void madness::MP2::help ( )
inlinestatic

◆ increment()

void madness::MP2::increment ( ElectronPair pair,
real_convolution_6d green 
)

◆ iterate()

real_function_6d madness::MP2::iterate ( const real_function_6d f) const
inline

solve the residual equation for electron pair (i,j)

Todo:
Parameter documentation. Below are un-doxygenated comments that no longer seem relevant?

References compute_gQf(), madness::ElectronPair::constant_term, madness::copy(), madness::f, madness::ElectronPair::function, madness::ElectronPair::ij_gQf_ij, madness::ElectronPair::ji_gQf_ij, and solve_residual_equations().

◆ J()

real_function_3d madness::MP2::J ( const real_function_3d phi) const
private

apply the Coulomb operator a on orbital

Parameters
[in]phithe orbital
Returns
Jphi

References hf, and madness::Function< T, NDIM >::truncate().

Referenced by JK1phi0_on_demand(), and JK2phi0_on_demand().

◆ JK1phi0_on_demand()

real_function_6d madness::MP2::JK1phi0_on_demand ( const int  i,
const int  j,
const bool  hc = false 
) const
private

return the function (J(1)-K(1)) |phi0> as on-demand function

Parameters
[in]hccompute hermitian conjugate -> swap bra and ket space

References madness::copy(), hf, J(), K(), madness::CompositeFactory< T, NDIM, MDIM >::particle1(), madness::CompositeFactory< T, NDIM, MDIM >::particle2(), and world.

Referenced by compute_energy().

◆ JK2phi0_on_demand()

real_function_6d madness::MP2::JK2phi0_on_demand ( const int  i,
const int  j,
const bool  hc = false 
) const
private

return the function (J(2)-K(2)) |phi0> as on-demand function

References madness::copy(), hf, J(), K(), madness::CompositeFactory< T, NDIM, MDIM >::particle1(), madness::CompositeFactory< T, NDIM, MDIM >::particle2(), and world.

Referenced by compute_energy().

◆ K() [1/2]

real_function_3d madness::MP2::K ( const real_function_3d phi,
const bool  hc = false 
) const
private

apply the exchange operator on an orbital

Parameters
[in]phithe orbital
[in]hchermitian conjugate -> swap bra and ket space
Returns
Kphi

References hf, k, madness::mul(), and world.

Referenced by JK1phi0_on_demand(), JK2phi0_on_demand(), make_fKphi0(), make_KffKphi0(), and multiply_with_0th_order_Hamiltonian().

◆ K() [2/2]

real_function_6d madness::MP2::K ( const real_function_6d phi,
const bool  is_symmetric = false 
) const
private

apply the exchange operator on a pair function

Parameters
[in]phithe pair function
[in]is_symmetricis the function symmetric wrt particle exchange
Returns
(K1 + K2) |phi >

References apply_exchange_vector(), madness::swap_particles(), and madness::Function< T, NDIM >::truncate().

◆ load_function()

template<typename T , size_t NDIM>
void madness::MP2::load_function ( Function< T, NDIM > &  f,
const std::string  name 
) const

load a function

References madness::f, name(), madness::print(), madness::World::rank(), and world.

Referenced by increment().

◆ make_chi()

std::vector< real_function_3d > madness::MP2::make_chi ( const real_function_3d phi,
const real_convolution_3d op,
const bool  hc = false 
) const
private

make the quantity chi_k

chi is the Poisson kernel applied on an orbital product of the input function and the vector of orbitals

\[ \chi_{k{*} i}(1) = \int dr_2 \frac{k(2) i(2)}{|r_1-r_2|} \]

\[ \chi_{ki{*}}(1) = \int dr_2 \frac{k(2) i(2)}{|r_1-r_2|} \]

if hc

Parameters
[in]phiorbital phi_i
[in]opthe operator in SeparatedConvolution form
[in]hccompute hermitian conjugate -> pass the correct phi!
Returns
a vector of length nocc

References madness::apply(), hf, MADNESS_ASSERT, madness::mul_sparse(), op(), madness::truncate(), and world.

Referenced by make_xi().

◆ make_fKphi0()

real_function_6d madness::MP2::make_fKphi0 ( const int  i,
const int  j 
) const
private

apply the operator K on the reference and multiply with f; fK |phi^0>

Parameters
[in]iindex of orbital i
[in]jindex of orbital j
Returns
the function f12 (K(1)+K(2))|phi^0>

References madness::copy(), corrfac, madness::Function< T, NDIM >::fill_tree(), madness::CompositeFactory< T, NDIM, MDIM >::g12(), hf, K(), madness::CompositeFactory< T, NDIM, MDIM >::particle1(), madness::CompositeFactory< T, NDIM, MDIM >::particle2(), madness::Function< T, NDIM >::truncate(), madness::truncate(), and world.

Referenced by make_KffKphi0().

◆ make_KffKphi0()

real_function_6d madness::MP2::make_KffKphi0 ( const ElectronPair pair) const
private

◆ make_pair()

ElectronPair madness::MP2::make_pair ( const int  i,
const int  j 
) const
private

compute some matrix elements that don't change during the SCF

References compute_gQf(), p(), param, madness::World::rank(), madness::MP2::Parameters::restart(), madness::ElectronPair::uninitialized(), madness::wall_time(), and world.

Referenced by value().

◆ make_Uphi0()

real_function_6d madness::MP2::make_Uphi0 ( ElectronPair pair) const
private

◆ make_xi()

std::vector< real_function_3d > madness::MP2::make_xi ( const real_function_3d phi_i,
const real_function_3d phi_j,
const real_convolution_3d op,
const bool  hc = false 
) const
private

make the quantity xi_k

xi is chi multiplied with an orbital j

\[ \xi_{k{*}i,j}(1) = \chi_{ki}(1) j(1) \]

\[ \xi_{ki{*},j{*}}(1) = \chi_{k{*}i}(1) j(1) \]

if hc

Parameters
[in]phi_iorbital i
[in]phi_jorbital j
[in]opthe operator in SeparatedConvolution form
[in]hccompute hermitian conjugate -> pass the correct phi!
Returns
a vector of length k=0,..,nocc

References make_chi(), madness::mul_sparse(), op(), and world.

Referenced by compute_gQf().

◆ multiply_with_0th_order_Hamiltonian()

real_function_6d madness::MP2::multiply_with_0th_order_Hamiltonian ( const real_function_6d f,
const int  i,
const int  j 
) const
private

◆ name()

std::string madness::MP2::name ( ) const
inlinevirtual

◆ nemo0_on_demand()

real_function_6d madness::MP2::nemo0_on_demand ( const int  i,
const int  j 
) const
private

◆ phi0_on_demand()

real_function_6d madness::MP2::phi0_on_demand ( const int  i,
const int  j 
) const
private

◆ print_options()

template<typename T >
void madness::MP2::print_options ( const std::string  option,
const T  val 
) const
inline

pretty print the options

invoke only in (world.rank()==0) !!

◆ print_parameters()

static void madness::MP2::print_parameters ( )
inlinestatic

◆ save_function()

template<typename T , size_t NDIM>
void madness::MP2::save_function ( const Function< T, NDIM > &  f,
const std::string  name 
) const

◆ selftest()

virtual bool madness::MP2::selftest ( )
inlinevirtual

◆ solve_coupled_equations()

double madness::MP2::solve_coupled_equations ( Pairs< ElectronPair > &  pairs,
const double  econv,
const double  dconv 
) const

solve the coupled MP1 equations (e.g. for local orbitals)

solve the coupled MP1 equations for local orbitals

Parameters
[in]pairsset of (coupled) electron pairs to solve
[in]econvenergy convergence criterion (for all pairs)
[in]dconvdensity convergence criterion (for all pairs)
[in]pairssolved decoupled electron pairs

References std::abs(), add_local_coupling(), bsh_eps, compute_energy(), END_TIMER, energy, madness::MP2::Parameters::freeze(), function(), hf, lo, madness::MP2::Parameters::maxiter(), multiply_with_0th_order_Hamiltonian(), pairs, param, Q12, madness::World::rank(), residual(), madness::Function< T, NDIM >::scale(), START_TIMER, madness::stringify(), madness::Function< T, NDIM >::truncate(), madness::truncate(), madness::wall_time(), world, and zeroth_order_energy().

Referenced by value().

◆ solve_residual_equations()

void madness::MP2::solve_residual_equations ( ElectronPair pair,
const double  econv,
const double  dconv 
) const

◆ START_TIMER()

void madness::MP2::START_TIMER ( World world) const
inlineprivate

◆ value() [1/2]

double madness::MP2::value ( )

return the molecular correlation energy energy (without the HF energy)

References check_core_valence_separation(), enforce_core_valence_separation(), hf, and value().

Referenced by value().

◆ value() [2/2]

double madness::MP2::value ( const Tensor< double > &  x)
virtual

◆ zeroth_order_energy()

double madness::MP2::zeroth_order_energy ( const int  i,
const int  j 
) const
inline

return the 0th order energy of pair ij (= sum of orbital energies)

References hf.

Referenced by guess_mp1_3(), make_Uphi0(), multiply_with_0th_order_Hamiltonian(), solve_coupled_equations(), and solve_residual_equations().

Member Data Documentation

◆ coords_sum

double madness::MP2::coords_sum
private

check sum for the geometry

Referenced by coord_chksum(), and value().

◆ correlation_energy

double madness::MP2::correlation_energy
private

the correlation energy

Referenced by value().

◆ corrfac

CorrelationFactor madness::MP2::corrfac
private

correlation factor: Slater

Referenced by MP2(), compute_gQf(), guess_mp1_3(), make_fKphi0(), make_KffKphi0(), and make_Uphi0().

◆ fock

Tensor<double> madness::MP2::fock
mutableprivate

◆ hf

std::shared_ptr<HartreeFock> madness::MP2::hf
private

◆ nuclear_corrfac

std::shared_ptr<NuclearCorrelationFactor> madness::MP2::nuclear_corrfac
private

Referenced by get_residue(), and value().

◆ pairs

Pairs<ElectronPair> madness::MP2::pairs
private

pair functions and energies

Referenced by MP2(), add_local_coupling(), solve_coupled_equations(), and value().

◆ param

Parameters madness::MP2::param
private

◆ poisson

std::shared_ptr<real_convolution_3d> madness::MP2::poisson
private

Referenced by MP2(), compute_gQf(), and guess_mp1_3().

◆ Q12

StrongOrthogonalityProjector<double, 3> madness::MP2::Q12
private

◆ sss

double madness::MP2::sss
private

Referenced by END_TIMER(), and START_TIMER().

◆ ttt

double madness::MP2::ttt
mutableprivate

Referenced by END_TIMER(), and START_TIMER().

◆ world

World& madness::MP2::world
private

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