ergo
LR::LRSolver Class Reference

Linear Response iterative solver using a variant of the Davidson method. More...

#include <slr.h>

Inheritance diagram for LR::LRSolver:
LR::EigenSolver LR::SetOfEqSolver

List of all members.

Public Member Functions

 LRSolver (int nbast, int nocc, const ergo_real *fock_matrix, const ergo_real *s)
 Initialize the solver by computing the diagonal of the E2 operator as needed for preconditioning.
virtual ~LRSolver ()
virtual bool getResidual (VarVectorCollection &residualv)=0
 Computes the residual vector.
virtual int getInitialGuess (VarVectorCollection &vecs)=0
 Computes the initial vector the subspace is to be seeded with.
virtual ergo_real getPreconditionerShift (int i) const =0
 returns the preconditioning shift.
virtual void increaseSubspaceLimit (int newSize)
 expands above the default limit
bool solve (E2Evaluator &e, bool diskMode=false)
 Solves the problem defined by the subclass.
void computeExactE2Diag (E2Evaluator &e2)

Public Attributes

ergo_real convThreshold
 iterative method convergence threshold
int maxSubspaceSize
 current subspace size limit.

Protected Member Functions

void getAvMinusFreqSv (ergo_real f, ergo_real *weights, VarVector &r)
 Computes a vector built of base vectors with specified vectors.
void projectOnSubspace (const VarVector &full, ergo_real *w)
 Projects vector.
void buildVector (const ergo_real *w, VarVector &full)
 Build full fector from the reduced form.
void operToVec (OneElOperator &oper, VarVector &res) const
 Transform square operator to the vector form.
ergo_real setE2diag (int nbast, int nocc, const ergo_real *fock_matrix, const ergo_real *s)
 setE2diag is called by the constructor to fill in the approximation of the E[2] operator diagonal.
virtual void addToSpace (VarVectorCollection &vecs, E2Evaluator &e2)
 extends the subspace with v and its transformed vector Av.
void mo2ao (int nbast, const ergo_real *mo, ergo_real *ao) const
void ao2mo (int nbast, const ergo_real *ao, ergo_real *mo) const
 computes mo := cmo'*ao*cmo

Protected Attributes

VarVector e2diag
 approximation to the diagonal of E2 operator
int subspaceSize
 current subspace size
SmallMatrix eSub
 E[2] matrix projected onto subspace.
SmallMatrix sSub
 S[2] matrix projected onto subspace.
ergo_realxSub
 solution vector projected onto subspace
int nbast
 number of basis functions
int nocc
 number of occupied orbitals
VarVectorCollection vects
 base vectors

Static Protected Attributes

static const int MVEC = 200
 default limit for subspace size

Private Member Functions

void load_F_MO (ergo_real *fmat) const
bool lintrans (E2Evaluator &e2, const VarVector &v, VarVector &Av) const
 performs the linear transformation of the vector with E[2] operator.

Private Attributes

VarVectorCollection Avects
 vects and Avects members store the trial vectors and their transformed versions.
ergo_realfdiag
 the eigenvalues of the Fock matrix.
ergo_realcmo
 the MO coefficients.

Detailed Description

Linear Response iterative solver using a variant of the Davidson method.


Constructor & Destructor Documentation

LR::LRSolver::LRSolver ( int  aNbast,
int  aNocc,
const ergo_real fock_matrix,
const ergo_real s 
)

Initialize the solver by computing the diagonal of the E2 operator as needed for preconditioning.

References setE2diag(), nbast, and nocc.

virtual LR::LRSolver::~LRSolver ( ) [inline, virtual]

References cmo, fdiag, and xSub.


Member Function Documentation

void LR::LRSolver::addToSpace ( VarVectorCollection v,
E2Evaluator e2 
) [protected, virtual]

extends the subspace with v and its transformed vector Av.

The eSub and sSub projected matrices are modified as well. We do not store explicitely the swapped vectors (y x), only the (x y) combination.

Reimplemented in LR::SetOfEqSolver.

References subspaceSize, LR::VarVectorCollection::size(), maxSubspaceSize, LR::precondition(), e2diag, getPreconditionerShift(), vects, LR::swapXY(), LR::VarVectorCollection::releaseAll(), lintrans(), Avects, LR::dot(), eSub, sSub, and LR::sTimes().

Referenced by solve().

void LR::LRSolver::ao2mo ( int  nbast,
const ergo_real ao,
ergo_real mo 
) const [protected]

computes mo := cmo'*ao*cmo

References cmo, nbast, and LR::gemm().

Referenced by lintrans(), operToVec(), LR::SetOfEqSolver::setRHS(), and LR::EigenSolver::computeMoments().

void LR::LRSolver::buildVector ( const ergo_real w,
VarVector full 
) [protected]

Build full fector from the reduced form.

References LR::VarVector::setSize(), vects, subspaceSize, and LR::VarVector::nvar.

void LR::LRSolver::computeExactE2Diag ( E2Evaluator e2)
void LR::LRSolver::getAvMinusFreqSv ( ergo_real  f,
ergo_real weights,
VarVector r 
) [protected]

