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