Go to the documentation of this file.
38 #if !defined(SLR_HEADER)
50 template<
bool MultByS,
bool SwapXY>
107 void print(
const char *comment = NULL) {
108 if(comment) puts(comment);
109 for(
int i=0; i<
nvar*2; i++) printf(
"%15.10f\n", (
double)
v[i]);
116 for(
int i=0; i<2*
nvar; i++)
v[i] = scalar;
121 if(
this == &b)
return *
this;
127 memcpy(
v, b.
v, 2*
nvar*
sizeof(
v[0]));
134 if (&proxy.
vec ==
this)
135 throw "VarVector self-assignment not-implemented";
142 for(
int i=0; i<2*
nvar; i++)
149 if (&proxy.
vec ==
this)
150 throw "VarVector self-assignment not-implemented";
156 for(
int i=0; i<
nvar; i++) {
165 void load(
const char* tmpdir);
167 void save(
const char* tmpdir);
169 void release(
const char* tmpdir);
void releaseAll()
Release all vectors from the memory, saving if necessary.
Definition: slr.cc:356
void symorth(void)
Uses symmetric orthogonalization to orthonormalize itself (x y) with the swapped vector (y x).
Definition: slr.cc:466
Treal template_blas_sqrt(Treal x)
virtual ~SetOfEqSolver()
Definition: slr.h:350
Functionality for solving linear equation systems.
void mo2ao(int nbast, const ergo_real *mo, ergo_real *ao) const
Definition: slr.cc:604
RowProxy(ergo_real *r)
Definition: slr.h:229
void computeExactE2Diag(E2Evaluator &e2)
Definition: slr.cc:788
unsigned currentAge
Definition: slr.h:192
Definition of the main floating-point datatype used; the ergo_real type.
int size() const
Definition: slr.h:106
static const int MVEC
default limit for subspace size
Definition: slr.h:285
virtual int getInitialGuess(VarVectorCollection &vecs)
generate the starting guess for the HOMO-LUMO excitation by placing one in th the right position.
Definition: slr.cc:1192
void setRHS(OneElOperator &op)
initializes the rhs field
Definition: slr.cc:1008
VarVector & operator=(ergo_real scalar)
Definition: slr.h:115
ergo_real * x() const
return the X part of the vector.
Definition: slr.h:94
void buildVector(const ergo_real *w, VarVector &full)
Build full fector from the reduced form.
Definition: slr.cc:889
ergo_real getPolarisability(OneElOperator &oper)
computes polarizability by contracting the response vector with specified operator
Definition: slr.cc:1039
VarVector()
Definition: slr.h:79
char * fName
Present in secondary storage (i.e.
Definition: slr.h:65
int nvar
nvar := nocc*nvirt.
Definition: slr.h:67
void getAvMinusFreqSv(ergo_real f, ergo_real *weights, VarVector &r)
Computes a vector built of base vectors with specified vectors.
Definition: slr.cc:852
Vector of variables parametrising the solution to the linear response equations.
Definition: slr.h:62
int nVecs
Definition: slr.h:193
#define LOG_CAT_ERROR
Definition: output.h:47
unsigned inMemory
valid representation in memory
Definition: slr.h:69
VarVector e2diag
approximation to the diagonal of E2 operator
Definition: slr.h:286
ergo_real * rhsSub
RHS vector projected onto subspace.
Definition: slr.h:358
void expand(int newSize)
increase the dimension of the matrix without losing the data.
Definition: slr.cc:374
virtual bool getResidual(VarVectorCollection &residualv)
get residual of the eigenvalue problem.
Definition: slr.cc:1058
int maxSubspaceSize
current subspace size limit.
Definition: slr.h:283
static void gemm(int n, const char *at, const ergo_real *a, const char *bt, const ergo_real *b, ergo_real alpha, ergo_real beta, ergo_real *c)
Definition: slr.cc:584
virtual ~E2Evaluator()
Definition: slr.h:184
double ergo_real
Definition: realtype.h:69
const VarVectorProxyOp< true, false > sTimes(const VarVector &arg)
returns a proxy object corresponding to a vector multiplied by S[2], i.e.
Definition: slr.cc:207
virtual bool transform(const ergo_real *dmat, ergo_real *fmat)=0
const VarVector & vec
Definition: slr.h:53
void release()
Make sure there is space for one vector.
Definition: slr.cc:330
void computeMoments(OneElOperator &dipx, OneElOperator &dipy, OneElOperator &dipz)
Definition: slr.cc:1226
VarVector * vecs
Definition: slr.h:190
int nbast
number of basis functions
Definition: slr.h:315
~VarVector()
Definition: slr.h:87
void print(const char *comment=NULL)
Definition: slr.h:107
ergo_real scalar
Definition: slr.h:54
int size() const
Definition: slr.h:204
static void ggev(const char *jobbl, const char *jobvr, const int *n, T *A, const int *lda, T *B, const int *ldb, T *alphar, T *alphai, T *beta, T *vl, const int *ldvl, T *vr, const int *ldvr, T *work, const int *lwork, int *info)
Definition: mat_gblas.h:301
VarVector & operator=(const VarVector &b)
Definition: slr.h:120
ergo_real multiplyXtimesVec(const VarVector &rhs)
multiplies current solution by some vector.
Definition: slr.cc:950
virtual ergo_real getPreconditionerShift(int i) const =0
returns the preconditioning shift.
#define LOG_AREA_LR
Definition: output.h:59
virtual ergo_real getPreconditionerShift(int) const
returns the preconditioning shift.
Definition: slr.h:351
VarVector & operator=(const VarVectorProxyOp< false, false > &proxy)
Definition: slr.h:133
bool diskMode
Definition: slr.h:195
E2Evaluator interface provides a way to perform a linear transformation of supplied transition densit...
Definition: slr.h:181
SmallMatrix sSub
S[2] matrix projected onto subspace.
Definition: slr.h:289
SmallMatrix eSub
E[2] matrix projected onto subspace.
Definition: slr.h:288
Iterative Eigenvalue solver, extending the generic LRSolver.
Definition: slr.h:367
ergo_real & operator[](int j) const
Definition: slr.h:230
Treal template_blas_fabs(Treal x)
Contains a Simple Linear Response implementation based on the MO orbital picture.
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.
Definition: slr.cc:804
static void commute(int nbast, const ergo_real *a, const ergo_real *b, ergo_real f, ergo_real *res)
res := f*res + [a, b]
Definition: slr.cc:595
friend ergo_real operator*(const VarVector &a, const VarVector &b)
Definition: slr.cc:101
virtual void increaseSubspaceLimit(int newSize)
expands above the default limit
Definition: slr.cc:996
SmallMatrix(int sz)
Definition: slr.h:235
a collection of vectors, usually handled at once.
Definition: slr.h:189
const VarVectorProxyOp< false, true > swapXY(const VarVector &arg)
returns a proxy object corresponding to a swapped vector.
Definition: slr.cc:200
ergo_real * mat
Definition: slr.h:224
void ao2mo(int nbast, const ergo_real *ao, ergo_real *mo) const
computes mo := cmo'*ao*cmo
Definition: slr.cc:615
VarVector & operator[](int i)
Definition: slr.cc:319
void setSize(int sz)
Definition: slr.cc:309
VarVector & operator+=(VarVector &a, const VarVectorProxyOp< false, false > &proxy)
Definition: slr.cc:152
void save(const char *tmpdir)
Save the object.
Definition: slr.cc:250
ergo_real * cmo
the MO coefficients.
Definition: slr.h:328
int nConverged
number of already converged eigenvalues
Definition: slr.h:371
a class implementing dynamic resized two dimensional arrays.
Definition: slr.h:223
void projectOnSubspace(const VarVector &full, ergo_real *w)
Projects vector.
Definition: slr.cc:876
ergo_real xTimesRHS
Definition: slr.h:361
ergo_real operator*(const VarVector &a, const VarVector &b)
Definition: slr.cc:101
virtual ~OneElOperator()
Definition: slr.h:219
VarVector(const VarVector &a)
Definition: slr.h:71
static void gemm(const char *ta, const char *tb, const int *n, const int *k, const int *l, const T *alpha, const T *A, const int *lda, const T *B, const int *ldb, const T *beta, T *C, const int *ldc)
Definition: mat_gblas.h:232
ergo_real getTransitionMoment2(int i) const
Definition: slr.h:400
virtual bool getResidual(VarVectorCollection &residualv)
get the residual of the set of linear equations.
Definition: slr.cc:967
void setFull(int nbast, int nocc, ergo_real *full_mat) const
Definition: slr.cc:433
SetOfEqSolver(int nbast, int nocc, const ergo_real *fock_matrix, const ergo_real *s, ergo_real freq)
Creates the set-of-equations solver.
Definition: slr.h:343
~SmallMatrix()
Definition: slr.h:236
int nAllocated
Definition: slr.h:194
void operToVec(OneElOperator &oper, VarVector &res) const
Transform square operator to the vector form.
Definition: slr.cc:902
ergo_real * v
vector coefficients
Definition: slr.h:63
void print(int area, const char *routine)
Definition: utilities.h:111
ergo_real dot(int len, const ergo_real *a, const ergo_real *b)
returns dot_product(a, b)
Definition: slr.cc:93
ergo_real * ritzVals
recent ritz values in the subspace.
Definition: slr.h:368
int nocc
number of occupied orbitals
Definition: slr.h:316
Basic OS access utilities.
Definition: allocate.cc:39
#define LOG_CAT_INFO
Definition: output.h:49
virtual void increaseSubspaceLimit(int newSize)
expands above the default limit
Definition: slr.cc:735
virtual int getInitialGuess(VarVectorCollection &vecs)
returns the initial guess for the linear set of equations.
Definition: slr.cc:926
#define UNIT_one_eV
Definition: units.h:45
VarVectorProxyOp(const VarVector &a, ergo_real s=1.0)
Definition: slr.h:55
int solve_linear_equation_system(int n, const ergo_real *matrix, const ergo_real *RHS, ergo_real *resultVector)
Definition: solve_lin_eq_syst.cc:43
ergo_real * fdiag
the eigenvalues of the Fock matrix.
Definition: slr.h:326
virtual void addToSpace(VarVectorCollection &vecs, E2Evaluator &e2)
extends the subspace with v and its transformed vector Av.
Definition: slr.cc:1022
bool solve(E2Evaluator &e, bool diskMode=false)
Solves the problem defined by the subclass.
Definition: slr.cc:753
virtual int getInitialGuess(VarVectorCollection &vecs)=0
Computes the initial vector the subspace is to be seeded with.
VarVector rhs
RHS of the SOE.
Definition: slr.h:339
bool getDiskMode() const
Definition: slr.h:205
Abstract interface to a one electron operator.
Definition: slr.h:216
Constants for conversion between units for some common units like Angstrom, electron-volt (eV),...
VarVectorCollection vects
base vectors
Definition: slr.h:317
void load_F_MO(ergo_real *fmat) const
Definition: slr.cc:625
ergo_real * xSub
solution vector projected onto subspace
Definition: slr.h:290
Linear Response iterative solver using a variant of the Davidson method.
Definition: slr.h:247
bool lintrans(E2Evaluator &e2, const VarVector &v, VarVector &Av) const
performs the linear transformation of the vector with E[2] operator.
Definition: slr.cc:707
static void precondition(VarVector &v, const VarVector &e2diag, ergo_real shift)
pre-condition a vector given an approximation of the E[2] operator diagonal and a shift of the S[2] o...
Definition: slr.cc:498
static void sygv(const int *itype, const char *jobz, const char *uplo, const int *n, T *A, const int *lda, T *B, const int *ldb, T *w, T *work, const int *lwork, int *info)
Definition: mat_gblas.h:293
unsigned onDisk
valid representation on disk
Definition: slr.h:68
const RowProxy operator[](int i)
Definition: slr.h:237
ergo_real getFreq(int i) const
Definition: slr.h:396
static void commuteWithDMO(int nbast, int nocc, ergo_real *mat)
mat := [mat, D_MO]
Definition: slr.cc:513
VarVector & operator=(const VarVectorProxyOp< false, true > &proxy)
Definition: slr.h:148
virtual ~EigenSolver()
Definition: slr.h:383
virtual void increaseSubspaceLimit(int newSize)
expands above the default limit
Definition: slr.cc:1173
ergo_real * last_ev
most recent eigenvectors in the reduced space
Definition: slr.h:372
VarVectorCollection(int nSize=0)
Definition: slr.h:197
EigenSolver(int nbast, int nocc, const ergo_real *fock_matrix, const ergo_real *overlap, int n)
Definition: slr.h:374
int nStates
number of excited states to compute
Definition: slr.h:370
template based proxy object that uses bool-valued policies to perform the assignments.
Definition: slr.h:51
int nsize
Definition: slr.h:225
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.
Definition: slr.cc:389
Iterative Set Of Linear Equations solver, extending the generic LRSolver.
Definition: slr.h:337
unsigned * ages
Definition: slr.h:191
ergo_real * y() const
returns the Y part.
Definition: slr.h:95
void release(const char *tmpdir)
Releases the memory, saving if necessary.
Definition: slr.cc:286
virtual void getOper(ergo_real *result)=0
ergo_real * transMoms2
most recent SQUARED transition moments.
Definition: slr.h:369
ergo_real & operator[](int i)
Definition: slr.h:114
ergo_real frequency
frequency for which the SOE is to be solved.
Definition: slr.h:338
void load(const char *tmpdir)
Load the object to memory.
Definition: slr.cc:219
const ergo_real & operator[](int i) const
Definition: slr.h:113
static const char * tmpdir
Definition: slr.h:211
void do_output(int logCategory, int logArea, const char *format,...)
Definition: output.cc:53
~VarVectorCollection()
Definition: slr.cc:302
ergo_real convThreshold
iterative method convergence threshold
Definition: slr.h:282
virtual ergo_real getPreconditionerShift(int i) const
returns the preconditioning shift.
Definition: slr.h:388
void setDiskMode(bool x)
Definition: slr.h:206
void setFromFull(int nbast, int nocc, const ergo_real *full_mat)
Definition: slr.cc:404
void setSize(int n)
Definition: slr.h:97
VarVectorCollection Avects
vects and Avects members store the trial vectors and their transformed versions.
Definition: slr.h:325
virtual bool getResidual(VarVectorCollection &residualv)=0
Computes the residual vector.
Time-measuring class.
Definition: utilities.h:80
virtual ~LRSolver()
Definition: slr.h:253
virtual void addToSpace(VarVectorCollection &vecs, E2Evaluator &e2)
extends the subspace with v and its transformed vector Av.
Definition: slr.cc:641
Functionality for writing output messages to a text file.
ergo_real * toprow
Definition: slr.h:228
VarVector(int nbast, int nocc, const ergo_real *full_mat)
Creates a vector from a full matrix.
Definition: slr.h:82
int subspaceSize
current subspace size
Definition: slr.h:287