ergo
|
Linear Response iterative solver using a variant of the Davidson method. More...
#include <slr.h>
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_real * | xSub |
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_real * | fdiag |
the eigenvalues of the Fock matrix. | |
ergo_real * | cmo |
the MO coefficients. |
Linear Response iterative solver using a variant of the Davidson method.
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.
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().
computes mo := cmo'*ao*cmo
References cmo, nbast, and LR::gemm().
Referenced by lintrans(), operToVec(), LR::SetOfEqSolver::setRHS(), and LR::EigenSolver::computeMoments().
Build full fector from the reduced form.
References LR::VarVector::setSize(), vects, subspaceSize, and LR::VarVector::nvar.
void LR::LRSolver::computeExactE2Diag | ( | E2Evaluator & | e2 | ) |
References nbast, nocc, LR::VarVector::setSize(), lintrans(), and e2diag.
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
vecs | and 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] |
Referenced by lintrans().
References cmo, nbast, and LR::gemm().
Referenced by lintrans().
void LR::LRSolver::operToVec | ( | OneElOperator & | oper, |
VarVector & | res | ||
) | const [protected] |
Transform square operator to the vector form.
References nbast, LR::OneElOperator::getOper(), ao2mo(), LR::commuteWithDMO(), nocc, and LR::VarVector::setFromFull().
Referenced by LR::SetOfEqSolver::getPolarisability(), and LR::EigenSolver::computeMoments().
Projects vector.
Projects a full vector onto the reduced space.
full | on the reduced subspace, returns the result in |
w | which 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().
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(), increaseSubspaceLimit(), and getAvMinusFreqSv().
ergo_real* LR::LRSolver::cmo [private] |
the MO coefficients.
Referenced by mo2ao(), ao2mo(), setE2diag(), and ~LRSolver().
iterative method convergence threshold
Referenced by es_getexc(), es_get_polarisability(), LR::SetOfEqSolver::getResidual(), and LR::EigenSolver::getResidual().
VarVector LR::LRSolver::e2diag [protected] |
approximation to the diagonal of E2 operator
Referenced by addToSpace(), computeExactE2Diag(), setE2diag(), LR::SetOfEqSolver::getInitialGuess(), and LR::EigenSolver::getInitialGuess().
SmallMatrix LR::LRSolver::eSub [protected] |
E[2] matrix projected onto subspace.
Referenced by addToSpace(), increaseSubspaceLimit(), LR::SetOfEqSolver::getResidual(), and LR::EigenSolver::getResidual().
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().
current subspace size limit.
Referenced by addToSpace(), increaseSubspaceLimit(), solve(), LR::SetOfEqSolver::increaseSubspaceLimit(), and LR::EigenSolver::increaseSubspaceLimit().
const int LR::LRSolver::MVEC = 200 [static, protected] |
default limit for subspace size
int LR::LRSolver::nbast [protected] |
number of basis functions
Referenced by LRSolver(), mo2ao(), ao2mo(), load_F_MO(), lintrans(), computeExactE2Diag(), setE2diag(), operToVec(), LR::SetOfEqSolver::setRHS(), LR::EigenSolver::getInitialGuess(), and LR::EigenSolver::computeMoments().
int LR::LRSolver::nocc [protected] |
number of occupied orbitals
Referenced by LRSolver(), lintrans(), computeExactE2Diag(), setE2diag(), operToVec(), LR::SetOfEqSolver::setRHS(), LR::EigenSolver::getInitialGuess(), and LR::EigenSolver::computeMoments().
SmallMatrix LR::LRSolver::sSub [protected] |
S[2] matrix projected onto subspace.
Referenced by addToSpace(), increaseSubspaceLimit(), LR::SetOfEqSolver::getResidual(), and LR::EigenSolver::getResidual().
int LR::LRSolver::subspaceSize [protected] |
current subspace size
Referenced by addToSpace(), solve(), getAvMinusFreqSv(), projectOnSubspace(), buildVector(), LR::SetOfEqSolver::multiplyXtimesVec(), LR::SetOfEqSolver::getResidual(), LR::SetOfEqSolver::addToSpace(), LR::EigenSolver::getResidual(), and LR::EigenSolver::computeMoments().
VarVectorCollection LR::LRSolver::vects [protected] |
base vectors
Referenced by addToSpace(), increaseSubspaceLimit(), solve(), getAvMinusFreqSv(), projectOnSubspace(), buildVector(), and LR::SetOfEqSolver::addToSpace().
ergo_real* LR::LRSolver::xSub [protected] |
solution vector projected onto subspace
Referenced by increaseSubspaceLimit(), LR::SetOfEqSolver::multiplyXtimesVec(), LR::SetOfEqSolver::getResidual(), and ~LRSolver().