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-2019 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  ~DFMP2() override;
117 
118  double compute_energy() override;
119  SharedMatrix compute_gradient() override;
120 };
121 
122 class RDFMP2 : public DFMP2 {
123  protected:
128 
133 
134  void common_init();
135 
136  // Print additional header
137  void print_header() override;
138  // Form the (A|ia) = (A|mn) C_mi C_na tensor(s)
139  void form_Aia() override;
140  // Apply the fitting (Q|ia) = J_QA^-1/2 (A|ia)
141  void form_Qia() override;
142  // Apply the fitting (Q|ia) = J_QA^-1/2 (A|ia) and J_QA^-1 (A|ia)
143  void form_Qia_gradient() override;
144  // Transpose the integrals to (ai|Q)
145  void form_Qia_transpose() override;
146  // Form the energy contributions
147  void form_energy() override;
148  // Form the energy contributions and gradients
149  void form_Pab() override;
150  // Form the energy contributions and gradients
151  void form_Pij() override;
152  // Form the small gamma
153  void form_gamma() override;
154  // Transpose the G
155  void form_G_transpose() override;
156  // Form the (A|B)^x contribution to the gradient
157  void form_AB_x_terms() override;
158  // Form the (A|mn)^x contribution to the gradient
159  void form_Amn_x_terms() override;
160  // Form the Lma and Lmi matrices
161  void form_L() override;
162  // Form the unrelaxed OPDM
163  void form_P() override;
164  // Form the unrelaxed energy-weighted OPDM
165  void form_W() override;
166  // Form the full Lagrangian, solve the Z-vector equations, and apply final corrections to W and P
167  void form_Z() override;
168  // Manage the formation of W and P contributions to the gradient
169  void form_gradient() override;
170 
171  public:
172  RDFMP2(SharedWavefunction ref_wfn, Options& options, std::shared_ptr<PSIO> psio);
173  ~RDFMP2() override;
174 };
175 
176 class UDFMP2 : public DFMP2 {
177  protected:
182 
187 
188  void common_init();
189 
190  // Print additional header
191  void print_header() override;
192  // Form the (A|ia) = (A|mn) C_mi C_na tensor(s)
193  void form_Aia() override;
194  // Apply the fitting (Q|ia) = J_QA^-1/2 (A|ia)
195  void form_Qia() override;
196  // Apply the fitting (Q|ia) = J_QA^-1/2 (A|ia) and J_QA^-1 (A|ia)
197  void form_Qia_gradient() override;
198  // Transpose the integrals to (ai|Q)
199  void form_Qia_transpose() override;
200  // Form the energy contributions
201  void form_energy() override;
202  // Form the energy contributions and gradients
203  void form_Pab() override;
204  // Form the energy contributions and gradients
205  void form_Pij() override;
206  // Form the small gamma
207  void form_gamma() override;
208  // Transpose the G
209  void form_G_transpose() override;
210  // Form the (A|B)^x contribution to the gradient
211  void form_AB_x_terms() override;
212  // Form the (A|mn)^x contribution to the gradient
213  void form_Amn_x_terms() override;
214  // Form the Lma and Lmi matrices
215  void form_L() override;
216  // Form the unrelaxed OPDM
217  void form_P() override;
218  // Form the unrelaxed energy-weighted OPDM
219  void form_W() override;
220  // Form the full Lagrangian, solve the Z-vector equations, and apply final corrections to W and P
221  void form_Z() override;
222  // Manage the formation of W and P contributions to the gradient
223  void form_gradient() override;
224 
225  public:
226  UDFMP2(SharedWavefunction ref_wfn, Options& options, std::shared_ptr<PSIO> psio);
227  ~UDFMP2() override;
228 };
229 
230 class RODFMP2 : public UDFMP2 {
231  protected:
232  void common_init();
233 
234  // Print additional header
235  void print_header() override;
236 
237  public:
238  RODFMP2(SharedWavefunction ref_wfn, Options& options, std::shared_ptr<PSIO> psio);
239  ~RODFMP2() override;
240 };
241 
242 } // namespace dfmp2
243 } // namespace psi
244 
245 #endif
virtual void form_gradient()=0
virtual void form_Qia()=0
void form_Pab() override
Definition: dfmp2/mp2.cc:3333
std::map< std::string, SharedMatrix > gradients_
Definition: mp2.h:46
Options & options() const
Definition: wavefunction.cc:648
void block_status(std::vector< int > inds, const char *file, int line)
Definition: dfmp2/mp2.cc:141
std::shared_ptr< PSIO > psio() const
Definition: wavefunction.cc:646
void form_Aia() override
Definition: dfmp2/mp2.cc:2762
void print_header() override
Definition: dfmp2/mp2.cc:825
void form_gradient() override
Definition: dfmp2/mp2.cc:3343
void form_energy() override
Definition: dfmp2/mp2.cc:2956
virtual void form_gamma()=0
RODFMP2(SharedWavefunction ref_wfn, Options &options, std::shared_ptr< PSIO > psio)
Definition: dfmp2/mp2.cc:3345
virtual void form_Pab()=0
SharedVector eps_aocc_
Definition: mp2.h:130
void common_init()
Definition: dfmp2/mp2.cc:814
DFMP2(SharedWavefunction ref_wfn, Options &options, std::shared_ptr< PSIO > psio)
Definition: dfmp2/mp2.cc:158
SharedMatrix Cavir_
Definition: mp2.h:126
Definition: mp2.h:230
void common_init()
Definition: dfmp2/mp2.cc:3350
SharedVector eps_aocc_a_
Definition: mp2.h:183
void print_header() override
Definition: dfmp2/mp2.cc:3351
void form_W() override
Definition: dfmp2/mp2.cc:3341
void form_G_transpose() override
Definition: dfmp2/mp2.cc:3336
virtual void apply_fitting(SharedMatrix Jm12, size_t file, size_t naux, size_t nia)
Definition: dfmp2/mp2.cc:452
void form_Qia_gradient() override
Definition: dfmp2/mp2.cc:2948
void form_P() override
Definition: dfmp2/mp2.cc:1999
void form_Qia_gradient() override
Definition: dfmp2/mp2.cc:1009
~DFMP2() override
Definition: dfmp2/mp2.cc:165
void form_W() override
Definition: dfmp2/mp2.cc:2096
SharedMatrix Caocc_a_
Definition: mp2.h:178
virtual void apply_G_transpose(size_t file, size_t naux, size_t nia)
Definition: dfmp2/mp2.cc:632
virtual void form_W()=0
SharedMatrix Cfocc_
Definition: mp2.h:124
virtual void form_energy()=0
std::shared_ptr< BasisSet > ribasis_
Definition: mp2.h:44
void form_G_transpose() override
Definition: dfmp2/mp2.cc:1500
void form_Qia() override
Definition: dfmp2/mp2.cc:2943
virtual void form_AB_x_terms()=0
void form_L() override
Definition: dfmp2/mp2.cc:3339
SharedMatrix Caocc_b_
Definition: mp2.h:180
double oss_
Definition: mp2.h:51
void form_gamma() override
Definition: dfmp2/mp2.cc:1497
void form_AB_x_terms() override
Definition: dfmp2/mp2.cc:1503
void form_Pab() override
Definition: dfmp2/mp2.cc:1143
void form_Amn_x_terms() override
Definition: dfmp2/mp2.cc:1614
virtual void form_singles()
Definition: dfmp2/mp2.cc:323
virtual void apply_fitting_grad(SharedMatrix Jm12, size_t file, size_t naux, size_t nia)
Definition: dfmp2/mp2.cc:513
virtual void form_Aia()=0
SharedVector eps_avir_a_
Definition: mp2.h:184
void form_Aia() override
Definition: dfmp2/mp2.cc:860
void form_Qia() override
Definition: dfmp2/mp2.cc:1005
void form_Qia_transpose() override
Definition: dfmp2/mp2.cc:1014
Definition: mp2.h:122
UDFMP2(SharedWavefunction ref_wfn, Options &options, std::shared_ptr< PSIO > psio)
Definition: dfmp2/mp2.cc:2708
void print_header() override
Definition: dfmp2/mp2.cc:2724
SharedVector eps_fvir_
Definition: mp2.h:132
void form_AB_x_terms() override
Definition: dfmp2/mp2.cc:3337
SharedMatrix Cavir_b_
Definition: mp2.h:181
Definition: mp2.h:176
void form_Pij() override
Definition: dfmp2/mp2.cc:1335
~RODFMP2() override
Definition: dfmp2/mp2.cc:3349
virtual void print_gradients()
Definition: dfmp2/mp2.cc:787
void form_gamma() override
Definition: dfmp2/mp2.cc:3335
SharedMatrix Cfvir_
Definition: mp2.h:127
virtual void print_header()=0
Definition: liboptions.h:352
void form_P() override
Definition: dfmp2/mp2.cc:3340
void form_energy() override
Definition: dfmp2/mp2.cc:1017
void compute_opdm_and_nos(const SharedMatrix Dnosym, SharedMatrix Dso, SharedMatrix Cno, SharedVector occ)
Definition: dfmp2/mp2.cc:63
virtual void form_L()=0
virtual void form_G_transpose()=0
SharedMatrix Cavir_a_
Definition: mp2.h:179
void form_Amn_x_terms() override
Definition: dfmp2/mp2.cc:3338
virtual void form_Qia_transpose()=0
virtual void print_energies()
Definition: dfmp2/mp2.cc:742
std::shared_ptr< Matrix > SharedMatrix
Definition: adc.h:49
void common_init()
Definition: dfmp2/mp2.cc:2713
virtual void form_Qia_gradient()=0
Simple wavefunction base class.
Definition: wavefunction.h:85
~UDFMP2() override
Definition: dfmp2/mp2.cc:2712
virtual void form_Z()=0
void form_Z() override
Definition: dfmp2/mp2.cc:3342
SharedMatrix Caocc_
Definition: mp2.h:125
SharedWavefunction dfmp2(SharedWavefunction, Options &)
Definition: dfmp2/wrapper.cc:52
void form_gradient() override
Definition: dfmp2/mp2.cc:2486
void form_Z() override
Definition: dfmp2/mp2.cc:2190
SharedMatrix compute_gradient() override
Compute gradient. Subclasses override this function to compute the gradient.
Definition: dfmp2/mp2.cc:224
~RDFMP2() override
Definition: dfmp2/mp2.cc:813
RDFMP2(SharedWavefunction ref_wfn, Options &options, std::shared_ptr< PSIO > psio)
Definition: dfmp2/mp2.cc:809
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:696
double compute_energy() override
Compute energy. Subclasses override this function to compute its energy.
Definition: dfmp2/mp2.cc:187
std::shared_ptr< Wavefunction > SharedWavefunction
Definition: typedefs.h:54
virtual SharedMatrix form_inverse_metric()
Definition: dfmp2/mp2.cc:416
SharedVector eps_focc_
Definition: mp2.h:129
void form_L() override
Definition: dfmp2/mp2.cc:1815
virtual void form_Amn_x_terms()=0
void form_Qia_transpose() override
Definition: dfmp2/mp2.cc:2955
SharedVector eps_avir_
Definition: mp2.h:131
Definition: mp2.h:41
virtual void form_Pij()=0
void common_init()
Definition: dfmp2/mp2.cc:166
virtual void form_P()=0
double sss_
Definition: mp2.h:49
std::shared_ptr< Vector > SharedVector
Definition: adc.h:51
virtual void apply_gamma(size_t file, size_t naux, size_t nia)
Definition: dfmp2/mp2.cc:571
void form_Pij() override
Definition: dfmp2/mp2.cc:3334