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-2017 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 
34 #include <cstdio>
35 #include <map>
36 #include <tuple>
37 #include <vector>
38 #include <string>
39 
40 namespace psi {
41 
42 class BasisSet;
43 class Vector;
44 class BlockOPoints;
45 
46 
48 
49 protected:
51  std::shared_ptr<BasisSet> primary_;
53  bool puream_;
59  int deriv_;
61  std::map<std::string, SharedMatrix > basis_values_;
63  std::map<std::string, SharedMatrix > basis_temps_;
65  std::vector<std::vector<std::tuple<int,int,double> > > spherical_transforms_;
66 
68  void build_spherical();
70  virtual void allocate();
71 
72 public:
73  // => Constructors <= //
74 
75  BasisFunctions(std::shared_ptr<BasisSet> primary, int max_points, int max_functions);
76  virtual ~BasisFunctions();
77 
78  // => Computers <= //
79 
80  void compute_functions(std::shared_ptr<BlockOPoints> block);
81 
82  // => Accessors <= //
83 
84  SharedMatrix basis_value(const std::string& key);
85  std::map<std::string, SharedMatrix>& basis_values() { return basis_values_; }
86 
87  int max_functions() const { return max_functions_; }
88  int max_points() const { return max_points_; }
89  int deriv() const { return deriv_; }
90 
91  virtual void print(std::string out_fname = "outfile", int print = 2) const;
92 
93  // => Setters <= //
94 
95  void set_deriv(int deriv) { deriv_ = deriv; allocate(); }
98 };
99 
101 
102 protected:
104  int ansatz_;
106  std::map<std::string, std::shared_ptr<Vector> > point_values_;
107 
108  // => Orbital Collocation <= //
109 
111  std::map<std::string, std::shared_ptr<Matrix> > orbital_values_;
112 
113 public:
114  // => Constructors <= //
115 
116  PointFunctions(std::shared_ptr<BasisSet> primary, int max_points, int max_functions);
117  virtual ~PointFunctions();
118 
119  // => Computers <= //
120 
121  virtual void compute_points(std::shared_ptr<BlockOPoints> block) = 0;
122 
123  // => Accessors <= //
124 
125  std::shared_ptr<Vector> point_value(const std::string& key);
126  std::map<std::string, SharedVector>& point_values() { return point_values_; }
127 
128  virtual std::vector<SharedMatrix> scratch() = 0;
129  virtual std::vector<SharedMatrix> D_scratch() = 0;
130 
131  int ansatz() const { return ansatz_; }
132 
133  // => Setters <= //
134 
136  virtual void set_pointers(SharedMatrix Da_occ_AO) = 0;
137  virtual void set_pointers(SharedMatrix Da_occ_AO, SharedMatrix Db_occ_AO) = 0;
138 
139  // => Orbital Collocation <= //
140 
141  std::shared_ptr<Matrix> orbital_value(const std::string& key);
142  std::map<std::string, SharedMatrix>& orbital_values() { return orbital_values_; }
143 
144  virtual void compute_orbitals(std::shared_ptr<BlockOPoints> block) = 0;
145  virtual void set_Cs(SharedMatrix Cocc) = 0;
146  virtual void set_Cs(SharedMatrix Caocc, SharedMatrix Cbocc) = 0;
147 };
148 
149 class RKSFunctions : public PointFunctions {
150 
151 protected:
152  // => Pointers <= //
153 
156 
157  // => Temps <= //
158 
163 
165  void build_temps();
167  void allocate();
168 
169  // => Orbital Collocation <= //
170 
175 
176 public:
177  RKSFunctions(std::shared_ptr<BasisSet> primary, int max_points, int max_functions);
178  virtual ~RKSFunctions();
179 
180  void set_pointers(SharedMatrix Da_occ_AO);
181  void set_pointers(SharedMatrix Da_occ_AO, SharedMatrix Db_occ_AO);
182 
183  void compute_points(std::shared_ptr<BlockOPoints> block);
184 
185  std::vector<SharedMatrix> scratch();
186  std::vector<SharedMatrix> D_scratch();
187 
188  void print(std::string out_fname = "outfile", int print = 2) const;
189 
190  void compute_orbitals(std::shared_ptr<BlockOPoints> block);
191  void set_Cs(SharedMatrix Cocc);
192  void set_Cs(SharedMatrix Caocc, SharedMatrix Cbocc);
193 };
194 
195 class UKSFunctions : public PointFunctions {
196 
197 protected:
198  // => Pointers <= //
199 
204 
205  // => Temps <= //
206 
215 
217  void build_temps();
219  void allocate();
220 
221  // => Orbital Collocation <= //
222 
231 
232 public:
233  UKSFunctions(std::shared_ptr<BasisSet> primary, int max_points, int max_functions);
234  virtual ~UKSFunctions();
235 
236  void set_pointers(SharedMatrix Da_occ_AO);
237  void set_pointers(SharedMatrix Da_occ_AO, SharedMatrix Db_occ_AO);
238 
239  void compute_points(std::shared_ptr<BlockOPoints> block);
240 
241  std::vector<SharedMatrix> scratch();
242  std::vector<SharedMatrix> D_scratch();
243 
244  void print(std::string out_fname = "outfile", int print = 2) const;
245 
246  void compute_orbitals(std::shared_ptr<BlockOPoints> block);
247  void set_Cs(SharedMatrix Cocc);
248  void set_Cs(SharedMatrix Caocc, SharedMatrix Cbocc);
249 };
250 
251 
252 }
253 #endif
void set_Cs(SharedMatrix Cocc)
Definition: points.cc:521
std::map< std::string, SharedMatrix > basis_values_
Map of value names to Matrices containing values.
Definition: points.h:61
SharedMatrix D_local_
Local D matrix.
Definition: points.h:162
virtual void print(std::string out_fname="outfile", int print=2) const
Definition: points.cc:1097
void set_pointers(SharedMatrix Da_occ_AO)
Definition: points.cc:377
std::map< std::string, SharedMatrix > & basis_values()
Definition: points.h:85
virtual void allocate()
Allocate registers.
Definition: points.cc:657
Definition: points.h:100
std::vector< std::vector< std::tuple< int, int, double > > > spherical_transforms_
[L]: pure_index, cart_index, coef
Definition: points.h:65
int max_functions_
Maximum number of functions in a block.
Definition: points.h:57
void compute_points(std::shared_ptr< BlockOPoints > block)
Definition: points.cc:386
std::map< std::string, SharedVector > & point_values()
Definition: points.h:126
SharedMatrix Cb_AO_
Orbital coefficients, AO.
Definition: points.h:226
void compute_orbitals(std::shared_ptr< BlockOPoints > block)
Definition: points.cc:259
SharedMatrix basis_value(const std::string &key)
Definition: points.cc:697
virtual ~RKSFunctions()
Definition: points.cc:48
SharedMatrix tempa_
Buffer for half-transform.
Definition: points.h:208
void build_spherical()
Setup spherical_transforms_.
Definition: points.cc:635
std::map< std::string, SharedMatrix > basis_temps_
Map of temp names to Matrices containing temps.
Definition: points.h:63
virtual std::vector< SharedMatrix > scratch()=0
int ansatz() const
Definition: points.h:131
void set_max_functions(int max_functions)
Definition: points.h:96
virtual void set_Cs(SharedMatrix Cocc)=0
void compute_orbitals(std::shared_ptr< BlockOPoints > block)
Definition: points.cc:534
std::shared_ptr< BasisSet > primary_
Basis set for this BasisFunctions.
Definition: points.h:51
virtual ~BasisFunctions()
Definition: points.cc:632
SharedMatrix Db_AO_
Density matrix, AO.
Definition: points.h:203
void set_pointers(SharedMatrix Da_occ_AO)
Definition: points.cc:102
void set_Cs(SharedMatrix Cocc)
Definition: points.cc:249
virtual std::vector< SharedMatrix > D_scratch()=0
virtual void compute_orbitals(std::shared_ptr< BlockOPoints > block)=0
SharedMatrix Ca_AO_
Orbital coefficients, AO.
Definition: points.h:224
int ansatz_
Ansatz (0 - LSDA, 1 - GGA, 2 - Meta-GGA)
Definition: points.h:104
SharedMatrix C_AO_
Orbital coefficients, AO.
Definition: points.h:172
SharedMatrix Db_local_
Local D matrix.
Definition: points.h:214
std::vector< SharedMatrix > D_scratch()
Definition: points.cc:334
SharedMatrix Cb_local_
Orbital coefficeints, local AO.
Definition: points.h:230
Definition: points.h:149
BasisFunctions(std::shared_ptr< BasisSet > primary, int max_points, int max_functions)
Definition: points.cc:626
virtual void set_pointers(SharedMatrix Da_occ_AO)=0
int deriv_
Maximum derivative to compute.
Definition: points.h:59
SharedMatrix Ca_local_
Orbital coefficeints, local AO.
Definition: points.h:228
std::vector< SharedMatrix > scratch()
Definition: points.cc:51
virtual ~PointFunctions()
Definition: points.cc:613
void print(std::string out_fname="outfile", int print=2) const
Definition: points.cc:292
SharedMatrix tempb_
Buffer for half-transform.
Definition: points.h:210
PointFunctions(std::shared_ptr< BasisSet > primary, int max_points, int max_functions)
Definition: points.cc:608
virtual ~UKSFunctions()
Definition: points.cc:324
void print(std::string out_fname="outfile", int print=2) const
Definition: points.cc:580
bool puream_
Pure AM or not.
Definition: points.h:53
virtual void compute_points(std::shared_ptr< BlockOPoints > block)=0
SharedMatrix D_AO_
Density matrix, AO.
Definition: points.h:155
RKSFunctions(std::shared_ptr< BasisSet > primary, int max_points, int max_functions)
Definition: points.cc:43
std::map< std::string, SharedMatrix > & orbital_values()
Definition: points.h:142
Definition: points.h:47
void build_temps()
Build temporary work arrays.
Definition: points.cc:63
Definition: points.h:195
void set_max_points(int max_points)
Definition: points.h:97
void set_deriv(int deriv)
Definition: points.h:95
UKSFunctions(std::shared_ptr< BasisSet > primary, int max_points, int max_functions)
Definition: points.cc:319
std::shared_ptr< Matrix > SharedMatrix
Definition: adc.h:49
int deriv() const
Definition: points.h:89
int max_functions() const
Definition: points.h:87
void allocate()
Allocate registers.
Definition: points.cc:348
std::map< std::string, std::shared_ptr< Matrix > > orbital_values_
Map of value names to Matrices containing values.
Definition: points.h:111
SharedMatrix C_local_
Orbital coefficeints, local AO.
Definition: points.h:174
SharedMatrix temp_
Buffer for half-transform.
Definition: points.h:160
std::shared_ptr< Vector > point_value(const std::string &key)
Definition: points.cc:616
SharedMatrix Da_AO_
Density matrix, AO.
Definition: points.h:201
std::map< std::string, std::shared_ptr< Vector > > point_values_
Map of value names to Vectors containing values.
Definition: points.h:106
std::vector< SharedMatrix > D_scratch()
Definition: points.cc:57
int max_points() const
Definition: points.h:88
void set_ansatz(int ansatz)
Definition: points.h:135
std::shared_ptr< Matrix > orbital_value(const std::string &key)
Definition: points.cc:621
std::vector< SharedMatrix > scratch()
Definition: points.cc:327
SharedMatrix Da_local_
Local D matrix.
Definition: points.h:212
void compute_points(std::shared_ptr< BlockOPoints > block)
Definition: points.cc:110
void compute_functions(std::shared_ptr< BlockOPoints > block)
Definition: points.cc:701
int max_points_
Maximum number of points in a block.
Definition: points.h:55
void allocate()
Allocate registers.
Definition: points.cc:68
void build_temps()
Build temporary work arrays.
Definition: points.cc:341