Psi4
uhf.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 __math_test_uhf_h__
30 #define __math_test_uhf_h__
31 
32 #include "hf.h"
33 #include "psi4/libpsio/psio.hpp"
34 
35 namespace psi {
36 namespace scf {
37 
38 class UHF : public HF {
39  protected:
43 
44  double compute_initial_E() override;
45  bool stability_analysis_pk();
46 
47  void common_init();
48 
49  // Scaling factor for orbital rotation
50  double step_scale_;
51  // Increment to explore different scaling factors
53  // Stability eigenvalue, for doing smart eigenvector following
54  double stab_val;
55 
56  // Compute UHF NOs
57  void compute_nos();
58 
59  // Second-order convergence code
60  void Hx(SharedMatrix x_a, SharedMatrix IFock_a, SharedMatrix Cocc_a, SharedMatrix Cvir_a, SharedMatrix ret_a,
61  SharedMatrix x_b, SharedMatrix IFock_b, SharedMatrix Cocc_b, SharedMatrix Cvir_b, SharedMatrix ret_b);
62 
63  public:
64  UHF(SharedWavefunction ref_wfn, std::shared_ptr<SuperFunctional> functional);
65  UHF(SharedWavefunction ref_wfn, std::shared_ptr<SuperFunctional> functional, Options& options,
66  std::shared_ptr<PSIO> psio);
67  ~UHF() override;
68 
69  virtual bool same_a_b_orbs() const { return false; }
70  virtual bool same_a_b_dens() const { return false; }
71 
72  bool diis() override;
73  void save_density_and_energy() override;
74  double compute_orbital_gradient(bool save_diis, int max_diis_vectors) override;
75 
76  void form_C() override;
77  void form_D() override;
78  void form_F() override;
79  void form_G() override;
80  void form_V() override;
81  double compute_E() override;
82  void finalize() override;
83 
84  void damping_update(double) override;
85  int soscf_update(double soscf_conv, int soscf_min_iter, int soscf_max_iter, int soscf_print) override;
86  bool stability_analysis() override;
87 
89  std::vector<SharedMatrix> onel_Hx(std::vector<SharedMatrix> x) override;
90  std::vector<SharedMatrix> twoel_Hx(std::vector<SharedMatrix> x, bool combine = true,
91  std::string return_basis = "MO") override;
92  std::vector<SharedMatrix> cphf_Hx(std::vector<SharedMatrix> x) override;
93  std::vector<SharedMatrix> cphf_solve(std::vector<SharedMatrix> x_vec, double conv_tol = 1.e-4, int max_iter = 10,
94  int print_lvl = 1) override;
95 
96  std::shared_ptr<UHF> c1_deep_copy(std::shared_ptr<BasisSet> basis);
97 };
98 } // namespace scf
99 } // namespace psi
100 
101 #endif
void compute_nos()
Definition: uhf.cc:889
Options & options() const
Definition: wavefunction.cc:645
~UHF() override
Definition: uhf.cc:80
std::shared_ptr< UHF > c1_deep_copy(std::shared_ptr< BasisSet > basis)
Definition: uhf.cc:1013
double compute_initial_E() override
Definition: uhf.cc:307
std::shared_ptr< PSIO > psio() const
Definition: wavefunction.cc:643
void common_init()
Definition: uhf.cc:82
std::shared_ptr< BasisSet > basis
Definition: dx_write.cc:59
SharedMatrix J_
Definition: uhf.h:42
bool stability_analysis() override
Check the stability of the wavefunction, and correct (if requested)
Definition: uhf.cc:843
virtual bool same_a_b_dens() const
Definition: uhf.h:70
double compute_orbital_gradient(bool save_diis, int max_diis_vectors) override
Definition: uhf.cc:821
SharedMatrix Ga_
Definition: uhf.h:42
double step_scale_
Definition: uhf.h:50
double ** scf
Definition: dx_write.cc:57
std::vector< SharedMatrix > cphf_Hx(std::vector< SharedMatrix > x) override
Definition: uhf.cc:535
SharedMatrix wKa_
Definition: uhf.h:42
std::shared_ptr< SuperFunctional > functional() const
The DFT Functional object (or null if it has been deleted)
Definition: hf.h:296
SharedMatrix wKb_
Definition: uhf.h:42
SharedMatrix Gb_
Definition: uhf.h:42
void form_G() override
Definition: uhf.cc:172
double stab_val
Definition: uhf.h:54
void form_F() override
Definition: uhf.cc:228
SharedMatrix Da_old_
Definition: uhf.h:41
double step_increment_
Definition: uhf.h:52
SharedMatrix Kb_
Definition: uhf.h:42
void Hx(SharedMatrix x_a, SharedMatrix IFock_a, SharedMatrix Cocc_a, SharedMatrix Cvir_a, SharedMatrix ret_a, SharedMatrix x_b, SharedMatrix IFock_b, SharedMatrix Cocc_b, SharedMatrix Cvir_b, SharedMatrix ret_b)
bool stability_analysis_pk()
int soscf_update(double soscf_conv, int soscf_min_iter, int soscf_max_iter, int soscf_print) override
Definition: uhf.cc:789
SharedMatrix Dt_
Definition: uhf.h:40
void save_density_and_energy() override
Save the current density and energy.
Definition: uhf.cc:149
UHF(SharedWavefunction ref_wfn, std::shared_ptr< SuperFunctional > functional)
Definition: uhf.cc:69
bool diis() override
Definition: uhf.cc:841
void form_C() override
Compute the MO coefficients (C_)
Definition: uhf.cc:247
SharedMatrix Dt_old_
Definition: uhf.h:40
Definition: liboptions.h:352
void form_D() override
Computes the density matrix (D_)
Definition: uhf.cc:267
std::vector< SharedMatrix > onel_Hx(std::vector< SharedMatrix > x) override
Hessian-vector computers and solvers.
Definition: uhf.cc:360
SharedMatrix Db_old_
Definition: uhf.h:41
SharedMatrix Ka_
Definition: uhf.h:42
std::shared_ptr< Matrix > SharedMatrix
Definition: adc.h:49
void damping_update(double) override
Definition: uhf.cc:297
Definition: hf.h:48
void finalize() override
Definition: uhf.cc:119
virtual bool same_a_b_orbs() const
Definition: uhf.h:69
std::vector< SharedMatrix > cphf_solve(std::vector< SharedMatrix > x_vec, double conv_tol=1.e-4, int max_iter=10, int print_lvl=1) override
Definition: uhf.cc:546
std::shared_ptr< Wavefunction > SharedWavefunction
Definition: typedefs.h:54
void form_V() override
Computes the density matrix (V_)
Definition: uhf.cc:154
Definition: uhf.h:38
std::vector< SharedMatrix > twoel_Hx(std::vector< SharedMatrix > x, bool combine=true, std::string return_basis="MO") override
Definition: uhf.cc:403
double compute_E() override
Compute energy for the iteration.
Definition: uhf.cc:313