CheMPS2
Davidson.h
1 /*
2  CheMPS2: a spin-adapted implementation of DMRG for ab initio quantum chemistry
3  Copyright (C) 2013-2016 Sebastian Wouters
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 
20 #ifndef DAVIDSON_CHEMPS2_H
21 #define DAVIDSON_CHEMPS2_H
22 
23 namespace CheMPS2{
34  class Davidson{
35 
36  public:
37 
39 
46  Davidson( const int veclength, const int MAX_NUM_VEC, const int NUM_VEC_KEEP, const double RTOL, const double DIAG_CUTOFF, const bool debug_print, const char problem_type = 'E' );
47 
49  virtual ~Davidson();
50 
52 
54  char FetchInstruction( double ** pointers );
55 
57 
58  int GetNumMultiplications() const;
59 
60  private:
61 
62  int veclength; // The vector length
63  int nMultiplications; // Current number of requested matrix-vector multiplications
64  char state; // Current state of the algorithm --> based on this parameter the next instruction is given
65  bool debug_print;
66  char problem_type;
67 
68  // Davidson parameters
69  int MAX_NUM_VEC;
70  int NUM_VEC_KEEP;
71  double DIAG_CUTOFF;
72  double RTOL;
73 
74  // To store the vectors and the matrix x vectors
75  int num_vec;
76  double ** vecs;
77  double ** Hvecs;
78  int num_allocated;
79 
80  // The effective diagonalization problem
81  double * mxM;
82  double * mxM_eigs;
83  double * mxM_vecs;
84  int mxM_lwork;
85  double * mxM_work;
86  double * mxM_rhs;
87 
88  // Vector spaces
89  double * t_vec;
90  double * u_vec;
91  double * work_vec;
92  double * diag;
93  double * RHS;
94 
95  // For the deflation
96  double * Reortho_Lowdin;
97  double * Reortho_Overlap_eigs;
98  double * Reortho_Overlap;
99  double * Reortho_Eigenvecs;
100 
101  // Control script functions
102  double FrobeniusNorm( double * current_vector );
103  void SafetyCheckGuess();
104  void AddNewVec();
105  double DiagonalizeSmallMatrixAndCalcResidual(); // Returns the residual norm
106  void CalculateNewVec();
107  void Deflation();
108  void MxMafterDeflation();
109  void SolveLinearSystemDeflation( const int NUM_SOLUTIONS );
110 
111  };
112 }
113 
114 #endif
115 
virtual ~Davidson()
Destructor.
Definition: Davidson.cpp:75
int GetNumMultiplications() const
Get the number of matrix vector multiplications which have been performed.
Definition: Davidson.cpp:103
Definition: CASPT2.h:42
Davidson(const int veclength, const int MAX_NUM_VEC, const int NUM_VEC_KEEP, const double RTOL, const double DIAG_CUTOFF, const bool debug_print, const char problem_type= 'E')
Constructor.
Definition: Davidson.cpp:31
char FetchInstruction(double **pointers)
The iterator to converge the ground state vector.
Definition: Davidson.cpp:105