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-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 FISAPT_H
30 #define FISAPT_H
31 
32 #include "psi4/libmints/typedefs.h"
33 #include "psi4/libmints/basisset.h"
36 
37 #include <map>
38 #include <tuple>
39 
40 namespace psi {
41 
42 class JK;
43 class BasisSet;
44 class DFHelper;
45 
46 namespace fisapt {
47 
48 class FISAPT {
49  protected:
50  // sSAPT0 exchange-scaling
51  double sSAPT0_scale_;
55  size_t doubles_;
57  std::shared_ptr<Wavefunction> reference_;
58 
60  std::shared_ptr<BasisSet> primary_;
61  std::shared_ptr<BasisSet> df_basis_scf_;
62 
64  std::shared_ptr<JK> jk_;
65 
67  std::map<std::string, double> scalars_;
69  std::map<std::string, std::shared_ptr<Vector> > vectors_;
71  std::map<std::string, std::shared_ptr<Matrix> > matrices_;
72 
73  // Build the ExchInd20 potential in the monomer A ov space
74  std::shared_ptr<Matrix> build_exch_ind_pot(std::map<std::string, std::shared_ptr<Matrix> >& vars);
75  // Build the Ind20 potential in the monomer A ov space
76  std::shared_ptr<Matrix> build_ind_pot(std::map<std::string, std::shared_ptr<Matrix> >& vars);
77 
78  // DFHelper object
79  std::shared_ptr<DFHelper> dfh_;
80 
83  // drop(<Matrix> or <Vector>, filepath) moved py-side
85  static std::shared_ptr<Matrix> extract_columns(const std::vector<int>& cols, std::shared_ptr<Matrix> A);
86 
87  public:
89  FISAPT(std::shared_ptr<Wavefunction> scf);
90  FISAPT(std::shared_ptr<Wavefunction> scf, Options& options);
91  virtual ~FISAPT();
92 
94  // void compute_energy(); moved py-side
95 
97  std::shared_ptr<Molecule> molecule() { return primary_->molecule(); }
98 
99  // => FISAPT 0th-Order Wavefunction <= //
100 
102  void common_init();
104  void print_header();
106  void localize();
108  void partition();
110  void overlap();
112  void kinetic();
114  void nuclear();
116  void coulomb();
118  void scf();
120  void freeze_core();
122  void unify();
124  void raw_plot(const std::string& filepath);
125 
126  // => F-SAPT0 <= //
127 
129  void flocalize();
131  void felst();
133  void fexch();
135  void find();
137  void fdisp();
139  // fdrop() moved py-side
140 
141  // => SAPT0 <= //
142 
144  void dHF();
146  void elst();
148  void exch();
150  void ind();
152  void print_trailer();
153 
155  void disp(std::map<std::string, SharedMatrix> matrix_cache, std::map<std::string, SharedVector> vector_cache,
156  bool do_print);
157 
159  std::map<std::string, double>& scalars() { return scalars_; }
160  std::map<std::string, std::shared_ptr<Vector> >& vectors() { return vectors_; }
161  std::map<std::string, std::shared_ptr<Matrix> >& matrices() { return matrices_; }
162 };
163 
164 class FISAPTSCF {
165  protected:
168 
170  std::shared_ptr<JK> jk_;
171 
173  std::map<std::string, double> scalars_;
175  std::map<std::string, std::shared_ptr<Vector> > vectors_;
177  std::map<std::string, std::shared_ptr<Matrix> > matrices_;
178 
180  void print_orbitals(const std::string& header, int start, std::shared_ptr<Vector> eps);
181 
182  public:
183  FISAPTSCF(std::shared_ptr<JK> jk, // JK object
184  double enuc, // Nuclear repulsion energy
185  std::shared_ptr<Matrix> S, // Overlap integrals
186  std::shared_ptr<Matrix> X, // Restricted orthogonalization matrix [nbf x nmo]
187  std::shared_ptr<Matrix> T, // Kinetic integrals
188  std::shared_ptr<Matrix> V, // Potential integrals
189  std::shared_ptr<Matrix> W, // External embedding potential
190  std::shared_ptr<Matrix> C, // Guess for occupied orbitals [nbf x nocc]
191  Options& options);
192  virtual ~FISAPTSCF();
193 
194  void compute_energy();
195 
196  std::map<std::string, double>& scalars() { return scalars_; }
197  std::map<std::string, std::shared_ptr<Vector> >& vectors() { return vectors_; }
198  std::map<std::string, std::shared_ptr<Matrix> >& matrices() { return matrices_; }
199 };
200 
201 class CPHF_FISAPT {
202  friend class FISAPT;
203 
204  protected:
205  // => Global Data <= //
206 
207  // Convergence tolerance
208  double delta_;
209  // Maximum allowed iterations
210  int maxiter_;
211  // JK Object
212  std::shared_ptr<JK> jk_;
213 
214  // => Monomer A Problem <= //
215 
216  // Perturbation applied to A
217  std::shared_ptr<Matrix> w_A_;
218  // Response of A
219  std::shared_ptr<Matrix> x_A_;
220  // Active occ orbital coefficients of A
221  std::shared_ptr<Matrix> Cocc_A_;
222  // Active vir orbital coefficients of A
223  std::shared_ptr<Matrix> Cvir_A_;
224  // Active occ orbital eigenvalues of A
225  std::shared_ptr<Vector> eps_occ_A_;
226  // Active vir orbital eigenvalues of A
227  std::shared_ptr<Vector> eps_vir_A_;
228 
229  // => Monomer B Problem <= //
230 
231  // Perturbation applied to B
232  std::shared_ptr<Matrix> w_B_;
233  // Response of B
234  std::shared_ptr<Matrix> x_B_;
235  // Active occ orbital coefficients of B
236  std::shared_ptr<Matrix> Cocc_B_;
237  // Active vir orbital coefficients of B
238  std::shared_ptr<Matrix> Cvir_B_;
239  // Active occ orbital eigenvalues of B
240  std::shared_ptr<Vector> eps_occ_B_;
241  // Active vir orbital eigenvalues of B
242  std::shared_ptr<Vector> eps_vir_B_;
243 
244  // Form the s = Ab product for the provided vectors b (may or may not need more iterations)
245  std::map<std::string, std::shared_ptr<Matrix> > product(std::map<std::string, std::shared_ptr<Matrix> > b);
246  // Apply the denominator from r into z
247  void preconditioner(std::shared_ptr<Matrix> r, std::shared_ptr<Matrix> z, std::shared_ptr<Vector> o,
248  std::shared_ptr<Vector> v);
249 
250  public:
251  CPHF_FISAPT();
252  virtual ~CPHF_FISAPT();
253 
254  void compute_cphf();
255 };
256 
257 } // Namespace fisapt
258 
259 } // Namespace psi
260 
261 #endif
void print_header()
Print header, bases, sizes, etc.
Definition: fisapt.cc:86
void flocalize()
Localize.
Definition: fisapt.cc:2416
std::map< std::string, std::shared_ptr< Matrix > > & matrices()
Definition: fisapt.h:161
void partition()
Partition the nuclei and electrons.
Definition: fisapt.cc:118
void overlap()
Build the overlap integrals S.
Definition: fisapt.cc:482
std::shared_ptr< Matrix > x_A_
Definition: fisapt.h:219
std::map< std::string, double > scalars_
Map of scalars.
Definition: fisapt.h:173
void elst()
Electrostatics.
Definition: fisapt.cc:1172
std::shared_ptr< Vector > eps_occ_A_
Definition: fisapt.h:225
std::shared_ptr< Vector > eps_vir_B_
Definition: fisapt.h:242
virtual ~FISAPTSCF()
Definition: fisapt.cc:4087
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:4057
std::shared_ptr< JK > jk_
Definition: fisapt.h:212
void print_orbitals(const std::string &header, int start, std::shared_ptr< Vector > eps)
Print orbitals.
Definition: fisapt.cc:4308
std::shared_ptr< Matrix > Cocc_A_
Definition: fisapt.h:221
void freeze_core()
Freeze the core orbitals.
Definition: fisapt.cc:694
Definition: fisapt.h:48
void nuclear()
Build the nuclear potentials V and interaction energies.
Definition: fisapt.cc:500
std::shared_ptr< BasisSet > primary_
Orbital Basis Set (full molecule)
Definition: fisapt.h:60
std::shared_ptr< Matrix > Cvir_A_
Definition: fisapt.h:223
double delta_
Definition: fisapt.h:208
void kinetic()
Build the kinetic integrals T.
Definition: fisapt.cc:491
void print_trailer()
Print SAPT results.
Definition: fisapt.cc:2230
CPHF_FISAPT()
Definition: fisapt.cc:4321
std::map< std::string, std::shared_ptr< Matrix > > matrices_
Map of matrices.
Definition: fisapt.h:177
int * T
Definition: stringlist.cc:66
int maxiter_
Definition: fisapt.h:210
std::shared_ptr< DFHelper > dfh_
Definition: fisapt.h:79
std::map< std::string, double > & scalars()
Definition: fisapt.h:196
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:238
std::shared_ptr< JK > jk_
Global JK object.
Definition: fisapt.h:64
double sSAPT0_scale_
Definition: fisapt.h:51
std::shared_ptr< Wavefunction > reference_
Reference wavefunction.
Definition: fisapt.h:57
void coulomb()
Build the J/K potentials for C, D, and E.
Definition: fisapt.cc:600
std::shared_ptr< Matrix > w_A_
Definition: fisapt.h:217
std::map< std::string, std::shared_ptr< Vector > > & vectors()
Definition: fisapt.h:197
void disp(std::map< std::string, SharedMatrix > matrix_cache, std::map< std::string, SharedVector > vector_cache, bool do_print)
Dispersion.
Definition: fisapt.cc:1804
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:4075
void common_init()
Common initialization (bases, orbitals, eigenvalues, etc)
Definition: fisapt.cc:62
std::shared_ptr< Vector > eps_vir_A_
Definition: fisapt.h:227
size_t doubles_
Memory in doubles.
Definition: fisapt.h:55
std::shared_ptr< Matrix > x_B_
Definition: fisapt.h:234
std::shared_ptr< Matrix > w_B_
Definition: fisapt.h:232
std::shared_ptr< Vector > eps_occ_B_
Definition: fisapt.h:240
void ind()
Induction.
Definition: fisapt.cc:1403
void dHF()
Output.
Definition: fisapt.cc:848
std::shared_ptr< BasisSet > df_basis_scf_
Definition: fisapt.h:61
void find()
Induction.
Definition: fisapt.cc:2897
std::map< std::string, std::shared_ptr< Matrix > > matrices_
Map of matrices.
Definition: fisapt.h:71
void exch()
Exchange.
Definition: fisapt.cc:1204
void fexch()
Exchange.
Definition: fisapt.cc:2704
std::shared_ptr< JK > jk_
Global JK object.
Definition: fisapt.h:170
std::map< std::string, double > & scalars()
Return arrays.
Definition: fisapt.h:159
std::map< std::string, std::shared_ptr< Vector > > & vectors()
Definition: fisapt.h:160
std::shared_ptr< Matrix > build_ind_pot(std::map< std::string, std::shared_ptr< Matrix > > &vars)
Definition: fisapt.cc:1677
virtual ~CPHF_FISAPT()
Definition: fisapt.cc:4322
void compute_cphf()
Definition: fisapt.cc:4323
Definition: liboptions.h:353
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:4464
void unify()
Produce unified matrices for A&#39;, B&#39;, and C&#39;.
Definition: fisapt.cc:799
void raw_plot(const std::string &filepath)
Plot some analysis files.
Definition: fisapt.cc:2351
Options & options_
Global options object.
Definition: fisapt.h:53
void fdisp()
Dispersion.
Definition: fisapt.cc:3519
std::shared_ptr< Matrix > Cocc_B_
Definition: fisapt.h:236
std::shared_ptr< Matrix > build_exch_ind_pot(std::map< std::string, std::shared_ptr< Matrix > > &vars)
Definition: fisapt.cc:1690
std::shared_ptr< Molecule > molecule()
Gogo!
Definition: fisapt.h:97
std::map< std::string, std::shared_ptr< Matrix > > product(std::map< std::string, std::shared_ptr< Matrix > > b)
Definition: fisapt.cc:4481
std::map< std::string, std::shared_ptr< Vector > > vectors_
Map of vectors.
Definition: fisapt.h:175
void localize()
Localize the active occupied orbitals via IBO2.
Definition: fisapt.cc:98
virtual ~FISAPT()
Definition: fisapt.cc:61
Definition: fisapt.h:201
Definition: fisapt.h:164
void scf()
Solve the relaxed SCF equations for A0 and B0.
Definition: fisapt.cc:641
std::map< std::string, double > scalars_
Map of scalars.
Definition: fisapt.h:67
std::map< std::string, std::shared_ptr< Matrix > > & matrices()
Definition: fisapt.h:198
void compute_energy()
Definition: fisapt.cc:4088
Options & options_
Global options object.
Definition: fisapt.h:167
std::map< std::string, std::shared_ptr< Vector > > vectors_
Map of vectors.
Definition: fisapt.h:69
void felst()
Electrostatics.
Definition: fisapt.cc:2556