ergo
LR::SetOfEqSolver Class Reference

Iterative Set Of Linear Equations solver, extending the generic LRSolver. More...

#include <slr.h>

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

Public Member Functions

 SetOfEqSolver (int nbast, int nocc, const ergo_real *fock_matrix, const ergo_real *s, ergo_real freq)
 Creates the set-of-equations solver. More...
 
void setRHS (OneElOperator &op)
 initializes the rhs field More...
 
virtual ~SetOfEqSolver ()
 
virtual ergo_real getPreconditionerShift (int) const
 returns the preconditioning shift. More...
 
virtual int getInitialGuess (VarVectorCollection &vecs)
 returns the initial guess for the linear set of equations. More...
 
virtual bool getResidual (VarVectorCollection &residualv)
 get the residual of the set of linear equations. More...
 
virtual void increaseSubspaceLimit (int newSize)
 expands above the default limit More...
 
ergo_real getPolarisability (OneElOperator &oper)
 computes polarizability by contracting the response vector with specified operator More...
 
- Public Member Functions inherited from LR::LRSolver
 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 ()
 
bool solve (E2Evaluator &e, bool diskMode=false)
 Solves the problem defined by the subclass. More...
 
void computeExactE2Diag (E2Evaluator &e2)
 

Protected Member Functions

virtual void addToSpace (VarVectorCollection &vecs, E2Evaluator &e2)
 extends the subspace with v and its transformed vector Av. More...
 
ergo_real multiplyXtimesVec (const VarVector &rhs)
 multiplies current solution by some vector. More...
 
- Protected Member Functions inherited from LR::LRSolver
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...
 
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

ergo_realrhsSub
 RHS vector projected onto subspace. More...
 
ergo_real xTimesRHS
 
- Protected Attributes inherited from LR::LRSolver
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...
 

Private Attributes

ergo_real frequency
 frequency for which the SOE is to be solved. More...
 
VarVector rhs
 RHS of the SOE. More...
 

Additional Inherited Members

- Public Attributes inherited from LR::LRSolver
ergo_real convThreshold
 iterative method convergence threshold More...
 
int maxSubspaceSize
 current subspace size limit. More...
 
- Static Protected Attributes inherited from LR::LRSolver
static const int MVEC = 200
 default limit for subspace size More...
 

Detailed Description

Iterative Set Of Linear Equations solver, extending the generic LRSolver.

Constructor & Destructor Documentation

◆ SetOfEqSolver()

LR::SetOfEqSolver::SetOfEqSolver ( int  nbast,
int  nocc,
const ergo_real fock_matrix,
const ergo_real s,
ergo_real  freq 
)
inline

Creates the set-of-equations solver.

The KS and overlap matrix may be deleted immediately after the object creation.

◆ ~SetOfEqSolver()

virtual LR::SetOfEqSolver::~SetOfEqSolver ( )
inlinevirtual

References rhsSub.

Member Function Documentation

◆ addToSpace()

void LR::SetOfEqSolver::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 from LR::LRSolver.

References LR::LRSolver::addToSpace(), LR::dot(), LR::VarVector::nvar, rhs, rhsSub, LR::LRSolver::subspaceSize, LR::LRSolver::vects, LR::VarVector::x(), and LR::VarVector::y().

◆ getInitialGuess()

int LR::SetOfEqSolver::getInitialGuess ( VarVectorCollection guess)
virtual

returns the initial guess for the linear set of equations.

The explicit value is obtained from the diagonal assumption for the E[2] operator and is: (E[2]- freq*S[2])*g = Y -> g = Y./(E[2]-freq*S[2])

Implements LR::LRSolver.

References LR::LRSolver::e2diag, LR::VarVector::nvar, rhs, LR::VarVector::setSize(), and LR::VarVectorCollection::setSize().

◆ getPolarisability()

ergo_real LR::SetOfEqSolver::getPolarisability ( OneElOperator oper)

computes polarizability by contracting the response vector with specified operator

References multiplyXtimesVec(), and LR::LRSolver::operToVec().

Referenced by solveForRHS().

◆ getPreconditionerShift()

virtual ergo_real LR::SetOfEqSolver::getPreconditionerShift ( int  i) const
inlinevirtual

returns the preconditioning shift.

Proper preconditioning is vital for the quick convergence.

Implements LR::LRSolver.

References frequency.

◆ getResidual()

bool LR::SetOfEqSolver::getResidual ( VarVectorCollection residualv)
virtual

get the residual of the set of linear equations.

This is done in two steps: Solution in the subspace: Xsub = (eSub-freq*Ssub)\Ysub; Residual vector is: residualv= (Av-freq*Sv)*Xsub - Y;

Implements LR::LRSolver.

References A, LR::LRSolver::convThreshold, do_output(), LR::LRSolver::eSub, frequency, LR::LRSolver::getAvMinusFreqSv(), LOG_AREA_LR, LOG_CAT_INFO, multiplyXtimesVec(), LR::VarVector::nvar, rhs, rhsSub, LR::VarVectorCollection::setSize(), solve_linear_equation_system(), LR::LRSolver::sSub, LR::LRSolver::subspaceSize, template_blas_sqrt(), LR::LRSolver::xSub, and xTimesRHS.

◆ increaseSubspaceLimit()

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

expands above the default limit

Reimplemented from LR::LRSolver.

References LR::LRSolver::increaseSubspaceLimit(), LR::LRSolver::maxSubspaceSize, and rhsSub.

Referenced by es_get_polarisability().

◆ multiplyXtimesVec()

ergo_real LR::SetOfEqSolver::multiplyXtimesVec ( const VarVector rhs)
protected

multiplies current solution by some vector.

If such contractions are to be done several times, perhaps a single vector solution should be created and only then contracted with rhs vector.

References LR::LRSolver::projectOnSubspace(), rhs, LR::LRSolver::subspaceSize, and LR::LRSolver::xSub.

Referenced by getPolarisability(), and getResidual().

◆ setRHS()

void LR::SetOfEqSolver::setRHS ( OneElOperator op)

Member Data Documentation

◆ frequency

ergo_real LR::SetOfEqSolver::frequency
private

frequency for which the SOE is to be solved.

Referenced by getPreconditionerShift(), and getResidual().

◆ rhs

VarVector LR::SetOfEqSolver::rhs
private

◆ rhsSub

ergo_real* LR::SetOfEqSolver::rhsSub
protected

RHS vector projected onto subspace.

Referenced by addToSpace(), getResidual(), increaseSubspaceLimit(), and ~SetOfEqSolver().

◆ xTimesRHS

ergo_real LR::SetOfEqSolver::xTimesRHS
protected

Referenced by getResidual().


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