00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
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     
00069     
00070     
00071     int dynamic_;
00072 
00073     
00074     int max_norb_;
00075 
00076     
00077     int *symorb_irrep_;
00078     int *symorb_num_;
00079 
00080     char *method_;
00081     char *algorithm_;
00082     
00083     int do_d1_;
00084     
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     
00100     void compute();
00101 
00102     
00103     
00104     void eigen(RefDiagSCMatrix &vals, RefSCMatrix &vecs,
00105                RefDiagSCMatrix &occs);
00106 
00107     
00108     void compute_hsos_v1();
00109 
00110     
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     
00117     void compute_hsos_v2_lb();
00118 
00119     
00120     int compute_cs_batchsize(int mem_static, int nocc_act);
00121     
00122     
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     
00247     void obsolete();
00248 
00249     void print(std::ostream&o=ExEnv::out()) const;
00250 };
00251 
00252 
00253 #endif
00254 
00255 
00256 
00257 
00258