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, RemovalPolicy = LargestError, StoragePolicy = OnDisk);
65  DIISManager() { _maxSubspaceSize = 0; }
66  ~DIISManager();
67 
68  // C-style variadic? Why?
69  void set_error_vector_size(int numQuantities, ...);
70  void set_vector_size(int numQuantities, ...);
71  bool extrapolate(int numQuatities, ...);
72  bool add_entry(int numQuatities, ...);
73 
74  // Wrappers for those who dislike variadic
76 
78 
79  bool add_entry(SharedMatrix state, SharedMatrix error) {
80  return DIISManager::add_entry(2, state.get(), error.get());
81  }
82 
83  bool extrapolate(SharedMatrix extrapolated) { return DIISManager::extrapolate(1, extrapolated.get()); }
84 
85  int remove_entry();
86  void reset_subspace();
87  void delete_diis_file();
89  int subspace_size();
90 
91  protected:
92  int get_next_entry_id();
93 
111  std::vector<DIISEntry*> _subspace;
113  std::vector<DIISEntry::InputType> _componentTypes;
115  std::vector<size_t> _componentSizes;
117  std::string _label;
119  std::shared_ptr<PSIO> _psio;
120 };
121 
122 } // namespace psi
123 
124 #endif // Header guard
std::vector< size_t > _componentSizes
The types used in the vector.
Definition: diismanager.h:115
StoragePolicy
How the quantities are to be stored;.
Definition: diismanager.h:55
int _numVectorComponents
The number of components in the vector.
Definition: diismanager.h:107
void set_vector_size(int numQuantities,...)
Definition: diismanager.cc:75
int _errorVectorSize
The size of the error vector.
Definition: diismanager.h:101
DIISManager()
Definition: diismanager.h:65
void set_vector_size(SharedMatrix state)
Definition: diismanager.h:77
bool extrapolate(int numQuatities,...)
Definition: diismanager.cc:337
std::string _label
The label used in disk storage of the DIISEntry objects.
Definition: diismanager.h:117
int _entryCount
The counter that keeps track of how many entries have been added.
Definition: diismanager.h:109
int _vectorSize
The size of the vector.
Definition: diismanager.h:103
int _numErrorVectorComponents
The number of components in the error vector.
Definition: diismanager.h:105
bool extrapolate(SharedMatrix extrapolated)
Definition: diismanager.h:83
std::vector< DIISEntry::InputType > _componentTypes
The types used in building the vector and the error vector.
Definition: diismanager.h:113
std::vector< DIISEntry * > _subspace
The DIIS entries.
Definition: diismanager.h:111
std::shared_ptr< PSIO > _psio
The PSIO object to use for I/O.
Definition: diismanager.h:119
std::shared_ptr< Matrix > SharedMatrix
Definition: adc.h:49
#define PSI_API
Definition: pragma.h:155
void set_error_vector_size(SharedMatrix error)
Definition: diismanager.h:75
RemovalPolicy _removalPolicy
How vectors are removed from the subspace.
Definition: diismanager.h:97
RemovalPolicy
How vectors are removed from the subspace, when required.
Definition: diismanager.h:62
bool add_entry(SharedMatrix state, SharedMatrix error)
Definition: diismanager.h:79
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:99
StoragePolicy _storagePolicy
How the vectors are handled in memory.
Definition: diismanager.h:95
The DIISManager class handles DIIS extrapolations.
Definition: diismanager.h:47