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

mbpt.h

00001 //
00002 // mbpt.h
00003 //
00004 // Copyright (C) 1996 Limit Point Systems, Inc.
00005 //
00006 // Author: Ida Nielsen <ibniels@kemi.aau.dk>
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_mbpt_mbpt_h
00029 #define _chemistry_qc_mbpt_mbpt_h
00030 
00031 #ifdef __GNUC__
00032 #pragma interface
00033 #endif
00034 
00035 #include <util/group/memory.h>
00036 #include <util/group/message.h>
00037 #include <util/group/thread.h>
00038 #include <chemistry/qc/basis/obint.h>
00039 #include <chemistry/qc/basis/tbint.h>
00040 #include <chemistry/qc/scf/scf.h>
00041 
00042 // //////////////////////////////////////////////////////////////////////////
00043 
00046 class MBPT2: public Wavefunction {
00047   protected:
00048 #define ref_to_mp2_acc 100.0
00049 
00050     Ref<SCF> reference_;
00051     Ref<MemoryGrp> mem;
00052     int nfzc, nfzv;
00053     unsigned int mem_alloc;
00054 
00055     double cphf_epsilon_;
00056     int eliminate_in_gmat_;
00057     const double *intbuf_;
00058     Ref<TwoBodyInt> tbint_;
00059     Ref<TwoBodyInt> *tbints_;
00060     Ref<TwoBodyDerivInt> *tbintder_;
00061     int nbasis;
00062     int noso;
00063     Ref<MessageGrp> msg_;
00064     int nvir, nocc, nsocc;
00065 
00066     Ref<ThreadGrp> thr_;
00067 
00068     // use a dynamic load balance algorithm if possible if true
00069     // (will not work if messagegrp not thread safe and
00070     // memorygrp needs catchup to work)
00071     int dynamic_;
00072 
00073     // The maximum number of orbitals in a pass.
00074     int max_norb_;
00075 
00076     // the irreps of the orbitals and the offset within the irrep
00077     int *symorb_irrep_;
00078     int *symorb_num_;
00079 
00080     char *method_;
00081     char *algorithm_;
00082     // if do_d1_ is true, D1(MP2) will be computed even if the gradient is not
00083     int do_d1_;
00084     // if do_d2_ is true, D2(MP1) will be computed 
00085     int do_d2_;
00086     
00087     int nfuncmax;
00088 
00089     double hf_energy_;
00090     RefSCVector hf_gradient_;
00091 
00092     double restart_ecorr_;
00093     int restart_orbital_v1_;
00094     int restart_orbital_memgrp_;
00095 
00096   protected:
00097     void init_variables();
00098 
00099     // implement the Compute::compute() function
00100     void compute();
00101 
00102     // Fill in the eigenvectors and eigenvalues (Guest & Saunders general
00103     // form is used for the Fock matrix in the open shell case).
00104     void eigen(RefDiagSCMatrix &vals, RefSCMatrix &vecs,
00105                RefDiagSCMatrix &occs);
00106 
00107     // calculate the opt2 energy using algorithm v1
00108     void compute_hsos_v1();
00109 
00110     // calculate the opt2 energy using algorithm v2
00111     distsize_t compute_v2_memory(int ni,
00112                              int nfuncmax, int nbfme, int nshell,
00113                              int ndocc, int nsocc, int nvir, int nproc);
00114     void compute_hsos_v2();
00115 
00116     // calculate the opt2 energy using the load balanced version of v2
00117     void compute_hsos_v2_lb();
00118 
00119     // calculate the closed shell mp2 energy and gradient
00120     int compute_cs_batchsize(int mem_static, int nocc_act);
00121     // distsize_t is used to allow memory requirements to be
00122     // estimated by starting the calculation on a single processor
00123     distsize_t compute_cs_dynamic_memory(int ni, int nocc_act);
00124     int make_cs_gmat(RefSymmSCMatrix& Gmat, double *DPmat);
00125     int make_cs_gmat_new(RefSymmSCMatrix& Gmat, const RefSymmSCMatrix& DPmat);
00126     void form_max_dens(double *DPmat, signed char *maxp);
00127     int init_cs_gmat();
00128     void done_cs_gmat();
00129     int make_g_d_nor(RefSymmSCMatrix& Gmat,
00130                      double *DPmat, const double *mgdbuff);
00131     void cs_cphf(double **scf_vector,
00132                  double *Laj, double *eigval, RefSCMatrix& P2aj);
00133     void s2pdm_contrib(const double *intderbuf, double *PHF,
00134                        double *P2AO, double **hf_ginter, double **ginter);
00135     void hcore_cs_grad(double *PHF, double *PMP2,
00136                        double **hf_ginter, double **ginter);
00137     void overlap_cs_grad(double *WHF, double *WMP2,
00138                          double **hf_ginter, double **ginter);
00139     void compute_cs_grad();
00140   public:
00141     MBPT2(StateIn&);
00225     MBPT2(const Ref<KeyVal>&);
00226     ~MBPT2();
00227 
00228     void save_data_state(StateOut&);
00229 
00230     Ref<SCF> ref() { return reference_; }
00231     double ref_energy();
00232     double corr_energy();
00233     RefSCVector ref_energy_gradient();
00234     RefSCVector corr_energy_gradient();
00235 
00236     int nelectron();
00237 
00238     RefSymmSCMatrix density();
00239     int spin_polarized();
00240 
00241     int gradient_implemented() const;
00242     int value_implemented() const;
00243 
00244     void symmetry_changed();
00245 
00246     // override compute's obsolete so we can call the reference's obsolete
00247     void obsolete();
00248 
00249     void print(std::ostream&o=ExEnv::out()) const;
00250 };
00251 
00252 
00253 #endif
00254 
00255 // Local Variables:
00256 // mode: c++
00257 // c-file-style: "CLJ"
00258 // End:

Generated at Thu Oct 4 18:08:45 2001 for MPQC 2.0.0 using the documentation package Doxygen 1.2.5.