Psi4
fisapt.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 FISAPT_H
29 #define FISAPT_H
30 
31 #include "psi4/libmints/typedefs.h"
33 #include <map>
34 #include <tuple>
35 
36 namespace psi {
37 
38 class JK;
39 
40 namespace fisapt {
41 
42 class FISAPT {
43 
44 protected:
45 
46  // sSAPT0 exchange-scaling
47  double sSAPT0_scale_;
51  size_t doubles_;
53  std::shared_ptr<Wavefunction> reference_;
54 
56  std::shared_ptr<BasisSet> primary_;
57  std::shared_ptr<BasisSet> df_basis_scf_;
58 
60  std::shared_ptr<JK> jk_;
61 
63  std::map<std::string, double> scalars_;
65  std::map<std::string, std::shared_ptr<Vector> > vectors_;
67  std::map<std::string, std::shared_ptr<Matrix> > matrices_;
68 
69  // => FISAPT 0th-Order Wavefunction <= //
70 
72  void common_init();
74  void print_header();
76  void localize();
78  void partition();
80  void overlap();
82  void kinetic();
84  void nuclear();
86  void coulomb();
88  void scf();
90  void freeze_core();
92  void unify();
94  void plot();
95 
96  // => F-SAPT0 <= //
97 
99  void flocalize();
101  void felst();
103  void fexch();
105  void find();
107  void fdisp();
109  void fdrop();
110 
111  // => SAPT0 <= //
112 
114  void dHF();
116  void elst();
118  void exch();
120  void ind();
122  void disp();
124  void print_trailer();
125 
126  // Build the ExchInd20 potential in the monomer A ov space
127  std::shared_ptr<Matrix> build_exch_ind_pot(std::map<std::string, std::shared_ptr<Matrix> >& vars);
128  // Build the Ind20 potential in the monomer A ov space
129  std::shared_ptr<Matrix> build_ind_pot(std::map<std::string, std::shared_ptr<Matrix> >& vars);
130 
132  void drop(std::shared_ptr<Matrix> A, const std::string& filepath);
134  void drop(std::shared_ptr<Vector> A, const std::string& filepath);
136  static std::shared_ptr<Matrix> extract_columns(
137  const std::vector<int>& cols,
138  std::shared_ptr<Matrix> A);
139 
140 public:
142  FISAPT(std::shared_ptr<Wavefunction> scf, Options& options);
143  virtual ~FISAPT();
144 
146  void compute_energy();
147 
148 };
149 
150 class FISAPTSCF {
151 
152 protected:
153 
154 
157 
159  std::shared_ptr<JK> jk_;
160 
162  std::map<std::string, double> scalars_;
164  std::map<std::string, std::shared_ptr<Vector> > vectors_;
166  std::map<std::string, std::shared_ptr<Matrix> > matrices_;
167 
169  void print_orbitals(
170  const std::string& header,
171  int start,
172  std::shared_ptr<Vector> eps
173  );
174 
175 
176 public:
177 
178  FISAPTSCF(
179  std::shared_ptr<JK> jk, // JK object
180  double enuc, // Nuclear repulsion energy
181  std::shared_ptr<Matrix> S, // Overlap integrals
182  std::shared_ptr<Matrix> X, // Restricted orthogonalization matrix [nbf x nmo]
183  std::shared_ptr<Matrix> T, // Kinetic integrals
184  std::shared_ptr<Matrix> V, // Potential integrals
185  std::shared_ptr<Matrix> W, // External embedding potential
186  std::shared_ptr<Matrix> C, // Guess for occupied orbitals [nbf x nocc]
187  Options& options
188  );
189  virtual ~FISAPTSCF();
190 
191  void compute_energy();
192 
193  std::map<std::string, double>& scalars() { return scalars_; }
194  std::map<std::string, std::shared_ptr<Vector> >& vectors() { return vectors_; }
195  std::map<std::string, std::shared_ptr<Matrix> >& matrices() { return matrices_; }
196 
197 };
198 
199 class CPHF_FISAPT {
200 
201 friend class FISAPT;
202 
203 protected:
204 
205  // => Global Data <= //
206 
207 
208  // Convergence tolerance
209  double delta_;
210  // Maximum allowed iterations
211  int maxiter_;
212  // JK Object
213  std::shared_ptr<JK> jk_;
214 
215  // => Monomer A Problem <= //
216 
217  // Perturbation applied to A
218  std::shared_ptr<Matrix> w_A_;
219  // Response of A
220  std::shared_ptr<Matrix> x_A_;
221  // Active occ orbital coefficients of A
222  std::shared_ptr<Matrix> Cocc_A_;
223  // Active vir orbital coefficients of A
224  std::shared_ptr<Matrix> Cvir_A_;
225  // Active occ orbital eigenvalues of A
226  std::shared_ptr<Vector> eps_occ_A_;
227  // Active vir orbital eigenvalues of A
228  std::shared_ptr<Vector> eps_vir_A_;
229 
230  // => Monomer B Problem <= //
231 
232  // Perturbation applied to B
233  std::shared_ptr<Matrix> w_B_;
234  // Response of B
235  std::shared_ptr<Matrix> x_B_;
236  // Active occ orbital coefficients of B
237  std::shared_ptr<Matrix> Cocc_B_;
238  // Active vir orbital coefficients of B
239  std::shared_ptr<Matrix> Cvir_B_;
240  // Active occ orbital eigenvalues of B
241  std::shared_ptr<Vector> eps_occ_B_;
242  // Active vir orbital eigenvalues of B
243  std::shared_ptr<Vector> eps_vir_B_;
244 
245  // Form the s = Ab product for the provided vectors b (may or may not need more iterations)
246  std::map<std::string, std::shared_ptr<Matrix> > product(std::map<std::string, std::shared_ptr<Matrix> > b);
247  // Apply the denominator from r into z
248  void preconditioner(std::shared_ptr<Matrix> r,
249  std::shared_ptr<Matrix> z,
250  std::shared_ptr<Vector> o,
251  std::shared_ptr<Vector> v);
252 
253 public:
254  CPHF_FISAPT();
255  virtual ~CPHF_FISAPT();
256 
257  void compute_cphf();
258 };
259 
260 } // Namespace fisapt
261 
262 } // Namespace psi
263 
264 #endif
void print_header()
Print header, bases, sizes, etc.
Definition: fisapt.cc:141
void flocalize()
Localize.
Definition: fisapt.cc:2582
void partition()
Partition the nuclei and electrons.
Definition: fisapt.cc:176
void overlap()
Build the overlap integrals S.
Definition: fisapt.cc:553
std::shared_ptr< Matrix > x_A_
Definition: fisapt.h:220
std::map< std::string, double > scalars_
Map of scalars.
Definition: fisapt.h:162
void elst()
Electrostatics.
Definition: fisapt.cc:1266
std::shared_ptr< Vector > eps_occ_A_
Definition: fisapt.h:226
std::shared_ptr< Vector > eps_vir_B_
Definition: fisapt.h:243
virtual ~FISAPTSCF()
Definition: fisapt.cc:4465
static std::shared_ptr< Matrix > extract_columns(const std::vector< int > &cols, std::shared_ptr< Matrix > A)
Helper to extract columns from a matrix.
Definition: fisapt.cc:4422
std::shared_ptr< JK > jk_
Definition: fisapt.h:213
void print_orbitals(const std::string &header, int start, std::shared_ptr< Vector > eps)
Print orbitals.
Definition: fisapt.cc:4691
std::shared_ptr< Matrix > Cocc_A_
Definition: fisapt.h:222
void freeze_core()
Freeze the core orbitals.
Definition: fisapt.cc:786
Definition: fisapt.h:42
void drop(std::shared_ptr< Matrix > A, const std::string &filepath)
Helper to drop a matrix to filepath/A-&gt;name().dat.
Definition: fisapt.cc:4389
void nuclear()
Build the nuclear potentials V and interaction energies.
Definition: fisapt.cc:573
std::shared_ptr< BasisSet > primary_
Orbital Basis Set (full molecule)
Definition: fisapt.h:56
std::shared_ptr< Matrix > Cvir_A_
Definition: fisapt.h:224
double delta_
Definition: fisapt.h:209
void kinetic()
Build the kinetic integrals T.
Definition: fisapt.cc:563
void print_trailer()
Print SAPT results.
Definition: fisapt.cc:2375
CPHF_FISAPT()
Definition: fisapt.cc:4711
std::map< std::string, std::shared_ptr< Matrix > > matrices_
Map of matrices.
Definition: fisapt.h:166
int maxiter_
Definition: fisapt.h:211
void fdrop()
Output.
Definition: fisapt.cc:4329
std::map< std::string, double > & scalars()
Definition: fisapt.h:193
std::shared_ptr< Matrix > Cvir_B_
Definition: fisapt.h:239
std::shared_ptr< JK > jk_
Global JK object.
Definition: fisapt.h:60
double sSAPT0_scale_
Definition: fisapt.h:47
std::shared_ptr< Wavefunction > reference_
Reference wavefunction.
Definition: fisapt.h:53
void coulomb()
Build the J/K potentials for C, D, and E.
Definition: fisapt.cc:674
std::shared_ptr< Matrix > w_A_
Definition: fisapt.h:218
std::map< std::string, std::shared_ptr< Vector > > & vectors()
Definition: fisapt.h:194
void compute_energy()
Gogo!
Definition: fisapt.cc:92
FISAPTSCF(std::shared_ptr< JK > jk, double enuc, std::shared_ptr< Matrix > S, std::shared_ptr< Matrix > X, std::shared_ptr< Matrix > T, std::shared_ptr< Matrix > V, std::shared_ptr< Matrix > W, std::shared_ptr< Matrix > C, Options &options)
Definition: fisapt.cc:4443
void common_init()
Common initialization (bases, orbitals, eigenvalues, etc)
Definition: fisapt.cc:67
std::shared_ptr< Vector > eps_vir_A_
Definition: fisapt.h:228
size_t doubles_
Memory in doubles.
Definition: fisapt.h:51
std::shared_ptr< Matrix > x_B_
Definition: fisapt.h:235
std::shared_ptr< Matrix > w_B_
Definition: fisapt.h:233
std::shared_ptr< Vector > eps_occ_B_
Definition: fisapt.h:241
void ind()
Induction.
Definition: fisapt.cc:1496
void dHF()
Delta HF.
Definition: fisapt.cc:940
std::shared_ptr< BasisSet > df_basis_scf_
Definition: fisapt.h:57
void find()
Induction.
Definition: fisapt.cc:3095
std::map< std::string, std::shared_ptr< Matrix > > matrices_
Map of matrices.
Definition: fisapt.h:67
void exch()
Exchange.
Definition: fisapt.cc:1299
void fexch()
Exchange.
Definition: fisapt.cc:2884
std::shared_ptr< JK > jk_
Global JK object.
Definition: fisapt.h:159
std::shared_ptr< Matrix > build_ind_pot(std::map< std::string, std::shared_ptr< Matrix > > &vars)
Definition: fisapt.cc:1770
virtual ~CPHF_FISAPT()
Definition: fisapt.cc:4714
void disp()
Dispersion.
Definition: fisapt.cc:1899
void compute_cphf()
Definition: fisapt.cc:4717
Definition: liboptions.h:359
PsiReturnType fisapt(SharedWavefunction, Options &)
Definition: fisapt/wrapper.cc:39
void preconditioner(std::shared_ptr< Matrix > r, std::shared_ptr< Matrix > z, std::shared_ptr< Vector > o, std::shared_ptr< Vector > v)
Definition: fisapt.cc:4865
void plot()
Plot some analysis files.
Definition: fisapt.cc:2509
void unify()
Produce unified matrices for A&#39;, B&#39;, and C&#39;.
Definition: fisapt.cc:892
Options & options_
Global options object.
Definition: fisapt.h:49
void fdisp()
Dispersion.
Definition: fisapt.cc:3734
FISAPT(std::shared_ptr< Wavefunction > scf, Options &options)
Initialize an FISAPT object with an SCF reference.
Definition: fisapt.cc:58
std::shared_ptr< Matrix > Cocc_B_
Definition: fisapt.h:237
std::shared_ptr< Matrix > build_exch_ind_pot(std::map< std::string, std::shared_ptr< Matrix > > &vars)
Definition: fisapt.cc:1784
std::map< std::string, std::shared_ptr< Matrix > > product(std::map< std::string, std::shared_ptr< Matrix > > b)
Definition: fisapt.cc:4885
std::map< std::string, std::shared_ptr< Vector > > vectors_
Map of vectors.
Definition: fisapt.h:164
void localize()
Localize the active occupied orbitals via IBO2.
Definition: fisapt.cc:154
virtual ~FISAPT()
Definition: fisapt.cc:64
Definition: PsiFileImpl.h:38
Definition: fisapt.h:199
Definition: fisapt.h:150
void scf()
Solve the relaxed SCF equations for A0 and B0.
Definition: fisapt.cc:716
std::map< std::string, double > scalars_
Map of scalars.
Definition: fisapt.h:63
Definition: PsiFileImpl.h:39
std::map< std::string, std::shared_ptr< Matrix > > & matrices()
Definition: fisapt.h:195
void compute_energy()
Definition: fisapt.cc:4468
Options & options_
Global options object.
Definition: fisapt.h:156
std::map< std::string, std::shared_ptr< Vector > > vectors_
Map of vectors.
Definition: fisapt.h:65
void felst()
Electrostatics.
Definition: fisapt.cc:2723