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 program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License along
22  * with this program; if not, write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  *
25  * @END LICENSE
26  */
27 
28 #ifndef HF_H
29 #define HF_H
30 
31 #include <vector>
32 #include "psi4/libpsio/psio.hpp"
34 #include "psi4/libmints/basisset.h"
35 #include "psi4/libmints/vector.h"
37 #include "psi4/libdiis/diisentry.h"
38 #include "psi4/psi4-dec.h"
39 #include "psi4/libqt/qt.h"
40 
41 namespace psi {
42 class Matrix;
43 class Vector;
44 class SimpleVector;
45 class TwoBodySOInt;
46 class JK;
47 class MinimalInterface;
48 class SOSCF;
49 class PCM;
50 class SuperFunctional;
51 class VBase;
52 namespace scf {
53 
54 class HF : public Wavefunction {
55 protected:
56 
72 
77 
81 
84 
87 
89  double Eold_;
90  double E_;
91 
93  std::map<std::string, double> energies_;
94 
96  std::vector<std::shared_ptr<BasisSet>> sad_basissets_;
97  std::vector<std::shared_ptr<BasisSet>> sad_fitting_basissets_;
98 
100  double Drms_;
101 
103  int maxiter_;
104 
106  bool ref_C_;
107 
110 
113 
115 
117 
119  double nuclearrep_;
120 
123 
126 
129 
132 
133  //Initial SAD doubly occupied may be more than ndocc
134  // int sad_nocc_[8];
140 
143  int *so2index_;
144 
146  std::string scf_type_;
147 
150  std::string old_scf_type_;
151 
159 
162 
164  std::shared_ptr<JK> jk_;
165 
174 
179 
183  std::shared_ptr<DIISManager> diis_manager_;
184 
193 
203  double soscf_conv_;
205  double soscf_print_;
206 
215 
216  // parameters for hard-sphere potentials
217  double radius_; // radius of spherical potential
218  double thickness_; // thickness of spherical barrier
219  int r_points_; // number of radial integration points
220  int theta_points_; // number of colatitude integration points
221  int phi_points_; // number of azimuthal integration points
222 
224  std::shared_ptr<SuperFunctional> functional_;
225  std::shared_ptr<VBase> potential_;
226 
227 public:
231 
234 
236  std::shared_ptr<JK> jk() const { return jk_; }
237 
239  std::shared_ptr<SuperFunctional> functional() const { return functional_; }
240 
242  std::shared_ptr<VBase> V_potential() const { return potential_; }
243 
245  double rms_density_error() {return Drms_;}
246 
248  std::shared_ptr<Vector> occupation_a() const;
249  std::shared_ptr<Vector> occupation_b() const;
250 
251  // PCM interface
253  std::shared_ptr<PCM> hf_pcm_;
254 
255 protected:
256 
258  // Temporarily converting to virtual function for testing embedding
259  // potentials. TDC, 5/23/12.
260  virtual void form_H();
261 
263  void form_Shalf();
264 
266  virtual void prepare_canonical_orthogonalization() { return; }
267 
269  void print_occupation();
270 
272  void common_init();
273 
275  void find_occupation();
276 
278  void MOM();
280  void MOM_start();
281 
283  void frac();
285  void frac_renormalize();
286 
288  virtual bool stability_analysis();
289  void print_stability_analysis(std::vector<std::pair<double, int> > &vec);
290 
291 
293  void compute_fcpi();
294  void compute_fvpi();
295 
297  void print_orbitals(const char* header, std::vector<std::pair<double,
298  std::pair<const char*, int> > > orbs);
299 
301  void print_orbitals();
302 
304  void print_energies();
305 
307  void print_header();
308 
310  void print_preiterations();
311 
313  virtual void integrals();
314 
320 
323 
325  int charge_;
326 
329 
332 
334  virtual double compute_E() = 0;
335 
337  virtual void save_density_and_energy() = 0;
338 
340  void check_phases();
341 
343  void compute_SAD_guess();
344 
346  void reset_occupation();
347 
349  virtual void guess();
350 
352  virtual void damp_update();
353 
355  virtual int soscf_update();
356 
358  void rotate_orbitals(SharedMatrix C, const SharedMatrix x);
359 
361  virtual void diagonalize_F(const SharedMatrix& F, SharedMatrix& C, std::shared_ptr<Vector>& eps);
362 
364  virtual void form_F() =0;
365 
367  virtual void form_initial_C() { form_C(); }
368 
370  virtual void form_G() =0;
371 
373  virtual double compute_initial_E() { return 0.0; }
374 
376  virtual bool test_convergency() { return false; }
377 
379  virtual void compute_spin_contamination();
380 
382  virtual void save_information() {}
383 
385  virtual void compute_orbital_gradient(bool) {}
386 
388  virtual bool diis() { return false; }
389 
391  virtual SharedMatrix form_Fia(SharedMatrix Fso, SharedMatrix Cso, int* noccpi);
392 
395 
397  virtual void format_guess();
398 
400  // virtual void save_orbitals();
401 
403  // bool do_use_fock_guess();
404 
406  // virtual void load_fock();
407 
409  // virtual void load_orbitals();
410 
411 public:
412  HF(SharedWavefunction ref_wfn, std::shared_ptr<SuperFunctional> funct,
413  Options& options, std::shared_ptr<PSIO> psio);
414 
415  virtual ~HF();
416 
418  virtual void initialize();
419 
421  virtual void iterations();
422 
427  virtual double finalize_E();
428 
432  virtual double compute_energy();
433 
436  virtual void finalize();
437 
443  virtual void semicanonicalize();
444 
446  virtual void form_C();
447 
449  virtual void form_D();
450 
452  virtual void form_V();
453 
454  // Return the DFT potenitals
455  SharedMatrix Va() { return Va_; }
456  SharedMatrix Vb() { return Vb_; }
457 
458  // Set guess occupied orbitals, nalpha and nbeta will be taken from the number of passed in eigenvectors
461 
462  // Expert option to reset the occuption or not at iteration zero
463  void reset_occ(bool reset) { reset_occ_ = reset; }
464 
465  void set_sad_basissets(std::vector<std::shared_ptr<BasisSet>> basis_vec) { sad_basissets_ = basis_vec; }
466  void set_sad_fitting_basissets(std::vector<std::shared_ptr<BasisSet>> basis_vec) { sad_fitting_basissets_ = basis_vec; }
467 };
468 
469 }} // Namespaces
470 
471 #endif
virtual void form_initial_C()
Definition: hf.h:367
int multiplicity_
The multiplicity of the system (specified as 2 Ms + 1)
Definition: hf.h:328
Definition: hf.h:157
std::shared_ptr< Vector > occupation_a() const
Returns the occupation vectors.
Definition: hf.cc:1912
virtual void save_density_and_energy()=0
Save the current density and energy.
int * so2index_
Definition: hf.h:143
Options & options() const
Definition: wavefunction.cc:400
SharedMatrix T_
The kinetic energy matrix.
Definition: hf.h:58
bool MOM_performed_
MOM performed?
Definition: hf.h:173
std::shared_ptr< Vector > occupation_b() const
Definition: hf.cc:1923
SharedMatrix Ca_old_
Old C Alpha matrix (if needed for MOM)
Definition: hf.h:74
std::shared_ptr< PSIO > psio() const
Definition: wavefunction.cc:395
SharedMatrix Cb() const
Returns the beta electrons MO coefficients.
Definition: wavefunction.cc:475
bool reset_occ_
Definition: hf.h:139
int original_nbeta_
Definition: hf.h:138
std::shared_ptr< VBase > potential_
Definition: hf.h:225
virtual void iterations()
Performs the actual SCF iterations.
Definition: hf.cc:1607
bool damping_enabled_
Whether to use SCF damping.
Definition: hf.h:212
bool pcm_enabled_
Definition: hf.h:252
void MOM()
Maximum overlap method for prevention of oscillation/excited state SCF.
Definition: mom.cc:584
bool fail_on_maxiter_
Fail if we don&#39;t converge by maxiter?
Definition: hf.h:109
int max_diis_vectors_
How many max vectors for DIIS.
Definition: hf.h:188
bool input_docc_
DOCC vector from input (if found)
Definition: hf.h:125
std::map< std::string, double > energies_
Table of energy components.
Definition: hf.h:93
Vector nuclear_quadrupole_contribution_
Definition: hf.h:230
double ** scf
Definition: dx_write.cc:56
virtual void form_V()
Computes the density matrix (V_)
Definition: hf.cc:401
SharedMatrix Vb_
Definition: hf.h:63
std::vector< std::shared_ptr< BasisSet > > sad_fitting_basissets_
Definition: hf.h:97
virtual void compute_orbital_gradient(bool)
Definition: hf.h:385
double integral_threshold_
The value below which integrals are neglected.
Definition: hf.h:161
virtual double compute_initial_E()
Definition: hf.h:373
int min_diis_vectors_
How many min vectors for DIIS.
Definition: hf.h:186
void frac()
Fractional occupation UHF/UKS.
Definition: frac.cc:64
void guess_Ca(SharedMatrix Ca)
Definition: hf.h:459
double damping_percentage_
The amount (%) of the previous orbitals to mix in during SCF damping.
Definition: hf.h:208
std::shared_ptr< DIISManager > diis_manager_
DIIS manager for all SCF wavefunctions.
Definition: hf.h:183
SharedMatrix Va()
Definition: hf.h:455
double thickness_
Definition: hf.h:218
std::shared_ptr< SuperFunctional > functional() const
The DFT Functional object (or null if it has been deleted)
Definition: hf.h:239
double Drms_
The RMS error in the density.
Definition: hf.h:100
Definition: vector3.h:36
SharedMatrix Cb_old_
Old C Beta matrix (if needed for MOM)
Definition: hf.h:76
void check_phases()
Check MO phases.
Definition: hf.cc:1504
Definition: hf.h:157
void print_header()
Prints some opening information.
Definition: hf.cc:761
void print_occupation()
Prints the orbital occupation.
Definition: hf.cc:1881
virtual void format_guess()
Definition: hf.cc:1498
std::string old_scf_type_
Definition: hf.h:150
Definition: hf.h:157
int soscf_max_iter_
Minimum number of iterations.
Definition: hf.h:201
SharedMatrix diag_temp_
Temporary matrix for diagonalize_F.
Definition: hf.h:67
Definition: hf.h:157
Vector3 perturb_dipoles_
How big of a perturbation.
Definition: hf.h:155
int attempt_number_
Definition: hf.h:317
SharedMatrix guess_Ca_
User defined orbitals.
Definition: hf.h:79
void guess_Cb(SharedMatrix Cb)
Definition: hf.h:460
int diis_enabled_
Are we even using DIIS?
Definition: hf.h:192
virtual void form_D()
Computes the density matrix (D_)
Definition: hf.cc:409
void print_preiterations()
Prints some details about nsopi/nmopi, and initial occupations.
Definition: hf.cc:813
SharedMatrix Ca() const
Returns the alpha electrons MO coefficients.
Definition: wavefunction.cc:463
std::shared_ptr< JK > jk_
The soon to be ubiquitous JK object.
Definition: hf.h:164
virtual void initialize()
Specialized initialization, compute integrals and does everything to prepare for iterations.
Definition: hf.cc:1536
virtual double compute_E()=0
Compute energy for the iteration.
virtual void compute_spin_contamination()
Definition: frac.cc:227
bool MOM_enabled_
Are we to do MOM?
Definition: hf.h:167
virtual void finalize()
Definition: hf.cc:660
bool damping_performed_
Whether damping was actually performed this iteration.
Definition: hf.h:214
bool converged_
Did the SCF converge?
Definition: hf.h:116
double Eold_
Previous iteration&#39;s energy and current energy.
Definition: hf.h:89
void set_sad_fitting_basissets(std::vector< std::shared_ptr< BasisSet >> basis_vec)
Definition: hf.h:466
virtual ~HF()
Definition: hf.cc:89
perturb
With what...
Definition: hf.h:157
SharedMatrix diag_F_temp_
Temporary matrix for diagonalize_F.
Definition: hf.h:69
void print_orbitals()
Prints the orbitals in arbitrary order (works with MOM)
Definition: hf.cc:1211
bool soscf_enabled_
Are we doing second-order convergence acceleration?
Definition: hf.h:195
void print_stability_analysis(std::vector< std::pair< double, int > > &vec)
Definition: hf.cc:2032
bool input_socc_
SOCC vector from input (if found)
Definition: hf.h:128
std::shared_ptr< VBase > V_potential() const
The DFT Potential object (or null if it has been deleted)
Definition: hf.h:242
void compute_fvpi()
Definition: hf.cc:1171
bool diis_performed_
Whether DIIS was performed this iteration, or not.
Definition: hf.h:122
virtual SharedMatrix form_Fia(SharedMatrix Fso, SharedMatrix Cso, int *noccpi)
Definition: hf.cc:1959
std::string scf_type_
SCF algorithm type.
Definition: hf.h:146
virtual double compute_energy()
Definition: hf.cc:505
SharedMatrix X_
The orthogonalization matrix (symmetric or canonical)
Definition: hf.h:65
double nuclearrep_
Nuclear repulsion energy.
Definition: hf.h:119
virtual void form_G()=0
double radius_
Definition: hf.h:217
virtual double finalize_E()
Definition: hf.cc:512
bool broken_symmetry_
Whether its broken symmetry solution or not.
Definition: hf.h:131
bool MOM_excited_
Are we to do excited-state MOM?
Definition: hf.h:169
double energy_threshold_
Energy convergence threshold.
Definition: hf.h:83
void form_Shalf()
Formation of S^+1/2 and S^-1/2 are the same.
Definition: hf.cc:1012
virtual bool diis()
Definition: hf.h:388
double damping_convergence_
The energy convergence at which SCF damping is disabled.
Definition: hf.h:210
std::shared_ptr< SuperFunctional > functional_
DFT variables.
Definition: hf.h:224
virtual void form_F()=0
void rotate_orbitals(SharedMatrix C, const SharedMatrix x)
Definition: hf.cc:413
int iterations_needed_
The number of iterations need to reach convergence.
Definition: hf.h:331
virtual void save_information()
Definition: hf.h:382
virtual bool stability_analysis()
Check the stability of the wavefunction, and correct (if requested)
Definition: hf.cc:2058
Definition: dimension.h:39
Definition: hf.h:157
bool initialized_diis_manager_
DIIS manager intiialized?
Definition: hf.h:181
virtual void form_C()
Compute the MO coefficients (C_)
Definition: hf.cc:405
perturb perturb_
Definition: hf.h:158
Definition: hf.h:157
Definition: liboptions.h:359
Header file for the Quantum Trio LibraryDavid Sherrill 1994.
virtual void semicanonicalize()
Definition: hf.cc:690
double density_threshold_
Density convergence threshold.
Definition: hf.h:86
virtual int soscf_update()
Definition: hf.cc:396
void MOM_start()
Start the MOM algorithm (requires one iteration worth of setup)
Definition: mom.cc:57
int soscf_min_iter_
Maximum number of iterations.
Definition: hf.h:199
Dimension original_doccpi_
Definition: hf.h:135
int diis_start_
When do we start collecting vectors for DIIS.
Definition: hf.h:190
int perturb_h_
Perturb the Hamiltonian?
Definition: hf.h:153
std::shared_ptr< Matrix > SharedMatrix
Definition: adc.h:50
void set_sad_basissets(std::vector< std::shared_ptr< BasisSet >> basis_vec)
Definition: hf.h:465
std::shared_ptr< JK > jk() const
The JK object (or null if it has been deleted)
Definition: hf.h:236
virtual void damp_update()
Definition: hf.cc:390
Definition: hf.h:157
Simple wavefunction base class.
Definition: wavefunction.h:85
bool frac_enabled_
Are we to fractionally occupy?
Definition: hf.h:176
void reset_occ(bool reset)
Definition: hf.h:463
int nelectron_
The number of electrons.
Definition: hf.h:322
virtual void prepare_canonical_orthogonalization()
Edit matrices if we are doing canonical orthogonalization.
Definition: hf.h:266
int theta_points_
Definition: hf.h:220
int charge_
The charge of the system.
Definition: hf.h:325
SharedMatrix V_
The 1e potential energy matrix.
Definition: hf.h:60
SharedMatrix Vb()
Definition: hf.h:456
Definition: hf.h:54
int original_nalpha_
Definition: hf.h:137
void common_init()
Common initializer.
Definition: hf.cc:93
std::vector< std::shared_ptr< BasisSet > > sad_basissets_
Basis list for SAD.
Definition: hf.h:96
HF(SharedWavefunction ref_wfn, std::shared_ptr< SuperFunctional > funct, Options &options, std::shared_ptr< PSIO > psio)
Definition: hf.cc:77
int max_attempts_
Maximum number of macroiterations to take in e.g. a stability analysis.
Definition: hf.h:319
void compute_SAD_guess()
SAD Guess and propagation.
Definition: sad.cc:655
void reset_occupation()
Reset to regular occupation from the fractional occupation.
Definition: hf.cc:1946
bool frac_performed_
Frac started? (Same thing as frac_performed_)
Definition: hf.h:178
double soscf_r_start_
What is the gradient threshold that we should start?
Definition: hf.h:197
virtual bool test_convergency()
Definition: hf.h:376
int iterations_needed()
The number of iterations needed to reach convergence.
Definition: hf.h:233
int maxiter_
Max number of iterations for HF.
Definition: hf.h:103
virtual void integrals()
Do any needed integral setup.
Definition: hf.cc:457
void find_occupation()
Figure out how to occupy the orbitals in the absence of DOCC and SOCC.
Definition: hf.cc:695
std::shared_ptr< PCM > hf_pcm_
Definition: hf.h:253
double rms_density_error()
The RMS error in the density.
Definition: hf.h:245
virtual void form_H()
Formation of H is the same regardless of RHF, ROHF, UHF.
Definition: hf.cc:832
Dimension original_soccpi_
Definition: hf.h:136
int r_points_
Definition: hf.h:219
virtual void diagonalize_F(const SharedMatrix &F, SharedMatrix &C, std::shared_ptr< Vector > &eps)
Definition: hf.cc:1933
int phi_points_
Definition: hf.h:221
virtual SharedMatrix form_FDSmSDF(SharedMatrix Fso, SharedMatrix Dso)
Definition: hf.cc:2008
Vector nuclear_dipole_contribution_
Nuclear contributions.
Definition: hf.h:229
std::shared_ptr< Wavefunction > SharedWavefunction
Definition: typedefs.h:50
SharedMatrix diag_C_temp_
Temporary matrix for diagonalize_F.
Definition: hf.h:71
Definition: hf.h:157
double E_
Definition: hf.h:90
double soscf_conv_
Break if the residual RMS is less than this.
Definition: hf.h:203
void print_energies()
Prints the energy breakdown from this SCF.
Definition: hf.cc:1835
bool MOM_started_
MOM started?
Definition: hf.h:171
Definition: vector.h:48
void frac_renormalize()
Renormalize orbitals to 1.0 before saving.
Definition: frac.cc:186
void compute_fcpi()
Determine how many core and virtual orbitals to freeze.
Definition: hf.cc:1136
double soscf_print_
Do we print the microiterations?
Definition: hf.h:205
int iteration_
Current Iteration.
Definition: hf.h:112
SharedMatrix Va_
The DFT potential matrices (nice naming scheme)
Definition: hf.h:62
bool ref_C_
Fail if we don&#39;t converge by maxiter?
Definition: hf.h:106
virtual void guess()
Form the guess (gaurantees C, D, and E)
Definition: hf.cc:1341
int * so2symblk_
Mapping arrays.
Definition: hf.h:142
SharedMatrix guess_Cb_
Definition: hf.h:80