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-2018 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  protected:
43  // Auxiliary basis
44  std::shared_ptr<BasisSet> ribasis_;
45  // Gradients map
46  std::map<std::string, SharedMatrix> gradients_;
47 
48  // Same-spin scale
49  double sss_;
50  // Opposite-spin scale
51  double oss_;
52 
53  void common_init();
54  // Common printing of energies/SCS
55  virtual void print_energies();
56  virtual void print_gradients();
57 
58  // Print header/reference information
59  virtual void print_header() = 0;
60  // Form the (A|ia) = (A|mn) C_mi C_na tensor(s)
61  virtual void form_Aia() = 0;
62  // Apply the fitting (Q|ia) = J_QA^-1/2 (A|ia)
63  virtual void form_Qia() = 0;
64  // Apply the fitting (Q|ia) = J_QA^-1/2 (A|ia) and J_QA^-1 (A|ia)
65  virtual void form_Qia_gradient() = 0;
66  // Transpose the integrals to (ai|Q)
67  virtual void form_Qia_transpose() = 0;
68  // Form the energy contributions
69  virtual void form_energy() = 0;
70  // Form the energy contributions and gradients
71  virtual void form_Pab() = 0;
72  // Form the energy contributions and gradients
73  virtual void form_Pij() = 0;
74  // Form the small gamma
75  virtual void form_gamma() = 0;
76  // Transpose the G
77  virtual void form_G_transpose() = 0;
78  // Form the (A|B)^x contribution to the gradient
79  virtual void form_AB_x_terms() = 0;
80  // Form the (A|mn)^x contribution to the gradient
81  virtual void form_Amn_x_terms() = 0;
82  // Form the Lma and Lmi matrices
83  virtual void form_L() = 0;
84  // Form the unrelaxed OPDM
85  virtual void form_P() = 0;
86  // Form the unrelaxed energy-weighted OPDM
87  virtual void form_W() = 0;
88  // Form the full Lagrangian, solve the Z-vector equations, and apply final corrections to W and P
89  virtual void form_Z() = 0;
90  // Manage the formation of W and P contributions to the gradient
91  virtual void form_gradient() = 0;
92 
93  // Compute singles correction [for ROHF-MBPT(2) or dual-basis]
94  virtual void form_singles();
95  // Apply the fitting and transposition to a given disk entry Aia tensor
96  virtual void apply_fitting(SharedMatrix Jm12, size_t file, size_t naux, size_t nia);
97  // Apply the fitting again to a given disk entry Qia tensor
98  virtual void apply_fitting_grad(SharedMatrix Jm12, size_t file, size_t naux, size_t nia);
99  // Form the inverse square root of the fitting metric, or read it off disk
101  // Form an abstract gamma
102  virtual void apply_gamma(size_t file, size_t naux, size_t nia);
103  // Form a transposed copy of G_ia^P
104  virtual void apply_G_transpose(size_t file, size_t naux, size_t nia);
105  // Form a transposed copy of iaQ
106  virtual void apply_B_transpose(size_t file, size_t naux, size_t naocc, size_t navir);
107 
108  // Debugging-routine: prints block sizing
109  void block_status(std::vector<int> inds, const char* file, int line);
110  void block_status(std::vector<size_t> inds, const char* file, int line);
111 
112  void compute_opdm_and_nos(const SharedMatrix Dnosym, SharedMatrix Dso, SharedMatrix Cno, SharedVector occ);
113 
114  public:
115  DFMP2(SharedWavefunction ref_wfn, Options& options, std::shared_ptr<PSIO> psio);
116  virtual ~DFMP2();
117 
118  double compute_energy();
119  virtual SharedMatrix compute_gradient();
120 };
121 
122 class RDFMP2 : public DFMP2 {
123  protected:
128 
133 
134  void common_init();
135 
136  // Print additional header
137  virtual void print_header();
138  // Form the (A|ia) = (A|mn) C_mi C_na tensor(s)
139  virtual void form_Aia();
140  // Apply the fitting (Q|ia) = J_QA^-1/2 (A|ia)
141  virtual void form_Qia();
142  // Apply the fitting (Q|ia) = J_QA^-1/2 (A|ia) and J_QA^-1 (A|ia)
143  virtual void form_Qia_gradient();
144  // Transpose the integrals to (ai|Q)
145  virtual void form_Qia_transpose();
146  // Form the energy contributions
147  virtual void form_energy();
148  // Form the energy contributions and gradients
149  virtual void form_Pab();
150  // Form the energy contributions and gradients
151  virtual void form_Pij();
152  // Form the small gamma
153  virtual void form_gamma();
154  // Transpose the G
155  virtual void form_G_transpose();
156  // Form the (A|B)^x contribution to the gradient
157  virtual void form_AB_x_terms();
158  // Form the (A|mn)^x contribution to the gradient
159  virtual void form_Amn_x_terms();
160  // Form the Lma and Lmi matrices
161  virtual void form_L();
162  // Form the unrelaxed OPDM
163  virtual void form_P();
164  // Form the unrelaxed energy-weighted OPDM
165  virtual void form_W();
166  // Form the full Lagrangian, solve the Z-vector equations, and apply final corrections to W and P
167  virtual void form_Z();
168  // Manage the formation of W and P contributions to the gradient
169  virtual void form_gradient();
170 
171  public:
172  RDFMP2(SharedWavefunction ref_wfn, Options& options, std::shared_ptr<PSIO> psio);
173  virtual ~RDFMP2();
174 };
175 
176 class UDFMP2 : public DFMP2 {
177  protected:
182 
187 
188  void common_init();
189 
190  // Print additional header
191  virtual void print_header();
192  // Form the (A|ia) = (A|mn) C_mi C_na tensor(s)
193  virtual void form_Aia();
194  // Apply the fitting (Q|ia) = J_QA^-1/2 (A|ia)
195  virtual void form_Qia();
196  // Apply the fitting (Q|ia) = J_QA^-1/2 (A|ia) and J_QA^-1 (A|ia)
197  virtual void form_Qia_gradient();
198  // Transpose the integrals to (ai|Q)
199  virtual void form_Qia_transpose();
200  // Form the energy contributions
201  virtual void form_energy();
202  // Form the energy contributions and gradients
203  virtual void form_Pab();
204  // Form the energy contributions and gradients
205  virtual void form_Pij();
206  // Form the small gamma
207  virtual void form_gamma();
208  // Transpose the G
209  virtual void form_G_transpose();
210  // Form the (A|B)^x contribution to the gradient
211  virtual void form_AB_x_terms();
212  // Form the (A|mn)^x contribution to the gradient
213  virtual void form_Amn_x_terms();
214  // Form the Lma and Lmi matrices
215  virtual void form_L();
216  // Form the unrelaxed OPDM
217  virtual void form_P();
218  // Form the unrelaxed energy-weighted OPDM
219  virtual void form_W();
220  // Form the full Lagrangian, solve the Z-vector equations, and apply final corrections to W and P
221  virtual void form_Z();
222  // Manage the formation of W and P contributions to the gradient
223  virtual void form_gradient();
224 
225  public:
226  UDFMP2(SharedWavefunction ref_wfn, Options& options, std::shared_ptr<PSIO> psio);
227  virtual ~UDFMP2();
228 };
229 
230 class RODFMP2 : public UDFMP2 {
231  protected:
232  void common_init();
233 
234  // Print additional header
235  virtual void print_header();
236 
237  public:
238  RODFMP2(SharedWavefunction ref_wfn, Options& options, std::shared_ptr<PSIO> psio);
239  virtual ~RODFMP2();
240 };
241 
242 } // namespace dfmp2
243 } // namespace psi
244 
245 #endif
virtual void form_gradient()=0
virtual void form_Qia()=0
virtual void form_Z()
Definition: dfmp2/mp2.cc:3344
std::map< std::string, SharedMatrix > gradients_
Definition: mp2.h:46
virtual void form_W()
Definition: dfmp2/mp2.cc:3343
Options & options() const
Definition: wavefunction.cc:565
void block_status(std::vector< int > inds, const char *file, int line)
Definition: dfmp2/mp2.cc:143
std::shared_ptr< PSIO > psio() const
Definition: wavefunction.cc:563
virtual void form_gamma()=0
RODFMP2(SharedWavefunction ref_wfn, Options &options, std::shared_ptr< PSIO > psio)
Definition: dfmp2/mp2.cc:3347
virtual ~RDFMP2()
Definition: dfmp2/mp2.cc:815
virtual void form_Qia_transpose()
Definition: dfmp2/mp2.cc:1016
virtual void form_P()
Definition: dfmp2/mp2.cc:2001
virtual void form_Pab()=0
SharedVector eps_aocc_
Definition: mp2.h:130
void common_init()
Definition: dfmp2/mp2.cc:816
DFMP2(SharedWavefunction ref_wfn, Options &options, std::shared_ptr< PSIO > psio)
Definition: dfmp2/mp2.cc:160
SharedMatrix Cavir_
Definition: mp2.h:126
Definition: mp2.h:230
void common_init()
Definition: dfmp2/mp2.cc:3352
virtual void print_header()
Definition: dfmp2/mp2.cc:2726
virtual SharedMatrix compute_gradient()
Compute gradient. Subclasses override this function to compute the gradient.
Definition: dfmp2/mp2.cc:226
virtual void form_G_transpose()
Definition: dfmp2/mp2.cc:3338
virtual void form_Aia()
Definition: dfmp2/mp2.cc:2764
virtual void print_header()
Definition: dfmp2/mp2.cc:827
SharedVector eps_aocc_a_
Definition: mp2.h:183
virtual void apply_fitting(SharedMatrix Jm12, size_t file, size_t naux, size_t nia)
Definition: dfmp2/mp2.cc:451
virtual void form_Qia()
Definition: dfmp2/mp2.cc:1007
SharedMatrix Caocc_a_
Definition: mp2.h:178
virtual void form_gradient()
Definition: dfmp2/mp2.cc:3345
virtual void form_Qia()
Definition: dfmp2/mp2.cc:2945
virtual ~UDFMP2()
Definition: dfmp2/mp2.cc:2714
virtual void form_gradient()
Definition: dfmp2/mp2.cc:2488
virtual void apply_G_transpose(size_t file, size_t naux, size_t nia)
Definition: dfmp2/mp2.cc:631
virtual void form_W()=0
SharedMatrix Cfocc_
Definition: mp2.h:124
virtual void form_energy()=0
virtual void print_header()
Definition: dfmp2/mp2.cc:3353
std::shared_ptr< BasisSet > ribasis_
Definition: mp2.h:44
virtual void form_Qia_gradient()
Definition: dfmp2/mp2.cc:2950
virtual void form_AB_x_terms()=0
virtual void form_gamma()
Definition: dfmp2/mp2.cc:1499
virtual void form_G_transpose()
Definition: dfmp2/mp2.cc:1502
virtual ~DFMP2()
Definition: dfmp2/mp2.cc:167
SharedMatrix Caocc_b_
Definition: mp2.h:180
double oss_
Definition: mp2.h:51
virtual void form_singles()
Definition: dfmp2/mp2.cc:322
virtual void form_Amn_x_terms()
Definition: dfmp2/mp2.cc:1616
virtual void apply_fitting_grad(SharedMatrix Jm12, size_t file, size_t naux, size_t nia)
Definition: dfmp2/mp2.cc:512
virtual void form_Aia()=0
SharedVector eps_avir_a_
Definition: mp2.h:184
Definition: mp2.h:122
UDFMP2(SharedWavefunction ref_wfn, Options &options, std::shared_ptr< PSIO > psio)
Definition: dfmp2/mp2.cc:2710
virtual void form_energy()
Definition: dfmp2/mp2.cc:1019
SharedVector eps_fvir_
Definition: mp2.h:132
virtual void form_gamma()
Definition: dfmp2/mp2.cc:3337
SharedMatrix Cavir_b_
Definition: mp2.h:181
virtual void form_Pij()
Definition: dfmp2/mp2.cc:1337
Definition: mp2.h:176
virtual void form_energy()
Definition: dfmp2/mp2.cc:2958
virtual void print_gradients()
Definition: dfmp2/mp2.cc:789
virtual void form_W()
Definition: dfmp2/mp2.cc:2098
virtual void form_Qia_transpose()
Definition: dfmp2/mp2.cc:2957
virtual void form_Pab()
Definition: dfmp2/mp2.cc:1145
SharedMatrix Cfvir_
Definition: mp2.h:127
virtual void print_header()=0
virtual void form_AB_x_terms()
Definition: dfmp2/mp2.cc:1505
Definition: liboptions.h:353
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:179
double compute_energy()
Compute energy. Subclasses override this function to compute its energy.
Definition: dfmp2/mp2.cc:189
virtual void form_Qia_transpose()=0
virtual void print_energies()
Definition: dfmp2/mp2.cc:741
std::shared_ptr< Matrix > SharedMatrix
Definition: adc.h:49
virtual void form_Aia()
Definition: dfmp2/mp2.cc:862
void common_init()
Definition: dfmp2/mp2.cc:2715
virtual void form_Qia_gradient()=0
Simple wavefunction base class.
Definition: wavefunction.h:85
virtual ~RODFMP2()
Definition: dfmp2/mp2.cc:3351
virtual void form_Pij()
Definition: dfmp2/mp2.cc:3336
virtual void form_Amn_x_terms()
Definition: dfmp2/mp2.cc:3340
virtual void form_Z()=0
virtual void form_L()
Definition: dfmp2/mp2.cc:1817
virtual void form_P()
Definition: dfmp2/mp2.cc:3342
SharedMatrix Caocc_
Definition: mp2.h:125
virtual void form_L()
Definition: dfmp2/mp2.cc:3341
SharedWavefunction dfmp2(SharedWavefunction, Options &)
Definition: dfmp2/wrapper.cc:52
RDFMP2(SharedWavefunction ref_wfn, Options &options, std::shared_ptr< PSIO > psio)
Definition: dfmp2/mp2.cc:811
SharedVector eps_aocc_b_
Definition: mp2.h:185
SharedVector eps_avir_b_
Definition: mp2.h:186
virtual void apply_B_transpose(size_t file, size_t naux, size_t naocc, size_t navir)
Definition: dfmp2/mp2.cc:695
std::shared_ptr< Wavefunction > SharedWavefunction
Definition: typedefs.h:54
virtual void form_AB_x_terms()
Definition: dfmp2/mp2.cc:3339
virtual SharedMatrix form_inverse_metric()
Definition: dfmp2/mp2.cc:415
virtual void form_Pab()
Definition: dfmp2/mp2.cc:3335
SharedVector eps_focc_
Definition: mp2.h:129
virtual void form_Amn_x_terms()=0
SharedVector eps_avir_
Definition: mp2.h:131
Definition: mp2.h:41
virtual void form_Pij()=0
void common_init()
Definition: dfmp2/mp2.cc:168
virtual void form_P()=0
double sss_
Definition: mp2.h:49
std::shared_ptr< Vector > SharedVector
Definition: adc.h:51
virtual void form_Z()
Definition: dfmp2/mp2.cc:2192
virtual void form_Qia_gradient()
Definition: dfmp2/mp2.cc:1011
virtual void apply_gamma(size_t file, size_t naux, size_t nia)
Definition: dfmp2/mp2.cc:570