Computes a vector built of base vectors with specified vectors.

get_av_minus_freq_sv scans through transformed vectors creating their linear combination and returning r := Av - f*Sv

r := Av - f*Sv

References Avects, LR::swapXY(), subspaceSize, LR::sTimes(), and vects.

Referenced by LR::SetOfEqSolver::getResidual(), and LR::EigenSolver::getResidual().

virtual int LR::LRSolver::getInitialGuess ( VarVectorCollection vecs) [pure virtual]

Computes the initial vector the subspace is to be seeded with.

Allocates

Parameters:
vecsand returns the number of vectors.

Implemented in LR::EigenSolver, and LR::SetOfEqSolver.

Referenced by solve().

virtual ergo_real LR::LRSolver::getPreconditionerShift ( int  i) const [pure virtual]

returns the preconditioning shift.

Proper preconditioning is vital for the quick convergence.

Implemented in LR::EigenSolver, and LR::SetOfEqSolver.

Referenced by addToSpace(), and solve().

virtual bool LR::LRSolver::getResidual ( VarVectorCollection residualv) [pure virtual]

Computes the residual vector.

The residual vector is created by solving the problem in the subspace and then using the solution coefficients to form the approximate solution vector. This trial vector is then substituted to the equation and the residual is defined as the difference between the transformed trial vector and the expected solution.

Implemented in LR::EigenSolver, and LR::SetOfEqSolver.

Referenced by solve().

void LR::LRSolver::increaseSubspaceLimit ( int  newSize) [virtual]

expands above the default limit

Reimplemented in LR::EigenSolver, and LR::SetOfEqSolver.

References maxSubspaceSize, eSub, LR::SmallMatrix::expand(), sSub, xSub, vects, LR::VarVectorCollection::setSize(), and Avects.

bool LR::LRSolver::lintrans ( E2Evaluator e2,
const VarVector v,
VarVector Av 
) const [private]

performs the linear transformation of the vector with E[2] operator.

References nbast, LR::VarVector::setFull(), nocc, LR::commuteWithDMO(), mo2ao(), LR::E2Evaluator::transform(), ao2mo(), load_F_MO(), LR::commute(), and LR::VarVector::setFromFull().

Referenced by addToSpace(), and computeExactE2Diag().

void LR::LRSolver::load_F_MO ( ergo_real fmat) const [private]

References nbast, and fdiag.

Referenced by lintrans().

void LR::LRSolver::mo2ao ( int  nbast,
const ergo_real mo,
ergo_real ao 
) const [protected]

References cmo, nbast, and LR::gemm().

Referenced by lintrans().

void LR::LRSolver::operToVec ( OneElOperator oper,
VarVector res 
) const [protected]
void LR::LRSolver::projectOnSubspace ( const VarVector full,
ergo_real w 
) [protected]

Projects vector.

Projects a full vector onto the reduced space.

Parameters:
fullon the reduced subspace, returns the result in
wwhich is a preallocated vector of projection coefficients (weights) with size equal at least to the subspace size.

References subspaceSize, LR::dot(), LR::VarVector::nvar, vects, LR::VarVector::x(), and LR::VarVector::y().

Referenced by LR::SetOfEqSolver::multiplyXtimesVec(), and LR::EigenSolver::computeMoments().

ergo_real LR::LRSolver::setE2diag ( int  nbast,
int  nocc,
const ergo_real fock_matrix,
const ergo_real s 
) [protected]

setE2diag is called by the constructor to fill in the approximation of the E[2] operator diagonal.

It returns E_LUMO-E_HOMO which is useful for other things.

References fdiag, nbast, cmo, mat::sygv(), e2diag, LR::VarVector::setFromFull(), nocc, do_output(), LOG_CAT_INFO, LOG_AREA_LR, and LOG_CAT_ERROR.

Referenced by LRSolver(), and LR::EigenSolver::EigenSolver().

bool LR::LRSolver::solve ( E2Evaluator e2,
bool  diskMode = false 
)

Solves the problem defined by the subclass.

solve the problem as defined by the subclass.

This involves generation of the initial guess, symmetric orthogonalization, subspace extension routines, etc.

References vects, LR::VarVectorCollection::setDiskMode(), getInitialGuess(), do_output(), LOG_CAT_INFO, LOG_AREA_LR, subspaceSize, maxSubspaceSize, addToSpace(), getResidual(), and getPreconditionerShift().

Referenced by es_getexc(), and solveForRHS().


Member Data Documentation

vects and Avects members store the trial vectors and their transformed versions.

Only every second vector is stored, the paired vectors are recovered with help of swapXY() function. transformed base vectors

Referenced by addToSpace(), increaseSubspaceLimit(), and getAvMinusFreqSv().

the MO coefficients.

Referenced by mo2ao(), ao2mo(), setE2diag(), and ~LRSolver().

the eigenvalues of the Fock matrix.

Used by load_F_MO.

Referenced by load_F_MO(), setE2diag(), and ~LRSolver().

const int LR::LRSolver::MVEC = 200 [static, protected]

default limit for subspace size


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