ergo
slr.h
Go to the documentation of this file.
1 /* Ergo, version 3.8, a program for linear scaling electronic structure
2  * calculations.
3  * Copyright (C) 2019 Elias Rudberg, Emanuel H. Rubensson, Pawel Salek,
4  * and Anastasia Kruchinina.
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  *
19  * Primary academic reference:
20  * Ergo: An open-source program for linear-scaling electronic structure
21  * calculations,
22  * Elias Rudberg, Emanuel H. Rubensson, Pawel Salek, and Anastasia
23  * Kruchinina,
24  * SoftwareX 7, 107 (2018),
25  * <http://dx.doi.org/10.1016/j.softx.2018.03.005>
26  *
27  * For further information about Ergo, see <http://www.ergoscf.org>.
28  */
29 
38 #if !defined(SLR_HEADER)
39 #define SLR_HEADER
40 /* Copyright(c) Pawel Salek 2006. */
41 
42 #include <unistd.h>
43 
44 #include "realtype.h"
45 
46 namespace LR {
47 class VarVector;
50 template<bool MultByS,bool SwapXY>
52  public:
53  const VarVector& vec;
55  explicit VarVectorProxyOp(const VarVector& a, ergo_real s=1.0) : vec(a), scalar(s) {}
56 };
57 
58 
62 class VarVector {
64  public:
65  char *fName;
67  int nvar;
68  unsigned onDisk:1;
69  unsigned inMemory:1;
71  VarVector(const VarVector& a) : fName(NULL), nvar(a.nvar),
72  onDisk(0), inMemory(1) {
73  if(nvar) {
74  v = new ergo_real[nvar*2];
75  memcpy(v, a.v, 2*nvar*sizeof(ergo_real));
76  } else v = NULL;
77  }
78 
79  VarVector() : v(NULL), fName(NULL), nvar(0), onDisk(0), inMemory(1) {}
80 
82  VarVector(int nbast, int nocc, const ergo_real *full_mat)
83  : v(NULL), fName(NULL), nvar(0), onDisk(0), inMemory(1) {
84  setFromFull(nbast, nocc, full_mat);
85  }
86 
88  if(v) delete v;
89  if(fName) {
90  unlink(fName);
91  delete fName;
92  }
93 }
94  ergo_real* x() const { return v; }
95  ergo_real* y() const { return v + nvar; }
96  void symorth(void);
97  void setSize(int n) {
98  if(nvar != n) {
99  if(v)
100  delete v;
101  v = new ergo_real[2*n];
102  nvar = n;
103  onDisk = 0;
104  }
105  }
106  int size() const { return nvar; }
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]);
110  }
111  void setFromFull(int nbast, int nocc, const ergo_real *full_mat);
112  void setFull(int nbast, int nocc, ergo_real *full_mat) const;
113  const ergo_real& operator[](int i) const { return v[i]; }
114  ergo_real& operator[](int i) { return v[i]; }
116  for(int i=0; i<2*nvar; i++) v[i] = scalar;
117  onDisk = 0;
118  return *this;
119  };
121  if(this == &b) return *this;
122  if(nvar != b.nvar) {
123  nvar = b.nvar;
124  if(v) delete v;
125  v = new ergo_real[2*nvar];
126  }
127  memcpy(v, b.v, 2*nvar*sizeof(v[0]));
128  onDisk = 0;
129  return *this;
130  }
131 
132  VarVector&
134  if (&proxy.vec == this)
135  throw "VarVector self-assignment not-implemented";
136  if(nvar != proxy.vec.nvar) {
137  if(v) delete v;
138  nvar = proxy.vec.nvar;
139  v = new ergo_real[2*nvar];
140  }
141 
142  for(int i=0; i<2*nvar; i++)
143  v[i] = proxy.scalar*proxy.vec[i];
144  onDisk = 0;
145  return *this;
146  }
147  VarVector&
149  if (&proxy.vec == this)
150  throw "VarVector self-assignment not-implemented";
151  if(nvar != proxy.vec.nvar) {
152  if(v) delete v;
153  nvar = proxy.vec.nvar;
154  v = new ergo_real[2*nvar];
155  }
156  for(int i=0; i<nvar; i++) {
157  v[i] = proxy.scalar*proxy.vec[i+nvar];
158  v[i+nvar] = proxy.scalar*proxy.vec[i];
159  }
160  onDisk = 0;
161  return *this;
162  }
163 
165  void load(const char* tmpdir);
167  void save(const char* tmpdir);
169  void release(const char* tmpdir);
170 
171  friend ergo_real operator*(const VarVector& a, const VarVector& b);
172  friend ergo_real operator*(const VarVector &a,
174  friend ergo_real operator*(const VarVector &a,
176 };
177 
181 class E2Evaluator {
182  public:
183  virtual bool transform(const ergo_real *dmat, ergo_real *fmat) = 0;
184  virtual ~E2Evaluator() {}
185 };
186 
187 /* ################################################################### */
191  unsigned *ages;
192  unsigned currentAge;
193  int nVecs;
195  bool diskMode;
196  public:
197  explicit VarVectorCollection(int nSize=0) : vecs(NULL), ages(NULL), currentAge(0),
198  nVecs(0), nAllocated(0), diskMode(false) {
199  if(nSize) setSize(nSize);
200  }
202  void setSize(int sz);
203  VarVector& operator[](int i);
204  int size() const { return nVecs; }
205  bool getDiskMode() const { return diskMode; }
206  void setDiskMode(bool x) { diskMode = x; }
208  void release();
210  void releaseAll();
211  static const char *tmpdir;
212 };
213 
214 /* ################################################################### */
217  public:
218  virtual void getOper(ergo_real *result) = 0;
219  virtual ~OneElOperator() {}
220 };
221 
223 class SmallMatrix {
225  int nsize;
226  protected:
227  struct RowProxy {
229  explicit RowProxy(ergo_real *r) : toprow(r) {}
230  ergo_real& operator[](int j) const {
231  //printf(" returning row %i -> %p\n", j, toprow + j);
232  return toprow[j]; }
233  };
234  public:
235  explicit SmallMatrix(int sz) : mat(new ergo_real[sz*sz]), nsize(sz) {}
236  ~SmallMatrix() { delete [] mat; }
237  const RowProxy operator[](int i) {
238  //printf("Returning column %i -> %p\n", i, mat + i*nsize);
239  return RowProxy(mat + i*nsize); }
240  void expand(int newSize);
241 };
242 
243 
244 /* ################################################################### */
247 class LRSolver {
248  public:
249 
250  LRSolver(int nbast, int nocc,
251  const ergo_real *fock_matrix,
252  const ergo_real *s);
253  virtual ~LRSolver() {/* FIXME: delete esub etc */
254  if(cmo) delete cmo;
255  if(fdiag) delete fdiag;
256  delete [] xSub;
257  }
258 
265  virtual bool getResidual(VarVectorCollection& residualv) = 0;
266 
270  virtual int getInitialGuess(VarVectorCollection& vecs) = 0;
271 
274  virtual ergo_real getPreconditionerShift(int i) const = 0;
275 
277  virtual void increaseSubspaceLimit(int newSize);
278 
280  bool solve(E2Evaluator& e, bool diskMode = false);
284  protected:
285  static const int MVEC = 200;
294  void getAvMinusFreqSv(ergo_real f, ergo_real *weights,
295  VarVector& r);
296 
301  void projectOnSubspace(const VarVector& full, ergo_real *w)/* const*/;
303  void buildVector(const ergo_real *w, VarVector& full) /* const */;
304 
306  void operToVec(OneElOperator& oper, VarVector& res) const;
307 
311  ergo_real setE2diag(int nbast, int nocc,
312  const ergo_real *fock_matrix,
313  const ergo_real *s);
314 
315  int nbast;
316  int nocc;
318  virtual void addToSpace(VarVectorCollection& vecs, E2Evaluator& e2);
319  void mo2ao(int nbast, const ergo_real *mo, ergo_real *ao) const;
320  void ao2mo(int nbast, const ergo_real *ao, ergo_real *mo) const;
321  private:
330  void load_F_MO(ergo_real *fmat) const;
331  bool lintrans(E2Evaluator& e2, const VarVector& v, VarVector& Av) const;
332 };
333 
334 /* ################################################################### */
337 class SetOfEqSolver : public LRSolver {
340  public:
344  const ergo_real *fock_matrix,
345  const ergo_real *s,
346  ergo_real freq)
347  : LRSolver(nbast, nocc, fock_matrix, s), frequency(freq),
348  rhsSub(new ergo_real[MVEC]) {};
349  void setRHS(OneElOperator& op);
350  virtual ~SetOfEqSolver() { delete [] rhsSub; }
351  virtual ergo_real getPreconditionerShift(int) const { return frequency; }
352  virtual int getInitialGuess(VarVectorCollection& vecs);
353  virtual bool getResidual(VarVectorCollection& residualv);
355  virtual void increaseSubspaceLimit(int newSize);
356  ergo_real getPolarisability(OneElOperator& oper) /* const */;
357  protected:
359  virtual void addToSpace(VarVectorCollection& vecs, E2Evaluator& e2);
360  ergo_real multiplyXtimesVec(const VarVector& rhs) /* const */;
362 };
363 
364 
365 /* ################################################################### */
367 class EigenSolver : public LRSolver {
370  int nStates;
373  public:
375  const ergo_real *fock_matrix,
376  const ergo_real *overlap, int n)
377  : LRSolver(nbast, nocc, NULL, NULL),
379  nStates(n), nConverged(0), last_ev(NULL) {
380  ritzVals[0] = setE2diag(nbast, nocc, fock_matrix, overlap);
381  for(int i=1; i<n; i++) ritzVals[i] = ritzVals[0];
382  }
383  virtual ~EigenSolver() {
384  if(last_ev) delete last_ev;
385  delete [] ritzVals;
386  delete [] transMoms2;
387  }
388  virtual ergo_real getPreconditionerShift(int i) const {
389  return ritzVals[nConverged+i];
390  }
391  virtual int getInitialGuess(VarVectorCollection& vecs);
392  virtual bool getResidual(VarVectorCollection& residualv);
394  virtual void increaseSubspaceLimit(int newSize);
395 
396  ergo_real getFreq(int i) const { return ritzVals[i]; }
397  void computeMoments(OneElOperator& dipx,
398  OneElOperator& dipy,
399  OneElOperator& dipz);
400  ergo_real getTransitionMoment2(int i) const { return transMoms2[i]; }
401 };
402 
403 } /* End of namespace LR */
404 #endif /* !defined(SLR_HEADER) */
LR::VarVectorCollection::releaseAll
void releaseAll()
Release all vectors from the memory, saving if necessary.
Definition: slr.cc:356
LR::VarVector::symorth
void symorth(void)
Uses symmetric orthogonalization to orthonormalize itself (x y) with the swapped vector (y x).
Definition: slr.cc:466
template_blas_sqrt
Treal template_blas_sqrt(Treal x)
LR::SetOfEqSolver::~SetOfEqSolver
virtual ~SetOfEqSolver()
Definition: slr.h:350
solve_lin_eq_syst.h
Functionality for solving linear equation systems.
LR::LRSolver::mo2ao
void mo2ao(int nbast, const ergo_real *mo, ergo_real *ao) const
Definition: slr.cc:604
LR::SmallMatrix::RowProxy::RowProxy
RowProxy(ergo_real *r)
Definition: slr.h:229
LR::LRSolver::computeExactE2Diag
void computeExactE2Diag(E2Evaluator &e2)
Definition: slr.cc:788
LR::VarVectorCollection::currentAge
unsigned currentAge
Definition: slr.h:192
realtype.h
Definition of the main floating-point datatype used; the ergo_real type.
LR::VarVector::size
int size() const
Definition: slr.h:106
LR::LRSolver::MVEC
static const int MVEC
default limit for subspace size
Definition: slr.h:285
LR::EigenSolver::getInitialGuess
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
LR::SetOfEqSolver::setRHS
void setRHS(OneElOperator &op)
initializes the rhs field
Definition: slr.cc:1008
LR::VarVector::operator=
VarVector & operator=(ergo_real scalar)
Definition: slr.h:115
LR::VarVector::x
ergo_real * x() const
return the X part of the vector.
Definition: slr.h:94
LR::LRSolver::buildVector
void buildVector(const ergo_real *w, VarVector &full)
Build full fector from the reduced form.
Definition: slr.cc:889
LR::SetOfEqSolver::getPolarisability
ergo_real getPolarisability(OneElOperator &oper)
computes polarizability by contracting the response vector with specified operator
Definition: slr.cc:1039
LR::VarVector::VarVector
VarVector()
Definition: slr.h:79
LR::VarVector::fName
char * fName
Present in secondary storage (i.e.
Definition: slr.h:65
LR::VarVector::nvar
int nvar
nvar := nocc*nvirt.
Definition: slr.h:67
LR::LRSolver::getAvMinusFreqSv
void getAvMinusFreqSv(ergo_real f, ergo_real *weights, VarVector &r)
Computes a vector built of base vectors with specified vectors.
Definition: slr.cc:852
LR::VarVector
Vector of variables parametrising the solution to the linear response equations.
Definition: slr.h:62
LR::VarVectorCollection::nVecs
int nVecs
Definition: slr.h:193
LOG_CAT_ERROR
#define LOG_CAT_ERROR
Definition: output.h:47
LR::VarVector::inMemory
unsigned inMemory
valid representation in memory
Definition: slr.h:69
LR::LRSolver::e2diag
VarVector e2diag
approximation to the diagonal of E2 operator
Definition: slr.h:286
LR::SetOfEqSolver::rhsSub
ergo_real * rhsSub
RHS vector projected onto subspace.
Definition: slr.h:358
LR::SmallMatrix::expand
void expand(int newSize)
increase the dimension of the matrix without losing the data.
Definition: slr.cc:374
LR::EigenSolver::getResidual
virtual bool getResidual(VarVectorCollection &residualv)
get residual of the eigenvalue problem.
Definition: slr.cc:1058
LR::LRSolver::maxSubspaceSize
int maxSubspaceSize
current subspace size limit.
Definition: slr.h:283
LR::gemm
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
LR::E2Evaluator::~E2Evaluator
virtual ~E2Evaluator()
Definition: slr.h:184
ergo_real
double ergo_real
Definition: realtype.h:69
LR::sTimes
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
LR::E2Evaluator::transform
virtual bool transform(const ergo_real *dmat, ergo_real *fmat)=0
LR::VarVectorProxyOp::vec
const VarVector & vec
Definition: slr.h:53
LR::VarVectorCollection::release
void release()
Make sure there is space for one vector.
Definition: slr.cc:330
LR::EigenSolver::computeMoments
void computeMoments(OneElOperator &dipx, OneElOperator &dipy, OneElOperator &dipz)
Definition: slr.cc:1226
LR::VarVectorCollection::vecs
VarVector * vecs
Definition: slr.h:190
LR::LRSolver::nbast
int nbast
number of basis functions
Definition: slr.h:315
LR::VarVector::~VarVector
~VarVector()
Definition: slr.h:87
LR::VarVector::print
void print(const char *comment=NULL)
Definition: slr.h:107
LR::VarVectorProxyOp::scalar
ergo_real scalar
Definition: slr.h:54
LR::VarVectorCollection::size
int size() const
Definition: slr.h:204
mat::ggev
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
LR::VarVector::operator=
VarVector & operator=(const VarVector &b)
Definition: slr.h:120
LR::SetOfEqSolver::multiplyXtimesVec
ergo_real multiplyXtimesVec(const VarVector &rhs)
multiplies current solution by some vector.
Definition: slr.cc:950
LR::LRSolver::getPreconditionerShift
virtual ergo_real getPreconditionerShift(int i) const =0
returns the preconditioning shift.
LOG_AREA_LR
#define LOG_AREA_LR
Definition: output.h:59
mat_gblas.h
LR::SetOfEqSolver::getPreconditionerShift
virtual ergo_real getPreconditionerShift(int) const
returns the preconditioning shift.
Definition: slr.h:351
LR::VarVector::operator=
VarVector & operator=(const VarVectorProxyOp< false, false > &proxy)
Definition: slr.h:133
LR::VarVectorCollection::diskMode
bool diskMode
Definition: slr.h:195
LR::E2Evaluator
E2Evaluator interface provides a way to perform a linear transformation of supplied transition densit...
Definition: slr.h:181
LR::LRSolver::sSub
SmallMatrix sSub
S[2] matrix projected onto subspace.
Definition: slr.h:289
LR::LRSolver::eSub
SmallMatrix eSub
E[2] matrix projected onto subspace.
Definition: slr.h:288
LR::EigenSolver
Iterative Eigenvalue solver, extending the generic LRSolver.
Definition: slr.h:367
LR::SmallMatrix::RowProxy::operator[]
ergo_real & operator[](int j) const
Definition: slr.h:230
template_blas_fabs
Treal template_blas_fabs(Treal x)
slr.h
Contains a Simple Linear Response implementation based on the MO orbital picture.
LR::LRSolver::setE2diag
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
LR::commute
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
LR::VarVector::operator*
friend ergo_real operator*(const VarVector &a, const VarVector &b)
Definition: slr.cc:101
LR::SetOfEqSolver::increaseSubspaceLimit
virtual void increaseSubspaceLimit(int newSize)
expands above the default limit
Definition: slr.cc:996
LR::SmallMatrix::SmallMatrix
SmallMatrix(int sz)
Definition: slr.h:235
LR::VarVectorCollection
a collection of vectors, usually handled at once.
Definition: slr.h:189
LR::swapXY
const VarVectorProxyOp< false, true > swapXY(const VarVector &arg)
returns a proxy object corresponding to a swapped vector.
Definition: slr.cc:200
LR::SmallMatrix::mat
ergo_real * mat
Definition: slr.h:224
LR::LRSolver::ao2mo
void ao2mo(int nbast, const ergo_real *ao, ergo_real *mo) const
computes mo := cmo'*ao*cmo
Definition: slr.cc:615
LR::VarVectorCollection::operator[]
VarVector & operator[](int i)
Definition: slr.cc:319
LR::VarVectorCollection::setSize
void setSize(int sz)
Definition: slr.cc:309
LR::operator+=
VarVector & operator+=(VarVector &a, const VarVectorProxyOp< false, false > &proxy)
Definition: slr.cc:152
LR::VarVector::save
void save(const char *tmpdir)
Save the object.
Definition: slr.cc:250
LR::LRSolver::cmo
ergo_real * cmo
the MO coefficients.
Definition: slr.h:328
LR::EigenSolver::nConverged
int nConverged
number of already converged eigenvalues
Definition: slr.h:371
LR::SmallMatrix
a class implementing dynamic resized two dimensional arrays.
Definition: slr.h:223
LR::LRSolver::projectOnSubspace
void projectOnSubspace(const VarVector &full, ergo_real *w)
Projects vector.
Definition: slr.cc:876
LR::SetOfEqSolver::xTimesRHS
ergo_real xTimesRHS
Definition: slr.h:361
LR::operator*
ergo_real operator*(const VarVector &a, const VarVector &b)
Definition: slr.cc:101
LR::OneElOperator::~OneElOperator
virtual ~OneElOperator()
Definition: slr.h:219
LR::VarVector::VarVector
VarVector(const VarVector &a)
Definition: slr.h:71
mat::gemm
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
LR::EigenSolver::getTransitionMoment2
ergo_real getTransitionMoment2(int i) const
Definition: slr.h:400
LR::SetOfEqSolver::getResidual
virtual bool getResidual(VarVectorCollection &residualv)
get the residual of the set of linear equations.
Definition: slr.cc:967
LR::VarVector::setFull
void setFull(int nbast, int nocc, ergo_real *full_mat) const
Definition: slr.cc:433
LR::SetOfEqSolver::SetOfEqSolver
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
LR::SmallMatrix::~SmallMatrix
~SmallMatrix()
Definition: slr.h:236
LR::VarVectorCollection::nAllocated
int nAllocated
Definition: slr.h:194
LR::LRSolver::operToVec
void operToVec(OneElOperator &oper, VarVector &res) const
Transform square operator to the vector form.
Definition: slr.cc:902
LR::VarVector::v
ergo_real * v
vector coefficients
Definition: slr.h:63
Util::TimeMeter::print
void print(int area, const char *routine)
Definition: utilities.h:111
LR::dot
ergo_real dot(int len, const ergo_real *a, const ergo_real *b)
returns dot_product(a, b)
Definition: slr.cc:93
LR::EigenSolver::ritzVals
ergo_real * ritzVals
recent ritz values in the subspace.
Definition: slr.h:368
LR::LRSolver::nocc
int nocc
number of occupied orbitals
Definition: slr.h:316
utilities.h
Basic OS access utilities.
mat
Definition: allocate.cc:39
A
#define A
LOG_CAT_INFO
#define LOG_CAT_INFO
Definition: output.h:49
LR::LRSolver::increaseSubspaceLimit
virtual void increaseSubspaceLimit(int newSize)
expands above the default limit
Definition: slr.cc:735
LR::SetOfEqSolver::getInitialGuess
virtual int getInitialGuess(VarVectorCollection &vecs)
returns the initial guess for the linear set of equations.
Definition: slr.cc:926
UNIT_one_eV
#define UNIT_one_eV
Definition: units.h:45
LR::VarVectorProxyOp::VarVectorProxyOp
VarVectorProxyOp(const VarVector &a, ergo_real s=1.0)
Definition: slr.h:55
solve_linear_equation_system
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
LR::LRSolver::fdiag
ergo_real * fdiag
the eigenvalues of the Fock matrix.
Definition: slr.h:326
LR::SetOfEqSolver::addToSpace
virtual void addToSpace(VarVectorCollection &vecs, E2Evaluator &e2)
extends the subspace with v and its transformed vector Av.
Definition: slr.cc:1022
LR::LRSolver::solve
bool solve(E2Evaluator &e, bool diskMode=false)
Solves the problem defined by the subclass.
Definition: slr.cc:753
LR::LRSolver::getInitialGuess
virtual int getInitialGuess(VarVectorCollection &vecs)=0
Computes the initial vector the subspace is to be seeded with.
LR::SetOfEqSolver::rhs
VarVector rhs
RHS of the SOE.
Definition: slr.h:339
LR::VarVectorCollection::getDiskMode
bool getDiskMode() const
Definition: slr.h:205
LR::OneElOperator
Abstract interface to a one electron operator.
Definition: slr.h:216
units.h
Constants for conversion between units for some common units like Angstrom, electron-volt (eV),...
LR::LRSolver::vects
VarVectorCollection vects
base vectors
Definition: slr.h:317
LR::LRSolver::load_F_MO
void load_F_MO(ergo_real *fmat) const
Definition: slr.cc:625
LR::LRSolver::xSub
ergo_real * xSub
solution vector projected onto subspace
Definition: slr.h:290
LR::LRSolver
Linear Response iterative solver using a variant of the Davidson method.
Definition: slr.h:247
LR::LRSolver::lintrans
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
LR::precondition
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
mat::sygv
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
LR::VarVector::onDisk
unsigned onDisk
valid representation on disk
Definition: slr.h:68
LR::SmallMatrix::operator[]
const RowProxy operator[](int i)
Definition: slr.h:237
LR::EigenSolver::getFreq
ergo_real getFreq(int i) const
Definition: slr.h:396
LR::commuteWithDMO
static void commuteWithDMO(int nbast, int nocc, ergo_real *mat)
mat := [mat, D_MO]
Definition: slr.cc:513
LR::VarVector::operator=
VarVector & operator=(const VarVectorProxyOp< false, true > &proxy)
Definition: slr.h:148
LR::EigenSolver::~EigenSolver
virtual ~EigenSolver()
Definition: slr.h:383
LR::EigenSolver::increaseSubspaceLimit
virtual void increaseSubspaceLimit(int newSize)
expands above the default limit
Definition: slr.cc:1173
LR::EigenSolver::last_ev
ergo_real * last_ev
most recent eigenvectors in the reduced space
Definition: slr.h:372
LR::VarVectorCollection::VarVectorCollection
VarVectorCollection(int nSize=0)
Definition: slr.h:197
LR::EigenSolver::EigenSolver
EigenSolver(int nbast, int nocc, const ergo_real *fock_matrix, const ergo_real *overlap, int n)
Definition: slr.h:374
LR::EigenSolver::nStates
int nStates
number of excited states to compute
Definition: slr.h:370
LR
Definition: slr.cc:90
LR::VarVectorProxyOp
template based proxy object that uses bool-valued policies to perform the assignments.
Definition: slr.h:51
LR::SmallMatrix::nsize
int nsize
Definition: slr.h:225
LR::LRSolver::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.
Definition: slr.cc:389
LR::SetOfEqSolver
Iterative Set Of Linear Equations solver, extending the generic LRSolver.
Definition: slr.h:337
LR::VarVectorCollection::ages
unsigned * ages
Definition: slr.h:191
LR::VarVector::y
ergo_real * y() const
returns the Y part.
Definition: slr.h:95
LR::VarVector::release
void release(const char *tmpdir)
Releases the memory, saving if necessary.
Definition: slr.cc:286
LR::OneElOperator::getOper
virtual void getOper(ergo_real *result)=0
LR::EigenSolver::transMoms2
ergo_real * transMoms2
most recent SQUARED transition moments.
Definition: slr.h:369
LR::VarVector::operator[]
ergo_real & operator[](int i)
Definition: slr.h:114
LR::SetOfEqSolver::frequency
ergo_real frequency
frequency for which the SOE is to be solved.
Definition: slr.h:338
LR::VarVector::load
void load(const char *tmpdir)
Load the object to memory.
Definition: slr.cc:219
LR::VarVector::operator[]
const ergo_real & operator[](int i) const
Definition: slr.h:113
LR::VarVectorCollection::tmpdir
static const char * tmpdir
Definition: slr.h:211
do_output
void do_output(int logCategory, int logArea, const char *format,...)
Definition: output.cc:53
LR::VarVectorCollection::~VarVectorCollection
~VarVectorCollection()
Definition: slr.cc:302
LR::LRSolver::convThreshold
ergo_real convThreshold
iterative method convergence threshold
Definition: slr.h:282
LR::SmallMatrix::RowProxy
Definition: slr.h:227
LR::EigenSolver::getPreconditionerShift
virtual ergo_real getPreconditionerShift(int i) const
returns the preconditioning shift.
Definition: slr.h:388
LR::VarVectorCollection::setDiskMode
void setDiskMode(bool x)
Definition: slr.h:206
LR::VarVector::setFromFull
void setFromFull(int nbast, int nocc, const ergo_real *full_mat)
Definition: slr.cc:404
LR::VarVector::setSize
void setSize(int n)
Definition: slr.h:97
LR::LRSolver::Avects
VarVectorCollection Avects
vects and Avects members store the trial vectors and their transformed versions.
Definition: slr.h:325
LR::LRSolver::getResidual
virtual bool getResidual(VarVectorCollection &residualv)=0
Computes the residual vector.
Util::TimeMeter
Time-measuring class.
Definition: utilities.h:80
LR::LRSolver::~LRSolver
virtual ~LRSolver()
Definition: slr.h:253
LR::LRSolver::addToSpace
virtual void addToSpace(VarVectorCollection &vecs, E2Evaluator &e2)
extends the subspace with v and its transformed vector Av.
Definition: slr.cc:641
output.h
Functionality for writing output messages to a text file.
LR::SmallMatrix::RowProxy::toprow
ergo_real * toprow
Definition: slr.h:228
LR::VarVector::VarVector
VarVector(int nbast, int nocc, const ergo_real *full_mat)
Creates a vector from a full matrix.
Definition: slr.h:82
LR::LRSolver::subspaceSize
int subspaceSize
current subspace size
Definition: slr.h:287