Psi4
diisentry.h
Go to the documentation of this file.
1 /*
2  * @BEGIN LICENSE
3  *
4  * Psi4: an open-source quantum chemistry software package
5  *
6  * Copyright (c) 2007-2017 The Psi4 Developers.
7  *
8  * The copyrights for code used from other parties are included in
9  * the corresponding files.
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License along
22  * with this program; if not, write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  *
25  * @END LICENSE
26  */
27 
28 #ifndef _PSI_SRC_LIB_LIBDIIS_DIISENTRY_H_
29 #define _PSI_SRC_LIB_LIBDIIS_DIISENTRY_H_
30 
31 #include <string>
32 #include <map>
33 
34 namespace psi{
35 
36 class PSIO;
37 
43 class DIISEntry{
44  public:
60  DIISEntry(std::string label, int ID, int count, int vectorSize, double *vector,
61  int errorVectorSize, double *errorVector, std::shared_ptr<PSIO> psio);
62  ~DIISEntry();
64  bool dot_is_known_with(int n) {return _knownDotProducts[n];}
66  double dot_with(int n) {return _dotProducts[n];}
68  double rmsError() {return _rmsError;}
70  int orderAdded() {return _orderAdded;}
72  void set_dot_with(int n, double val) {_knownDotProducts[n] = true; _dotProducts[n] = val;}
74  void invalidate_dot(int n) {_knownDotProducts[n] = false;}
76  void set_vector(double *vec) {_vector = vec;}
78  void set_error_vector(double *vec) {_errorVector = vec;}
80  void dump_vector_to_disk();
82  void read_vector_from_disk();
88  void free_vector_memory();
94  const double *vector() {read_vector_from_disk(); return _vector;}
96  void open_psi_file();
98  void close_psi_file();
99  protected:
101  std::map<int, bool> _knownDotProducts;
103  std::map<int, double> _dotProducts;
111  int _ID;
113  double _rmsError;
115  double *_errorVector;
117  double *_vector;
119  std::string _label;
121  std::shared_ptr<PSIO> _psio;
122 };
123 
124 } // End namespace
125 
126 #endif // Header guard
int _orderAdded
The absolute number of this entry.
Definition: diisentry.h:109
double _rmsError
The RMS error for this entry.
Definition: diisentry.h:113
bool dot_is_known_with(int n)
Whether the dot product of this entry&#39;s and the nth entry&#39;s error vector is known.
Definition: diisentry.h:64
double * _errorVector
The error vector.
Definition: diisentry.h:115
std::map< int, double > _dotProducts
The list of known dot products with other DIISEntries.
Definition: diisentry.h:103
void read_error_vector_from_disk()
Allocate error vector memory and read from disk.
Definition: diisentry.cc:114
double rmsError()
The RMS error of this entry.
Definition: diisentry.h:68
void free_error_vector_memory()
Free error vector memory.
Definition: diisentry.cc:134
void set_error_vector(double *vec)
set the error vector
Definition: diisentry.h:78
double * _vector
The error vector.
Definition: diisentry.h:117
#define ID(x)
Definition: adc.h:37
void open_psi_file()
Open the psi file, if needed.
Definition: diisentry.cc:66
void invalidate_dot(int n)
Marks the dot product with vector n as invalid.
Definition: diisentry.h:74
double dot_with(int n)
The dot product of this entry&#39;s and the nth entry&#39;s error vectors.
Definition: diisentry.h:66
int orderAdded()
The absolute number of this entry.
Definition: diisentry.h:70
std::shared_ptr< PSIO > _psio
PSIO object.
Definition: diisentry.h:121
Definition: diisentry.h:59
void read_vector_from_disk()
Allocate vector memory and read from disk.
Definition: diisentry.cc:92
void free_vector_memory()
Free vector memory.
Definition: diisentry.cc:125
The DIISManager class is used to manage DIIS quantities and their corresponding error vectors...
Definition: diisentry.h:43
Definition: diisentry.h:59
void dump_error_vector_to_disk()
Put this error vector entry on disk and free the memory.
Definition: diisentry.cc:104
const double * vector()
Returns the vector.
Definition: diisentry.h:94
std::map< int, bool > _knownDotProducts
The list of which dot products, with other DIISEntries, are known.
Definition: diisentry.h:101
Definition: diisentry.h:59
std::string _label
The label used for disk storage.
Definition: diisentry.h:119
DIISEntry(std::string label, int ID, int count, int vectorSize, double *vector, int errorVectorSize, double *errorVector, std::shared_ptr< PSIO > psio)
Definition: diisentry.cc:44
InputType
The type of quantity to add to either an error vector or vector.
Definition: diisentry.h:59
const double * errorVector()
Returns the error vector.
Definition: diisentry.h:92
Definition: diisentry.h:59
void close_psi_file()
Close the psi file, if needed.
Definition: diisentry.cc:74
int _ID
The number of this entry in the current subspace.
Definition: diisentry.h:111
void set_dot_with(int n, double val)
Sets the dot product with vector n to val.
Definition: diisentry.h:72
~DIISEntry()
Definition: diisentry.cc:142
int _errorVectorSize
The length of the error vector.
Definition: diisentry.h:105
void set_vector(double *vec)
Set the vector.
Definition: diisentry.h:76
int _vectorSize
The length of the vector.
Definition: diisentry.h:107
void dump_vector_to_disk()
Put this vector entry on disk and free the memory.
Definition: diisentry.cc:82
Definition: diisentry.h:59