Google

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

Generated at Fri Jan 10 08:14:09 2003 for MPQC 2.1.3 using the documentation package Doxygen 1.2.14.