Psi4
diismanager.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-2018 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_DIISMANAGER_H_
30 #define _PSI_SRC_LIB_LIBDIIS_DIISMANAGER_H_
31 
32 #include <vector>
33 #include <map>
34 
35 #include "psi4/pragma.h"
36 #include "psi4/libdiis/diisentry.h"
37 #include "psi4/libmints/matrix.h"
38 
39 namespace psi{
40 
41 class PSIO;
42 
48  public:
55  enum StoragePolicy {InCore, OnDisk};
62  enum RemovalPolicy {LargestError, OldestAdded};
63 
64  DIISManager(int maxSubspaceSize, const std::string& label,
65  RemovalPolicy = LargestError,
66  StoragePolicy = OnDisk);
67  DIISManager() {_maxSubspaceSize = 0;}
68  ~DIISManager();
69 
70  // C-style variadic? Why?
71  void set_error_vector_size(int numQuantities, ...);
72  void set_vector_size(int numQuantities, ...);
73  bool extrapolate(int numQuatities, ...);
74  bool add_entry(int numQuatities, ...);
75 
76  // Wrappers for those who dislike variadic
78  DIISManager::set_error_vector_size(1, error.get());
79  }
80 
82  DIISManager::set_vector_size(1, state.get());
83  }
84 
85  bool add_entry(SharedMatrix state, SharedMatrix error){
86  return DIISManager::add_entry(2, state.get(), error.get());
87  }
88 
89  bool extrapolate(SharedMatrix extrapolated){
90  return DIISManager::extrapolate(1, extrapolated.get());
91  }
92 
93  int remove_entry();
94  void reset_subspace();
95  void delete_diis_file();
97  int subspace_size();
98  protected:
99  int get_next_entry_id();
100 
118  std::vector<DIISEntry*> _subspace;
120  std::vector<DIISEntry::InputType> _componentTypes;
122  std::vector<size_t> _componentSizes;
124  std::string _label;
126  std::shared_ptr<PSIO> _psio;
127 };
128 
129 } // End namespace
130 
131 #endif // Header guard
std::vector< size_t > _componentSizes
The types used in the vector.
Definition: diismanager.h:122
StoragePolicy
How the quantities are to be stored;.
Definition: diismanager.h:55
int _numVectorComponents
The number of components in the vector.
Definition: diismanager.h:114
void set_vector_size(int numQuantities,...)
Definition: diismanager.cc:75
int _errorVectorSize
The size of the error vector.
Definition: diismanager.h:108
DIISManager()
Definition: diismanager.h:67
void set_vector_size(SharedMatrix state)
Definition: diismanager.h:81
bool extrapolate(int numQuatities,...)
Definition: diismanager.cc:337
std::string _label
The label used in disk storage of the DIISEntry objects.
Definition: diismanager.h:124
int _entryCount
The counter that keeps track of how many entries have been added.
Definition: diismanager.h:116
int _vectorSize
The size of the vector.
Definition: diismanager.h:110
int _numErrorVectorComponents
The number of components in the error vector.
Definition: diismanager.h:112
bool extrapolate(SharedMatrix extrapolated)
Definition: diismanager.h:89
std::vector< DIISEntry::InputType > _componentTypes
The types used in building the vector and the error vector.
Definition: diismanager.h:120
std::vector< DIISEntry * > _subspace
The DIIS entries.
Definition: diismanager.h:118
std::shared_ptr< PSIO > _psio
The PSIO object to use for I/O.
Definition: diismanager.h:126
std::shared_ptr< Matrix > SharedMatrix
Definition: adc.h:49
#define PSI_API
Definition: pragma.h:128
void set_error_vector_size(SharedMatrix error)
Definition: diismanager.h:77
RemovalPolicy _removalPolicy
How vectors are removed from the subspace.
Definition: diismanager.h:104
RemovalPolicy
How vectors are removed from the subspace, when required.
Definition: diismanager.h:62
bool add_entry(SharedMatrix state, SharedMatrix error)
Definition: diismanager.h:85
bool add_entry(int numQuatities,...)
Definition: diismanager.cc:196
void set_error_vector_size(int numQuantities,...)
Definition: diismanager.cc:132
int _maxSubspaceSize
The maximum number of vectors allowed in the subspace.
Definition: diismanager.h:106
StoragePolicy _storagePolicy
How the vectors are handled in memory.
Definition: diismanager.h:102
The DIISManager class handles DIIS extrapolations.
Definition: diismanager.h:47