ergo
LR::LRSolver Class Referenceabstract

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

#include <slr.h>

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

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. More...
 
virtual ~LRSolver ()
 
virtual bool getResidual (VarVectorCollection &residualv)=0
 Computes the residual vector. More...
 
virtual int getInitialGuess (VarVectorCollection &vecs)=0
 Computes the initial vector the subspace is to be seeded with. More...
 
virtual ergo_real getPreconditionerShift (int i) const =0
 returns the preconditioning shift. More...
 
virtual void increaseSubspaceLimit (int newSize)
 expands above the default limit More...
 
bool solve (E2Evaluator &e, bool diskMode=false)
 Solves the problem defined by the subclass. More...
 
void computeExactE2Diag (E2Evaluator &e2)
 

Public Attributes

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

Protected Member Functions

void getAvMinusFreqSv (ergo_real f, ergo_real *weights, VarVector &r)
 Computes a vector built of base vectors with specified vectors. More...
 
void projectOnSubspace (const VarVector &full, ergo_real *w)
 Projects vector. More...
 
void buildVector (const ergo_real *w, VarVector &full)
 Build full fector from the reduced form. More...
 
void operToVec (OneElOperator &oper, VarVector &res) const
 Transform square operator to the vector form. More...
 
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. More...
 
virtual void addToSpace (VarVectorCollection &vecs, E2Evaluator &e2)
 extends the subspace with v and its transformed vector Av. More...
 
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 More...
 

Protected Attributes

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

Static Protected Attributes

static const int MVEC = 200
 default limit for subspace size More...
 

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. More...
 

Private Attributes

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

Detailed Description

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

Constructor & Destructor Documentation

◆ LRSolver()

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 nbast, nocc, and setE2diag().

◆ ~LRSolver()

virtual LR::LRSolver::~LRSolver ( )
inlinevirtual

References cmo, fdiag, and xSub.

Member Function Documentation

◆ addToSpace()

void LR::LRSolver::addToSpace ( VarVectorCollection v,
E2Evaluator e2 
)
protectedvirtual

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 Avects, LR::dot(), e2diag, eSub, getPreconditionerShift(), lintrans(), maxSubspaceSize, LR::precondition(), LR::VarVectorCollection::releaseAll(), LR::VarVectorCollection::size(), sSub, LR::sTimes(), subspaceSize, LR::swapXY(), template_blas_fabs(), and vects.

Referenced by LR::SetOfEqSolver::addToSpace(), and solve().

◆ ao2mo()

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

computes mo := cmo'*ao*cmo

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

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

◆ buildVector()

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

Build full fector from the reduced form.

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

◆ computeExactE2Diag()

void LR::LRSolver::computeExactE2Diag ( E2Evaluator e2)

◆ getAvMinusFreqSv()

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::sTimes(), subspaceSize, LR::swapXY(), and vects.

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

◆ getInitialGuess()

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().

◆ getPreconditionerShift()

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().

◆ getResidual()

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().

◆ increaseSubspaceLimit()

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

◆ lintrans()

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 ao2mo(), LR::commute(), LR::commuteWithDMO(), load_F_MO(), mo2ao(), nbast, nocc, LR::VarVector::setFromFull(), LR::VarVector::setFull(), and LR::E2Evaluator::transform().

Referenced by addToSpace(), and computeExactE2Diag().

◆ load_F_MO()

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

References fdiag, and nbast.

Referenced by lintrans().

◆ mo2ao()

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

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

Referenced by lintrans().

◆ operToVec()

void LR::LRSolver::operToVec ( OneElOperator oper,
VarVector res 
) const
protected

◆ projectOnSubspace()

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 LR::dot(), LR::VarVector::nvar, subspaceSize, vects, LR::VarVector::x(), and LR::VarVector::y().

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

◆ setE2diag()

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 cmo, do_output(), e2diag, fdiag, LOG_AREA_LR, LOG_CAT_ERROR, LOG_CAT_INFO, nbast, nocc, LR::VarVector::setFromFull(), mat::sygv(), and UNIT_one_eV.

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

◆ solve()

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 addToSpace(), do_output(), getInitialGuess(), getPreconditionerShift(), getResidual(), LOG_AREA_LR, LOG_CAT_INFO, maxSubspaceSize, Util::TimeMeter::print(), LR::VarVectorCollection::setDiskMode(), subspaceSize, template_blas_sqrt(), and vects.

Referenced by es_getexc(), and solveForRHS().

Member Data Documentation

◆ Avects

VarVectorCollection LR::LRSolver::Avects
private

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(), getAvMinusFreqSv(), and increaseSubspaceLimit().

◆ cmo

ergo_real* LR::LRSolver::cmo
private

the MO coefficients.

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

◆ convThreshold

ergo_real LR::LRSolver::convThreshold

iterative method convergence threshold

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

◆ e2diag

VarVector LR::LRSolver::e2diag
protected

◆ eSub

SmallMatrix LR::LRSolver::eSub
protected

◆ fdiag

ergo_real* LR::LRSolver::fdiag
private

the eigenvalues of the Fock matrix.

Used by load_F_MO.

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

◆ maxSubspaceSize

int LR::LRSolver::maxSubspaceSize

◆ MVEC

const int LR::LRSolver::MVEC = 200
staticprotected

default limit for subspace size

◆ nbast

◆ nocc

◆ sSub

SmallMatrix LR::LRSolver::sSub
protected

◆ subspaceSize

◆ vects

◆ xSub

ergo_real* LR::LRSolver::xSub
protected

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