Psi4
mp2.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 TOTAL_DFMP2_H
30 #define TOTAL_DFMP2_H
31 
33 #include <map>
34 
35 namespace psi {
36 
37 class PSIO;
38 
39 namespace dfmp2 {
40 
41 class DFMP2 : public Wavefunction {
42 
43 protected:
44 
45  // Auxiliary basis
46  std::shared_ptr<BasisSet> ribasis_;
47  // Gradients map
48  std::map<std::string, SharedMatrix> gradients_;
49 
50  // Same-spin scale
51  double sss_;
52  // Opposite-spin scale
53  double oss_;
54 
55  void common_init();
56  // Common printing of energies/SCS
57  virtual void print_energies();
58  virtual void print_gradients();
59 
60  // Print header/reference information
61  virtual void print_header() = 0;
62  // Form the (A|ia) = (A|mn) C_mi C_na tensor(s)
63  virtual void form_Aia() = 0;
64  // Apply the fitting (Q|ia) = J_QA^-1/2 (A|ia)
65  virtual void form_Qia() = 0;
66  // Apply the fitting (Q|ia) = J_QA^-1/2 (A|ia) and J_QA^-1 (A|ia)
67  virtual void form_Qia_gradient() = 0;
68  // Transpose the integrals to (ai|Q)
69  virtual void form_Qia_transpose() = 0;
70  // Form the energy contributions
71  virtual void form_energy() = 0;
72  // Form the energy contributions and gradients
73  virtual void form_Pab() = 0;
74  // Form the energy contributions and gradients
75  virtual void form_Pij() = 0;
76  // Form the small gamma
77  virtual void form_gamma() = 0;
78  // Transpose the G
79  virtual void form_G_transpose() = 0;
80  // Form the (A|B)^x contribution to the gradient
81  virtual void form_AB_x_terms() = 0;
82  // Form the (A|mn)^x contribution to the gradient
83  virtual void form_Amn_x_terms() = 0;
84  // Form the Lma and Lmi matrices
85  virtual void form_L() = 0;
86  // Form the unrelaxed OPDM
87  virtual void form_P() = 0;
88  // Form the unrelaxed energy-weighted OPDM
89  virtual void form_W() = 0;
90  // Form the full Lagrangian, solve the Z-vector equations, and apply final corrections to W and P
91  virtual void form_Z() = 0;
92  // Manage the formation of W and P contributions to the gradient
93  virtual void form_gradient() = 0;
94 
95  // Compute singles correction [for ROHF-MBPT(2) or dual-basis]
96  virtual void form_singles();
97  // Apply the fitting and transposition to a given disk entry Aia tensor
98  virtual void apply_fitting(SharedMatrix Jm12, size_t file, size_t naux, size_t nia);
99  // Apply the fitting again to a given disk entry Qia tensor
100  virtual void apply_fitting_grad(SharedMatrix Jm12, size_t file, size_t naux, size_t nia);
101  // Form the inverse square root of the fitting metric, or read it off disk
103  // Form an abstract gamma
104  virtual void apply_gamma(size_t file, size_t naux, size_t nia);
105  // Form a transposed copy of G_ia^P
106  virtual void apply_G_transpose(size_t file, size_t naux, size_t nia);
107  // Form a transposed copy of iaQ
108  virtual void apply_B_transpose(size_t file, size_t naux, size_t naocc, size_t navir);
109 
110  // Debugging-routine: prints block sizing
111  void block_status(std::vector<int> inds, const char* file, int line);
112  void block_status(std::vector<size_t> inds, const char* file, int line);
113 
114  void compute_opdm_and_nos(const SharedMatrix Dnosym, SharedMatrix Dso, SharedMatrix Cno, SharedVector occ);
115 
116 public:
117  DFMP2(SharedWavefunction ref_wfn, Options& options, std::shared_ptr<PSIO> psio);
118  virtual ~DFMP2();
119 
120  double compute_energy();
121  virtual SharedMatrix compute_gradient();
122 
123 };
124 
125 class RDFMP2 : public DFMP2 {
126 
127 protected:
128 
133 
138 
139  void common_init();
140 
141  // Print additional header
142  virtual void print_header();
143  // Form the (A|ia) = (A|mn) C_mi C_na tensor(s)
144  virtual void form_Aia();
145  // Apply the fitting (Q|ia) = J_QA^-1/2 (A|ia)
146  virtual void form_Qia();
147  // Apply the fitting (Q|ia) = J_QA^-1/2 (A|ia) and J_QA^-1 (A|ia)
148  virtual void form_Qia_gradient();
149  // Transpose the integrals to (ai|Q)
150  virtual void form_Qia_transpose();
151  // Form the energy contributions
152  virtual void form_energy();
153  // Form the energy contributions and gradients
154  virtual void form_Pab();
155  // Form the energy contributions and gradients
156  virtual void form_Pij();
157  // Form the small gamma
158  virtual void form_gamma();
159  // Transpose the G
160  virtual void form_G_transpose();
161  // Form the (A|B)^x contribution to the gradient
162  virtual void form_AB_x_terms();
163  // Form the (A|mn)^x contribution to the gradient
164  virtual void form_Amn_x_terms();
165  // Form the Lma and Lmi matrices
166  virtual void form_L();
167  // Form the unrelaxed OPDM
168  virtual void form_P();
169  // Form the unrelaxed energy-weighted OPDM
170  virtual void form_W();
171  // Form the full Lagrangian, solve the Z-vector equations, and apply final corrections to W and P
172  virtual void form_Z();
173  // Manage the formation of W and P contributions to the gradient
174  virtual void form_gradient();
175 
176 public:
177  RDFMP2(SharedWavefunction ref_wfn, Options& options, std::shared_ptr<PSIO> psio);
178  virtual ~RDFMP2();
179 };
180 
181 class UDFMP2 : public DFMP2 {
182 
183 protected:
184 
189 
194 
195  void common_init();
196 
197  // Print additional header
198  virtual void print_header();
199  // Form the (A|ia) = (A|mn) C_mi C_na tensor(s)
200  virtual void form_Aia();
201  // Apply the fitting (Q|ia) = J_QA^-1/2 (A|ia)
202  virtual void form_Qia();
203  // Apply the fitting (Q|ia) = J_QA^-1/2 (A|ia) and J_QA^-1 (A|ia)
204  virtual void form_Qia_gradient();
205  // Transpose the integrals to (ai|Q)
206  virtual void form_Qia_transpose();
207  // Form the energy contributions
208  virtual void form_energy();
209  // Form the energy contributions and gradients
210  virtual void form_Pab();
211  // Form the energy contributions and gradients
212  virtual void form_Pij();
213  // Form the small gamma
214  virtual void form_gamma();
215  // Transpose the G
216  virtual void form_G_transpose();
217  // Form the (A|B)^x contribution to the gradient
218  virtual void form_AB_x_terms();
219  // Form the (A|mn)^x contribution to the gradient
220  virtual void form_Amn_x_terms();
221  // Form the Lma and Lmi matrices
222  virtual void form_L();
223  // Form the unrelaxed OPDM
224  virtual void form_P();
225  // Form the unrelaxed energy-weighted OPDM
226  virtual void form_W();
227  // Form the full Lagrangian, solve the Z-vector equations, and apply final corrections to W and P
228  virtual void form_Z();
229  // Manage the formation of W and P contributions to the gradient
230  virtual void form_gradient();
231 
232 public:
233  UDFMP2(SharedWavefunction ref_wfn, Options& options, std::shared_ptr<PSIO> psio);
234  virtual ~UDFMP2();
235 };
236 
237 class RODFMP2 : public UDFMP2 {
238 
239 protected:
240 
241  void common_init();
242 
243  // Print additional header
244  virtual void print_header();
245 
246 public:
247  RODFMP2(SharedWavefunction ref_wfn, Options& options, std::shared_ptr<PSIO> psio);
248  virtual ~RODFMP2();
249 };
250 
251 }}
252 
253 #endif
virtual void form_gradient()=0
virtual void form_Qia()=0
virtual void form_Z()
Definition: dfmp2/mp2.cc:3868
std::map< std::string, SharedMatrix > gradients_
Definition: mp2.h:48
virtual void form_W()
Definition: dfmp2/mp2.cc:3864
Options & options() const
Definition: wavefunction.cc:412
void block_status(std::vector< int > inds, const char *file, int line)
Definition: dfmp2/mp2.cc:144
std::shared_ptr< PSIO > psio() const
Definition: wavefunction.cc:407
virtual void form_gamma()=0
RODFMP2(SharedWavefunction ref_wfn, Options &options, std::shared_ptr< PSIO > psio)
Definition: dfmp2/mp2.cc:3877
virtual ~RDFMP2()
Definition: dfmp2/mp2.cc:846
virtual void form_Qia_transpose()
Definition: dfmp2/mp2.cc:1057
virtual void form_P()
Definition: dfmp2/mp2.cc:2049
virtual void form_Pab()=0
SharedVector eps_aocc_
Definition: mp2.h:135
void common_init()
Definition: dfmp2/mp2.cc:849
DFMP2(SharedWavefunction ref_wfn, Options &options, std::shared_ptr< PSIO > psio)
Definition: dfmp2/mp2.cc:161
SharedMatrix Cavir_
Definition: mp2.h:131
Definition: mp2.h:237
void common_init()
Definition: dfmp2/mp2.cc:3885
virtual void print_header()
Definition: dfmp2/mp2.cc:3212
virtual SharedMatrix compute_gradient()
Compute gradient. Subclasses override this function to compute the gradient.
Definition: dfmp2/mp2.cc:234
virtual void form_G_transpose()
Definition: dfmp2/mp2.cc:3844
virtual void form_Aia()
Definition: dfmp2/mp2.cc:3253
virtual void print_header()
Definition: dfmp2/mp2.cc:861
SharedVector eps_aocc_a_
Definition: mp2.h:190
virtual void apply_fitting(SharedMatrix Jm12, size_t file, size_t naux, size_t nia)
Definition: dfmp2/mp2.cc:465
virtual void form_Qia()
Definition: dfmp2/mp2.cc:1046
SharedMatrix Caocc_a_
Definition: mp2.h:185
virtual void form_gradient()
Definition: dfmp2/mp2.cc:3872
virtual void form_Qia()
Definition: dfmp2/mp2.cc:3433
virtual ~UDFMP2()
Definition: dfmp2/mp2.cc:3197
virtual void form_gradient()
Definition: dfmp2/mp2.cc:2532
virtual void apply_G_transpose(size_t file, size_t naux, size_t nia)
Definition: dfmp2/mp2.cc:654
virtual void form_W()=0
SharedMatrix Cfocc_
Definition: mp2.h:129
virtual void form_energy()=0
virtual void print_header()
Definition: dfmp2/mp2.cc:3888
std::shared_ptr< BasisSet > ribasis_
Definition: mp2.h:46
virtual void form_Qia_gradient()
Definition: dfmp2/mp2.cc:3439
virtual void form_AB_x_terms()=0
virtual void form_gamma()
Definition: dfmp2/mp2.cc:1539
virtual void form_G_transpose()
Definition: dfmp2/mp2.cc:1543
virtual ~DFMP2()
Definition: dfmp2/mp2.cc:170
SharedMatrix Caocc_b_
Definition: mp2.h:187
double oss_
Definition: mp2.h:53
virtual void form_singles()
Definition: dfmp2/mp2.cc:331
virtual void form_Amn_x_terms()
Definition: dfmp2/mp2.cc:1659
virtual void apply_fitting_grad(SharedMatrix Jm12, size_t file, size_t naux, size_t nia)
Definition: dfmp2/mp2.cc:529
virtual void form_Aia()=0
SharedVector eps_avir_a_
Definition: mp2.h:191
Definition: mp2.h:125
UDFMP2(SharedWavefunction ref_wfn, Options &options, std::shared_ptr< PSIO > psio)
Definition: dfmp2/mp2.cc:3192
virtual void form_energy()
Definition: dfmp2/mp2.cc:1061
SharedVector eps_fvir_
Definition: mp2.h:137
virtual void form_gamma()
Definition: dfmp2/mp2.cc:3840
SharedMatrix Cavir_b_
Definition: mp2.h:188
virtual void form_Pij()
Definition: dfmp2/mp2.cc:1377
Definition: mp2.h:181
virtual void form_energy()
Definition: dfmp2/mp2.cc:3451
virtual void print_gradients()
Definition: dfmp2/mp2.cc:817
virtual void form_W()
Definition: dfmp2/mp2.cc:2148
virtual void form_Qia_transpose()
Definition: dfmp2/mp2.cc:3447
virtual void form_Pab()
Definition: dfmp2/mp2.cc:1188
SharedMatrix Cfvir_
Definition: mp2.h:132
virtual void print_header()=0
virtual void form_AB_x_terms()
Definition: dfmp2/mp2.cc:1547
Definition: liboptions.h:355
void compute_opdm_and_nos(const SharedMatrix Dnosym, SharedMatrix Dso, SharedMatrix Cno, SharedVector occ)
Definition: dfmp2/mp2.cc:65
virtual void form_L()=0
virtual void form_G_transpose()=0
SharedMatrix Cavir_a_
Definition: mp2.h:186
double compute_energy()
Compute energy. Subclasses override this function to compute its energy.
Definition: dfmp2/mp2.cc:195
virtual void form_Qia_transpose()=0
virtual void print_energies()
Definition: dfmp2/mp2.cc:768
std::shared_ptr< Matrix > SharedMatrix
Definition: adc.h:49
virtual void form_Aia()
Definition: dfmp2/mp2.cc:897
void common_init()
Definition: dfmp2/mp2.cc:3200
virtual void form_Qia_gradient()=0
Simple wavefunction base class.
Definition: wavefunction.h:84
virtual ~RODFMP2()
Definition: dfmp2/mp2.cc:3882
virtual void form_Pij()
Definition: dfmp2/mp2.cc:3836
virtual void form_Amn_x_terms()
Definition: dfmp2/mp2.cc:3852
virtual void form_Z()=0
virtual void form_L()
Definition: dfmp2/mp2.cc:1861
virtual void form_P()
Definition: dfmp2/mp2.cc:3860
SharedMatrix Caocc_
Definition: mp2.h:130
virtual void form_L()
Definition: dfmp2/mp2.cc:3856
SharedWavefunction dfmp2(SharedWavefunction, Options &)
Definition: dfmp2/wrapper.cc:53
RDFMP2(SharedWavefunction ref_wfn, Options &options, std::shared_ptr< PSIO > psio)
Definition: dfmp2/mp2.cc:841
SharedVector eps_aocc_b_
Definition: mp2.h:192
SharedVector eps_avir_b_
Definition: mp2.h:193
virtual void apply_B_transpose(size_t file, size_t naux, size_t naocc, size_t navir)
Definition: dfmp2/mp2.cc:720
std::shared_ptr< Wavefunction > SharedWavefunction
Definition: typedefs.h:54
virtual void form_AB_x_terms()
Definition: dfmp2/mp2.cc:3848
virtual SharedMatrix form_inverse_metric()
Definition: dfmp2/mp2.cc:426
virtual void form_Pab()
Definition: dfmp2/mp2.cc:3832
SharedVector eps_focc_
Definition: mp2.h:134
virtual void form_Amn_x_terms()=0
SharedVector eps_avir_
Definition: mp2.h:136
Definition: mp2.h:41
virtual void form_Pij()=0
void common_init()
Definition: dfmp2/mp2.cc:173
virtual void form_P()=0
double sss_
Definition: mp2.h:51
std::shared_ptr< Vector > SharedVector
Definition: adc.h:51
virtual void form_Z()
Definition: dfmp2/mp2.cc:2237
virtual void form_Qia_gradient()
Definition: dfmp2/mp2.cc:1051
virtual void apply_gamma(size_t file, size_t naux, size_t nia)
Definition: dfmp2/mp2.cc:591