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-2019 The Psi4 Developers.
7  *
8  * The copyrights for code used from other parties are included in
9  * the corresponding files.
10  *
11  * This file is part of Psi4.
12  *
13  * Psi4 is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU Lesser General Public License as published by
15  * the Free Software Foundation, version 3.
16  *
17  * Psi4 is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public License along
23  * with Psi4; if not, write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25  *
26  * @END LICENSE
27  */
28 
29 #ifndef _PSI_SRC_LIB_LIBDIIS_DIISENTRY_H_
30 #define _PSI_SRC_LIB_LIBDIIS_DIISENTRY_H_
31 
32 #include <map>
33 #include <memory>
34 #include <string>
35 
36 namespace psi {
37 
38 class PSIO;
39 
45 class DIISEntry {
46  public:
62  DIISEntry(std::string label, int ID, int count, int vectorSize, double *vector, int errorVectorSize,
63  double *errorVector, std::shared_ptr<PSIO> psio);
64  ~DIISEntry();
66  bool dot_is_known_with(int n) { return _knownDotProducts[n]; }
68  double dot_with(int n) { return _dotProducts[n]; }
70  double rmsError() { return _rmsError; }
72  int orderAdded() { return _orderAdded; }
74  void set_dot_with(int n, double val) {
75  _knownDotProducts[n] = true;
76  _dotProducts[n] = val;
77  }
79  void invalidate_dot(int n) { _knownDotProducts[n] = false; }
81  void set_vector(double *vec) { _vector = vec; }
83  void set_error_vector(double *vec) { _errorVector = vec; }
85  void dump_vector_to_disk();
87  void read_vector_from_disk();
93  void free_vector_memory();
97  const double *errorVector() {
99  return _errorVector;
100  }
102  const double *vector() {
104  return _vector;
105  }
107  void open_psi_file();
109  void close_psi_file();
110 
111  protected:
113  std::map<int, bool> _knownDotProducts;
115  std::map<int, double> _dotProducts;
123  int _ID;
125  double _rmsError;
127  double *_errorVector;
129  double *_vector;
131  std::string _label;
133  std::shared_ptr<PSIO> _psio;
134 };
135 
136 } // namespace psi
137 
138 #endif // Header guard
int _orderAdded
The absolute number of this entry.
Definition: diisentry.h:121
double _rmsError
The RMS error for this entry.
Definition: diisentry.h:125
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:66
double * _errorVector
The error vector.
Definition: diisentry.h:127
std::map< int, double > _dotProducts
The list of known dot products with other DIISEntries.
Definition: diisentry.h:115
void read_error_vector_from_disk()
Allocate error vector memory and read from disk.
Definition: diisentry.cc:96
double rmsError()
The RMS error of this entry.
Definition: diisentry.h:70
void free_error_vector_memory()
Free error vector memory.
Definition: diisentry.cc:110
void set_error_vector(double *vec)
set the error vector
Definition: diisentry.h:83
double * _vector
The error vector.
Definition: diisentry.h:129
#define ID(x)
Definition: adc.h:38
void open_psi_file()
Open the psi file, if needed.
Definition: diisentry.cc:61
void invalidate_dot(int n)
Marks the dot product with vector n as invalid.
Definition: diisentry.h:79
double dot_with(int n)
The dot product of this entry&#39;s and the nth entry&#39;s error vectors.
Definition: diisentry.h:68
int orderAdded()
The absolute number of this entry.
Definition: diisentry.h:72
std::shared_ptr< PSIO > _psio
PSIO object.
Definition: diisentry.h:133
Definition: diisentry.h:61
void read_vector_from_disk()
Allocate vector memory and read from disk.
Definition: diisentry.cc:80
void free_vector_memory()
Free vector memory.
Definition: diisentry.cc:105
The DIISManager class is used to manage DIIS quantities and their corresponding error vectors...
Definition: diisentry.h:45
Definition: diisentry.h:61
void dump_error_vector_to_disk()
Put this error vector entry on disk and free the memory.
Definition: diisentry.cc:89
const double * vector()
Returns the vector.
Definition: diisentry.h:102
std::map< int, bool > _knownDotProducts
The list of which dot products, with other DIISEntries, are known.
Definition: diisentry.h:113
Definition: diisentry.h:61
std::string _label
The label used for disk storage.
Definition: diisentry.h:131
DIISEntry(std::string label, int ID, int count, int vectorSize, double *vector, int errorVectorSize, double *errorVector, std::shared_ptr< PSIO > psio)
Definition: diisentry.cc:42
InputType
The type of quantity to add to either an error vector or vector.
Definition: diisentry.h:61
const double * errorVector()
Returns the error vector.
Definition: diisentry.h:97
Definition: diisentry.h:61
void close_psi_file()
Close the psi file, if needed.
Definition: diisentry.cc:67
int _ID
The number of this entry in the current subspace.
Definition: diisentry.h:123
void set_dot_with(int n, double val)
Sets the dot product with vector n to val.
Definition: diisentry.h:74
~DIISEntry()
Definition: diisentry.cc:115
int _errorVectorSize
The length of the error vector.
Definition: diisentry.h:117
void set_vector(double *vec)
Set the vector.
Definition: diisentry.h:81
int _vectorSize
The length of the vector.
Definition: diisentry.h:119
void dump_vector_to_disk()
Put this vector entry on disk and free the memory.
Definition: diisentry.cc:73
Definition: diisentry.h:61