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 program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License along
22  * with this program; if not, write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  *
25  * @END LICENSE
26  */
27 
28 #ifndef LRERI_H
29 #define LRERI_H
30 
31 #include <map>
32 #include <string>
33  #include "psi4/pragma.h"
34  PRAGMA_WARNING_PUSH
35  PRAGMA_WARNING_IGNORE_DEPRECATED_DECLARATIONS
36  #include <memory>
38 #include "psi4/libmints/typedefs.h"
39 
40 namespace psi {
41 
42 class Options;
43 class Tensor;
44 class CoreTensor;
45 class DiskTensor;
46 class BasisSet;
47 class LRERI {
48 
49 protected:
50 
51  // => Utility <= //
52 
54  int print_;
56  int debug_;
58  int bench_;
60  unsigned long int memory_;
61 
62  // => Basis Set <= //
63 
65  std::shared_ptr<BasisSet> primary_;
66 
67  // => Orbital Spaces <= //
68 
70  std::shared_ptr<Matrix> C_;
72  std::map<std::string, std::pair<int, int> > spaces_;
74  std::vector<std::string> spaces_order_;
75 
76  // => Utility Routines <= //
77 
79  void common_init();
80 
82  std::shared_ptr<Matrix> Jm12(std::shared_ptr<BasisSet> auxiliary, double condition);
83 
84 public:
85  // => Constructors <= //
86 
87  LRERI(std::shared_ptr<BasisSet> primary);
88  virtual ~LRERI();
89 
90  // => Defaults <= //
91 
93  virtual void load_wavefunction(std::shared_ptr<Wavefunction> ref);
95  virtual void load_options(Options& options);
96 
97  // => Orbital Space Control <= //
98 
100  void set_C(std::shared_ptr<Matrix> C);
102  void add_space(const std::string& key, int start, int end);
104  virtual void clear();
105 
106  // => Computers <= //
107 
109  virtual void print_header(int level = 1) = 0;
111  virtual void compute() = 0;
112 
113  // => Setters <= //
114 
116  void set_print(int print) { print_ = print; }
118  void set_debug(int debug) { debug_ = debug; }
120  void set_bench(int bench) { bench_ = bench; }
122  void set_memory(unsigned long int memory) { memory_ = memory; }
123 
124 };
125 
129 class DFERI : public LRERI {
130 
131 protected:
132 
133  // => DF Tech <= //
134 
136  std::shared_ptr<BasisSet> auxiliary_;
138  double J_cutoff_;
141 
142  // => HACK for LRC-ERIs <= //
143 
144  double omega_;
145 
146  // => Targets <= //
147 
149  std::map<std::string, std::shared_ptr<Tensor> > ints_;
151  std::map<std::string, std::pair<std::string, std::string> > pair_spaces_;
153  std::map<std::string, double> pair_powers_;
155  std::map<std::string, bool> pair_transposes_;
157  std::vector<std::string> pair_spaces_order_;
158 
161 
162  // => Utility Routines <= //
163 
165  void common_init();
166 
167  void allocate();
168  void transform();
169  void fit();
170 
171 public:
172  // => Constructors <= //
173 
174  DFERI(std::shared_ptr<BasisSet> primary,
175  std::shared_ptr<BasisSet> auxiliary);
176  virtual ~DFERI();
177 
178  static std::shared_ptr<DFERI> build(std::shared_ptr<BasisSet> primary, std::shared_ptr<BasisSet> auxiliary, Options& options);
179  static std::shared_ptr<DFERI> build(std::shared_ptr<BasisSet> primary, std::shared_ptr<BasisSet> auxiliary, Options& options, std::shared_ptr<Wavefunction> ref);
180 
181  // => Defaults <= //
182 
184  virtual void load_options(Options& options);
185 
186  // => Pair Space Control <= //
187 
188  // R: add an orbital pair space to the list of tasks
189  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);
190  // Clear this DFERI object of tasks
191  virtual void clear();
192  // Clear this DFERI object of pair spaces
193  virtual void clear_pair_spaces();
194 
195  // => Computers <= //
196 
198  virtual void print_header(int level = 1);
200  int size_Q();
202  virtual void compute();
204  std::map<std::string, std::shared_ptr<Tensor> >& ints() { return ints_; }
206  std::shared_ptr<Matrix> Jpow(double power = -1.0/2.0);
207 
208  // => Setters <= //
209 
211  void set_J_cutoff(double J_cutoff) { J_cutoff_ = J_cutoff; }
213  void set_schwarz_cutoff(double schwarz_cutoff) { schwarz_cutoff_ = schwarz_cutoff; }
215  void set_keep_raw_integrals(bool val) { keep_raw_integrals_ = val; }
216 
218  void set_omega(double omega) { omega_ = omega; }
219 
220 };
221 
225 class LSTHCERI : public LRERI {
226 
227 
228 protected:
229 
230  // => LS-LSTHC Tech <= //
231 
233  std::shared_ptr<Matrix> X_;
235  std::shared_ptr<BasisSet> auxiliary_;
237  double J_cutoff_;
239  double S_cutoff_;
243  bool balance_;
244 
245  // => Targets <= //
246 
248  std::map<std::string, std::vector<std::shared_ptr<Tensor> > > ints_;
250  std::map<std::string, std::vector<std::shared_ptr<Tensor> > > meths_;
252  std::map<std::string, std::vector<std::string> > eri_spaces_;
254  std::vector<std::string> eri_spaces_order_;
255 
256  // => Utility Routines <= //
257 
259  void common_init();
260 
262  std::map<std::string, std::shared_ptr<Tensor> > build_X(bool meth = false);
264  std::map<std::string, std::shared_ptr<Tensor> > build_E(std::map<std::string, std::shared_ptr<Tensor> >& Xs);
266  std::map<std::string, std::shared_ptr<Tensor> > build_S(std::map<std::string, std::shared_ptr<Tensor> >& Xs, bool meth = false);
268  std::map<std::string, std::shared_ptr<Tensor> > build_L(std::map<std::string, std::shared_ptr<Tensor> >& Es,
269  std::map<std::string, std::shared_ptr<Tensor> >& Ss);
271  std::map<std::string, std::shared_ptr<Tensor> > build_Z(std::map<std::string, std::shared_ptr<Tensor> >& Ls);
273  void pack(std::map<std::string, std::shared_ptr<Tensor> >& Xs,
274  std::map<std::string, std::shared_ptr<Tensor> >& Zs,
275  std::map<std::string, std::shared_ptr<Tensor> >& Ls,
276  std::map<std::string, std::shared_ptr<Tensor> >& Ss);
278  void pack_meth(std::map<std::string, std::shared_ptr<Tensor> >& Xs,
279  std::map<std::string, std::shared_ptr<Tensor> >& Ss);
280 
281 public:
282  // => Constructors <= //
283 
284  LSTHCERI(std::shared_ptr<BasisSet> primary,
285  std::shared_ptr<BasisSet> auxiliary,
286  std::shared_ptr<Matrix> X);
287  virtual ~LSTHCERI();
288 
289  static std::shared_ptr<LSTHCERI> build(std::shared_ptr<BasisSet> primary, std::shared_ptr<BasisSet> auxiliary, std::shared_ptr<Matrix> X, Options& options);
290  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);
291 
292  // => Defaults <= //
293 
295  virtual void load_options(Options& options);
296 
297  // => ERI Space Control <= //
298 
299  // R: add an eri space to the list of tasks
300  void add_eri_space(const std::string& name, const std::string& space1, const std::string& space2, const std::string& space3, const std::string& space4);
301  // Clear this LSTHCERI object of tasks
302  virtual void clear();
303 
304  // => Computers <= //
305 
307  virtual void print_header(int level = 1);
309  virtual void compute();
311  std::map<std::string, std::vector<std::shared_ptr<Tensor> > >& ints() { return ints_; };
312 
314  virtual void compute_meth();
316  std::map<std::string, std::vector<std::shared_ptr<Tensor> > >& meths() { return meths_; }
317 
318  // => Setters <= //
319 
321  void set_J_cutoff(double J_cutoff) { J_cutoff_ = J_cutoff; }
323  void set_S_cutoff(double S_cutoff) { S_cutoff_ = S_cutoff; }
325  void set_schwarz_cutoff(double schwarz_cutoff) { schwarz_cutoff_ = schwarz_cutoff; }
328 };
329 
330 
331 } // End namespace
332 
333 #endif
std::map< std::string, std::shared_ptr< Tensor > > & ints()
Handle to computed disk tensors, by name in add_pair above.
Definition: lreri.h:204
std::map< std::string, bool > pair_transposes_
Requested pair space transpositions (ab|Q) -&gt; (ba|Q)
Definition: lreri.h:155
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:1342
std::shared_ptr< Matrix > C_
Occupation matrix coefficients (nso x nmo)
Definition: lreri.h:70
virtual ~DFERI()
Definition: lreri.cc:224
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:776
Definition: lreri.h:129
virtual void print_header(int level=1)
Print info.
Definition: lreri.cc:793
std::map< std::string, std::vector< std::shared_ptr< Tensor > > > & meths()
METH helper factors [X1,X2,Sinv].
Definition: lreri.h:316
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:140
LSTHCERI(std::shared_ptr< BasisSet > primary, std::shared_ptr< BasisSet > auxiliary, std::shared_ptr< Matrix > X)
Definition: lreri.cc:737
std::map< std::string, std::vector< std::shared_ptr< Tensor > > > ints_
ERI factors, CoreTensor, swapped out.
Definition: lreri.h:248
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:1320
void set_omega(double omega)
Set the omega value. ALL integrals and metrics will use this value if set.
Definition: lreri.h:218
virtual void clear()
Clear the C matrix and orbital spaces list.
Definition: lreri.cc:267
virtual void load_options(Options &options)
O: Load the usual options objects.
Definition: lreri.cc:128
virtual void load_options(Options &options)
O: Load the usual options objects.
Definition: lreri.cc:246
void common_init()
Set defaults.
Definition: lreri.cc:68
void fit()
Definition: lreri.cc:660
virtual void load_options(Options &options)
O: Load the usual options objects.
Definition: lreri.cc:768
double schwarz_cutoff_
Schwarz sieve tolerance.
Definition: lreri.h:241
virtual void clear_pair_spaces()
Definition: lreri.cc:259
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:908
Definition: lreri.h:225
void set_balance(bool balance)
Set to balance or not?
Definition: lreri.h:327
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:1250
double schwarz_cutoff_
Schwarz sieve tolerance.
Definition: lreri.h:140
std::shared_ptr< Matrix > Jm12(std::shared_ptr< BasisSet > auxiliary, double condition)
Inverse fitting metric.
Definition: lreri.cc:151
DFERI(std::shared_ptr< BasisSet > primary, std::shared_ptr< BasisSet > auxiliary)
Definition: lreri.cc:218
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:311
int print_
Print flag.
Definition: lreri.h:54
virtual void compute()
R: Compute the requested DF 3-index integrals.
Definition: lreri.cc:385
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:323
virtual ~LSTHCERI()
Definition: lreri.cc:746
std::vector< std::string > eri_spaces_order_
Order of ERI spaces, to keep printing nice.
Definition: lreri.h:254
std::shared_ptr< Matrix > X_
Raw AO-basis X matrix (nso x nP, for now)
Definition: lreri.h:233
double J_cutoff_
Relative condition number in J^-1/2.
Definition: lreri.h:138
double S_cutoff_
Relative condition number in S^-1.
Definition: lreri.h:239
virtual void compute()
R: Compute the requested LS-LSTHC factors.
Definition: lreri.cc:834
PRAGMA_WARNING_PUSH PRAGMA_WARNING_IGNORE_DEPRECATED_DECLARATIONS PRAGMA_WARNING_POP
Definition: integraliter.cc:42
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:1295
void balance(double **a, int n)
double omega_
Definition: lreri.h:144
std::map< std::string, std::vector< std::shared_ptr< Tensor > > > meths_
METH factors, CoreTensor, swapped out.
Definition: lreri.h:250
Definition: liboptions.h:359
LRERI(std::shared_ptr< BasisSet > primary)
Definition: lreri.cc:60
std::shared_ptr< BasisSet > primary_
Primary orbital basis (nso)
Definition: lreri.h:65
std::shared_ptr< Matrix > Jpow(double power=-1.0/2.0)
Return the J matrix raised to the desired power.
Definition: lreri.cc:315
int debug_
Debug flag.
Definition: lreri.h:56
std::map< std::string, std::pair< std::string, std::string > > pair_spaces_
Requested pair spaces.
Definition: lreri.h:151
int bench_
Bench flag.
Definition: lreri.h:58
virtual ~LRERI()
Definition: lreri.cc:65
virtual void compute_meth()
O: Compute the METH X and Sinv matrices.
Definition: lreri.cc:858
std::map< std::string, std::vector< std::string > > eri_spaces_
Requested ERI spaces.
Definition: lreri.h:252
bool balance_
Balance the X matrices?
Definition: lreri.h:243
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:756
std::vector< std::string > pair_spaces_order_
Order of pair spaces, to keep printing nice.
Definition: lreri.h:157
virtual void clear()
Clear the C matrix and orbital spaces list.
Definition: lreri.cc:786
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:869
static std::shared_ptr< DFERI > build(std::shared_ptr< BasisSet > primary, std::shared_ptr< BasisSet > auxiliary, Options &options)
Definition: lreri.cc:234
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:1203
void transform()
Definition: lreri.cc:427
std::shared_ptr< BasisSet > auxiliary_
Auxiliary orbital-pair basis.
Definition: lreri.h:235
std::map< std::string, std::shared_ptr< Tensor > > ints_
Three-center integrals, by name, sorted e.g. (ov|Q), DiskTensor.
Definition: lreri.h:149
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:252
virtual void print_header(int level=1)
Print info.
Definition: lreri.cc:272
unsigned long int memory_
Memory in doubles.
Definition: lreri.h:60
void set_C(std::shared_ptr< Matrix > C)
R: Set the overall C matrix (calls clear before starting)
Definition: lreri.cc:135
void set_J_cutoff(double J_cutoff)
Set the relative eigenvalue cutoff in J^{-1/2}.
Definition: lreri.h:211
void set_print(int print)
Set the print flag.
Definition: lreri.h:116
int size_Q()
The size of the auxiliary basis.
Definition: lreri.cc:311
std::map< std::string, double > pair_powers_
Requested pair space powers.
Definition: lreri.h:153
std::shared_ptr< BasisSet > auxiliary_
Auxiliary orbital-pair basis.
Definition: lreri.h:136
void allocate()
Definition: lreri.cc:399
void set_J_cutoff(double J_cutoff)
Set the relative eigenvalue cutoff in J^{-1/2}.
Definition: lreri.h:321
void set_keep_raw_integrals(bool val)
Set to keep the raw integrals in (Q|ia) striping?
Definition: lreri.h:215
void set_schwarz_cutoff(double schwarz_cutoff)
Set the schwarz sieve cutoff.
Definition: lreri.h:325
double J_cutoff_
Relative condition number in J^-1/2.
Definition: lreri.h:237
virtual void print_header(int level=1)=0
Print info.
void common_init()
Set defaults.
Definition: lreri.cc:227
virtual void load_wavefunction(std::shared_ptr< Wavefunction > ref)
O: Load the usual orbital spaces for an RHF or UHF wavefunction.
Definition: lreri.cc:76
void set_debug(int debug)
Set the debug flag.
Definition: lreri.h:118
void set_bench(int bench)
Set the bench flag.
Definition: lreri.h:120
bool keep_raw_integrals_
Keep the raw (Q|ia)-type integrals?
Definition: lreri.h:160
std::vector< std::string > spaces_order_
Orbital spaces order buffer, to keep the printing nice.
Definition: lreri.h:74
Definition: lreri.h:47
void set_schwarz_cutoff(double schwarz_cutoff)
Set the schwarz sieve cutoff.
Definition: lreri.h:213
void common_init()
Set defaults.
Definition: lreri.cc:749
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:72
virtual void clear()
Clear the C matrix and orbital spaces list.
Definition: lreri.cc:145
void set_memory(unsigned long int memory)
Set the allowed memory in doubles.
Definition: lreri.h:122