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 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 FISAPT_H
30 #define FISAPT_H
31 
32 #include "psi4/libmints/typedefs.h"
35 
36 #include <map>
37 #include <tuple>
38 
39 namespace psi {
40 
41 class JK;
42 
43 namespace fisapt {
44 
45 class FISAPT {
46 
47 protected:
48 
49  // sSAPT0 exchange-scaling
50  double sSAPT0_scale_;
54  size_t doubles_;
56  std::shared_ptr<Wavefunction> reference_;
57 
59  std::shared_ptr<BasisSet> primary_;
60  std::shared_ptr<BasisSet> df_basis_scf_;
61 
63  std::shared_ptr<JK> jk_;
64 
66  std::map<std::string, double> scalars_;
68  std::map<std::string, std::shared_ptr<Vector> > vectors_;
70  std::map<std::string, std::shared_ptr<Matrix> > matrices_;
71 
72  // => FISAPT 0th-Order Wavefunction <= //
73 
75  void common_init();
77  void print_header();
79  void localize();
81  void partition();
83  void overlap();
85  void kinetic();
87  void nuclear();
89  void coulomb();
91  void scf();
93  void freeze_core();
95  void unify();
97  void plot();
98 
99  // => F-SAPT0 <= //
100 
102  void flocalize();
104  void felst();
106  void fexch();
108  void find();
110  void fdisp();
112  void fdrop();
113 
114  // => SAPT0 <= //
115 
117  void dHF();
119  void elst();
121  void exch();
123  void ind();
125  void print_trailer();
126 
127  // Build the ExchInd20 potential in the monomer A ov space
128  std::shared_ptr<Matrix> build_exch_ind_pot(std::map<std::string, std::shared_ptr<Matrix> >& vars);
129  // Build the Ind20 potential in the monomer A ov space
130  std::shared_ptr<Matrix> build_ind_pot(std::map<std::string, std::shared_ptr<Matrix> >& vars);
131 
133  void drop(std::shared_ptr<Matrix> A, const std::string& filepath);
135  void drop(std::shared_ptr<Vector> A, const std::string& filepath);
137  static std::shared_ptr<Matrix> extract_columns(
138  const std::vector<int>& cols,
139  std::shared_ptr<Matrix> A);
140 
141 public:
143  FISAPT(std::shared_ptr<Wavefunction> scf);
144  FISAPT(std::shared_ptr<Wavefunction> scf, Options& options);
145  virtual ~FISAPT();
146 
148  void compute_energy();
149 
151  void disp(std::map<std::string, SharedMatrix> matrix_cache,
152  std::map<std::string, SharedVector> vector_cache, bool do_print);
153 
154  std::map<std::string, double> scalars(){ return scalars_; }
155 };
156 
157 class FISAPTSCF {
158 
159 protected:
160 
161 
164 
166  std::shared_ptr<JK> jk_;
167 
169  std::map<std::string, double> scalars_;
171  std::map<std::string, std::shared_ptr<Vector> > vectors_;
173  std::map<std::string, std::shared_ptr<Matrix> > matrices_;
174 
176  void print_orbitals(
177  const std::string& header,
178  int start,
179  std::shared_ptr<Vector> eps
180  );
181 
182 
183 public:
184 
185  FISAPTSCF(
186  std::shared_ptr<JK> jk, // JK object
187  double enuc, // Nuclear repulsion energy
188  std::shared_ptr<Matrix> S, // Overlap integrals
189  std::shared_ptr<Matrix> X, // Restricted orthogonalization matrix [nbf x nmo]
190  std::shared_ptr<Matrix> T, // Kinetic integrals
191  std::shared_ptr<Matrix> V, // Potential integrals
192  std::shared_ptr<Matrix> W, // External embedding potential
193  std::shared_ptr<Matrix> C, // Guess for occupied orbitals [nbf x nocc]
194  Options& options
195  );
196  virtual ~FISAPTSCF();
197 
198  void compute_energy();
199 
200  std::map<std::string, double>& scalars() { return scalars_; }
201  std::map<std::string, std::shared_ptr<Vector> >& vectors() { return vectors_; }
202  std::map<std::string, std::shared_ptr<Matrix> >& matrices() { return matrices_; }
203 
204 };
205 
206 class CPHF_FISAPT {
207 
208 friend class FISAPT;
209 
210 protected:
211 
212  // => Global Data <= //
213 
214 
215  // Convergence tolerance
216  double delta_;
217  // Maximum allowed iterations
218  int maxiter_;
219  // JK Object
220  std::shared_ptr<JK> jk_;
221 
222  // => Monomer A Problem <= //
223 
224  // Perturbation applied to A
225  std::shared_ptr<Matrix> w_A_;
226  // Response of A
227  std::shared_ptr<Matrix> x_A_;
228  // Active occ orbital coefficients of A
229  std::shared_ptr<Matrix> Cocc_A_;
230  // Active vir orbital coefficients of A
231  std::shared_ptr<Matrix> Cvir_A_;
232  // Active occ orbital eigenvalues of A
233  std::shared_ptr<Vector> eps_occ_A_;
234  // Active vir orbital eigenvalues of A
235  std::shared_ptr<Vector> eps_vir_A_;
236 
237  // => Monomer B Problem <= //
238 
239  // Perturbation applied to B
240  std::shared_ptr<Matrix> w_B_;
241  // Response of B
242  std::shared_ptr<Matrix> x_B_;
243  // Active occ orbital coefficients of B
244  std::shared_ptr<Matrix> Cocc_B_;
245  // Active vir orbital coefficients of B
246  std::shared_ptr<Matrix> Cvir_B_;
247  // Active occ orbital eigenvalues of B
248  std::shared_ptr<Vector> eps_occ_B_;
249  // Active vir orbital eigenvalues of B
250  std::shared_ptr<Vector> eps_vir_B_;
251 
252  // Form the s = Ab product for the provided vectors b (may or may not need more iterations)
253  std::map<std::string, std::shared_ptr<Matrix> > product(std::map<std::string, std::shared_ptr<Matrix> > b);
254  // Apply the denominator from r into z
255  void preconditioner(std::shared_ptr<Matrix> r,
256  std::shared_ptr<Matrix> z,
257  std::shared_ptr<Vector> o,
258  std::shared_ptr<Vector> v);
259 
260 public:
261  CPHF_FISAPT();
262  virtual ~CPHF_FISAPT();
263 
264  void compute_cphf();
265 };
266 
267 } // Namespace fisapt
268 
269 } // Namespace psi
270 
271 #endif
void print_header()
Print header, bases, sizes, etc.
Definition: fisapt.cc:132
void flocalize()
Localize.
Definition: fisapt.cc:2456
void partition()
Partition the nuclei and electrons.
Definition: fisapt.cc:164
void overlap()
Build the overlap integrals S.
Definition: fisapt.cc:528
std::shared_ptr< Matrix > x_A_
Definition: fisapt.h:227
std::map< std::string, double > scalars_
Map of scalars.
Definition: fisapt.h:169
void elst()
Electrostatics.
Definition: fisapt.cc:1218
std::shared_ptr< Vector > eps_occ_A_
Definition: fisapt.h:233
std::map< std::string, double > scalars()
Definition: fisapt.h:154
std::shared_ptr< Vector > eps_vir_B_
Definition: fisapt.h:250
virtual ~FISAPTSCF()
Definition: fisapt.cc:4218
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:4188
std::shared_ptr< JK > jk_
Definition: fisapt.h:220
void print_orbitals(const std::string &header, int start, std::shared_ptr< Vector > eps)
Print orbitals.
Definition: fisapt.cc:4439
std::shared_ptr< Matrix > Cocc_A_
Definition: fisapt.h:229
void freeze_core()
Freeze the core orbitals.
Definition: fisapt.cc:740
Definition: fisapt.h:45
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:4157
void nuclear()
Build the nuclear potentials V and interaction energies.
Definition: fisapt.cc:546
std::shared_ptr< BasisSet > primary_
Orbital Basis Set (full molecule)
Definition: fisapt.h:59
std::shared_ptr< Matrix > Cvir_A_
Definition: fisapt.h:231
double delta_
Definition: fisapt.h:216
void kinetic()
Build the kinetic integrals T.
Definition: fisapt.cc:537
void print_trailer()
Print SAPT results.
Definition: fisapt.cc:2276
CPHF_FISAPT()
Definition: fisapt.cc:4452
std::map< std::string, std::shared_ptr< Matrix > > matrices_
Map of matrices.
Definition: fisapt.h:173
int * T
Definition: stringlist.cc:66
int maxiter_
Definition: fisapt.h:218
void fdrop()
Output.
Definition: fisapt.cc:4101
std::map< std::string, double > & scalars()
Definition: fisapt.h:200
FISAPT(std::shared_ptr< Wavefunction > scf)
Initialize an FISAPT object with an SCF reference.
Definition: fisapt.cc:57
std::shared_ptr< Matrix > Cvir_B_
Definition: fisapt.h:246
std::shared_ptr< JK > jk_
Global JK object.
Definition: fisapt.h:63
double sSAPT0_scale_
Definition: fisapt.h:50
std::shared_ptr< Wavefunction > reference_
Reference wavefunction.
Definition: fisapt.h:56
void coulomb()
Build the J/K potentials for C, D, and E.
Definition: fisapt.cc:646
std::shared_ptr< Matrix > w_A_
Definition: fisapt.h:225
std::map< std::string, std::shared_ptr< Vector > > & vectors()
Definition: fisapt.h:201
void compute_energy()
Gogo!
Definition: fisapt.cc:84
void disp(std::map< std::string, SharedMatrix > matrix_cache, std::map< std::string, SharedVector > vector_cache, bool do_print)
Dispersion.
Definition: fisapt.cc:1850
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:4206
void common_init()
Common initialization (bases, orbitals, eigenvalues, etc)
Definition: fisapt.cc:60
std::shared_ptr< Vector > eps_vir_A_
Definition: fisapt.h:235
size_t doubles_
Memory in doubles.
Definition: fisapt.h:54
std::shared_ptr< Matrix > x_B_
Definition: fisapt.h:242
std::shared_ptr< Matrix > w_B_
Definition: fisapt.h:240
std::shared_ptr< Vector > eps_occ_B_
Definition: fisapt.h:248
void ind()
Induction.
Definition: fisapt.cc:1449
void dHF()
Delta HF.
Definition: fisapt.cc:894
std::shared_ptr< BasisSet > df_basis_scf_
Definition: fisapt.h:60
void find()
Induction.
Definition: fisapt.cc:2939
std::map< std::string, std::shared_ptr< Matrix > > matrices_
Map of matrices.
Definition: fisapt.h:70
void exch()
Exchange.
Definition: fisapt.cc:1250
void fexch()
Exchange.
Definition: fisapt.cc:2741
std::shared_ptr< JK > jk_
Global JK object.
Definition: fisapt.h:166
PsiReturnType fisapt(SharedWavefunction ref_wfn, Options &options)
Definition: fisapt/wrapper.cc:40
std::shared_ptr< Matrix > build_ind_pot(std::map< std::string, std::shared_ptr< Matrix > > &vars)
Definition: fisapt.cc:1723
virtual ~CPHF_FISAPT()
Definition: fisapt.cc:4453
void compute_cphf()
Definition: fisapt.cc:4454
Definition: liboptions.h:355
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:4595
void plot()
Plot some analysis files.
Definition: fisapt.cc:2384
void unify()
Produce unified matrices for A&#39;, B&#39;, and C&#39;.
Definition: fisapt.cc:845
Options & options_
Global options object.
Definition: fisapt.h:52
void fdisp()
Dispersion.
Definition: fisapt.cc:3563
std::shared_ptr< Matrix > Cocc_B_
Definition: fisapt.h:244
std::shared_ptr< Matrix > build_exch_ind_pot(std::map< std::string, std::shared_ptr< Matrix > > &vars)
Definition: fisapt.cc:1736
std::map< std::string, std::shared_ptr< Matrix > > product(std::map< std::string, std::shared_ptr< Matrix > > b)
Definition: fisapt.cc:4612
std::map< std::string, std::shared_ptr< Vector > > vectors_
Map of vectors.
Definition: fisapt.h:171
void localize()
Localize the active occupied orbitals via IBO2.
Definition: fisapt.cc:144
virtual ~FISAPT()
Definition: fisapt.cc:59
Definition: fisapt.h:206
Definition: fisapt.h:157
void scf()
Solve the relaxed SCF equations for A0 and B0.
Definition: fisapt.cc:687
std::map< std::string, double > scalars_
Map of scalars.
Definition: fisapt.h:66
std::map< std::string, std::shared_ptr< Matrix > > & matrices()
Definition: fisapt.h:202
void compute_energy()
Definition: fisapt.cc:4219
Options & options_
Global options object.
Definition: fisapt.h:163
std::map< std::string, std::shared_ptr< Vector > > vectors_
Map of vectors.
Definition: fisapt.h:68
void felst()
Electrostatics.
Definition: fisapt.cc:2596