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. 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_real * | xSub |
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_real * | fdiag |
the eigenvalues of the Fock matrix. More... | |
ergo_real * | cmo |
the MO coefficients. More... | |
Linear Response iterative solver using a variant of the Davidson method.
Initialize the solver by computing the diagonal of the E2 operator as needed for preconditioning.
References nbast, nocc, and setE2diag().
|
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().
computes mo := cmo'*ao*cmo
References cmo, LR::gemm(), and nbast.
Referenced by LR::EigenSolver::computeMoments(), lintrans(), operToVec(), and LR::SetOfEqSolver::setRHS().
Build full fector from the reduced form.
References LR::VarVector::nvar, LR::VarVector::setSize(), subspaceSize, and vects.
void LR::LRSolver::computeExactE2Diag | ( | E2Evaluator & | e2 | ) |
References e2diag, lintrans(), nbast, nocc, and LR::VarVector::setSize().
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().
|
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().
|
pure virtual |
returns the preconditioning shift.
Proper preconditioning is vital for the quick convergence.
Implemented in LR::SetOfEqSolver, and LR::EigenSolver.
Referenced by addToSpace(), and solve().
|
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().
|
virtual |
expands above the default limit
Reimplemented in LR::EigenSolver, and LR::SetOfEqSolver.
References Avects, eSub, LR::SmallMatrix::expand(), maxSubspaceSize, LR::VarVectorCollection::setSize(), sSub, vects, and xSub.
Referenced by LR::SetOfEqSolver::increaseSubspaceLimit(), and LR::EigenSolver::increaseSubspaceLimit().
|
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().
|
private |
Referenced by lintrans().
References cmo, LR::gemm(), and nbast.
Referenced by lintrans().
|
protected |
Transform square operator to the vector form.
References ao2mo(), LR::commuteWithDMO(), LR::OneElOperator::getOper(), nbast, nocc, and LR::VarVector::setFromFull().
Referenced by LR::EigenSolver::computeMoments(), and LR::SetOfEqSolver::getPolarisability().
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 LR::dot(), LR::VarVector::nvar, subspaceSize, vects, LR::VarVector::x(), and LR::VarVector::y().
Referenced by LR::EigenSolver::computeMoments(), and LR::SetOfEqSolver::multiplyXtimesVec().
|
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().
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().
|
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().
|
private |
the MO coefficients.
Referenced by ao2mo(), mo2ao(), setE2diag(), and ~LRSolver().
ergo_real LR::LRSolver::convThreshold |
iterative method convergence threshold
Referenced by es_get_polarisability(), es_getexc(), LR::SetOfEqSolver::getResidual(), and LR::EigenSolver::getResidual().
|
protected |
approximation to the diagonal of E2 operator
Referenced by addToSpace(), computeExactE2Diag(), LR::SetOfEqSolver::getInitialGuess(), LR::EigenSolver::getInitialGuess(), and setE2diag().
|
protected |
E[2] matrix projected onto subspace.
Referenced by addToSpace(), LR::SetOfEqSolver::getResidual(), LR::EigenSolver::getResidual(), and increaseSubspaceLimit().
|
private |
the eigenvalues of the Fock matrix.
Used by load_F_MO.
Referenced by load_F_MO(), setE2diag(), and ~LRSolver().
int LR::LRSolver::maxSubspaceSize |
current subspace size limit.
Referenced by addToSpace(), increaseSubspaceLimit(), LR::SetOfEqSolver::increaseSubspaceLimit(), LR::EigenSolver::increaseSubspaceLimit(), and solve().
|
staticprotected |
default limit for subspace size
|
protected |
number of basis functions
Referenced by ao2mo(), computeExactE2Diag(), LR::EigenSolver::computeMoments(), LR::EigenSolver::EigenSolver(), LR::EigenSolver::getInitialGuess(), lintrans(), load_F_MO(), LRSolver(), mo2ao(), operToVec(), setE2diag(), and LR::SetOfEqSolver::setRHS().
|
protected |
number of occupied orbitals
Referenced by computeExactE2Diag(), LR::EigenSolver::computeMoments(), LR::EigenSolver::EigenSolver(), LR::EigenSolver::getInitialGuess(), lintrans(), LRSolver(), operToVec(), setE2diag(), and LR::SetOfEqSolver::setRHS().
|
protected |
S[2] matrix projected onto subspace.
Referenced by addToSpace(), LR::SetOfEqSolver::getResidual(), LR::EigenSolver::getResidual(), and increaseSubspaceLimit().
|
protected |
current subspace size
Referenced by addToSpace(), LR::SetOfEqSolver::addToSpace(), buildVector(), LR::EigenSolver::computeMoments(), getAvMinusFreqSv(), LR::SetOfEqSolver::getResidual(), LR::EigenSolver::getResidual(), LR::SetOfEqSolver::multiplyXtimesVec(), projectOnSubspace(), and solve().
|
protected |
base vectors
Referenced by addToSpace(), LR::SetOfEqSolver::addToSpace(), buildVector(), getAvMinusFreqSv(), increaseSubspaceLimit(), projectOnSubspace(), and solve().
|
protected |
solution vector projected onto subspace
Referenced by LR::SetOfEqSolver::getResidual(), increaseSubspaceLimit(), LR::SetOfEqSolver::multiplyXtimesVec(), and ~LRSolver().