Psi4
apps.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 APPS_H
29 #define APPS_H
30 #include <set>
31 #include <tuple>
33 
34 namespace psi {
35 
36 class BasisSet;
37 class Matrix;
38 class TwoBodyAOInt;
39 class JK;
40 class VBase;
41 
42 // => BASE CLASSES <= //
43 
44 class RBase : public Wavefunction {
45 
46 protected:
47 
48  int print_;
49  int bench_;
50 
52 
58 
59  std::shared_ptr<Vector> eps_focc_;
60  std::shared_ptr<Vector> eps_fvir_;
61  std::shared_ptr<Vector> eps_aocc_;
62  std::shared_ptr<Vector> eps_avir_;
63 
65 
67  double convergence_;
69  std::shared_ptr<JK> jk_;
70  std::shared_ptr<VBase> v_;
71 
73  double Eref_;
74 
75 public:
76 
77  RBase(SharedWavefunction ref_wfn, Options& options, bool use_symmetry=true);
78  // TODO: Remove AS SOON AS POSSIBLE, such a dirty hack
79  RBase(bool flag);
80  virtual ~RBase();
81 
82  virtual bool same_a_b_orbs() const { return true; }
83  virtual bool same_a_b_dens() const { return true; }
84 
85  // TODO: Remove AS SOON AS POSSIBLE, such a dirty hack
86  virtual double compute_energy() { return 0.0; }
87 
88  void set_print(int print) { print_ = print; }
89 
91  std::shared_ptr<JK> jk() const { return jk_;}
93  void set_jk(std::shared_ptr<JK> jk) { jk_ = jk; }
95  std::shared_ptr<VBase> v() const { return v_;}
97  void set_jk(std::shared_ptr<VBase> v) { v_ = v; }
99  virtual void preiterations();
101  virtual void postiterations();
102 
104 
105  void set_use_symmetry(bool usesym) { use_symmetry_ = usesym; }
107  void set_convergence(double convergence) { convergence_ = convergence; }
108 
110  void set_C(SharedMatrix C) { C_ = C; }
111  void set_Cocc(SharedMatrix Cocc) { Cocc_ = Cocc; }
112  void set_Cfocc(SharedMatrix Cfocc) { Cfocc_ = Cfocc; }
113  void set_Caocc(SharedMatrix Caocc) { Caocc_ = Caocc; }
114  void set_Cavir(SharedMatrix Cavir) { Cavir_ = Cavir; }
115  void set_Cfvir(SharedMatrix Cfvir) { Cfvir_ = Cfvir; }
116  void set_eps_focc(SharedVector eps) { eps_focc_ = eps; }
117  void set_eps_aocc(SharedVector eps) { eps_aocc_ = eps; }
118  void set_eps_avir(SharedVector eps) { eps_avir_ = eps; }
119  void set_eps_fvir(SharedVector eps) { eps_fvir_ = eps; }
120  void set_Eref(double Eref) { Eref_ = Eref; }
121 
123  void set_reference(std::shared_ptr<Wavefunction> reference);
124 };
125 
126 // => APPLIED CLASSES <= //
127 
128 class RCIS : public RBase {
129 
130 protected:
131 
132  std::vector<std::tuple<double, int, int, int> > states_;
133  std::vector<SharedMatrix > singlets_;
134  std::vector<SharedMatrix > triplets_;
135  std::vector<double> E_singlets_;
136  std::vector<double> E_triplets_;
137 
138  void sort_states();
139 
140  virtual void print_header();
141  virtual void print_wavefunctions();
142  virtual void print_amplitudes();
143  virtual void print_transitions();
144  virtual void print_densities();
145 
146  virtual SharedMatrix TDmo(SharedMatrix T1, bool singlet = true);
147  virtual SharedMatrix TDso(SharedMatrix T1, bool singlet = true);
148  virtual SharedMatrix TDao(SharedMatrix T1, bool singlet = true);
149 
150  virtual SharedMatrix Dmo(SharedMatrix T1, bool diff = false);
151  virtual SharedMatrix Dso(SharedMatrix T1, bool diff = false);
152  virtual SharedMatrix Dao(SharedMatrix T1, bool diff = false);
153 
154  virtual std::pair<SharedMatrix, std::shared_ptr<Vector> > Nmo(SharedMatrix T1, bool diff = false);
155  virtual std::pair<SharedMatrix, std::shared_ptr<Vector> > Nso(SharedMatrix T1, bool diff = false);
156  virtual std::pair<SharedMatrix, std::shared_ptr<Vector> > Nao(SharedMatrix T1, bool diff = false);
157 
158  virtual std::pair<SharedMatrix, SharedMatrix > ADmo(SharedMatrix T1);
159  virtual std::pair<SharedMatrix, SharedMatrix > ADso(SharedMatrix T1);
160  virtual std::pair<SharedMatrix, SharedMatrix > ADao(SharedMatrix T1);
161 
162 public:
164  virtual ~RCIS();
165 
166  virtual double compute_energy();
167 
168 };
169 
170 class RTDHF : public RBase {
171 
172 protected:
173 
174  std::vector<SharedMatrix > singlets_X_;
175  std::vector<SharedMatrix > triplets_X_;
176  std::vector<SharedMatrix > singlets_Y_;
177  std::vector<SharedMatrix > triplets_Y_;
178  std::vector<double> E_singlets_;
179  std::vector<double> E_triplets_;
180 
181  virtual void print_header();
182 
183 public:
185  virtual ~RTDHF();
186 
187  virtual double compute_energy();
188 
189 };
190 
191 class RCPHF : public RBase {
192 
193 protected:
194 
195  // OV-Rotations
196  std::map<std::string, SharedMatrix> x_;
197  // OV-Perturbations
198  std::map<std::string, SharedMatrix> b_;
199 
200  virtual void print_header();
201 
202  void add_named_tasks();
203  void analyze_named_tasks();
204 
205  void add_polarizability();
206  void analyze_polarizability();
207 
208  std::set<std::string> tasks_;
209 
210 public:
211  RCPHF(SharedWavefunction ref_wfn, Options& options, bool use_symmetry=true);
212  virtual ~RCPHF();
213 
215  virtual double compute_energy();
216 
218  std::map<std::string, SharedMatrix>& b() { return b_; }
220  std::map<std::string, SharedMatrix>& x() { return x_; }
221 
223  void add_task(const std::string& task);
224 
225 };
226 
227 class RCPKS : public RCPHF {
228 
229 protected:
230  virtual void print_header();
231 
232 public:
234  virtual ~RCPKS();
235 
236  virtual double compute_energy();
237 };
238 
239 class RTDA : public RCIS {
240 
241 protected:
242  virtual void print_header();
243 
244 public:
246  virtual ~RTDA();
247 
248  virtual double compute_energy();
249 };
250 
251 class RTDDFT : public RTDHF {
252 
253 protected:
254  virtual void print_header();
255 
256 public:
258  virtual ~RTDDFT();
259 
260  virtual double compute_energy();
261 };
262 
263 }
264 #endif
RTDHF(SharedWavefunction ref_wfn, Options &options)
Definition: apps.cc:1134
double convergence_
How far to converge the two-norm of the residual.
Definition: apps.h:67
virtual SharedMatrix Dao(SharedMatrix T1, bool diff=false)
Definition: apps.cc:762
std::map< std::string, SharedMatrix > & x()
Resultant solution vectors, available after compute_energy is called.
Definition: apps.h:220
std::vector< SharedMatrix > singlets_
Definition: apps.h:133
std::vector< double > E_triplets_
Definition: apps.h:136
virtual bool same_a_b_orbs() const
Definition: apps.h:82
virtual std::pair< SharedMatrix, SharedMatrix > ADmo(SharedMatrix T1)
Definition: apps.cc:870
Options & options() const
Definition: wavefunction.cc:400
std::vector< double > E_triplets_
Definition: apps.h:179
virtual SharedMatrix TDao(SharedMatrix T1, bool singlet=true)
Definition: apps.cc:657
SharedMatrix Cocc_
Definition: apps.h:53
void set_eps_avir(SharedVector eps)
Definition: apps.h:118
bool use_symmetry_
Definition: apps.h:72
void set_eps_focc(SharedVector eps)
Definition: apps.h:116
virtual void print_header()
Definition: apps.cc:1361
virtual double compute_energy()
Compute energy. Subclasses override this function to compute its energy.
Definition: apps.cc:1163
Definition: apps.h:44
SharedMatrix Cavir_
Definition: apps.h:57
virtual ~RBase()
Definition: apps.cc:76
void set_Cfvir(SharedMatrix Cfvir)
Definition: apps.h:115
void set_eps_fvir(SharedVector eps)
Definition: apps.h:119
virtual ~RCPKS()
Definition: apps.cc:1260
void set_C(SharedMatrix C)
Set reference info.
Definition: apps.h:110
std::shared_ptr< Vector > eps_fvir_
Definition: apps.h:60
virtual SharedMatrix Dmo(SharedMatrix T1, bool diff=false)
Definition: apps.cc:687
std::vector< SharedMatrix > triplets_Y_
Definition: apps.h:177
virtual void print_header()
Definition: apps.cc:1141
virtual SharedMatrix Dso(SharedMatrix T1, bool diff=false)
Definition: apps.cc:735
virtual void print_header()
Definition: apps.cc:1263
virtual ~RCIS()
Definition: apps.cc:345
void analyze_polarizability()
Definition: apps.cc:242
std::shared_ptr< VBase > v_
Definition: apps.h:70
void add_task(const std::string &task)
Add a named task.
Definition: apps.cc:187
Definition: apps.h:251
virtual void preiterations()
Builds JK object, if needed.
Definition: apps.cc:119
std::vector< SharedMatrix > triplets_
Definition: apps.h:134
std::shared_ptr< VBase > v() const
Gets a handle to the VBase object, if built by preiterations.
Definition: apps.h:95
Definition: apps.h:191
Definition: apps.h:239
virtual ~RTDDFT()
Definition: apps.cc:1509
virtual double compute_energy()
Solve for all perturbations currently in b.
Definition: apps.cc:1279
virtual double compute_energy()
Compute energy. Subclasses override this function to compute its energy.
Definition: apps.cc:1377
void set_Eref(double Eref)
Definition: apps.h:120
SharedMatrix Caocc_
Definition: apps.h:56
std::set< std::string > tasks_
Definition: apps.h:208
virtual void print_amplitudes()
Definition: apps.cc:424
void reference(void)
Definition: reference.cc:48
std::shared_ptr< Vector > eps_focc_
Definition: apps.h:59
virtual SharedMatrix TDmo(SharedMatrix T1, bool singlet=true)
Definition: apps.cc:615
std::vector< SharedMatrix > triplets_X_
Definition: apps.h:175
std::shared_ptr< JK > jk() const
Gets a handle to the JK object, if built by preiterations.
Definition: apps.h:91
int print_
Definition: apps.h:48
virtual double compute_energy()
Compute energy. Subclasses override this function to compute its energy.
Definition: apps.cc:1000
RCIS(SharedWavefunction ref_wfn, Options &options)
Definition: apps.cc:341
void set_use_symmetry(bool usesym)
=&gt; Setters &lt;= ///
Definition: apps.h:105
virtual double compute_energy()
Compute energy. Subclasses override this function to compute its energy.
Definition: apps.h:86
virtual void print_header()
Definition: apps.cc:1512
Definition: apps.h:227
virtual SharedMatrix TDso(SharedMatrix T1, bool singlet=true)
Definition: apps.cc:624
void set_print(int print)
Definition: apps.h:88
std::map< std::string, SharedMatrix > x_
Definition: apps.h:196
virtual ~RTDHF()
Definition: apps.cc:1138
virtual void postiterations()
Destroys JK object, if needed.
Definition: apps.cc:145
virtual void print_wavefunctions()
Definition: apps.cc:381
std::vector< SharedMatrix > singlets_Y_
Definition: apps.h:176
Definition: liboptions.h:359
void set_jk(std::shared_ptr< VBase > v)
Set the VBase object, say from SCF (except that wouldn&#39;t work, right?)
Definition: apps.h:97
virtual std::pair< SharedMatrix, SharedMatrix > ADao(SharedMatrix T1)
Definition: apps.cc:956
std::shared_ptr< JK > jk_
Global JK object, built in preiterations, destroyed in postiterations.
Definition: apps.h:69
std::shared_ptr< Vector > eps_aocc_
Definition: apps.h:61
void set_jk(std::shared_ptr< JK > jk)
Set the JK object, say from SCF.
Definition: apps.h:93
Definition: apps.h:170
void set_Cfocc(SharedMatrix Cfocc)
Definition: apps.h:112
std::map< std::string, SharedMatrix > b_
Definition: apps.h:198
virtual ~RTDA()
Definition: apps.cc:1358
std::shared_ptr< Vector > eps_avir_
Definition: apps.h:62
std::shared_ptr< Matrix > SharedMatrix
Definition: adc.h:50
void sort_states()
Definition: apps.cc:370
double Eref_
Definition: apps.h:73
Definition: apps.h:128
void set_Cocc(SharedMatrix Cocc)
Definition: apps.h:111
Simple wavefunction base class.
Definition: wavefunction.h:85
RBase(SharedWavefunction ref_wfn, Options &options, bool use_symmetry=true)
Definition: apps.cc:56
virtual bool same_a_b_dens() const
Definition: apps.h:83
void set_eps_aocc(SharedVector eps)
Definition: apps.h:117
RCPHF(SharedWavefunction ref_wfn, Options &options, bool use_symmetry=true)
Definition: apps.cc:150
std::map< std::string, SharedMatrix > & b()
Perturbation vector queue, shove tasks onto this guy before compute_energy.
Definition: apps.h:218
virtual std::pair< SharedMatrix, std::shared_ptr< Vector > > Nso(SharedMatrix T1, bool diff=false)
Definition: apps.cc:798
virtual void print_header()
Definition: apps.cc:157
std::vector< double > E_singlets_
Definition: apps.h:135
void add_named_tasks()
Definition: apps.cc:191
std::vector< double > E_singlets_
Definition: apps.h:178
SharedMatrix Cfvir_
Definition: apps.h:55
std::vector< SharedMatrix > singlets_X_
Definition: apps.h:174
RTDDFT(SharedWavefunction ref_wfn, Options &options)
Definition: apps.cc:1505
virtual void print_transitions()
Definition: apps.cc:491
RTDA(SharedWavefunction ref_wfn, Options &options)
Definition: apps.cc:1355
virtual std::pair< SharedMatrix, SharedMatrix > ADso(SharedMatrix T1)
Definition: apps.cc:913
virtual std::pair< SharedMatrix, std::shared_ptr< Vector > > Nao(SharedMatrix T1, bool diff=false)
Definition: apps.cc:821
virtual void print_densities()
Definition: apps.cc:545
SharedMatrix Cfocc_
Definition: apps.h:54
std::shared_ptr< Wavefunction > SharedWavefunction
Definition: typedefs.h:50
virtual void print_header()
Definition: apps.cc:348
std::vector< std::tuple< double, int, int, int > > states_
Definition: apps.h:132
RCPKS(SharedWavefunction ref_wfn, Options &options)
Definition: apps.cc:1256
virtual double compute_energy()
Compute energy. Subclasses override this function to compute its energy.
Definition: apps.cc:1528
void set_Cavir(SharedMatrix Cavir)
Definition: apps.h:114
virtual double compute_energy()
Solve for all perturbations currently in b.
Definition: apps.cc:265
virtual std::pair< SharedMatrix, std::shared_ptr< Vector > > Nmo(SharedMatrix T1, bool diff=false)
Definition: apps.cc:788
SharedMatrix AO2USO_
Definition: apps.h:64
void analyze_named_tasks()
Definition: apps.cc:197
void set_reference(std::shared_ptr< Wavefunction > reference)
Update reference info.
Definition: apps.cc:80
SharedMatrix C_
Definition: apps.h:51
int bench_
Definition: apps.h:49
std::shared_ptr< Vector > SharedVector
Definition: adc.h:52
void add_polarizability()
Definition: apps.cc:203
void set_Caocc(SharedMatrix Caocc)
Definition: apps.h:113
virtual ~RCPHF()
Definition: apps.cc:154
void set_convergence(double convergence)
Set convergence behavior.
Definition: apps.h:107