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>
34 #include "psi4/libmints/vector3.h"
35 #include "psi4/psi4-dec.h"
36 
37 namespace psi {
38 class Vector;
39 class JK;
40 class PCM;
41 class SuperFunctional;
42 class VBase;
43 class BasisSet;
44 class DIISManager;
45 class PSIO;
46 namespace scf {
47 
48 class HF : public Wavefunction {
49 protected:
50 
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:
229 
232 
234  std::shared_ptr<JK> jk() const { return jk_; }
235 
237  std::shared_ptr<SuperFunctional> functional() const { return functional_; }
238 
240  std::shared_ptr<VBase> V_potential() const { return potential_; }
241 
243  double rms_density_error() {return Drms_;}
244 
246  std::shared_ptr<Vector> occupation_a() const;
247  std::shared_ptr<Vector> occupation_b() const;
248 
249  // PCM interface
251  std::shared_ptr<PCM> hf_pcm_;
252 
253 protected:
254 
256  // Temporarily converting to virtual function for testing embedding
257  // potentials. TDC, 5/23/12.
258  virtual void form_H();
259 
261  void form_Shalf();
262 
264  virtual void prepare_canonical_orthogonalization() { return; }
265 
267  void print_occupation();
268 
270  void common_init();
271 
273  void find_occupation();
274 
276  void MOM();
278  void MOM_start();
279 
281  void frac();
283  void frac_renormalize();
284 
286  virtual bool stability_analysis();
287  void print_stability_analysis(std::vector<std::pair<double, int> > &vec);
288 
289 
291  void compute_fcpi();
292  void compute_fvpi();
293 
295  void print_orbitals(const char* header, std::vector<std::pair<double,
296  std::pair< std::string, int> > > orbs);
297 
299  void print_orbitals();
300 
302  void print_energies();
303 
305  void print_header();
306 
308  void print_preiterations();
309 
311  virtual void integrals();
312 
318 
321 
323  int charge_;
324 
327 
330 
332  virtual double compute_E() = 0;
333 
335  virtual void save_density_and_energy() = 0;
336 
338  void check_phases();
339 
341  void compute_SAD_guess();
342 
344  void reset_occupation();
345 
347  virtual void guess();
348 
350  virtual void damp_update();
351 
353  virtual int soscf_update();
354 
356  virtual void diagonalize_F(const SharedMatrix& F, SharedMatrix& C, std::shared_ptr<Vector>& eps);
357 
359  virtual void form_initial_C() { form_C(); }
360 
362  virtual double compute_initial_E() { return 0.0; }
363 
365  virtual bool test_convergency() { return false; }
366 
368  virtual void compute_spin_contamination();
369 
371  virtual void save_information() {}
372 
374  virtual void compute_orbital_gradient(bool) {}
375 
377  virtual bool diis() { return false; }
378 
380  virtual SharedMatrix form_Fia(SharedMatrix Fso, SharedMatrix Cso, int* noccpi);
381 
384 
386  virtual void format_guess();
387 
389  // virtual void save_orbitals();
390 
392  // bool do_use_fock_guess();
393 
395  // virtual void load_fock();
396 
398  // virtual void load_orbitals();
399 
400 public:
401  HF(SharedWavefunction ref_wfn, std::shared_ptr<SuperFunctional> funct,
402  Options& options, std::shared_ptr<PSIO> psio);
403 
404  virtual ~HF();
405 
407  virtual void initialize();
408 
410  virtual void iterations();
411 
416  virtual double finalize_E();
417 
421  virtual double compute_energy();
422 
425  virtual void finalize();
426 
432  virtual void semicanonicalize();
433 
435  virtual void form_C();
436 
438  virtual void form_D();
439 
441  virtual void form_V();
442 
444  void rotate_orbitals(SharedMatrix C, const SharedMatrix x);
445 
447  virtual void form_F() = 0;
448 
450  virtual void form_G() = 0;
451 
453  virtual std::vector<SharedMatrix> onel_Hx(std::vector<SharedMatrix> x);
454  virtual std::vector<SharedMatrix> twoel_Hx(std::vector<SharedMatrix> x, bool combine = true,
455  std::string return_basis = "MO");
456  virtual std::vector<SharedMatrix> cphf_Hx(std::vector<SharedMatrix> x);
457  virtual std::vector<SharedMatrix> cphf_solve(std::vector<SharedMatrix> x_vec,
458  double conv_tol = 1.e-4, int max_iter = 10,
459  int print_lvl = 1);
460  bool cphf_converged() { return cphf_converged_; }
462 
463  // Return the DFT potenitals
464  SharedMatrix Va() { return Va_; }
465  SharedMatrix Vb() { return Vb_; }
466 
467  // Set guess occupied orbitals, nalpha and nbeta will be taken from the number of passed in eigenvectors
470 
471  // Expert option to reset the occuption or not at iteration zero
472  void reset_occ(bool reset) { reset_occ_ = reset; }
473 
474  // SAD information
475  void set_sad_basissets(std::vector<std::shared_ptr<BasisSet>> basis_vec) { sad_basissets_ = basis_vec; }
476  void set_sad_fitting_basissets(std::vector<std::shared_ptr<BasisSet>> basis_vec) { sad_fitting_basissets_ = basis_vec; }
477 };
478 
479 }} // Namespaces
480 
481 #endif
virtual void form_initial_C()
Definition: hf.h:359
int multiplicity_
The multiplicity of the system (specified as 2 Ms + 1)
Definition: hf.h:326
Definition: hf.h:153
std::shared_ptr< Vector > occupation_a() const
Returns the occupation vectors.
Definition: hf.cc:1954
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:494
SharedMatrix T_
The kinetic energy matrix.
Definition: hf.h:52
bool MOM_performed_
MOM performed?
Definition: hf.h:169
std::shared_ptr< Vector > occupation_b() const
Definition: hf.cc:1965
SharedMatrix Ca_old_
Old C Alpha matrix (if needed for MOM)
Definition: hf.h:70
std::shared_ptr< PSIO > psio() const
Definition: wavefunction.cc:492
SharedMatrix Cb() const
Returns the beta electrons MO coefficients.
Definition: wavefunction.cc:553
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:1634
bool damping_enabled_
Whether to use SCF damping.
Definition: hf.h:208
bool pcm_enabled_
Definition: hf.h:250
void MOM()
Maximum overlap method for prevention of oscillation/excited state SCF.
Definition: mom.cc:589
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
double ** scf
Definition: dx_write.cc:57
virtual void form_V()
Computes the density matrix (V_)
Definition: hf.cc:414
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:374
double integral_threshold_
The value below which integrals are neglected.
Definition: hf.h:157
virtual double compute_initial_E()
Definition: hf.h:362
int min_diis_vectors_
How many min vectors for DIIS.
Definition: hf.h:182
void frac()
Fractional occupation UHF/UKS.
Definition: frac.cc:67
void guess_Ca(SharedMatrix Ca)
Definition: hf.h:468
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:434
std::shared_ptr< DIISManager > diis_manager_
DIIS manager for all SCF wavefunctions.
Definition: hf.h:179
SharedMatrix Va()
Definition: hf.h:464
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:237
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:424
void check_phases()
Check MO phases.
Definition: hf.cc:1531
Definition: hf.h:153
void print_header()
Prints some opening information.
Definition: hf.cc:795
virtual std::vector< SharedMatrix > twoel_Hx(std::vector< SharedMatrix > x, bool combine=true, std::string return_basis="MO")
Definition: hf.cc:427
void print_occupation()
Prints the orbital occupation.
Definition: hf.cc:1924
virtual void format_guess()
Definition: hf.cc:1525
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:315
SharedMatrix guess_Ca_
User defined orbitals.
Definition: hf.h:75
void guess_Cb(SharedMatrix Cb)
Definition: hf.h:469
int diis_enabled_
Are we even using DIIS?
Definition: hf.h:188
virtual void form_D()
Computes the density matrix (D_)
Definition: hf.cc:421
void print_preiterations()
Prints some details about nsopi/nmopi, and initial occupations.
Definition: hf.cc:849
SharedMatrix Ca() const
Returns the alpha electrons MO coefficients.
Definition: wavefunction.cc:542
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:1563
virtual double compute_E()=0
Compute energy for the iteration.
virtual void compute_spin_contamination()
Definition: frac.cc:230
bool MOM_enabled_
Are we to do MOM?
Definition: hf.h:163
virtual void finalize()
Definition: hf.cc:684
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:476
virtual ~HF()
Definition: hf.cc:89
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:1241
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:2074
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:240
void compute_fvpi()
Definition: hf.cc:1203
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:2001
std::string scf_type_
SCF algorithm type.
Definition: hf.h:142
virtual double compute_energy()
Definition: hf.cc:529
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:536
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
SharedMatrix Horig_
A temporary spot for the H matrix.
Definition: hf.h:56
void form_Shalf()
Formation of S^+1/2 and S^-1/2 are the same.
Definition: hf.cc:1044
virtual bool diis()
Definition: hf.h:377
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:438
int iterations_needed_
The number of iterations need to reach convergence.
Definition: hf.h:329
virtual void save_information()
Definition: hf.h:371
virtual bool stability_analysis()
Check the stability of the wavefunction, and correct (if requested)
Definition: hf.cc:2097
Definition: dimension.h:38
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:418
perturb perturb_
Definition: hf.h:154
Definition: hf.h:153
Definition: liboptions.h:355
virtual void semicanonicalize()
Definition: hf.cc:714
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:409
virtual std::vector< SharedMatrix > cphf_Hx(std::vector< SharedMatrix > x)
Definition: hf.cc:431
void MOM_start()
Start the MOM algorithm (requires one iteration worth of setup)
Definition: mom.cc:62
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:475
std::shared_ptr< JK > jk() const
The JK object (or null if it has been deleted)
Definition: hf.h:234
virtual void damp_update()
Definition: hf.cc:403
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:460
void reset_occ(bool reset)
Definition: hf.h:472
int nelectron_
The number of electrons.
Definition: hf.h:320
virtual void prepare_canonical_orthogonalization()
Edit matrices if we are doing canonical orthogonalization.
Definition: hf.h:264
int theta_points_
Definition: hf.h:216
int charge_
The charge of the system.
Definition: hf.h:323
SharedMatrix V_
The 1e potential energy matrix.
Definition: hf.h:54
SharedMatrix Vb()
Definition: hf.h:465
int cphf_nfock_builds()
Definition: hf.h:461
Definition: hf.h:48
int original_nalpha_
Definition: hf.h:133
void common_init()
Common initializer.
Definition: hf.cc:93
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:79
int max_attempts_
Maximum number of macroiterations to take in e.g. a stability analysis.
Definition: hf.h:317
void compute_SAD_guess()
SAD Guess and propagation.
Definition: sad.cc:618
void reset_occupation()
Reset to regular occupation from the fractional occupation.
Definition: hf.cc:1988
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:365
int iterations_needed()
The number of iterations needed to reach convergence.
Definition: hf.h:231
int maxiter_
Max number of iterations for HF.
Definition: hf.h:99
virtual void integrals()
Do any needed integral setup.
Definition: hf.cc:481
void find_occupation()
Figure out how to occupy the orbitals in the absence of DOCC and SOCC.
Definition: hf.cc:719
std::shared_ptr< PCM > hf_pcm_
Definition: hf.h:251
double rms_density_error()
The RMS error in the density.
Definition: hf.h:243
virtual void form_H()
Formation of H is the same regardless of RHF, ROHF, UHF.
Definition: hf.cc:868
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:1975
int phi_points_
Definition: hf.h:217
virtual SharedMatrix form_FDSmSDF(SharedMatrix Fso, SharedMatrix Dso)
Definition: hf.cc:2050
std::shared_ptr< Wavefunction > SharedWavefunction
Definition: typedefs.h:54
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:1868
bool MOM_started_
MOM started?
Definition: hf.h:167
void frac_renormalize()
Renormalize orbitals to 1.0 before saving.
Definition: frac.cc:189
void compute_fcpi()
Determine how many core and virtual orbitals to freeze.
Definition: hf.cc:1168
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:1368
int * so2symblk_
Mapping arrays.
Definition: hf.h:138
SharedMatrix guess_Cb_
Definition: hf.h:76