Psi4
corr_grad.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 Corr_GRAD_H
29 #define Corr_GRAD_H
30 
31 #include "psi4/libmints/typedefs.h"
32 #include <map>
33 
34 namespace psi {
35 
36 class ERISieve;
37 
38 namespace dfmp2 {
39 
40 class CorrGrad {
41 
42 protected:
44  int print_;
46  int debug_;
48  int bench_;
50  unsigned long int memory_;
52  int nthreads_;
54  double cutoff_;
55 
56  std::shared_ptr<BasisSet> primary_;
57 
72 
79 
80  std::map<std::string, SharedMatrix> gradients_;
81 
82  void common_init();
83 
84 public:
85  CorrGrad(std::shared_ptr<BasisSet> primary);
86  virtual ~CorrGrad();
87 
94  static std::shared_ptr<CorrGrad> build_CorrGrad(std::shared_ptr<BasisSet> primary,
95  std::shared_ptr<BasisSet> auxiliary);
96 
97  void set_Ca(SharedMatrix Ca) { Ca_ = Ca; }
98  void set_Cb(SharedMatrix Cb) { Cb_ = Cb; }
99  void set_La(SharedMatrix La) { La_ = La; }
100  void set_Lb(SharedMatrix Lb) { Lb_ = Lb; }
101  void set_Ra(SharedMatrix Ra) { Ra_ = Ra; }
102  void set_Rb(SharedMatrix Rb) { Rb_ = Rb; }
103  void set_Da(SharedMatrix Da) { Da_ = Da; }
104  void set_Db(SharedMatrix Db) { Db_ = Db; }
105  void set_Dt(SharedMatrix Dt) { Dt_ = Dt; }
106  void set_Pa(SharedMatrix Pa) { Pa_ = Pa; }
107  void set_Pb(SharedMatrix Pb) { Pb_ = Pb; }
108  void set_Pt(SharedMatrix Pt) { Pt_ = Pt; }
109 
117  void set_cutoff(double cutoff) { cutoff_ = cutoff; }
123  void set_memory(unsigned long int memory) { memory_ = memory; }
133  void set_omp_num_threads(int omp_nthread) { nthreads_ = omp_nthread; }
135  void set_print(int print) { print_ = print; }
137  void set_debug(int debug) { debug_ = debug; }
139  void set_bench(int bench) { bench_ = bench; }
140 
141  std::map<std::string, SharedMatrix>& gradients() { return gradients_; }
142 
143  virtual void compute_gradient() = 0;
144 
145  virtual void print_header() const = 0;
146 };
147 
148 class DFCorrGrad : public CorrGrad {
149 
150 protected:
151  std::shared_ptr<BasisSet> auxiliary_;
152 
153  std::shared_ptr<PSIO> psio_;
154 
158  double condition_;
159 
161  std::shared_ptr<ERISieve> sieve_;
162 
163  void common_init();
164 
165  void build_Amn_terms();
166  void build_AB_inv_terms();
167  void build_UV_terms();
168  void build_AB_x_terms();
169  void build_Amn_x_terms();
170 
171  void fitting_helper(SharedMatrix J, unsigned int file, const std::string& label, unsigned long int naux, unsigned long int nij, unsigned long int memory);
172  void UV_helper(SharedMatrix V, double c, unsigned int file, const std::string& label, unsigned long int naux, unsigned long int nij, unsigned long int memory);
173 
175  unsigned int unit_a_;
177  unsigned int unit_b_;
179  unsigned int unit_c_;
180 
181 public:
182  DFCorrGrad(std::shared_ptr<BasisSet> primary, std::shared_ptr<BasisSet> auxiliary);
183  virtual ~DFCorrGrad();
184 
185  void compute_gradient();
186 
187  void print_header() const;
188 
196  void set_condition(double condition) { condition_ = condition; }
201  void set_unit_a(unsigned int unit) { unit_a_ = unit; }
206  void set_unit_b(unsigned int unit) { unit_b_ = unit; }
211  void set_unit_c(unsigned int unit) { unit_c_ = unit; }
212 
218 };
219 
220 }} // Namespaces
221 #endif
double cutoff_
Integral cutoff (defaults to 0.0)
Definition: corr_grad.h:54
void build_AB_inv_terms()
Definition: corr_grad.cc:438
void print_header() const
Definition: corr_grad.cc:119
void set_unit_b(unsigned int unit)
Definition: corr_grad.h:206
SharedMatrix Pt_
Definition: corr_grad.h:78
int nthreads_
Number of OpenMP threads (defaults to 1 in no OpenMP, Process::environment.get_n_threads() otherwise)...
Definition: corr_grad.h:52
void common_init()
Definition: corr_grad.cc:107
SharedMatrix La_
Definition: corr_grad.h:68
void build_UV_terms()
Definition: corr_grad.cc:532
int print_
Print flag, defaults to 1.
Definition: corr_grad.h:44
SharedMatrix Pa_
Definition: corr_grad.h:76
void set_print(int print)
Print flag (defaults to 1)
Definition: corr_grad.h:135
void set_Rb(SharedMatrix Rb)
Definition: corr_grad.h:102
void build_Amn_terms()
Definition: corr_grad.cc:180
std::map< std::string, SharedMatrix > & gradients()
Definition: corr_grad.h:141
virtual ~DFCorrGrad()
Definition: corr_grad.cc:104
SharedMatrix Lb_
Definition: corr_grad.h:69
SharedMatrix Cb_
Definition: corr_grad.h:67
int df_ints_num_threads_
Number of threads for DF integrals.
Definition: corr_grad.h:156
void set_bench(int bench)
Bench flag (defaults to 0)
Definition: corr_grad.h:139
virtual ~CorrGrad()
Definition: corr_grad.cc:55
int bench_
Bench flag, defaults to 0.
Definition: corr_grad.h:48
Definition: corr_grad.h:40
void set_debug(int debug)
Debug flag (defaults to 0)
Definition: corr_grad.h:137
void build_Amn_x_terms()
Definition: corr_grad.cc:743
void set_Dt(SharedMatrix Dt)
Definition: corr_grad.h:105
unsigned int unit_c_
File number for J tensors.
Definition: corr_grad.h:179
SharedMatrix Ra_
Definition: corr_grad.h:70
SharedMatrix Dt_
Definition: corr_grad.h:75
SharedMatrix Ca_
Definition: corr_grad.h:66
std::map< std::string, SharedMatrix > gradients_
Definition: corr_grad.h:80
void set_df_ints_num_threads(int val)
Definition: corr_grad.h:217
std::shared_ptr< ERISieve > sieve_
Sieve, must be static throughout the life of the object.
Definition: corr_grad.h:161
void set_cutoff(double cutoff)
Definition: corr_grad.h:117
std::shared_ptr< BasisSet > primary_
Definition: corr_grad.h:56
void set_Cb(SharedMatrix Cb)
Definition: corr_grad.h:98
SharedMatrix Rb_
Definition: corr_grad.h:71
void build_AB_x_terms()
Definition: corr_grad.cc:604
void set_Ca(SharedMatrix Ca)
Definition: corr_grad.h:97
Definition: corr_grad.h:148
void set_Pb(SharedMatrix Pb)
Definition: corr_grad.h:107
DFCorrGrad(std::shared_ptr< BasisSet > primary, std::shared_ptr< BasisSet > auxiliary)
Definition: corr_grad.cc:99
virtual void print_header() const =0
void set_Pa(SharedMatrix Pa)
Definition: corr_grad.h:106
SharedMatrix Da_
Definition: corr_grad.h:73
std::shared_ptr< PSIO > psio_
Definition: corr_grad.h:153
void fitting_helper(SharedMatrix J, unsigned int file, const std::string &label, unsigned long int naux, unsigned long int nij, unsigned long int memory)
Definition: corr_grad.cc:495
int debug_
Debug flag, defaults to 0.
Definition: corr_grad.h:46
std::shared_ptr< BasisSet > auxiliary_
Definition: corr_grad.h:151
void set_Db(SharedMatrix Db)
Definition: corr_grad.h:104
void set_unit_a(unsigned int unit)
Definition: corr_grad.h:201
void set_Lb(SharedMatrix Lb)
Definition: corr_grad.h:100
std::shared_ptr< Matrix > SharedMatrix
Definition: adc.h:50
void UV_helper(SharedMatrix V, double c, unsigned int file, const std::string &label, unsigned long int naux, unsigned long int nij, unsigned long int memory)
Definition: corr_grad.cc:573
virtual void compute_gradient()=0
void common_init()
Definition: corr_grad.cc:85
void set_unit_c(unsigned int unit)
Definition: corr_grad.h:211
void set_Ra(SharedMatrix Ra)
Definition: corr_grad.h:101
unsigned int unit_a_
File number for Alpha (Q|mn) tensor.
Definition: corr_grad.h:175
unsigned long int memory_
Memory available, in doubles, defaults to 256 MB (32 M doubles)
Definition: corr_grad.h:50
SharedMatrix Db_
Definition: corr_grad.h:74
unsigned int unit_b_
File number for Beta (Q|mn) tensor.
Definition: corr_grad.h:177
void set_La(SharedMatrix La)
Definition: corr_grad.h:99
void compute_gradient()
Definition: corr_grad.cc:134
void set_condition(double condition)
Definition: corr_grad.h:196
SharedWavefunction dfmp2(SharedWavefunction, Options &)
Definition: dfmp2/wrapper.cc:49
static std::shared_ptr< CorrGrad > build_CorrGrad(std::shared_ptr< BasisSet > primary, std::shared_ptr< BasisSet > auxiliary)
Definition: corr_grad.cc:58
double condition_
Condition cutoff in fitting metric, defaults to 1.0E-12.
Definition: corr_grad.h:158
void set_Da(SharedMatrix Da)
Definition: corr_grad.h:103
void set_Pt(SharedMatrix Pt)
Definition: corr_grad.h:108
void set_memory(unsigned long int memory)
Definition: corr_grad.h:123
SharedMatrix Pb_
Definition: corr_grad.h:77
CorrGrad(std::shared_ptr< BasisSet > primary)
Definition: corr_grad.cc:50
void set_omp_num_threads(int omp_nthread)
Definition: corr_grad.h:133