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-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 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  protected:
44  int print_;
45  int bench_;
46 
48 
54 
55  std::shared_ptr<Vector> eps_focc_;
56  std::shared_ptr<Vector> eps_fvir_;
57  std::shared_ptr<Vector> eps_aocc_;
58  std::shared_ptr<Vector> eps_avir_;
59 
61 
63  double convergence_;
65  std::shared_ptr<JK> jk_;
66  std::shared_ptr<VBase> v_;
67 
69  double Eref_;
70 
71  public:
72  RBase(SharedWavefunction ref_wfn, Options& options, bool use_symmetry = true);
73  // TODO: Remove AS SOON AS POSSIBLE, such a dirty hack
74  RBase(bool flag);
75  ~RBase() override;
76 
77  virtual bool same_a_b_orbs() const { return true; }
78  virtual bool same_a_b_dens() const { return true; }
79 
80  // TODO: Remove AS SOON AS POSSIBLE, such a dirty hack
81  double compute_energy() override { return 0.0; }
82 
83  void set_print(int print) { print_ = print; }
84 
86  std::shared_ptr<JK> jk() const { return jk_; }
88  void set_jk(std::shared_ptr<JK> jk) { jk_ = jk; }
90  std::shared_ptr<VBase> v() const { return v_; }
92  void set_jk(std::shared_ptr<VBase> v) { v_ = v; }
94  virtual void preiterations();
96  virtual void postiterations();
97 
99 
100  void set_use_symmetry(bool usesym) { use_symmetry_ = usesym; }
102  void set_convergence(double convergence) { convergence_ = convergence; }
103 
105  void set_C(SharedMatrix C) { C_ = C; }
106  void set_Cocc(SharedMatrix Cocc) { Cocc_ = Cocc; }
107  void set_Cfocc(SharedMatrix Cfocc) { Cfocc_ = Cfocc; }
108  void set_Caocc(SharedMatrix Caocc) { Caocc_ = Caocc; }
109  void set_Cavir(SharedMatrix Cavir) { Cavir_ = Cavir; }
110  void set_Cfvir(SharedMatrix Cfvir) { Cfvir_ = Cfvir; }
111  void set_eps_focc(SharedVector eps) { eps_focc_ = eps; }
112  void set_eps_aocc(SharedVector eps) { eps_aocc_ = eps; }
113  void set_eps_avir(SharedVector eps) { eps_avir_ = eps; }
114  void set_eps_fvir(SharedVector eps) { eps_fvir_ = eps; }
115  void set_Eref(double Eref) { Eref_ = Eref; }
116 
118  void set_reference(std::shared_ptr<Wavefunction> reference);
119 };
120 
121 // => APPLIED CLASSES <= //
122 
123 class RCIS : public RBase {
124  protected:
125  std::vector<std::tuple<double, int, int, int> > states_;
126  std::vector<SharedMatrix> singlets_;
127  std::vector<SharedMatrix> triplets_;
128  std::vector<double> E_singlets_;
129  std::vector<double> E_triplets_;
130 
131  void sort_states();
132 
133  virtual void print_header();
134  virtual void print_wavefunctions();
135  virtual void print_amplitudes();
136  virtual void print_transitions();
137  virtual void print_densities();
138 
139  virtual SharedMatrix TDmo(SharedMatrix T1, bool singlet = true);
140  virtual SharedMatrix TDso(SharedMatrix T1, bool singlet = true);
141  virtual SharedMatrix TDao(SharedMatrix T1, bool singlet = true);
142 
143  virtual SharedMatrix Dmo(SharedMatrix T1, bool diff = false);
144  virtual SharedMatrix Dso(SharedMatrix T1, bool diff = false);
145  virtual SharedMatrix Dao(SharedMatrix T1, bool diff = false);
146 
147  virtual std::pair<SharedMatrix, std::shared_ptr<Vector> > Nmo(SharedMatrix T1, bool diff = false);
148  virtual std::pair<SharedMatrix, std::shared_ptr<Vector> > Nso(SharedMatrix T1, bool diff = false);
149  virtual std::pair<SharedMatrix, std::shared_ptr<Vector> > Nao(SharedMatrix T1, bool diff = false);
150 
151  virtual std::pair<SharedMatrix, SharedMatrix> ADmo(SharedMatrix T1);
152  virtual std::pair<SharedMatrix, SharedMatrix> ADso(SharedMatrix T1);
153  virtual std::pair<SharedMatrix, SharedMatrix> ADao(SharedMatrix T1);
154 
155  public:
157  ~RCIS() override;
158 
159  double compute_energy() override;
160 };
161 
162 class RTDHF : public RBase {
163  protected:
164  std::vector<SharedMatrix> singlets_X_;
165  std::vector<SharedMatrix> triplets_X_;
166  std::vector<SharedMatrix> singlets_Y_;
167  std::vector<SharedMatrix> triplets_Y_;
168  std::vector<double> E_singlets_;
169  std::vector<double> E_triplets_;
170 
171  virtual void print_header();
172 
173  public:
175  ~RTDHF() override;
176 
177  double compute_energy() override;
178 };
179 
180 class RCPHF : public RBase {
181  protected:
182  // OV-Rotations
183  std::map<std::string, SharedMatrix> x_;
184  // OV-Perturbations
185  std::map<std::string, SharedMatrix> b_;
186 
187  virtual void print_header();
188 
189  void add_named_tasks();
190  void analyze_named_tasks();
191 
192  void add_polarizability();
193  void analyze_polarizability();
194 
195  std::set<std::string> tasks_;
196 
197  public:
198  RCPHF(SharedWavefunction ref_wfn, Options& options, bool use_symmetry = true);
199  ~RCPHF() override;
200 
202  double compute_energy() override;
203 
205  std::map<std::string, SharedMatrix>& b() { return b_; }
207  std::map<std::string, SharedMatrix>& x() { return x_; }
208 
210  void add_task(const std::string& task);
211 };
212 
213 class RCPKS : public RCPHF {
214  protected:
215  void print_header() override;
216 
217  public:
219  ~RCPKS() override;
220 
221  double compute_energy() override;
222 };
223 
224 class RTDA : public RCIS {
225  protected:
226  void print_header() override;
227 
228  public:
230  ~RTDA() override;
231 
232  double compute_energy() override;
233 };
234 
235 class RTDDFT : public RTDHF {
236  protected:
237  void print_header() override;
238 
239  public:
241  ~RTDDFT() override;
242 
243  double compute_energy() override;
244 };
245 }
246 #endif
RTDHF(SharedWavefunction ref_wfn, Options &options)
Definition: apps.cc:1058
double convergence_
How far to converge the two-norm of the residual.
Definition: apps.h:63
virtual SharedMatrix Dao(SharedMatrix T1, bool diff=false)
Definition: apps.cc:703
std::map< std::string, SharedMatrix > & x()
Resultant solution vectors, available after compute_energy is called.
Definition: apps.h:207
double compute_energy() override
Compute energy. Subclasses override this function to compute its energy.
Definition: apps.cc:1082
std::vector< double > E_triplets_
Definition: apps.h:129
void print_header() override
Definition: apps.cc:1174
virtual bool same_a_b_orbs() const
Definition: apps.h:77
virtual std::pair< SharedMatrix, SharedMatrix > ADmo(SharedMatrix T1)
Definition: apps.cc:804
Options & options() const
Definition: wavefunction.cc:645
std::vector< double > E_triplets_
Definition: apps.h:169
virtual SharedMatrix TDao(SharedMatrix T1, bool singlet=true)
Definition: apps.cc:604
void print_header() override
Definition: apps.cc:1404
SharedMatrix Cocc_
Definition: apps.h:49
void set_eps_avir(SharedVector eps)
Definition: apps.h:113
bool use_symmetry_
Definition: apps.h:68
void set_eps_focc(SharedVector eps)
Definition: apps.h:111
double compute_energy() override
Solve for all perturbations currently in b.
Definition: apps.cc:1190
Definition: apps.h:42
SharedMatrix Cavir_
Definition: apps.h:53
void reference()
Definition: reference.cc:51
void set_Cfvir(SharedMatrix Cfvir)
Definition: apps.h:110
void set_eps_fvir(SharedVector eps)
Definition: apps.h:114
void set_C(SharedMatrix C)
Set reference info.
Definition: apps.h:105
std::shared_ptr< Vector > eps_fvir_
Definition: apps.h:56
virtual SharedMatrix Dmo(SharedMatrix T1, bool diff=false)
Definition: apps.cc:632
virtual void print_header()
Definition: apps.cc:1060
virtual SharedMatrix Dso(SharedMatrix T1, bool diff=false)
Definition: apps.cc:679
void analyze_polarizability()
Definition: apps.cc:223
std::shared_ptr< VBase > v_
Definition: apps.h:66
void add_task(const std::string &task)
Add a named task.
Definition: apps.cc:174
Definition: apps.h:235
virtual void preiterations()
Builds JK object, if needed.
Definition: apps.cc:118
std::shared_ptr< VBase > v() const
Gets a handle to the VBase object, if built by preiterations.
Definition: apps.h:90
std::vector< SharedMatrix > triplets_Y_
Definition: apps.h:167
Definition: apps.h:180
Definition: apps.h:224
~RCPHF() override
Definition: apps.cc:143
~RCPKS() override
Definition: apps.cc:1173
void set_Eref(double Eref)
Definition: apps.h:115
SharedMatrix Caocc_
Definition: apps.h:52
std::set< std::string > tasks_
Definition: apps.h:195
virtual void print_amplitudes()
Definition: apps.cc:387
std::shared_ptr< Vector > eps_focc_
Definition: apps.h:55
virtual SharedMatrix TDmo(SharedMatrix T1, bool singlet=true)
Definition: apps.cc:566
std::shared_ptr< JK > jk() const
Gets a handle to the JK object, if built by preiterations.
Definition: apps.h:86
std::vector< SharedMatrix > triplets_X_
Definition: apps.h:165
int print_
Definition: apps.h:44
~RTDHF() override
Definition: apps.cc:1059
RCIS(SharedWavefunction ref_wfn, Options &options)
Definition: apps.cc:315
void set_use_symmetry(bool usesym)
=&gt; Setters &lt;= ///
Definition: apps.h:100
Definition: apps.h:213
virtual SharedMatrix TDso(SharedMatrix T1, bool singlet=true)
Definition: apps.cc:574
void set_print(int print)
Definition: apps.h:83
std::map< std::string, SharedMatrix > x_
Definition: apps.h:183
double compute_energy() override
Compute energy. Subclasses override this function to compute its energy.
Definition: apps.h:81
void print_header() override
Definition: apps.cc:1262
virtual void postiterations()
Destroys JK object, if needed.
Definition: apps.cc:140
virtual void print_wavefunctions()
Definition: apps.cc:349
Definition: liboptions.h:352
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:92
virtual std::pair< SharedMatrix, SharedMatrix > ADao(SharedMatrix T1)
Definition: apps.cc:886
std::shared_ptr< JK > jk_
Global JK object, built in preiterations, destroyed in postiterations.
Definition: apps.h:65
double compute_energy() override
Compute energy. Subclasses override this function to compute its energy.
Definition: apps.cc:1278
std::vector< SharedMatrix > singlets_
Definition: apps.h:126
std::shared_ptr< Vector > eps_aocc_
Definition: apps.h:57
void set_jk(std::shared_ptr< JK > jk)
Set the JK object, say from SCF.
Definition: apps.h:88
Definition: apps.h:162
void set_Cfocc(SharedMatrix Cfocc)
Definition: apps.h:107
std::map< std::string, SharedMatrix > b_
Definition: apps.h:185
std::shared_ptr< Vector > eps_avir_
Definition: apps.h:58
std::shared_ptr< Matrix > SharedMatrix
Definition: adc.h:49
void sort_states()
Definition: apps.cc:339
double Eref_
Definition: apps.h:69
Definition: apps.h:123
void set_Cocc(SharedMatrix Cocc)
Definition: apps.h:106
Simple wavefunction base class.
Definition: wavefunction.h:85
RBase(SharedWavefunction ref_wfn, Options &options, bool use_symmetry=true)
Definition: apps.cc:63
virtual bool same_a_b_dens() const
Definition: apps.h:78
void set_eps_aocc(SharedVector eps)
Definition: apps.h:112
RCPHF(SharedWavefunction ref_wfn, Options &options, bool use_symmetry=true)
Definition: apps.cc:142
std::map< std::string, SharedMatrix > & b()
Perturbation vector queue, shove tasks onto this guy before compute_energy.
Definition: apps.h:205
virtual std::pair< SharedMatrix, std::shared_ptr< Vector > > Nso(SharedMatrix T1, bool diff=false)
Definition: apps.cc:736
virtual void print_header()
Definition: apps.cc:144
std::vector< double > E_singlets_
Definition: apps.h:128
~RTDA() override
Definition: apps.cc:1261
void add_named_tasks()
Definition: apps.cc:175
std::vector< double > E_singlets_
Definition: apps.h:168
SharedMatrix Cfvir_
Definition: apps.h:51
double compute_energy() override
Compute energy. Subclasses override this function to compute its energy.
Definition: apps.cc:928
~RCIS() override
Definition: apps.cc:316
~RTDDFT() override
Definition: apps.cc:1403
RTDDFT(SharedWavefunction ref_wfn, Options &options)
Definition: apps.cc:1402
double compute_energy() override
Solve for all perturbations currently in b.
Definition: apps.cc:245
virtual void print_transitions()
Definition: apps.cc:447
std::vector< SharedMatrix > singlets_X_
Definition: apps.h:164
RTDA(SharedWavefunction ref_wfn, Options &options)
Definition: apps.cc:1260
virtual std::pair< SharedMatrix, SharedMatrix > ADso(SharedMatrix T1)
Definition: apps.cc:845
virtual std::pair< SharedMatrix, std::shared_ptr< Vector > > Nao(SharedMatrix T1, bool diff=false)
Definition: apps.cc:757
virtual void print_densities()
Definition: apps.cc:495
SharedMatrix Cfocc_
Definition: apps.h:50
std::shared_ptr< Wavefunction > SharedWavefunction
Definition: typedefs.h:54
virtual void print_header()
Definition: apps.cc:317
std::vector< std::tuple< double, int, int, int > > states_
Definition: apps.h:125
~RBase() override
Definition: apps.cc:79
RCPKS(SharedWavefunction ref_wfn, Options &options)
Definition: apps.cc:1172
void set_Cavir(SharedMatrix Cavir)
Definition: apps.h:109
virtual std::pair< SharedMatrix, std::shared_ptr< Vector > > Nmo(SharedMatrix T1, bool diff=false)
Definition: apps.cc:727
SharedMatrix AO2USO_
Definition: apps.h:60
void analyze_named_tasks()
Definition: apps.cc:180
std::vector< SharedMatrix > singlets_Y_
Definition: apps.h:166
void set_reference(std::shared_ptr< Wavefunction > reference)
Update reference info.
Definition: apps.cc:80
SharedMatrix C_
Definition: apps.h:47
int bench_
Definition: apps.h:45
std::shared_ptr< Vector > SharedVector
Definition: adc.h:51
void add_polarizability()
Definition: apps.cc:185
double compute_energy() override
Compute energy. Subclasses override this function to compute its energy.
Definition: apps.cc:1420
void set_Caocc(SharedMatrix Caocc)
Definition: apps.h:108
std::vector< SharedMatrix > triplets_
Definition: apps.h:127
void set_convergence(double convergence)
Set convergence behavior.
Definition: apps.h:102