Psi4
hf.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 HF_H
30 #define HF_H
31 
32 #include <vector>
33 #include "psi4/libpsio/psio.hpp"
35 #include "psi4/libmints/basisset.h"
36 #include "psi4/libmints/vector.h"
38 #include "psi4/libdiis/diisentry.h"
39 #include "psi4/psi4-dec.h"
40 #include "psi4/libqt/qt.h"
41 
42 namespace psi {
43 class Vector;
44 class JK;
45 class PCM;
46 class SuperFunctional;
47 class VBase;
48 namespace scf {
49 
50 class HF : public Wavefunction {
51 protected:
52 
68 
73 
77 
80 
83 
85  double Eold_;
86  double E_;
87 
89  std::map<std::string, double> energies_;
90 
92  std::vector<std::shared_ptr<BasisSet>> sad_basissets_;
93  std::vector<std::shared_ptr<BasisSet>> sad_fitting_basissets_;
94 
96  double Drms_;
97 
99  int maxiter_;
100 
102  bool ref_C_;
103 
106 
109 
111 
113 
115  double nuclearrep_;
116 
119 
122 
125 
128 
129  //Initial SAD doubly occupied may be more than ndocc
130  // int sad_nocc_[8];
136 
139  int *so2index_;
140 
142  std::string scf_type_;
143 
146  std::string old_scf_type_;
147 
155 
158 
160  std::shared_ptr<JK> jk_;
161 
170 
175 
179  std::shared_ptr<DIISManager> diis_manager_;
180 
189 
199  double soscf_conv_;
201  double soscf_print_;
202 
211 
212  // parameters for hard-sphere potentials
213  double radius_; // radius of spherical potential
214  double thickness_; // thickness of spherical barrier
215  int r_points_; // number of radial integration points
216  int theta_points_; // number of colatitude integration points
217  int phi_points_; // number of azimuthal integration points
218 
220  std::shared_ptr<SuperFunctional> functional_;
221  std::shared_ptr<VBase> potential_;
222 
223 
224  // CPHF info
227 
228 public:
232 
235 
237  std::shared_ptr<JK> jk() const { return jk_; }
238 
240  std::shared_ptr<SuperFunctional> functional() const { return functional_; }
241 
243  std::shared_ptr<VBase> V_potential() const { return potential_; }
244 
246  double rms_density_error() {return Drms_;}
247 
249  std::shared_ptr<Vector> occupation_a() const;
250  std::shared_ptr<Vector> occupation_b() const;
251 
252  // PCM interface
254  std::shared_ptr<PCM> hf_pcm_;
255 
256 protected:
257 
259  // Temporarily converting to virtual function for testing embedding
260  // potentials. TDC, 5/23/12.
261  virtual void form_H();
262 
264  void form_Shalf();
265 
267  virtual void prepare_canonical_orthogonalization() { return; }
268 
270  void print_occupation();
271 
273  void common_init();
274 
276  void find_occupation();
277 
279  void MOM();
281  void MOM_start();
282 
284  void frac();
286  void frac_renormalize();
287 
289  virtual bool stability_analysis();
290  void print_stability_analysis(std::vector<std::pair<double, int> > &vec);
291 
292 
294  void compute_fcpi();
295  void compute_fvpi();
296 
298  void print_orbitals(const char* header, std::vector<std::pair<double,
299  std::pair<const char*, int> > > orbs);
300 
302  void print_orbitals();
303 
305  void print_energies();
306 
308  void print_header();
309 
311  void print_preiterations();
312 
314  virtual void integrals();
315 
321 
324 
326  int charge_;
327 
330 
333 
335  virtual double compute_E() = 0;
336 
338  virtual void save_density_and_energy() = 0;
339 
341  void check_phases();
342 
344  void compute_SAD_guess();
345 
347  void reset_occupation();
348 
350  virtual void guess();
351 
353  virtual void damp_update();
354 
356  virtual int soscf_update();
357 
359  virtual void diagonalize_F(const SharedMatrix& F, SharedMatrix& C, std::shared_ptr<Vector>& eps);
360 
362  virtual void form_initial_C() { form_C(); }
363 
365  virtual double compute_initial_E() { return 0.0; }
366 
368  virtual bool test_convergency() { return false; }
369 
371  virtual void compute_spin_contamination();
372 
374  virtual void save_information() {}
375 
377  virtual void compute_orbital_gradient(bool) {}
378 
380  virtual bool diis() { return false; }
381 
383  virtual SharedMatrix form_Fia(SharedMatrix Fso, SharedMatrix Cso, int* noccpi);
384 
387 
389  virtual void format_guess();
390 
392  // virtual void save_orbitals();
393 
395  // bool do_use_fock_guess();
396 
398  // virtual void load_fock();
399 
401  // virtual void load_orbitals();
402 
403 public:
404  HF(SharedWavefunction ref_wfn, std::shared_ptr<SuperFunctional> funct,
405  Options& options, std::shared_ptr<PSIO> psio);
406 
407  virtual ~HF();
408 
410  virtual void initialize();
411 
413  virtual void iterations();
414 
419  virtual double finalize_E();
420 
424  virtual double compute_energy();
425 
428  virtual void finalize();
429 
435  virtual void semicanonicalize();
436 
438  virtual void form_C();
439 
441  virtual void form_D();
442 
444  virtual void form_V();
445 
447  void rotate_orbitals(SharedMatrix C, const SharedMatrix x);
448 
450  virtual void form_F() =0;
451 
453  virtual void form_G() =0;
454 
456  virtual std::vector<SharedMatrix> onel_Hx(std::vector<SharedMatrix> x);
457  virtual std::vector<SharedMatrix> twoel_Hx(std::vector<SharedMatrix> x, bool combine = true,
458  std::string return_basis = "MO");
459  virtual std::vector<SharedMatrix> cphf_Hx(std::vector<SharedMatrix> x);
460  virtual std::vector<SharedMatrix> cphf_solve(std::vector<SharedMatrix> x_vec,
461  double conv_tol = 1.e-4, int max_iter = 10,
462  int print_lvl = 1);
463  bool cphf_converged() { return cphf_converged_; }
465 
466  // Return the DFT potenitals
467  SharedMatrix Va() { return Va_; }
468  SharedMatrix Vb() { return Vb_; }
469 
470  // Set guess occupied orbitals, nalpha and nbeta will be taken from the number of passed in eigenvectors
473 
474  // Expert option to reset the occuption or not at iteration zero
475  void reset_occ(bool reset) { reset_occ_ = reset; }
476 
477  // SAD information
478  void set_sad_basissets(std::vector<std::shared_ptr<BasisSet>> basis_vec) { sad_basissets_ = basis_vec; }
479  void set_sad_fitting_basissets(std::vector<std::shared_ptr<BasisSet>> basis_vec) { sad_fitting_basissets_ = basis_vec; }
480 };
481 
482 }} // Namespaces
483 
484 #endif
virtual void form_initial_C()
Definition: hf.h:362
int multiplicity_
The multiplicity of the system (specified as 2 Ms + 1)
Definition: hf.h:329
Definition: hf.h:153
std::shared_ptr< Vector > occupation_a() const
Returns the occupation vectors.
Definition: hf.cc:1951
virtual void save_density_and_energy()=0
Save the current density and energy.
int * so2index_
Definition: hf.h:139
Options & options() const
Definition: wavefunction.cc:413
SharedMatrix T_
The kinetic energy matrix.
Definition: hf.h:54
bool MOM_performed_
MOM performed?
Definition: hf.h:169
std::shared_ptr< Vector > occupation_b() const
Definition: hf.cc:1962
SharedMatrix Ca_old_
Old C Alpha matrix (if needed for MOM)
Definition: hf.h:70
std::shared_ptr< PSIO > psio() const
Definition: wavefunction.cc:408
SharedMatrix Cb() const
Returns the beta electrons MO coefficients.
Definition: wavefunction.cc:500
bool reset_occ_
Definition: hf.h:135
int original_nbeta_
Definition: hf.h:134
std::shared_ptr< VBase > potential_
Definition: hf.h:221
virtual void iterations()
Performs the actual SCF iterations.
Definition: hf.cc:1630
bool damping_enabled_
Whether to use SCF damping.
Definition: hf.h:208
bool pcm_enabled_
Definition: hf.h:253
void MOM()
Maximum overlap method for prevention of oscillation/excited state SCF.
Definition: mom.cc:585
bool fail_on_maxiter_
Fail if we don&#39;t converge by maxiter?
Definition: hf.h:105
int max_diis_vectors_
How many max vectors for DIIS.
Definition: hf.h:184
bool input_docc_
DOCC vector from input (if found)
Definition: hf.h:121
std::map< std::string, double > energies_
Table of energy components.
Definition: hf.h:89
Vector nuclear_quadrupole_contribution_
Definition: hf.h:231
double ** scf
Definition: dx_write.cc:57
virtual void form_V()
Computes the density matrix (V_)
Definition: hf.cc:411
SharedMatrix Vb_
Definition: hf.h:59
std::vector< std::shared_ptr< BasisSet > > sad_fitting_basissets_
Definition: hf.h:93
virtual void compute_orbital_gradient(bool)
Definition: hf.h:377
double integral_threshold_
The value below which integrals are neglected.
Definition: hf.h:157
virtual double compute_initial_E()
Definition: hf.h:365
int min_diis_vectors_
How many min vectors for DIIS.
Definition: hf.h:182
void frac()
Fractional occupation UHF/UKS.
Definition: frac.cc:65
void guess_Ca(SharedMatrix Ca)
Definition: hf.h:471
double damping_percentage_
The amount (%) of the previous orbitals to mix in during SCF damping.
Definition: hf.h:204
virtual std::vector< SharedMatrix > cphf_solve(std::vector< SharedMatrix > x_vec, double conv_tol=1.e-4, int max_iter=10, int print_lvl=1)
Definition: hf.cc:431
std::shared_ptr< DIISManager > diis_manager_
DIIS manager for all SCF wavefunctions.
Definition: hf.h:179
SharedMatrix Va()
Definition: hf.h:467
double thickness_
Definition: hf.h:214
std::shared_ptr< SuperFunctional > functional() const
The DFT Functional object (or null if it has been deleted)
Definition: hf.h:240
double Drms_
The RMS error in the density.
Definition: hf.h:96
Definition: vector3.h:37
SharedMatrix Cb_old_
Old C Beta matrix (if needed for MOM)
Definition: hf.h:72
virtual std::vector< SharedMatrix > onel_Hx(std::vector< SharedMatrix > x)
Hessian-vector computers and solvers.
Definition: hf.cc:421
void check_phases()
Check MO phases.
Definition: hf.cc:1527
Definition: hf.h:153
void print_header()
Prints some opening information.
Definition: hf.cc:781
virtual std::vector< SharedMatrix > twoel_Hx(std::vector< SharedMatrix > x, bool combine=true, std::string return_basis="MO")
Definition: hf.cc:424
void print_occupation()
Prints the orbital occupation.
Definition: hf.cc:1920
virtual void format_guess()
Definition: hf.cc:1521
std::string old_scf_type_
Definition: hf.h:146
Definition: hf.h:153
int soscf_max_iter_
Minimum number of iterations.
Definition: hf.h:197
SharedMatrix diag_temp_
Temporary matrix for diagonalize_F.
Definition: hf.h:63
Definition: hf.h:153
Vector3 perturb_dipoles_
How big of a perturbation.
Definition: hf.h:151
int attempt_number_
Definition: hf.h:318
SharedMatrix guess_Ca_
User defined orbitals.
Definition: hf.h:75
void guess_Cb(SharedMatrix Cb)
Definition: hf.h:472
int diis_enabled_
Are we even using DIIS?
Definition: hf.h:188
virtual void form_D()
Computes the density matrix (D_)
Definition: hf.cc:418
void print_preiterations()
Prints some details about nsopi/nmopi, and initial occupations.
Definition: hf.cc:836
SharedMatrix Ca() const
Returns the alpha electrons MO coefficients.
Definition: wavefunction.cc:488
std::shared_ptr< JK > jk_
The soon to be ubiquitous JK object.
Definition: hf.h:160
virtual void initialize()
Specialized initialization, compute integrals and does everything to prepare for iterations.
Definition: hf.cc:1559
virtual double compute_E()=0
Compute energy for the iteration.
virtual void compute_spin_contamination()
Definition: frac.cc:228
bool MOM_enabled_
Are we to do MOM?
Definition: hf.h:163
virtual void finalize()
Definition: hf.cc:681
bool damping_performed_
Whether damping was actually performed this iteration.
Definition: hf.h:210
bool converged_
Did the SCF converge?
Definition: hf.h:112
double Eold_
Previous iteration&#39;s energy and current energy.
Definition: hf.h:85
void set_sad_fitting_basissets(std::vector< std::shared_ptr< BasisSet >> basis_vec)
Definition: hf.h:479
virtual ~HF()
Definition: hf.cc:90
perturb
With what...
Definition: hf.h:153
SharedMatrix diag_F_temp_
Temporary matrix for diagonalize_F.
Definition: hf.h:65
void print_orbitals()
Prints the orbitals in arbitrary order (works with MOM)
Definition: hf.cc:1234
bool soscf_enabled_
Are we doing second-order convergence acceleration?
Definition: hf.h:191
void print_stability_analysis(std::vector< std::pair< double, int > > &vec)
Definition: hf.cc:2071
bool input_socc_
SOCC vector from input (if found)
Definition: hf.h:124
std::shared_ptr< VBase > V_potential() const
The DFT Potential object (or null if it has been deleted)
Definition: hf.h:243
void compute_fvpi()
Definition: hf.cc:1194
bool cphf_converged_
Definition: hf.h:226
bool diis_performed_
Whether DIIS was performed this iteration, or not.
Definition: hf.h:118
virtual SharedMatrix form_Fia(SharedMatrix Fso, SharedMatrix Cso, int *noccpi)
Definition: hf.cc:1998
std::string scf_type_
SCF algorithm type.
Definition: hf.h:142
virtual double compute_energy()
Definition: hf.cc:526
SharedMatrix X_
The orthogonalization matrix (symmetric or canonical)
Definition: hf.h:61
double nuclearrep_
Nuclear repulsion energy.
Definition: hf.h:115
virtual void form_G()=0
double radius_
Definition: hf.h:213
virtual double finalize_E()
Definition: hf.cc:533
bool broken_symmetry_
Whether its broken symmetry solution or not.
Definition: hf.h:127
bool MOM_excited_
Are we to do excited-state MOM?
Definition: hf.h:165
double energy_threshold_
Energy convergence threshold.
Definition: hf.h:79
void form_Shalf()
Formation of S^+1/2 and S^-1/2 are the same.
Definition: hf.cc:1035
virtual bool diis()
Definition: hf.h:380
double damping_convergence_
The energy convergence at which SCF damping is disabled.
Definition: hf.h:206
std::shared_ptr< SuperFunctional > functional_
DFT variables.
Definition: hf.h:220
virtual void form_F()=0
void rotate_orbitals(SharedMatrix C, const SharedMatrix x)
Definition: hf.cc:435
int iterations_needed_
The number of iterations need to reach convergence.
Definition: hf.h:332
virtual void save_information()
Definition: hf.h:374
virtual bool stability_analysis()
Check the stability of the wavefunction, and correct (if requested)
Definition: hf.cc:2097
Definition: dimension.h:40
Definition: hf.h:153
bool initialized_diis_manager_
DIIS manager intiialized?
Definition: hf.h:177
virtual void form_C()
Compute the MO coefficients (C_)
Definition: hf.cc:415
perturb perturb_
Definition: hf.h:154
Definition: hf.h:153
Definition: liboptions.h:360
Header file for the Quantum Trio LibraryDavid Sherrill 1994.
virtual void semicanonicalize()
Definition: hf.cc:711
double density_threshold_
Density convergence threshold.
Definition: hf.h:82
int cphf_nfock_builds_
Definition: hf.h:225
virtual int soscf_update()
Definition: hf.cc:406
virtual std::vector< SharedMatrix > cphf_Hx(std::vector< SharedMatrix > x)
Definition: hf.cc:428
void MOM_start()
Start the MOM algorithm (requires one iteration worth of setup)
Definition: mom.cc:58
int soscf_min_iter_
Maximum number of iterations.
Definition: hf.h:195
Dimension original_doccpi_
Definition: hf.h:131
int diis_start_
When do we start collecting vectors for DIIS.
Definition: hf.h:186
int perturb_h_
Perturb the Hamiltonian?
Definition: hf.h:149
std::shared_ptr< Matrix > SharedMatrix
Definition: adc.h:49
void set_sad_basissets(std::vector< std::shared_ptr< BasisSet >> basis_vec)
Definition: hf.h:478
std::shared_ptr< JK > jk() const
The JK object (or null if it has been deleted)
Definition: hf.h:237
virtual void damp_update()
Definition: hf.cc:400
Definition: hf.h:153
Simple wavefunction base class.
Definition: wavefunction.h:84
bool frac_enabled_
Are we to fractionally occupy?
Definition: hf.h:172
bool cphf_converged()
Definition: hf.h:463
void reset_occ(bool reset)
Definition: hf.h:475
int nelectron_
The number of electrons.
Definition: hf.h:323
virtual void prepare_canonical_orthogonalization()
Edit matrices if we are doing canonical orthogonalization.
Definition: hf.h:267
int theta_points_
Definition: hf.h:216
int charge_
The charge of the system.
Definition: hf.h:326
SharedMatrix V_
The 1e potential energy matrix.
Definition: hf.h:56
SharedMatrix Vb()
Definition: hf.h:468
int cphf_nfock_builds()
Definition: hf.h:464
Definition: hf.h:50
int original_nalpha_
Definition: hf.h:133
void common_init()
Common initializer.
Definition: hf.cc:94
std::vector< std::shared_ptr< BasisSet > > sad_basissets_
Basis list for SAD.
Definition: hf.h:92
HF(SharedWavefunction ref_wfn, std::shared_ptr< SuperFunctional > funct, Options &options, std::shared_ptr< PSIO > psio)
Definition: hf.cc:78
int max_attempts_
Maximum number of macroiterations to take in e.g. a stability analysis.
Definition: hf.h:320
void compute_SAD_guess()
SAD Guess and propagation.
Definition: sad.cc:656
void reset_occupation()
Reset to regular occupation from the fractional occupation.
Definition: hf.cc:1985
bool frac_performed_
Frac started? (Same thing as frac_performed_)
Definition: hf.h:174
double soscf_r_start_
What is the gradient threshold that we should start?
Definition: hf.h:193
virtual bool test_convergency()
Definition: hf.h:368
int iterations_needed()
The number of iterations needed to reach convergence.
Definition: hf.h:234
int maxiter_
Max number of iterations for HF.
Definition: hf.h:99
virtual void integrals()
Do any needed integral setup.
Definition: hf.cc:478
void find_occupation()
Figure out how to occupy the orbitals in the absence of DOCC and SOCC.
Definition: hf.cc:716
std::shared_ptr< PCM > hf_pcm_
Definition: hf.h:254
double rms_density_error()
The RMS error in the density.
Definition: hf.h:246
virtual void form_H()
Formation of H is the same regardless of RHF, ROHF, UHF.
Definition: hf.cc:855
Dimension original_soccpi_
Definition: hf.h:132
int r_points_
Definition: hf.h:215
virtual void diagonalize_F(const SharedMatrix &F, SharedMatrix &C, std::shared_ptr< Vector > &eps)
Definition: hf.cc:1972
int phi_points_
Definition: hf.h:217
virtual SharedMatrix form_FDSmSDF(SharedMatrix Fso, SharedMatrix Dso)
Definition: hf.cc:2047
Vector nuclear_dipole_contribution_
Nuclear contributions.
Definition: hf.h:230
std::shared_ptr< Wavefunction > SharedWavefunction
Definition: typedefs.h:52
SharedMatrix diag_C_temp_
Temporary matrix for diagonalize_F.
Definition: hf.h:67
Definition: hf.h:153
double E_
Definition: hf.h:86
double soscf_conv_
Break if the residual RMS is less than this.
Definition: hf.h:199
void print_energies()
Prints the energy breakdown from this SCF.
Definition: hf.cc:1864
bool MOM_started_
MOM started?
Definition: hf.h:167
Definition: vector.h:49
void frac_renormalize()
Renormalize orbitals to 1.0 before saving.
Definition: frac.cc:187
void compute_fcpi()
Determine how many core and virtual orbitals to freeze.
Definition: hf.cc:1159
double soscf_print_
Do we print the microiterations?
Definition: hf.h:201
int iteration_
Current Iteration.
Definition: hf.h:108
SharedMatrix Va_
The DFT potential matrices (nice naming scheme)
Definition: hf.h:58
bool ref_C_
Fail if we don&#39;t converge by maxiter?
Definition: hf.h:102
virtual void guess()
Form the guess (gaurantees C, D, and E)
Definition: hf.cc:1364
int * so2symblk_
Mapping arrays.
Definition: hf.h:138
SharedMatrix guess_Cb_
Definition: hf.h:76