MPQC 2.3.1
scf.h
1//
2// scf.h --- definition of the SCF abstract base class
3//
4// Copyright (C) 1996 Limit Point Systems, Inc.
5//
6// Author: Edward Seidl <seidl@janed.com>
7// Maintainer: LPS
8//
9// This file is part of the SC Toolkit.
10//
11// The SC Toolkit is free software; you can redistribute it and/or modify
12// it under the terms of the GNU Library General Public License as published by
13// the Free Software Foundation; either version 2, or (at your option)
14// any later version.
15//
16// The SC Toolkit 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 Library General Public License for more details.
20//
21// You should have received a copy of the GNU Library General Public License
22// along with the SC Toolkit; see the file COPYING.LIB. If not, write to
23// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24//
25// The U.S. Government is granted a limited license as per AL 91-7.
26//
27
28#ifndef _chemistry_qc_scf_scf_h
29#define _chemistry_qc_scf_scf_h
30
31#ifdef __GNUC__
32#pragma interface
33#endif
34
35#include <util/group/thread.h>
36
37#include <math/optimize/scextrap.h>
38
39#include <chemistry/qc/basis/tbint.h>
40#include <chemistry/qc/wfn/accum.h>
41#include <chemistry/qc/wfn/obwfn.h>
42
43namespace sc {
44
45// //////////////////////////////////////////////////////////////////////////
46
49class SCF: public OneBodyWavefunction {
50 protected:
51 int need_vec_;
52 int compute_guess_;
53
54 int keep_guess_wfn_;
55 Ref<OneBodyWavefunction> guess_wfn_;
56
57 int always_use_guess_wfn_;
58
60
61 Ref<AccumH> accumdih_;
62 Ref<AccumH> accumddh_;
63
64 int maxiter_;
65 int dens_reset_freq_;
66 int reset_occ_;
67 int local_dens_;
68 size_t storage_;
69 int print_all_evals_;
70 int print_occ_evals_;
71
72 double level_shift_;
73
74 Ref<MessageGrp> scf_grp_;
75 Ref<ThreadGrp> threadgrp_;
76 int local_;
77
78 Ref<TwoBodyInt>* tbis_; // a two body integral evaluator for each thread
79 virtual void init_threads();
80 virtual void done_threads();
81
82 // implement the Compute::compute() function
83 virtual void compute();
84
85 // calculate the scf vector, returning the accuracy
86 virtual double compute_vector(double&, double enuclear);
87
88 // return the DIIS error matrices
89 virtual Ref<SCExtrapError> extrap_error();
90
91 // calculate the scf gradient
92 virtual void compute_gradient(const RefSCVector&);
93
94 // calculate the scf hessian
95 virtual void compute_hessian(const RefSymmSCMatrix&);
96
97 // saves state and restart information after every checkpoint_freq()
98 // SCF iterations
99 virtual void savestate_iter(int);
100
101 // saves state to the given filename
102 virtual void savestate_to_file(const std::string &filename);
103 std::string previous_savestate_file_;
104
105 // returns the log of the max density element in each shell block
106 signed char * init_pmax(double *);
107
108 // given a matrix, this will convert the matrix to a local matrix if
109 // it isn't one already, and return that local matrix. it will also
110 // set the double* to point to the local matrix's data.
111 enum Access { Read, Write, Accum };
112 RefSymmSCMatrix get_local_data(const RefSymmSCMatrix&, double*&, Access);
113
114 // create the initial scf vector. either use the eigenvectors in
115 // guess_wfn_, or use a core Hamiltonian guess. Call this with needv
116 // equal to 0 if you expect to call it twice with the same geometry
117 // (eg. when calling from both set_occupations() and init_vector()).
118 virtual void initial_vector(int needv=1);
119
120 // given the total number of density and fock matrices, figure out
121 // how much memory that will require and then set the local_dens_
122 // variable accordingly
123 void init_mem(int);
124
125 void so_density(const RefSymmSCMatrix& d, double occ, int alp=1);
126
127 // Returns a new'ed allocation vector if it is in the input,
128 // otherwise null.
129 int *read_occ(const Ref<KeyVal> &, const char *name, int nirrep);
130 public:
131 SCF(StateIn&);
192 ~SCF();
193
195
198
199 int spin_unrestricted(); // return 0
200
201 // return the number of AO Fock matrices needed
202 virtual int n_fock_matrices() const =0;
203
204 // returns the n'th AO Fock matrix
205 virtual RefSymmSCMatrix fock(int) =0;
206
207 // return the effective MO fock matrix
208 virtual RefSymmSCMatrix effective_fock() =0;
209
210 virtual double one_body_energy();
211 virtual void two_body_energy(double &ec, double &ex);
212
214
215 void obsolete();
216
217 void print(std::ostream&o=ExEnv::out0()) const;
218
219 protected:
220 // the following are scratch and are not checkpointed
221 RefSCMatrix oso_scf_vector_;
222 RefSCMatrix oso_scf_vector_beta_; // only used if !spin_restricted
223 RefSymmSCMatrix hcore_;
224
225 // //////////////////////////////////////////////////////////////////////
226 // pure virtual member functions follow
227
228 // tries to automagically guess the MO occupations
229 virtual void set_occupations(const RefDiagSCMatrix&) =0;
230
231 // //////////////////////////////////////////////////////////////////////
232 // do setup for SCF calculation
233 virtual void init_vector() =0;
234 virtual void done_vector() =0;
235
236 // calculate new density matrices, returns the rms density difference
237 virtual double new_density() =0;
238
239 // reset density diff matrix and zero out delta G matrix
240 virtual void reset_density() =0;
241
242 // return the scf electronic energy
243 virtual double scf_energy() =0;
244
245 // return the DIIS data matrices
246 virtual Ref<SCExtrapData> extrap_data() =0;
247
248 // form the AO basis fock matrices
249 virtual void ao_fock(double accuracy) =0;
250
251 // //////////////////////////////////////////////////////////////////////
252 // do setup for gradient calculation
253 virtual void init_gradient() =0;
254 virtual void done_gradient() =0;
255
256 virtual RefSymmSCMatrix lagrangian() =0;
257 virtual RefSymmSCMatrix gradient_density() =0;
258 virtual void two_body_deriv(double*) =0;
259
260 // //////////////////////////////////////////////////////////////////////
261 // do setup for hessian calculation
262 virtual void init_hessian() =0;
263 virtual void done_hessian() =0;
264
265 private:
266 // This experimental function does SVD of Coulomb matrix
267 // to be used in low-rank reconstruction
268 void svd_product_basis();
269};
270
271}
272
273#endif
274
275// Local Variables:
276// mode: c++
277// c-file-style: "ETS"
278// End:
static std::ostream & out0()
Return an ostream that writes from node 0.
A OneBodyWavefunction is a MolecularEnergy that solves an effective one-body problem.
Definition: obwfn.h:41
The RefDiagSCMatrix class is a smart pointer to an DiagSCMatrix specialization.
Definition: matrix.h:380
The RefSCMatrix class is a smart pointer to an SCMatrix specialization.
Definition: matrix.h:135
The RefSCVector class is a smart pointer to an SCVector specialization.
Definition: matrix.h:55
The RefSymmSCMatrix class is a smart pointer to an SCSymmSCMatrix specialization.
Definition: matrix.h:261
A template class that maintains references counts.
Definition: ref.h:332
The SCF class is the base for all classes that use a self-consistent field procedure to solve an effe...
Definition: scf.h:49
void obsolete()
Marks all results as being out of date.
RefDiagSCMatrix eigenvalues()
Returns the MO basis eigenvalues.
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
void symmetry_changed()
Call this if you have changed the molecular symmetry of the molecule contained by this MolecularEnerg...
SCF(const Ref< KeyVal > &)
The KeyVal constructor.
void print(std::ostream &o=ExEnv::out0()) const
Print information about the object.
int spin_unrestricted()
Return 1 if the alpha orbitals are not equal to the beta orbitals.
RefSCMatrix oso_eigenvectors()
Returns the orthogonal MO (columns) to orthogonal-SO (rows) transformation matrix.
virtual void compute()
Recompute at least the results that have compute true and are not already computed.
Restores objects that derive from SavableState.
Definition: statein.h:70
Serializes objects that derive from SavableState.
Definition: stateout.h:61

Generated at Sun Nov 27 2022 00:00:00 for MPQC 2.3.1 using the documentation package Doxygen 1.9.5.