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