Main Page Class Hierarchy Compound List File List Compound Members Related Pages

# scf.h

    00001 //
    00002 // scf.h --- definition of the SCF abstract base class
    00003 //
    00004 // Copyright (C) 1996 Limit Point Systems, Inc.
    00005 //
    00006 // Author: Edward Seidl <seidl@janed.com>
    00007 // Maintainer: LPS
    00008 //
    00009 // This file is part of the SC Toolkit.
    00010 //
    00011 // The SC Toolkit is free software; you can redistribute it and/or modify
    00012 // it under the terms of the GNU Library General Public License as published by
    00013 // the Free Software Foundation; either version 2, or (at your option)
    00014 // any later version.
    00015 //
    00016 // The SC Toolkit is distributed in the hope that it will be useful,
    00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00019 // GNU Library General Public License for more details.
    00020 //
    00021 // You should have received a copy of the GNU Library General Public License
    00022 // along with the SC Toolkit; see the file COPYING.LIB.  If not, write to
    00023 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
    00024 //
    00025 // The U.S. Government is granted a limited license as per AL 91-7.
    00026 //
    00027
    00028 #ifndef _chemistry_qc_scf_scf_h
    00029 #define _chemistry_qc_scf_scf_h
    00030
    00031 #ifdef __GNUC__
    00032 #pragma interface
    00033 #endif
    00034
    00035 #include <util/group/thread.h>
    00036
    00037 #include <math/optimize/scextrap.h>
    00038
    00039 #include <chemistry/qc/basis/tbint.h>
    00040 #include <chemistry/qc/wfn/accum.h>
    00041 #include <chemistry/qc/wfn/obwfn.h>
    00042
    00043 namespace sc {
    00044
    00045 // //////////////////////////////////////////////////////////////////////////
    00046
    00049 class SCF: public OneBodyWavefunction {
    00050   protected:
    00051     int need_vec_;
    00052     int compute_guess_;
    00053
    00054     int keep_guess_wfn_;
    00055     Ref<OneBodyWavefunction> guess_wfn_;
    00056
    00057     int always_use_guess_wfn_;
    00058
    00059     Ref<SelfConsistentExtrapolation> extrap_;
    00060
    00061     Ref<AccumH> accumdih_;
    00062     Ref<AccumH> accumddh_;
    00063
    00064     int maxiter_;
    00065     int dens_reset_freq_;
    00066     int reset_occ_;
    00067     int local_dens_;
    00068     size_t storage_;
    00069     int print_all_evals_;
    00070     int print_occ_evals_;
    00071
    00072     double level_shift_;
    00073
    00074     Ref<MessageGrp> scf_grp_;
    00075     Ref<ThreadGrp> threadgrp_;
    00076     int local_;
    00077
    00078     Ref<TwoBodyInt>* tbis_; // a two body integral evaluator for each thread
    00079     virtual void init_threads();
    00080     virtual void done_threads();
    00081
    00082     // implement the Compute::compute() function
    00083     virtual void compute();
    00084
    00085     // calculate the scf vector, returning the accuracy
    00086     virtual double compute_vector(double&);
    00087
    00088     // return the DIIS error matrices
    00089     virtual Ref<SCExtrapError> extrap_error();
    00090
    00091     // calculate the scf gradient
    00092     virtual void compute_gradient(const RefSCVector&);
    00093
    00094     // calculate the scf hessian
    00095     virtual void compute_hessian(const RefSymmSCMatrix&);
    00096
    00097     // saves state and restart information after every checkpoint_freq()
    00098     // SCF iteration
    00099     virtual void savestate_iter(int);
    00100
    00101     // returns the log of the max density element in each shell block
    00102     signed char * init_pmax(double *);
    00103
    00104     // given a matrix, this will convert the matrix to a local matrix if
    00105     // it isn't one already, and return that local matrix.  it will also
    00106     // set the double* to point to the local matrix's data.
    00107     enum Access { Read, Write, Accum };
    00108     RefSymmSCMatrix get_local_data(const RefSymmSCMatrix&, double*&, Access);
    00109
    00110     // create the initial scf vector.  either use the eigenvectors in
    00111     // guess_wfn_, or use a core Hamiltonian guess.  Call this with needv
    00112     // equal to 0 if you expect to call it twice with the same geometry
    00113     // (eg. when calling from both set_occupations() and init_vector()).
    00114     virtual void initial_vector(int needv=1);
    00115
    00116     // given the total number of density and fock matrices, figure out
    00117     // how much memory that will require and then set the local_dens_
    00118     // variable accordingly
    00119     void init_mem(int);
    00120
    00121     void so_density(const RefSymmSCMatrix& d, double occ, int alp=1);
    00122
    00123     // Returns a new'ed allocation vector if it is in the input,
    00124     // otherwise null.
    00125     int *read_occ(const Ref<KeyVal> &, const char *name, int nirrep);
    00126   public:
    00127     SCF(StateIn&);
    00180     SCF(const Ref<KeyVal>&);
    00181     ~SCF();
    00182
    00183     void save_data_state(StateOut&);
    00184
    00185     RefSCMatrix oso_eigenvectors();
    00186     RefDiagSCMatrix eigenvalues();
    00187
    00188     int spin_unrestricted(); // return 0
    00189
    00190     // return the number of AO Fock matrices needed
    00191     virtual int n_fock_matrices() const =0;
    00192
    00193     // returns the n'th AO Fock matrix
    00194     virtual RefSymmSCMatrix fock(int) =0;
    00195
    00196     // return the effective MO fock matrix
    00197     virtual RefSymmSCMatrix effective_fock() =0;
    00198
    00199     virtual double one_body_energy();
    00200     virtual void two_body_energy(double &ec, double &ex);
    00201
    00202     void symmetry_changed();
    00203
    00204     void obsolete();
    00205
    00206     void print(std::ostream&o=ExEnv::out0()) const;
    00207
    00208   protected:
    00209     // the following are scratch and are not checkpointed
    00210     RefSCMatrix oso_scf_vector_;
    00211     RefSCMatrix oso_scf_vector_beta_; // only used if !spin_restricted
    00212     RefSymmSCMatrix hcore_;
    00213
    00214     // //////////////////////////////////////////////////////////////////////
    00215     // pure virtual member functions follow
    00216
    00217     // tries to automagically guess the MO occupations
    00218     virtual void set_occupations(const RefDiagSCMatrix&) =0;
    00219
    00220     // //////////////////////////////////////////////////////////////////////
    00221     // do setup for SCF calculation
    00222     virtual void init_vector() =0;
    00223     virtual void done_vector() =0;
    00224
    00225     // calculate new density matrices, returns the rms density difference
    00226     virtual double new_density() =0;
    00227
    00228     // reset density diff matrix and zero out delta G matrix
    00229     virtual void reset_density() =0;
    00230
    00231     // return the scf electronic energy
    00232     virtual double scf_energy() =0;
    00233
    00234     // return the DIIS data matrices
    00235     virtual Ref<SCExtrapData> extrap_data() =0;
    00236
    00237     // form the AO basis fock matrices
    00238     virtual void ao_fock(double accuracy) =0;
    00239
    00240     // //////////////////////////////////////////////////////////////////////
    00241     // do setup for gradient calculation
    00242     virtual void init_gradient() =0;
    00243     virtual void done_gradient() =0;
    00244
    00245     virtual RefSymmSCMatrix lagrangian() =0;
    00246     virtual RefSymmSCMatrix gradient_density() =0;
    00247     virtual void two_body_deriv(double*) =0;
    00248
    00249     // //////////////////////////////////////////////////////////////////////
    00250     // do setup for hessian calculation
    00251     virtual void init_hessian() =0;
    00252     virtual void done_hessian() =0;
    00253 };
    00254
    00255 }
    00256
    00257 #endif
    00258
    00259 // Local Variables:
    00260 // mode: c++
    00261 // c-file-style: "ETS"
    00262 // End: