Psi4
points.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 libfock_points_H
30 #define libfock_points_H
31 
32 #include "psi4/libmints/typedefs.h"
33 #include "psi4/pragma.h"
34 
35 #include <cstdio>
36 #include <map>
37 #include <unordered_map>
38 #include <tuple>
39 #include <vector>
40 #include <string>
41 
42 namespace psi {
43 
44 class BasisSet;
45 class Vector;
46 class BlockOPoints;
47 
48 
50 
51 protected:
53  std::shared_ptr<BasisSet> primary_;
55  bool puream_;
61  int deriv_;
63  std::map<std::string, SharedMatrix > basis_values_;
65  std::map<std::string, SharedMatrix > basis_temps_;
67  virtual void allocate();
68 
69 public:
70  // => Constructors <= //
71 
72  BasisFunctions(std::shared_ptr<BasisSet> primary, int max_points, int max_functions);
73  virtual ~BasisFunctions();
74 
75  // => Computers <= //
76 
77  void compute_functions(std::shared_ptr<BlockOPoints> block);
78 
79  // => Accessors <= //
80 
81  SharedMatrix basis_value(const std::string& key) { return basis_values_[key]; }
82  std::map<std::string, SharedMatrix>& basis_values() { return basis_values_; }
83 
84  int max_functions() const { return max_functions_; }
85  int max_points() const { return max_points_; }
86  int deriv() const { return deriv_; }
87 
88  virtual void print(std::string out_fname = "outfile", int print = 2) const;
89 
90  // => Setters <= //
91 
92  void set_deriv(int deriv) { deriv_ = deriv; allocate(); }
93  void set_max_functions(int max_functions) { max_functions_ = max_functions; allocate(); }
94  void set_max_points(int max_points) { max_points_ = max_points; allocate(); }
95 };
96 
98 
99 protected:
100  // => Indices <= //
101 
103  size_t block_index_;
104 
105  // Contains a map to the cache the global basis_values
106  std::unordered_map<size_t, std::map<std::string, SharedMatrix>> *cache_map_ = nullptr;
107 
108  // Contains a pointer to the current map to use for basis_values
109  std::map<std::string, SharedMatrix> *current_basis_map_ = nullptr;
110 
112  int ansatz_;
114  std::map<std::string, std::shared_ptr<Vector> > point_values_;
115 
116  // => Orbital Collocation <= //
117 
119  std::map<std::string, std::shared_ptr<Matrix> > orbital_values_;
120 
121 public:
122  // => Constructors <= //
123 
124  PointFunctions(std::shared_ptr<BasisSet> primary, int max_points, int max_functions);
125  virtual ~PointFunctions();
126 
127  // => Setters <= //
128  void set_cache_map(std::unordered_map<size_t, std::map<std::string, SharedMatrix>>* cache_map) { cache_map_ = cache_map; }
129 
130  // => Computers <= //
131 
132  virtual void compute_points(std::shared_ptr<BlockOPoints> block, bool force_compute = true) = 0;
133 
134  // => Accessors <= //
135 
136  std::shared_ptr<Vector> point_value(const std::string& key);
137  std::map<std::string, SharedVector>& point_values() { return point_values_; }
138 
139  SharedMatrix basis_value(const std::string& key) { return (*current_basis_map_)[key]; }
140  std::map<std::string, SharedMatrix>& basis_values() { return (*current_basis_map_); }
141 
142  virtual std::vector<SharedMatrix> scratch() = 0;
143  virtual std::vector<SharedMatrix> D_scratch() = 0;
144 
145  int ansatz() const { return ansatz_; }
146 
147  // => Setters <= //
148 
150  virtual void set_pointers(SharedMatrix Da_occ_AO) = 0;
151  virtual void set_pointers(SharedMatrix Da_occ_AO, SharedMatrix Db_occ_AO) = 0;
152 
153  // => Orbital Collocation <= //
154 
155  std::shared_ptr<Matrix> orbital_value(const std::string& key);
156  std::map<std::string, SharedMatrix>& orbital_values() { return orbital_values_; }
157 
158  virtual void compute_orbitals(std::shared_ptr<BlockOPoints> block, bool force_compute = true) = 0;
159  virtual void set_Cs(SharedMatrix Cocc) = 0;
160  virtual void set_Cs(SharedMatrix Caocc, SharedMatrix Cbocc) = 0;
161 };
162 
163 class RKSFunctions : public PointFunctions {
164 
165 protected:
166  // => Pointers <= //
167 
170 
171  // => Temps <= //
172 
177 
179  void build_temps();
181  void allocate();
182 
183  // => Orbital Collocation <= //
184 
189 
190 public:
191  RKSFunctions(std::shared_ptr<BasisSet> primary, int max_points, int max_functions);
192  virtual ~RKSFunctions();
193 
194  void set_pointers(SharedMatrix Da_occ_AO);
195  void set_pointers(SharedMatrix Da_occ_AO, SharedMatrix Db_occ_AO);
196 
197  void compute_points(std::shared_ptr<BlockOPoints> block, bool force_compute = true);
198 
199  std::vector<SharedMatrix> scratch();
200  std::vector<SharedMatrix> D_scratch();
201 
202  void print(std::string out_fname = "outfile", int print = 2) const;
203 
204  void compute_orbitals(std::shared_ptr<BlockOPoints> block, bool force_compute = true);
205  void set_Cs(SharedMatrix Cocc);
206  void set_Cs(SharedMatrix Caocc, SharedMatrix Cbocc);
207  size_t block_index() { return block_index_; }
208 };
209 
210 class UKSFunctions : public PointFunctions {
211 
212 protected:
213  // => Pointers <= //
214 
219 
220  // => Temps <= //
221 
230 
232  void build_temps();
234  void allocate();
235 
236  // => Orbital Collocation <= //
237 
246 
247 public:
248  UKSFunctions(std::shared_ptr<BasisSet> primary, int max_points, int max_functions);
249  virtual ~UKSFunctions();
250 
251  void set_pointers(SharedMatrix Da_occ_AO);
252  void set_pointers(SharedMatrix Da_occ_AO, SharedMatrix Db_occ_AO);
253  void set_cache_map(std::unordered_map<size_t, std::map<std::string, SharedMatrix>>* cache_map) { cache_map_ = cache_map; }
254 
255  void compute_points(std::shared_ptr<BlockOPoints> block, bool force_compute = true);
256 
257  std::vector<SharedMatrix> scratch();
258  std::vector<SharedMatrix> D_scratch();
259 
260  void print(std::string out_fname = "outfile", int print = 2) const;
261 
262  void compute_orbitals(std::shared_ptr<BlockOPoints> block, bool force_compute = true);
263  void set_Cs(SharedMatrix Cocc);
264  void set_Cs(SharedMatrix Caocc, SharedMatrix Cbocc);
265  size_t block_index() { return block_index_; }
266 };
267 
268 
269 }
270 #endif
void set_Cs(SharedMatrix Cocc)
Definition: points.cc:498
std::map< std::string, SharedMatrix > basis_values_
Map of value names to Matrices containing values.
Definition: points.h:63
SharedMatrix D_local_
Local D matrix.
Definition: points.h:176
void set_pointers(SharedMatrix Da_occ_AO)
Definition: points.cc:355
std::map< std::string, SharedMatrix > & basis_values()
Definition: points.h:82
virtual void compute_points(std::shared_ptr< BlockOPoints > block, bool force_compute=true)=0
virtual void allocate()
Allocate registers.
Definition: points.cc:604
Definition: points.h:97
int max_functions_
Maximum number of functions in a block.
Definition: points.h:59
std::map< std::string, SharedVector > & point_values()
Definition: points.h:137
SharedMatrix Cb_AO_
Orbital coefficients, AO.
Definition: points.h:241
SharedMatrix basis_value(const std::string &key)
Definition: points.h:81
virtual ~RKSFunctions()
Definition: points.cc:50
SharedMatrix tempa_
Buffer for half-transform.
Definition: points.h:223
std::map< std::string, SharedMatrix > basis_temps_
Map of temp names to Matrices containing temps.
Definition: points.h:65
virtual std::vector< SharedMatrix > scratch()=0
int ansatz() const
Definition: points.h:145
void set_max_functions(int max_functions)
Definition: points.h:93
virtual void set_Cs(SharedMatrix Cocc)=0
std::shared_ptr< BasisSet > primary_
Basis set for this BasisFunctions.
Definition: points.h:53
std::unordered_map< size_t, std::map< std::string, SharedMatrix > > * cache_map_
Definition: points.h:106
SharedMatrix Db_AO_
Density matrix, AO.
Definition: points.h:218
void set_cache_map(std::unordered_map< size_t, std::map< std::string, SharedMatrix >> *cache_map)
Definition: points.h:253
void set_pointers(SharedMatrix Da_occ_AO)
Definition: points.cc:89
void set_Cs(SharedMatrix Cocc)
Definition: points.cc:231
virtual std::vector< SharedMatrix > D_scratch()=0
SharedMatrix Ca_AO_
Orbital coefficients, AO.
Definition: points.h:239
int ansatz_
Ansatz (0 - LSDA, 1 - GGA, 2 - Meta-GGA)
Definition: points.h:112
SharedMatrix C_AO_
Orbital coefficients, AO.
Definition: points.h:186
SharedMatrix Db_local_
Local D matrix.
Definition: points.h:229
std::vector< SharedMatrix > D_scratch()
Definition: points.cc:315
SharedMatrix Cb_local_
Orbital coefficeints, local AO.
Definition: points.h:245
Definition: points.h:163
virtual void set_pointers(SharedMatrix Da_occ_AO)=0
int deriv_
Maximum derivative to compute.
Definition: points.h:61
SharedMatrix Ca_local_
Orbital coefficeints, local AO.
Definition: points.h:243
std::vector< SharedMatrix > scratch()
Definition: points.cc:51
std::map< std::string, SharedMatrix > * current_basis_map_
Definition: points.h:109
virtual ~PointFunctions()
Definition: points.cc:585
void print(std::string out_fname="outfile", int print=2) const
Definition: points.cc:277
SharedMatrix tempb_
Buffer for half-transform.
Definition: points.h:225
PointFunctions(std::shared_ptr< BasisSet > primary, int max_points, int max_functions)
Definition: points.cc:581
virtual ~UKSFunctions()
Definition: points.cc:308
void compute_orbitals(std::shared_ptr< BlockOPoints > block, bool force_compute=true)
Definition: points.cc:240
void print(std::string out_fname="outfile", int print=2) const
Definition: points.cc:555
bool puream_
Pure AM or not.
Definition: points.h:55
virtual void compute_orbitals(std::shared_ptr< BlockOPoints > block, bool force_compute=true)=0
size_t block_index()
Definition: points.h:207
SharedMatrix D_AO_
Density matrix, AO.
Definition: points.h:169
size_t block_index_
The index of the current referenced block.
Definition: points.h:103
RKSFunctions(std::shared_ptr< BasisSet > primary, int max_points, int max_functions)
Definition: points.cc:45
std::map< std::string, SharedMatrix > & orbital_values()
Definition: points.h:156
Definition: points.h:49
void build_temps()
Build temporary work arrays.
Definition: points.cc:61
void set_cache_map(std::unordered_map< size_t, std::map< std::string, SharedMatrix >> *cache_map)
Definition: points.h:128
Definition: points.h:210
void set_max_points(int max_points)
Definition: points.h:94
void set_deriv(int deriv)
Definition: points.h:92
UKSFunctions(std::shared_ptr< BasisSet > primary, int max_points, int max_functions)
Definition: points.cc:303
std::shared_ptr< Matrix > SharedMatrix
Definition: adc.h:49
int deriv() const
Definition: points.h:86
#define PSI_API
Definition: pragma.h:155
SharedMatrix basis_value(const std::string &key)
Definition: points.h:139
void compute_orbitals(std::shared_ptr< BlockOPoints > block, bool force_compute=true)
Definition: points.cc:509
int max_functions() const
Definition: points.h:84
void allocate()
Allocate registers.
Definition: points.cc:327
void compute_points(std::shared_ptr< BlockOPoints > block, bool force_compute=true)
Definition: points.cc:93
void compute_points(std::shared_ptr< BlockOPoints > block, bool force_compute=true)
Definition: points.cc:362
std::map< std::string, std::shared_ptr< Matrix > > orbital_values_
Map of value names to Matrices containing values.
Definition: points.h:119
SharedMatrix C_local_
Orbital coefficeints, local AO.
Definition: points.h:188
SharedMatrix temp_
Buffer for half-transform.
Definition: points.h:174
std::shared_ptr< Vector > point_value(const std::string &key)
Definition: points.cc:586
SharedMatrix Da_AO_
Density matrix, AO.
Definition: points.h:216
std::map< std::string, SharedMatrix > & basis_values()
Definition: points.h:140
std::map< std::string, std::shared_ptr< Vector > > point_values_
Map of value names to Vectors containing values.
Definition: points.h:114
std::vector< SharedMatrix > D_scratch()
Definition: points.cc:56
int max_points() const
Definition: points.h:85
void set_ansatz(int ansatz)
Definition: points.h:149
std::shared_ptr< Matrix > orbital_value(const std::string &key)
Definition: points.cc:588
std::vector< SharedMatrix > scratch()
Definition: points.cc:309
size_t block_index()
Definition: points.h:265
SharedMatrix Da_local_
Local D matrix.
Definition: points.h:227
int max_points_
Maximum number of points in a block.
Definition: points.h:57
void allocate()
Allocate registers.
Definition: points.cc:65
void build_temps()
Build temporary work arrays.
Definition: points.cc:321