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 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
00071
00072
00073 int dynamic_;
00074
00075
00076 double print_percent_;
00077
00078
00079 int max_norb_;
00080
00081
00082 int *symorb_irrep_;
00083 int *symorb_num_;
00084
00085 char *method_;
00086 char *algorithm_;
00087
00088 int do_d1_;
00089
00090 int do_d2_;
00091
00092 int nfuncmax;
00093
00094 double hf_energy_;
00095 RefSCVector hf_gradient_;
00096
00097 double restart_ecorr_;
00098 int restart_orbital_v1_;
00099 int restart_orbital_memgrp_;
00100
00101 protected:
00102 void init_variables();
00103
00104
00105 void compute();
00106
00107
00108
00109 void eigen(RefDiagSCMatrix &vals, RefSCMatrix &vecs,
00110 RefDiagSCMatrix &occs);
00111
00112
00113 void compute_hsos_v1();
00114
00115
00116 distsize_t compute_v2_memory(int ni,
00117 int nfuncmax, int nbfme, int nshell,
00118 int ndocc, int nsocc, int nvir, int nproc);
00119 void compute_hsos_v2();
00120
00121
00122 void compute_hsos_v2_lb();
00123
00124
00125 int compute_cs_batchsize(size_t mem_static, int nocc_act);
00126
00127
00128 distsize_t compute_cs_dynamic_memory(int ni, int nocc_act);
00129 int make_cs_gmat(RefSymmSCMatrix& Gmat, double *DPmat);
00130 int make_cs_gmat_new(RefSymmSCMatrix& Gmat, const RefSymmSCMatrix& DPmat);
00131 void form_max_dens(double *DPmat, signed char *maxp);
00132 int init_cs_gmat();
00133 void done_cs_gmat();
00134 int make_g_d_nor(RefSymmSCMatrix& Gmat,
00135 double *DPmat, const double *mgdbuff);
00136 void cs_cphf(double **scf_vector,
00137 double *Laj, double *eigval, RefSCMatrix& P2aj);
00138 void s2pdm_contrib(const double *intderbuf, double *PHF,
00139 double *P2AO, double **hf_ginter, double **ginter);
00140 void hcore_cs_grad(double *PHF, double *PMP2,
00141 double **hf_ginter, double **ginter);
00142 void overlap_cs_grad(double *WHF, double *WMP2,
00143 double **hf_ginter, double **ginter);
00144 void compute_cs_grad();
00145 public:
00146 MBPT2(StateIn&);
00230 MBPT2(const Ref<KeyVal>&);
00231 ~MBPT2();
00232
00233 void save_data_state(StateOut&);
00234
00235 Ref<SCF> ref() { return reference_; }
00236 double ref_energy();
00237 double corr_energy();
00238 RefSCVector ref_energy_gradient();
00239 RefSCVector corr_energy_gradient();
00240
00241 int nelectron();
00242
00243 int nfzcore() const { return nfzc; };
00244 int nfzvirt() const { return nfzv; };
00245
00246 RefSymmSCMatrix density();
00247 int spin_polarized();
00248
00249 int gradient_implemented() const;
00250 int value_implemented() const;
00251
00252 void symmetry_changed();
00253
00254
00255 void obsolete();
00256
00257 void print(std::ostream&o=ExEnv::out0()) const;
00258 };
00259
00260 }
00261
00262 #endif
00263
00264
00265
00266
00267