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 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 APPS_H
30 #define APPS_H
31 #include <set>
32 #include <tuple>
34 
35 namespace psi {
36 
37 class JK;
38 class VBase;
39 
40 // => BASE CLASSES <= //
41 
42 class RBase : public Wavefunction {
43 
44 protected:
45 
46  int print_;
47  int bench_;
48 
50 
56 
57  std::shared_ptr<Vector> eps_focc_;
58  std::shared_ptr<Vector> eps_fvir_;
59  std::shared_ptr<Vector> eps_aocc_;
60  std::shared_ptr<Vector> eps_avir_;
61 
63 
65  double convergence_;
67  std::shared_ptr<JK> jk_;
68  std::shared_ptr<VBase> v_;
69 
71  double Eref_;
72 
73 public:
74 
75  RBase(SharedWavefunction ref_wfn, Options& options, bool use_symmetry=true);
76  // TODO: Remove AS SOON AS POSSIBLE, such a dirty hack
77  RBase(bool flag);
78  virtual ~RBase();
79 
80  virtual bool same_a_b_orbs() const { return true; }
81  virtual bool same_a_b_dens() const { return true; }
82 
83  // TODO: Remove AS SOON AS POSSIBLE, such a dirty hack
84  virtual double compute_energy() { return 0.0; }
85 
86  void set_print(int print) { print_ = print; }
87 
89  std::shared_ptr<JK> jk() const { return jk_;}
91  void set_jk(std::shared_ptr<JK> jk) { jk_ = jk; }
93  std::shared_ptr<VBase> v() const { return v_;}
95  void set_jk(std::shared_ptr<VBase> v) { v_ = v; }
97  virtual void preiterations();
99  virtual void postiterations();
100 
102 
103  void set_use_symmetry(bool usesym) { use_symmetry_ = usesym; }
105  void set_convergence(double convergence) { convergence_ = convergence; }
106 
108  void set_C(SharedMatrix C) { C_ = C; }
109  void set_Cocc(SharedMatrix Cocc) { Cocc_ = Cocc; }
110  void set_Cfocc(SharedMatrix Cfocc) { Cfocc_ = Cfocc; }
111  void set_Caocc(SharedMatrix Caocc) { Caocc_ = Caocc; }
112  void set_Cavir(SharedMatrix Cavir) { Cavir_ = Cavir; }
113  void set_Cfvir(SharedMatrix Cfvir) { Cfvir_ = Cfvir; }
114  void set_eps_focc(SharedVector eps) { eps_focc_ = eps; }
115  void set_eps_aocc(SharedVector eps) { eps_aocc_ = eps; }
116  void set_eps_avir(SharedVector eps) { eps_avir_ = eps; }
117  void set_eps_fvir(SharedVector eps) { eps_fvir_ = eps; }
118  void set_Eref(double Eref) { Eref_ = Eref; }
119 
121  void set_reference(std::shared_ptr<Wavefunction> reference);
122 };
123 
124 // => APPLIED CLASSES <= //
125 
126 class RCIS : public RBase {
127 
128 protected:
129 
130  std::vector<std::tuple<double, int, int, int> > states_;
131  std::vector<SharedMatrix > singlets_;
132  std::vector<SharedMatrix > triplets_;
133  std::vector<double> E_singlets_;
134  std::vector<double> E_triplets_;
135 
136  void sort_states();
137 
138  virtual void print_header();
139  virtual void print_wavefunctions();
140  virtual void print_amplitudes();
141  virtual void print_transitions();
142  virtual void print_densities();
143 
144  virtual SharedMatrix TDmo(SharedMatrix T1, bool singlet = true);
145  virtual SharedMatrix TDso(SharedMatrix T1, bool singlet = true);
146  virtual SharedMatrix TDao(SharedMatrix T1, bool singlet = true);
147 
148  virtual SharedMatrix Dmo(SharedMatrix T1, bool diff = false);
149  virtual SharedMatrix Dso(SharedMatrix T1, bool diff = false);
150  virtual SharedMatrix Dao(SharedMatrix T1, bool diff = false);
151 
152  virtual std::pair<SharedMatrix, std::shared_ptr<Vector> > Nmo(SharedMatrix T1, bool diff = false);
153  virtual std::pair<SharedMatrix, std::shared_ptr<Vector> > Nso(SharedMatrix T1, bool diff = false);
154  virtual std::pair<SharedMatrix, std::shared_ptr<Vector> > Nao(SharedMatrix T1, bool diff = false);
155 
156  virtual std::pair<SharedMatrix, SharedMatrix > ADmo(SharedMatrix T1);
157  virtual std::pair<SharedMatrix, SharedMatrix > ADso(SharedMatrix T1);
158  virtual std::pair<SharedMatrix, SharedMatrix > ADao(SharedMatrix T1);
159 
160 public:
162  virtual ~RCIS();
163 
164  virtual double compute_energy();
165 
166 };
167 
168 class RTDHF : public RBase {
169 
170 protected:
171 
172  std::vector<SharedMatrix > singlets_X_;
173  std::vector<SharedMatrix > triplets_X_;
174  std::vector<SharedMatrix > singlets_Y_;
175  std::vector<SharedMatrix > triplets_Y_;
176  std::vector<double> E_singlets_;
177  std::vector<double> E_triplets_;
178 
179  virtual void print_header();
180 
181 public:
183  virtual ~RTDHF();
184 
185  virtual double compute_energy();
186 
187 };
188 
189 class RCPHF : public RBase {
190 
191 protected:
192 
193  // OV-Rotations
194  std::map<std::string, SharedMatrix> x_;
195  // OV-Perturbations
196  std::map<std::string, SharedMatrix> b_;
197 
198  virtual void print_header();
199 
200  void add_named_tasks();
201  void analyze_named_tasks();
202 
203  void add_polarizability();
204  void analyze_polarizability();
205 
206  std::set<std::string> tasks_;
207 
208 public:
209  RCPHF(SharedWavefunction ref_wfn, Options& options, bool use_symmetry=true);
210  virtual ~RCPHF();
211 
213  virtual double compute_energy();
214 
216  std::map<std::string, SharedMatrix>& b() { return b_; }
218  std::map<std::string, SharedMatrix>& x() { return x_; }
219 
221  void add_task(const std::string& task);
222 
223 };
224 
225 class RCPKS : public RCPHF {
226 
227 protected:
228  virtual void print_header();
229 
230 public:
232  virtual ~RCPKS();
233 
234  virtual double compute_energy();
235 };
236 
237 class RTDA : public RCIS {
238 
239 protected:
240  virtual void print_header();
241 
242 public:
244  virtual ~RTDA();
245 
246  virtual double compute_energy();
247 };
248 
249 class RTDDFT : public RTDHF {
250 
251 protected:
252  virtual void print_header();
253 
254 public:
256  virtual ~RTDDFT();
257 
258  virtual double compute_energy();
259 };
260 
261 }
262 #endif
RTDHF(SharedWavefunction ref_wfn, Options &options)
Definition: apps.cc:1135
double convergence_
How far to converge the two-norm of the residual.
Definition: apps.h:65
virtual SharedMatrix Dao(SharedMatrix T1, bool diff=false)
Definition: apps.cc:763
std::map< std::string, SharedMatrix > & x()
Resultant solution vectors, available after compute_energy is called.
Definition: apps.h:218
std::vector< SharedMatrix > singlets_
Definition: apps.h:131
std::vector< double > E_triplets_
Definition: apps.h:134
virtual bool same_a_b_orbs() const
Definition: apps.h:80
virtual std::pair< SharedMatrix, SharedMatrix > ADmo(SharedMatrix T1)
Definition: apps.cc:871
Options & options() const
Definition: wavefunction.cc:412
std::vector< double > E_triplets_
Definition: apps.h:177
virtual SharedMatrix TDao(SharedMatrix T1, bool singlet=true)
Definition: apps.cc:658
SharedMatrix Cocc_
Definition: apps.h:51
void set_eps_avir(SharedVector eps)
Definition: apps.h:116
bool use_symmetry_
Definition: apps.h:70
void set_eps_focc(SharedVector eps)
Definition: apps.h:114
virtual void print_header()
Definition: apps.cc:1362
virtual double compute_energy()
Compute energy. Subclasses override this function to compute its energy.
Definition: apps.cc:1164
Definition: apps.h:42
SharedMatrix Cavir_
Definition: apps.h:55
virtual ~RBase()
Definition: apps.cc:82
void set_Cfvir(SharedMatrix Cfvir)
Definition: apps.h:113
void set_eps_fvir(SharedVector eps)
Definition: apps.h:117
virtual ~RCPKS()
Definition: apps.cc:1261
void set_C(SharedMatrix C)
Set reference info.
Definition: apps.h:108
std::shared_ptr< Vector > eps_fvir_
Definition: apps.h:58
virtual SharedMatrix Dmo(SharedMatrix T1, bool diff=false)
Definition: apps.cc:688
std::vector< SharedMatrix > triplets_Y_
Definition: apps.h:175
virtual void print_header()
Definition: apps.cc:1142
virtual SharedMatrix Dso(SharedMatrix T1, bool diff=false)
Definition: apps.cc:736
virtual void print_header()
Definition: apps.cc:1264
virtual ~RCIS()
Definition: apps.cc:351
void analyze_polarizability()
Definition: apps.cc:248
std::shared_ptr< VBase > v_
Definition: apps.h:68
void add_task(const std::string &task)
Add a named task.
Definition: apps.cc:193
Definition: apps.h:249
virtual void preiterations()
Builds JK object, if needed.
Definition: apps.cc:125
std::vector< SharedMatrix > triplets_
Definition: apps.h:132
std::shared_ptr< VBase > v() const
Gets a handle to the VBase object, if built by preiterations.
Definition: apps.h:93
Definition: apps.h:189
Definition: apps.h:237
virtual ~RTDDFT()
Definition: apps.cc:1510
virtual double compute_energy()
Solve for all perturbations currently in b.
Definition: apps.cc:1280
virtual double compute_energy()
Compute energy. Subclasses override this function to compute its energy.
Definition: apps.cc:1378
void set_Eref(double Eref)
Definition: apps.h:118
SharedMatrix Caocc_
Definition: apps.h:54
std::set< std::string > tasks_
Definition: apps.h:206
virtual void print_amplitudes()
Definition: apps.cc:427
void reference(void)
Definition: reference.cc:50
std::shared_ptr< Vector > eps_focc_
Definition: apps.h:57
virtual SharedMatrix TDmo(SharedMatrix T1, bool singlet=true)
Definition: apps.cc:616
std::vector< SharedMatrix > triplets_X_
Definition: apps.h:173
std::shared_ptr< JK > jk() const
Gets a handle to the JK object, if built by preiterations.
Definition: apps.h:89
int print_
Definition: apps.h:46
virtual double compute_energy()
Compute energy. Subclasses override this function to compute its energy.
Definition: apps.cc:1001
RCIS(SharedWavefunction ref_wfn, Options &options)
Definition: apps.cc:347
void set_use_symmetry(bool usesym)
=&gt; Setters &lt;= ///
Definition: apps.h:103
virtual double compute_energy()
Compute energy. Subclasses override this function to compute its energy.
Definition: apps.h:84
virtual void print_header()
Definition: apps.cc:1513
Definition: apps.h:225
virtual SharedMatrix TDso(SharedMatrix T1, bool singlet=true)
Definition: apps.cc:625
void set_print(int print)
Definition: apps.h:86
std::map< std::string, SharedMatrix > x_
Definition: apps.h:194
virtual ~RTDHF()
Definition: apps.cc:1139
virtual void postiterations()
Destroys JK object, if needed.
Definition: apps.cc:151
virtual void print_wavefunctions()
Definition: apps.cc:387
std::vector< SharedMatrix > singlets_Y_
Definition: apps.h:174
Definition: liboptions.h:355
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:95
virtual std::pair< SharedMatrix, SharedMatrix > ADao(SharedMatrix T1)
Definition: apps.cc:957
std::shared_ptr< JK > jk_
Global JK object, built in preiterations, destroyed in postiterations.
Definition: apps.h:67
std::shared_ptr< Vector > eps_aocc_
Definition: apps.h:59
void set_jk(std::shared_ptr< JK > jk)
Set the JK object, say from SCF.
Definition: apps.h:91
Definition: apps.h:168
void set_Cfocc(SharedMatrix Cfocc)
Definition: apps.h:110
std::map< std::string, SharedMatrix > b_
Definition: apps.h:196
virtual ~RTDA()
Definition: apps.cc:1359
std::shared_ptr< Vector > eps_avir_
Definition: apps.h:60
std::shared_ptr< Matrix > SharedMatrix
Definition: adc.h:49
void sort_states()
Definition: apps.cc:376
double Eref_
Definition: apps.h:71
Definition: apps.h:126
void set_Cocc(SharedMatrix Cocc)
Definition: apps.h:109
Simple wavefunction base class.
Definition: wavefunction.h:84
RBase(SharedWavefunction ref_wfn, Options &options, bool use_symmetry=true)
Definition: apps.cc:62
virtual bool same_a_b_dens() const
Definition: apps.h:81
void set_eps_aocc(SharedVector eps)
Definition: apps.h:115
RCPHF(SharedWavefunction ref_wfn, Options &options, bool use_symmetry=true)
Definition: apps.cc:156
std::map< std::string, SharedMatrix > & b()
Perturbation vector queue, shove tasks onto this guy before compute_energy.
Definition: apps.h:216
virtual std::pair< SharedMatrix, std::shared_ptr< Vector > > Nso(SharedMatrix T1, bool diff=false)
Definition: apps.cc:799
virtual void print_header()
Definition: apps.cc:163
std::vector< double > E_singlets_
Definition: apps.h:133
void add_named_tasks()
Definition: apps.cc:197
std::vector< double > E_singlets_
Definition: apps.h:176
SharedMatrix Cfvir_
Definition: apps.h:53
std::vector< SharedMatrix > singlets_X_
Definition: apps.h:172
RTDDFT(SharedWavefunction ref_wfn, Options &options)
Definition: apps.cc:1506
virtual void print_transitions()
Definition: apps.cc:493
RTDA(SharedWavefunction ref_wfn, Options &options)
Definition: apps.cc:1356
virtual std::pair< SharedMatrix, SharedMatrix > ADso(SharedMatrix T1)
Definition: apps.cc:914
virtual std::pair< SharedMatrix, std::shared_ptr< Vector > > Nao(SharedMatrix T1, bool diff=false)
Definition: apps.cc:822
virtual void print_densities()
Definition: apps.cc:546
SharedMatrix Cfocc_
Definition: apps.h:52
std::shared_ptr< Wavefunction > SharedWavefunction
Definition: typedefs.h:54
virtual void print_header()
Definition: apps.cc:354
std::vector< std::tuple< double, int, int, int > > states_
Definition: apps.h:130
RCPKS(SharedWavefunction ref_wfn, Options &options)
Definition: apps.cc:1257
virtual double compute_energy()
Compute energy. Subclasses override this function to compute its energy.
Definition: apps.cc:1529
void set_Cavir(SharedMatrix Cavir)
Definition: apps.h:112
virtual double compute_energy()
Solve for all perturbations currently in b.
Definition: apps.cc:271
virtual std::pair< SharedMatrix, std::shared_ptr< Vector > > Nmo(SharedMatrix T1, bool diff=false)
Definition: apps.cc:789
SharedMatrix AO2USO_
Definition: apps.h:62
void analyze_named_tasks()
Definition: apps.cc:203
void set_reference(std::shared_ptr< Wavefunction > reference)
Update reference info.
Definition: apps.cc:86
SharedMatrix C_
Definition: apps.h:49
int bench_
Definition: apps.h:47
std::shared_ptr< Vector > SharedVector
Definition: adc.h:51
void add_polarizability()
Definition: apps.cc:209
void set_Caocc(SharedMatrix Caocc)
Definition: apps.h:111
virtual ~RCPHF()
Definition: apps.cc:160
void set_convergence(double convergence)
Set convergence behavior.
Definition: apps.h:105