CheMPS2
DIIS.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 DIIS_CHEMPS2_H
21 #define DIIS_CHEMPS2_H
22 
23 #include "Options.h"
24 
25 namespace CheMPS2{
34  class DIIS{
35 
36  public:
37 
39 
42  DIIS(const int numVarsParamIn, const int numVarsErrorIn, const int numVecsIn);
43 
45  virtual ~DIIS();
46 
48 
49  int getNumVarsParam() const;
50 
52 
53  int getNumVarsError() const;
54 
56 
57  int getNumVecs() const;
58 
60 
61  int getCurrentNumVecs() const;
62 
64 
65  double * getLastLinco();
66 
68 
70  void appendNew(double * newError, double * newParam);
71 
73 
74  void calculateParam(double * newParam);
75 
77 
78  void saveDIIS(const string filename=DMRGSCF_diis_storage_name) const;
79 
81 
82  void loadDIIS(const string filename=DMRGSCF_diis_storage_name);
83 
84  private:
85 
86  //The number of variables in the parameter vectors
87  int numVarsParam;
88 
89  //The number of variables in the error vectors
90  int numVarsError;
91 
92  //The max. number of vectors which should be kept
93  int numVecs;
94 
95  //The current number of vectors in this object
96  int currentNumVecs;
97 
98  //The error vectors
99  double ** errorVectors;
100 
101  //The parameter vectors
102  double ** paramVectors;
103 
104  //The last linco of parameter vectors
105  double * lastLinco;
106 
107  };
108 }
109 
110 #endif
int getNumVarsError() const
Get the number of variables in the error vectors.
Definition: DIIS.cpp:66
DIIS(const int numVarsParamIn, const int numVarsErrorIn, const int numVecsIn)
Constructor.
Definition: DIIS.cpp:37
void appendNew(double *newError, double *newParam)
Append a new error and parameter vector.
Definition: DIIS.cpp:74
void loadDIIS(const string filename=DMRGSCF_diis_storage_name)
Load the DIIS object from disk.
Definition: DIIS.cpp:223
Definition: CASPT2.h:42
int getNumVarsParam() const
Get the number of variables in the parameter vectors.
Definition: DIIS.cpp:64
void saveDIIS(const string filename=DMRGSCF_diis_storage_name) const
Save the DIIS object to disk.
Definition: DIIS.cpp:165
virtual ~DIIS()
Destructor.
Definition: DIIS.cpp:51
double * getLastLinco()
Get pointer to the last linco of parameter vectors.
Definition: DIIS.cpp:72
void calculateParam(double *newParam)
Calculate the new parameter vector, based on the just appended error and parameter vectors...
Definition: DIIS.cpp:103
int getCurrentNumVecs() const
Get the current number of vectors which are used for DIIS.
Definition: DIIS.cpp:70
int getNumVecs() const
Get the max. number of parameter and error vectors which are kept.
Definition: DIIS.cpp:68