Psi4
lreri.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 LRERI_H
30 #define LRERI_H
31 
32 #include <map>
33 #include <string>
34  #include "psi4/pragma.h"
35  PRAGMA_WARNING_PUSH
36  PRAGMA_WARNING_IGNORE_DEPRECATED_DECLARATIONS
37  #include <memory>
39 #include "psi4/libmints/typedefs.h"
40 
41 namespace psi {
42 
43 class Options;
44 class Tensor;
45 class BasisSet;
46 class LRERI {
47 
48 protected:
49 
50  // => Utility <= //
51 
53  int print_;
55  int debug_;
57  int bench_;
59  unsigned long int memory_;
60 
61  // => Basis Set <= //
62 
64  std::shared_ptr<BasisSet> primary_;
65 
66  // => Orbital Spaces <= //
67 
69  std::shared_ptr<Matrix> C_;
71  std::map<std::string, std::pair<int, int> > spaces_;
73  std::vector<std::string> spaces_order_;
74 
75  // => Utility Routines <= //
76 
78  void common_init();
79 
81  std::shared_ptr<Matrix> Jm12(std::shared_ptr<BasisSet> auxiliary, double condition);
82 
83 public:
84  // => Constructors <= //
85 
86  LRERI(std::shared_ptr<BasisSet> primary);
87  virtual ~LRERI();
88 
89  // => Defaults <= //
90 
92  virtual void load_wavefunction(std::shared_ptr<Wavefunction> ref);
94  virtual void load_options(Options& options);
95 
96  // => Orbital Space Control <= //
97 
99  void set_C(std::shared_ptr<Matrix> C);
101  void add_space(const std::string& key, int start, int end);
103  virtual void clear();
104 
105  // => Computers <= //
106 
108  virtual void print_header(int level = 1) = 0;
110  virtual void compute() = 0;
111 
112  // => Setters <= //
113 
115  void set_print(int print) { print_ = print; }
117  void set_debug(int debug) { debug_ = debug; }
119  void set_bench(int bench) { bench_ = bench; }
121  void set_memory(unsigned long int memory) { memory_ = memory; }
122 
123 };
124 
128 class DFERI : public LRERI {
129 
130 protected:
131 
132  // => DF Tech <= //
133 
135  std::shared_ptr<BasisSet> auxiliary_;
137  double J_cutoff_;
140 
141  // => HACK for LRC-ERIs <= //
142 
143  double omega_;
144 
145  // => Targets <= //
146 
148  std::map<std::string, std::shared_ptr<Tensor> > ints_;
150  std::map<std::string, std::pair<std::string, std::string> > pair_spaces_;
152  std::map<std::string, double> pair_powers_;
154  std::map<std::string, bool> pair_transposes_;
156  std::vector<std::string> pair_spaces_order_;
157 
160 
161  // => Utility Routines <= //
162 
164  void common_init();
165 
166  void allocate();
167  void transform();
168  void fit();
169 
170 public:
171  // => Constructors <= //
172 
173  DFERI(std::shared_ptr<BasisSet> primary,
174  std::shared_ptr<BasisSet> auxiliary);
175  virtual ~DFERI();
176 
177  static std::shared_ptr<DFERI> build(std::shared_ptr<BasisSet> primary, std::shared_ptr<BasisSet> auxiliary, Options& options);
178  static std::shared_ptr<DFERI> build(std::shared_ptr<BasisSet> primary, std::shared_ptr<BasisSet> auxiliary, Options& options, std::shared_ptr<Wavefunction> ref);
179 
180  // => Defaults <= //
181 
183  virtual void load_options(Options& options);
184 
185  // => Pair Space Control <= //
186 
187  // R: add an orbital pair space to the list of tasks
188  void add_pair_space(const std::string& name, const std::string& space1, const std::string& space2, double pow = -1.0/2.0, bool transpose12 = false);
189  // Clear this DFERI object of tasks
190  virtual void clear();
191  // Clear this DFERI object of pair spaces
192  virtual void clear_pair_spaces();
193 
194  // => Computers <= //
195 
197  virtual void print_header(int level = 1);
199  int size_Q();
201  virtual void compute();
203  std::map<std::string, std::shared_ptr<Tensor> >& ints() { return ints_; }
205  std::shared_ptr<Matrix> Jpow(double power = -1.0/2.0);
206 
207  // => Setters <= //
208 
210  void set_J_cutoff(double J_cutoff) { J_cutoff_ = J_cutoff; }
212  void set_schwarz_cutoff(double schwarz_cutoff) { schwarz_cutoff_ = schwarz_cutoff; }
214  void set_keep_raw_integrals(bool val) { keep_raw_integrals_ = val; }
215 
217  void set_omega(double omega) { omega_ = omega; }
218 
219 };
220 
224 class LSTHCERI : public LRERI {
225 
226 
227 protected:
228 
229  // => LS-LSTHC Tech <= //
230 
232  std::shared_ptr<Matrix> X_;
234  std::shared_ptr<BasisSet> auxiliary_;
236  double J_cutoff_;
238  double S_cutoff_;
242  bool balance_;
243 
244  // => Targets <= //
245 
247  std::map<std::string, std::vector<std::shared_ptr<Tensor> > > ints_;
249  std::map<std::string, std::vector<std::shared_ptr<Tensor> > > meths_;
251  std::map<std::string, std::vector<std::string> > eri_spaces_;
253  std::vector<std::string> eri_spaces_order_;
254 
255  // => Utility Routines <= //
256 
258  void common_init();
259 
261  std::map<std::string, std::shared_ptr<Tensor> > build_X(bool meth = false);
263  std::map<std::string, std::shared_ptr<Tensor> > build_E(std::map<std::string, std::shared_ptr<Tensor> >& Xs);
265  std::map<std::string, std::shared_ptr<Tensor> > build_S(std::map<std::string, std::shared_ptr<Tensor> >& Xs, bool meth = false);
267  std::map<std::string, std::shared_ptr<Tensor> > build_L(std::map<std::string, std::shared_ptr<Tensor> >& Es,
268  std::map<std::string, std::shared_ptr<Tensor> >& Ss);
270  std::map<std::string, std::shared_ptr<Tensor> > build_Z(std::map<std::string, std::shared_ptr<Tensor> >& Ls);
272  void pack(std::map<std::string, std::shared_ptr<Tensor> >& Xs,
273  std::map<std::string, std::shared_ptr<Tensor> >& Zs,
274  std::map<std::string, std::shared_ptr<Tensor> >& Ls,
275  std::map<std::string, std::shared_ptr<Tensor> >& Ss);
277  void pack_meth(std::map<std::string, std::shared_ptr<Tensor> >& Xs,
278  std::map<std::string, std::shared_ptr<Tensor> >& Ss);
279 
280 public:
281  // => Constructors <= //
282 
283  LSTHCERI(std::shared_ptr<BasisSet> primary,
284  std::shared_ptr<BasisSet> auxiliary,
285  std::shared_ptr<Matrix> X);
286  virtual ~LSTHCERI();
287 
288  static std::shared_ptr<LSTHCERI> build(std::shared_ptr<BasisSet> primary, std::shared_ptr<BasisSet> auxiliary, std::shared_ptr<Matrix> X, Options& options);
289  static std::shared_ptr<LSTHCERI> build(std::shared_ptr<BasisSet> primary, std::shared_ptr<BasisSet> auxiliary, std::shared_ptr<Matrix> X, Options& options, std::shared_ptr<Wavefunction> ref);
290 
291  // => Defaults <= //
292 
294  virtual void load_options(Options& options);
295 
296  // => ERI Space Control <= //
297 
298  // R: add an eri space to the list of tasks
299  void add_eri_space(const std::string& name, const std::string& space1, const std::string& space2, const std::string& space3, const std::string& space4);
300  // Clear this LSTHCERI object of tasks
301  virtual void clear();
302 
303  // => Computers <= //
304 
306  virtual void print_header(int level = 1);
308  virtual void compute();
310  std::map<std::string, std::vector<std::shared_ptr<Tensor> > >& ints() { return ints_; };
311 
313  virtual void compute_meth();
315  std::map<std::string, std::vector<std::shared_ptr<Tensor> > >& meths() { return meths_; }
316 
317  // => Setters <= //
318 
320  void set_J_cutoff(double J_cutoff) { J_cutoff_ = J_cutoff; }
322  void set_S_cutoff(double S_cutoff) { S_cutoff_ = S_cutoff; }
324  void set_schwarz_cutoff(double schwarz_cutoff) { schwarz_cutoff_ = schwarz_cutoff; }
327 };
328 
329 
330 } // End namespace
331 
332 #endif
std::map< std::string, std::shared_ptr< Tensor > > & ints()
Handle to computed disk tensors, by name in add_pair above.
Definition: lreri.h:203
std::map< std::string, bool > pair_transposes_
Requested pair space transpositions (ab|Q) -&gt; (ba|Q)
Definition: lreri.h:154
void pack_meth(std::map< std::string, std::shared_ptr< Tensor > > &Xs, std::map< std::string, std::shared_ptr< Tensor > > &Ss)
Pack up the meth intermediates.
Definition: lreri.cc:1351
std::shared_ptr< Matrix > C_
Occupation matrix coefficients (nso x nmo)
Definition: lreri.h:69
virtual ~DFERI()
Definition: lreri.cc:225
void add_eri_space(const std::string &name, const std::string &space1, const std::string &space2, const std::string &space3, const std::string &space4)
Definition: lreri.cc:785
Definition: lreri.h:128
virtual void print_header(int level=1)
Print info.
Definition: lreri.cc:802
std::map< std::string, std::vector< std::shared_ptr< Tensor > > > & meths()
METH helper factors [X1,X2,Sinv].
Definition: lreri.h:315
void add_space(const std::string &key, int start, int end)
R: Add an orbital subspace to the queue. The subspace will be referred to by key, and ranges from sta...
Definition: lreri.cc:141
LSTHCERI(std::shared_ptr< BasisSet > primary, std::shared_ptr< BasisSet > auxiliary, std::shared_ptr< Matrix > X)
Definition: lreri.cc:746
std::map< std::string, std::vector< std::shared_ptr< Tensor > > > ints_
ERI factors, CoreTensor, swapped out.
Definition: lreri.h:247
void pack(std::map< std::string, std::shared_ptr< Tensor > > &Xs, std::map< std::string, std::shared_ptr< Tensor > > &Zs, std::map< std::string, std::shared_ptr< Tensor > > &Ls, std::map< std::string, std::shared_ptr< Tensor > > &Ss)
Pack up the integrals.
Definition: lreri.cc:1329
void set_omega(double omega)
Set the omega value. ALL integrals and metrics will use this value if set.
Definition: lreri.h:217
virtual void clear()
Clear the C matrix and orbital spaces list.
Definition: lreri.cc:268
virtual void load_options(Options &options)
O: Load the usual options objects.
Definition: lreri.cc:129
virtual void load_options(Options &options)
O: Load the usual options objects.
Definition: lreri.cc:247
void common_init()
Set defaults.
Definition: lreri.cc:69
void fit()
Definition: lreri.cc:669
virtual void load_options(Options &options)
O: Load the usual options objects.
Definition: lreri.cc:777
double schwarz_cutoff_
Schwarz sieve tolerance.
Definition: lreri.h:240
virtual void clear_pair_spaces()
Definition: lreri.cc:260
std::map< std::string, std::shared_ptr< Tensor > > build_E(std::map< std::string, std::shared_ptr< Tensor > > &Xs)
Build all required E matrices (nA x nP, disk) [deleted].
Definition: lreri.cc:917
Definition: lreri.h:224
void set_balance(bool balance)
Set to balance or not?
Definition: lreri.h:326
std::map< std::string, std::shared_ptr< Tensor > > build_L(std::map< std::string, std::shared_ptr< Tensor > > &Es, std::map< std::string, std::shared_ptr< Tensor > > &Ss)
Build all requred L matrices (nP x nA, core, swapped)
Definition: lreri.cc:1259
double schwarz_cutoff_
Schwarz sieve tolerance.
Definition: lreri.h:139
std::shared_ptr< Matrix > Jm12(std::shared_ptr< BasisSet > auxiliary, double condition)
Inverse fitting metric.
Definition: lreri.cc:152
DFERI(std::shared_ptr< BasisSet > primary, std::shared_ptr< BasisSet > auxiliary)
Definition: lreri.cc:219
std::map< std::string, std::vector< std::shared_ptr< Tensor > > > & ints()
LS-LSTHC factors [X1,X2,Z,X3,X4,L12,L34,Sinv12,Sinv34].
Definition: lreri.h:310
int print_
Print flag.
Definition: lreri.h:53
virtual void compute()
R: Compute the requested DF 3-index integrals.
Definition: lreri.cc:394
virtual void compute()=0
R: Compute the desired ERI factorization.
void set_S_cutoff(double S_cutoff)
Set the relative eigenvalue cutoff in S^{-1}.
Definition: lreri.h:322
virtual ~LSTHCERI()
Definition: lreri.cc:755
std::vector< std::string > eri_spaces_order_
Order of ERI spaces, to keep printing nice.
Definition: lreri.h:253
std::shared_ptr< Matrix > X_
Raw AO-basis X matrix (nso x nP, for now)
Definition: lreri.h:232
double J_cutoff_
Relative condition number in J^-1/2.
Definition: lreri.h:137
double S_cutoff_
Relative condition number in S^-1.
Definition: lreri.h:238
virtual void compute()
R: Compute the requested LS-LSTHC factors.
Definition: lreri.cc:843
PRAGMA_WARNING_PUSH PRAGMA_WARNING_IGNORE_DEPRECATED_DECLARATIONS PRAGMA_WARNING_POP
Definition: integraliter.cc:43
std::map< std::string, std::shared_ptr< Tensor > > build_Z(std::map< std::string, std::shared_ptr< Tensor > > &Ls)
Build all required Z matrices (nP x nP, core, swapped)
Definition: lreri.cc:1304
void balance(double **a, int n)
double omega_
Definition: lreri.h:143
std::map< std::string, std::vector< std::shared_ptr< Tensor > > > meths_
METH factors, CoreTensor, swapped out.
Definition: lreri.h:249
Definition: liboptions.h:360
LRERI(std::shared_ptr< BasisSet > primary)
Definition: lreri.cc:61
std::shared_ptr< BasisSet > primary_
Primary orbital basis (nso)
Definition: lreri.h:64
std::shared_ptr< Matrix > Jpow(double power=-1.0/2.0)
Return the J matrix raised to the desired power.
Definition: lreri.cc:316
int debug_
Debug flag.
Definition: lreri.h:55
std::map< std::string, std::pair< std::string, std::string > > pair_spaces_
Requested pair spaces.
Definition: lreri.h:150
int bench_
Bench flag.
Definition: lreri.h:57
virtual ~LRERI()
Definition: lreri.cc:66
virtual void compute_meth()
O: Compute the METH X and Sinv matrices.
Definition: lreri.cc:867
std::map< std::string, std::vector< std::string > > eri_spaces_
Requested ERI spaces.
Definition: lreri.h:251
bool balance_
Balance the X matrices?
Definition: lreri.h:242
static std::shared_ptr< LSTHCERI > build(std::shared_ptr< BasisSet > primary, std::shared_ptr< BasisSet > auxiliary, std::shared_ptr< Matrix > X, Options &options)
Definition: lreri.cc:765
std::vector< std::string > pair_spaces_order_
Order of pair spaces, to keep printing nice.
Definition: lreri.h:156
virtual void clear()
Clear the C matrix and orbital spaces list.
Definition: lreri.cc:795
std::map< std::string, std::shared_ptr< Tensor > > build_X(bool meth=false)
Build all requred X matrices (np x nP, core)
Definition: lreri.cc:878
static std::shared_ptr< DFERI > build(std::shared_ptr< BasisSet > primary, std::shared_ptr< BasisSet > auxiliary, Options &options)
Definition: lreri.cc:235
std::map< std::string, std::shared_ptr< Tensor > > build_S(std::map< std::string, std::shared_ptr< Tensor > > &Xs, bool meth=false)
Build all required inverse S matrices (nP x nP, core, swapped)
Definition: lreri.cc:1212
void transform()
Definition: lreri.cc:436
std::shared_ptr< BasisSet > auxiliary_
Auxiliary orbital-pair basis.
Definition: lreri.h:234
std::map< std::string, std::shared_ptr< Tensor > > ints_
Three-center integrals, by name, sorted e.g. (ov|Q), DiskTensor.
Definition: lreri.h:148
void add_pair_space(const std::string &name, const std::string &space1, const std::string &space2, double pow=-1.0/2.0, bool transpose12=false)
Definition: lreri.cc:253
virtual void print_header(int level=1)
Print info.
Definition: lreri.cc:273
unsigned long int memory_
Memory in doubles.
Definition: lreri.h:59
void set_C(std::shared_ptr< Matrix > C)
R: Set the overall C matrix (calls clear before starting)
Definition: lreri.cc:136
void set_J_cutoff(double J_cutoff)
Set the relative eigenvalue cutoff in J^{-1/2}.
Definition: lreri.h:210
void set_print(int print)
Set the print flag.
Definition: lreri.h:115
int size_Q()
The size of the auxiliary basis.
Definition: lreri.cc:312
std::map< std::string, double > pair_powers_
Requested pair space powers.
Definition: lreri.h:152
std::shared_ptr< BasisSet > auxiliary_
Auxiliary orbital-pair basis.
Definition: lreri.h:135
void allocate()
Definition: lreri.cc:408
void set_J_cutoff(double J_cutoff)
Set the relative eigenvalue cutoff in J^{-1/2}.
Definition: lreri.h:320
void set_keep_raw_integrals(bool val)
Set to keep the raw integrals in (Q|ia) striping?
Definition: lreri.h:214
void set_schwarz_cutoff(double schwarz_cutoff)
Set the schwarz sieve cutoff.
Definition: lreri.h:324
double J_cutoff_
Relative condition number in J^-1/2.
Definition: lreri.h:236
virtual void print_header(int level=1)=0
Print info.
void common_init()
Set defaults.
Definition: lreri.cc:228
virtual void load_wavefunction(std::shared_ptr< Wavefunction > ref)
O: Load the usual orbital spaces for an RHF or UHF wavefunction.
Definition: lreri.cc:77
void set_debug(int debug)
Set the debug flag.
Definition: lreri.h:117
void set_bench(int bench)
Set the bench flag.
Definition: lreri.h:119
bool keep_raw_integrals_
Keep the raw (Q|ia)-type integrals?
Definition: lreri.h:159
std::vector< std::string > spaces_order_
Orbital spaces order buffer, to keep the printing nice.
Definition: lreri.h:73
Definition: lreri.h:46
void set_schwarz_cutoff(double schwarz_cutoff)
Set the schwarz sieve cutoff.
Definition: lreri.h:212
void common_init()
Set defaults.
Definition: lreri.cc:758
std::map< std::string, std::pair< int, int > > spaces_
Orbital spaces, each defined by a keyword and the index range in &lt;start, end+1&gt;.
Definition: lreri.h:71
virtual void clear()
Clear the C matrix and orbital spaces list.
Definition: lreri.cc:146
void set_memory(unsigned long int memory)
Set the allowed memory in doubles.
Definition: lreri.h:121