Psi4
soscf.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-2019 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 
46 #ifndef SOSCF_H
47 #define SOSCF_H
48 
50 #include "psi4/libmints/typedefs.h"
51 #include <map>
52 
53 namespace psi {
54 
56 class JK;
57 class IntegralTransform;
58 class PSIO;
59 class DFHelper;
60 
61 class SOMCSCF {
62  public:
69  SOMCSCF(std::shared_ptr<JK> jk, SharedMatrix AOTOSO, SharedMatrix H);
70 
71  virtual ~SOMCSCF();
72 
77  void set_memory(size_t memory) { memory_ = memory; }
78 
83  void set_ras(std::vector<Dimension> ras_spaces);
84 
90 
97  void set_AO_IFock(SharedMatrix IFock);
103  SharedMatrix form_rotation_matrix(SharedMatrix x, size_t order = 2);
104 
112 
118  double rhf_energy(SharedMatrix C);
119 
129  void update(SharedMatrix Cocc, SharedMatrix Cact, SharedMatrix Cvir, SharedMatrix OPDM, SharedMatrix TPDM);
130 
135  void set_occ_fock(SharedMatrix occ_Fock);
136 
142 
149 
155 
160  SharedMatrix solve(int max_iter = 5, double conv = 1.e-10, bool print = true);
161 
166 
172  virtual SharedMatrix compute_Q(SharedMatrix TPDM);
173 
182 
189 
193  double gradient_rms();
194 
199  void zero_redundant(SharedMatrix vector);
200 
201  double current_total_energy() { return (energy_drc_ + energy_ci_); }
202  double current_docc_energy() { return energy_drc_; }
203  double current_ci_energy() { return energy_ci_; }
204  SharedMatrix current_AFock() { return matrices_["AFock"]; }
205  SharedMatrix current_IFock() { return matrices_["IFock"]; }
207 
208  protected:
210  bool casscf_;
211  bool has_fzc_;
213  size_t memory_;
214 
216  double energy_drc_;
217  double energy_ci_;
218 
220  size_t nocc_;
221  size_t nact_;
222  size_t nvir_;
226 
227  size_t nirrep_;
228  size_t nmo_;
229  size_t nso_;
230  size_t nao_;
233 
234  // Non-redunant rotatations
237 
239  std::shared_ptr<JK> jk_;
240 
242  std::map<std::string, SharedMatrix> matrices_;
243 
245  std::vector<Dimension> ras_spaces_;
246  void check_ras();
247 
249  void zero_act(SharedMatrix vector);
250  void zero_ras(SharedMatrix vector);
251 
252  // Transform the integrals
253  virtual void transform(bool approx_only);
254 
255  // Grab actMO (dense)
256  virtual void set_act_MO();
257 
258 }; // SOMCSCF class
259 
265 class DFSOMCSCF : public SOMCSCF {
266  public:
273  DFSOMCSCF(std::shared_ptr<JK> jk, std::shared_ptr<DFHelper> df, SharedMatrix AOTOSO, SharedMatrix H);
274 
275  ~DFSOMCSCF() override;
276 
277  protected:
278  std::shared_ptr<DFHelper> dfh_;
279  void transform(bool approx_only) override;
280  void set_act_MO() override;
281  SharedMatrix compute_Q(SharedMatrix TPDM) override;
283 
284 }; // DFSOMCSCF class
285 
291 class DiskSOMCSCF : public SOMCSCF {
292  public:
298  DiskSOMCSCF(std::shared_ptr<JK> jk, std::shared_ptr<IntegralTransform> ints, SharedMatrix AOTOSO, SharedMatrix H);
299 
300  ~DiskSOMCSCF() override;
301 
302  protected:
303  std::shared_ptr<IntegralTransform> ints_;
304  std::shared_ptr<PSIO> psio_;
305  void transform(bool approx_only) override;
306  void set_act_MO() override;
307  SharedMatrix compute_Q(SharedMatrix TPDM) override;
309 
310 }; // DiskSOMCSCF class
311 
318 class IncoreSOMCSCF : public SOMCSCF {
319  public:
325  IncoreSOMCSCF(std::shared_ptr<JK> jk, SharedMatrix AOTOSO, SharedMatrix H);
326 
327  ~IncoreSOMCSCF() override;
328  void set_eri_tensors(SharedMatrix aaaa, SharedMatrix aaar) override;
329 
330  protected:
331  void set_act_MO() override;
332  SharedMatrix compute_Q(SharedMatrix TPDM) override;
334 
338 
339 };
340 
341 } // Namespace psi
342 
343 #endif
void zero_ras(SharedMatrix vector)
Definition: soscf.cc:792
size_t nao_
Definition: soscf.h:230
size_t memory_
Definition: soscf.h:213
virtual void set_eri_tensors(SharedMatrix, SharedMatrix)
Definition: soscf.h:206
int * U
Definition: stringlist.cc:66
Dimension noapi_
Definition: soscf.h:235
SharedMatrix gradient()
Definition: soscf.cc:770
DiskSOMCSCF(std::shared_ptr< JK > jk, std::shared_ptr< IntegralTransform > ints, SharedMatrix AOTOSO, SharedMatrix H)
DiskSOMCSCF class.
Definition: soscf.cc:1101
void zero_redundant(SharedMatrix vector)
Definition: soscf.cc:772
std::shared_ptr< JK > jk_
Integral objects.
Definition: soscf.h:239
double energy_ci_
Definition: soscf.h:217
Dimension nsopi_
Definition: soscf.h:232
std::shared_ptr< DFHelper > dfh_
Definition: soscf.h:278
virtual SharedMatrix compute_Q(SharedMatrix TPDM)
Definition: soscf.cc:66
void zero_act(SharedMatrix vector)
Zero&#39;s out redundant rotations, will chose act or ras.
Definition: soscf.cc:779
double df[MAX_DF]
Definition: wavefunction.cc:67
size_t nso_
Definition: soscf.h:229
void set_occ_fock(SharedMatrix occ_Fock)
SOMCSCF(std::shared_ptr< JK > jk, SharedMatrix AOTOSO, SharedMatrix H)
SOMCSCF class.
Definition: soscf.cc:52
virtual ~SOMCSCF()
Definition: soscf.cc:62
void set_memory(size_t memory)
Definition: soscf.h:77
SharedMatrix compute_AFock(SharedMatrix OPDM)
Definition: soscf.cc:504
Dimension nmopi_
Definition: soscf.h:231
SharedMatrix compute_Q(SharedMatrix TPDM) override
Definition: soscf.cc:899
~DiskSOMCSCF() override
Definition: soscf.cc:1107
double rhf_energy(SharedMatrix C)
Definition: soscf.cc:111
void set_act_MO() override
Definition: soscf.cc:1427
virtual void set_act_MO()
Definition: soscf.cc:72
void update(SharedMatrix Cocc, SharedMatrix Cact, SharedMatrix Cvir, SharedMatrix OPDM, SharedMatrix TPDM)
Definition: soscf.cc:164
void set_eri_tensors(SharedMatrix aaaa, SharedMatrix aaar) override
Definition: soscf.cc:1437
IncoreSOMCSCF(std::shared_ptr< JK > jk, SharedMatrix AOTOSO, SharedMatrix H)
IncoreSOMCSCF class.
Definition: soscf.cc:1380
Definition: soscf.h:61
Dimension noccpi_
Definition: soscf.h:223
size_t nmo_
Definition: soscf.h:228
double current_docc_energy()
Definition: soscf.h:202
void set_frozen_orbitals(SharedMatrix Cfzc)
Definition: soscf.cc:87
DFSOMCSCF(std::shared_ptr< JK > jk, std::shared_ptr< DFHelper > df, SharedMatrix AOTOSO, SharedMatrix H)
End SOMCSCF class.
Definition: soscf.cc:818
std::vector< Dimension > ras_spaces_
RAS arrays.
Definition: soscf.h:245
SharedMatrix form_rotation_matrix(SharedMatrix x, size_t order=2)
Definition: soscf.cc:134
void transform(bool approx_only) override
Definition: soscf.cc:823
size_t nvir_
Definition: soscf.h:222
Definition: soscf.h:265
double gradient_rms()
Definition: soscf.cc:771
std::map< std::string, SharedMatrix > matrices_
Map of matrices.
Definition: soscf.h:242
Dimension nactpi_
Definition: soscf.h:224
void set_ras(std::vector< Dimension > ras_spaces)
Definition: soscf.cc:73
SharedMatrix approx_solve()
Definition: soscf.cc:668
SharedMatrix Ck(SharedMatrix C, SharedMatrix x)
Definition: soscf.cc:157
size_t nact_
Definition: soscf.h:221
Definition: soscf.h:291
virtual SharedMatrix compute_Qk(SharedMatrix TPDM, SharedMatrix U, SharedMatrix Uact)
Definition: soscf.cc:69
Definition: dimension.h:40
bool compute_IFock_
Definition: soscf.h:212
~DFSOMCSCF() override
Definition: soscf.cc:822
SharedMatrix compute_Qk(SharedMatrix TPDM, SharedMatrix U, SharedMatrix Uact) override
Definition: soscf.cc:1434
bool casscf_
Parameters.
Definition: soscf.h:210
double energy_drc_
Doubles.
Definition: soscf.h:216
std::shared_ptr< IntegralTransform > ints_
Definition: soscf.h:303
SharedMatrix Hk(SharedMatrix x)
Definition: soscf.cc:529
std::shared_ptr< Matrix > SharedMatrix
Definition: adc.h:49
SharedMatrix compute_Qk(SharedMatrix TPDM, SharedMatrix U, SharedMatrix Uact) override
Definition: soscf.cc:1239
SharedMatrix compute_Qk(SharedMatrix TPDM, SharedMatrix U, SharedMatrix Uact) override
Definition: soscf.cc:964
size_t nirrep_
Definition: soscf.h:227
virtual void transform(bool approx_only)
Definition: soscf.cc:63
Definition: soscf.h:318
double current_total_energy()
Definition: soscf.h:201
void set_AO_IFock(SharedMatrix IFock)
Definition: soscf.cc:107
SharedMatrix mo_aaar_
Definition: soscf.h:337
void set_act_MO() override
Definition: soscf.cc:1111
SharedMatrix compute_Q(SharedMatrix TPDM) override
Definition: soscf.cc:1170
Dimension navpi_
Definition: soscf.h:236
SharedMatrix mo_aaaa_
Definition: soscf.h:336
bool has_fzc_
Definition: soscf.h:211
SharedMatrix solve(int max_iter=5, double conv=1.e-10, bool print=true)
Definition: soscf.cc:676
bool eri_tensor_set_
Definition: soscf.h:335
~IncoreSOMCSCF() override
Definition: soscf.cc:1383
SharedMatrix H_approx_diag()
Definition: soscf.cc:338
size_t nocc_
Orbital info.
Definition: soscf.h:220
void set_act_MO() override
Definition: soscf.cc:890
void transform(bool approx_only) override
Definition: soscf.cc:1108
SharedMatrix compute_Q(SharedMatrix TPDM) override
Definition: soscf.cc:1384
SharedMatrix current_IFock()
Definition: soscf.h:205
SharedMatrix current_AFock()
Definition: soscf.h:204
double current_ci_energy()
Definition: soscf.h:203
void check_ras()
Definition: soscf.cc:77
std::shared_ptr< PSIO > psio_
Definition: soscf.h:304
Dimension nvirpi_
Definition: soscf.h:225