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 #ifdef __GNUG__
00029 #pragma interface
00030 #endif
00031
00032 #include <util/ref/ref.h>
00033 #include <chemistry/qc/mbptr12/linearr12.h>
00034 #include <chemistry/qc/mbptr12/r12int_eval.h>
00035 #include <chemistry/qc/mbptr12/spin.h>
00036 #include <chemistry/qc/mbptr12/twobodygrid.h>
00037 #include <chemistry/qc/mbptr12/pairiter.h>
00038 #include <chemistry/qc/mbptr12/mp2r12_energy_util.h>
00039
00040 #ifndef _chemistry_qc_mbptr12_mp2r12energy_h
00041 #define _chemistry_qc_mbptr12_mp2r12energy_h
00042
00043 #define MP2R12ENERGY_CAN_COMPUTE_PAIRFUNCTION 1
00044
00045 namespace sc {
00051 class R12EnergyIntermediates : virtual public SavableState {
00052 private:
00053 LinearR12::StandardApproximation stdapprox_;
00054 Ref<R12IntEval> r12eval_;
00055 bool V_computed_;
00056 RefSCMatrix V_[NSpinCases2];
00057 bool X_computed_;
00058 RefSymmSCMatrix X_[NSpinCases2];
00059 bool B_computed_;
00060 RefSymmSCMatrix B_[NSpinCases2];
00061 bool A_computed_;
00062 RefSCMatrix A_[NSpinCases2];
00063 public:
00064 typedef enum { V=0, X=1, B=2, A=3 } IntermediateType;
00065 R12EnergyIntermediates(const Ref<R12IntEval>& r12eval,
00066 const LinearR12::StandardApproximation stdapp);
00067 R12EnergyIntermediates(StateIn &si);
00068 void save_data_state(StateOut &so);
00069 ~R12EnergyIntermediates(){}
00070 Ref<R12IntEval> r12eval() const;
00071 void set_r12eval(Ref<R12IntEval> &r12eval);
00072 LinearR12::StandardApproximation stdapprox() const;
00073 bool V_computed() const;
00074 bool X_computed() const;
00075 bool B_computed() const;
00076 bool A_computed() const;
00077 void V_computed(const bool computed);
00078 void X_computed(const bool computed);
00079 void B_computed(const bool computed);
00080 void A_computed(const bool computed);
00081 const RefSCMatrix& get_V(const SpinCase2 &spincase2) const;
00082 void assign_V(const SpinCase2 &spincase2, const RefSCMatrix& V);
00083 const RefSymmSCMatrix& get_X(const SpinCase2 &spincase2) const;
00084 void assign_X(const SpinCase2 &spincase2, const RefSymmSCMatrix& X);
00085 const RefSymmSCMatrix& get_B(const SpinCase2 &spincase2) const;
00086 void assign_B(const SpinCase2 &spincase2, const RefSymmSCMatrix& B);
00087 const RefSCMatrix& get_A(const SpinCase2 &spincase2) const;
00088 void assign_A(const SpinCase2 &spincase2, const RefSCMatrix& A);
00089 };
00090
00092 class MP2R12Energy : virtual public SavableState {
00093 protected:
00094 Ref<R12EnergyIntermediates> r12intermediates_;
00095 Ref<R12IntEval> r12eval_;
00096 bool ebc_;
00097 int debug_;
00098 bool evaluated_;
00099
00100
00101 virtual void init_() = 0;
00102 public:
00103
00104 MP2R12Energy(StateIn&);
00105 MP2R12Energy(const Ref<R12EnergyIntermediates>& r12intermediates,
00106 int debug);
00107 ~MP2R12Energy();
00108
00109 void save_data_state(StateOut&);
00110 void obsolete();
00111 void print(std::ostream&o=ExEnv::out0()) const;
00112
00113 Ref<R12IntEval> r12eval() const;
00114 const Ref<R12EnergyIntermediates>& r12intermediates() const;
00115 LinearR12::StandardApproximation stdapprox() const;
00118 bool gbc() const;
00121 bool ebc() const;
00122 void set_debug(int debug);
00123 int get_debug() const;
00124
00125 virtual void print_pair_energies(bool spinadapted, std::ostream&so=ExEnv::out0()) = 0;
00126 virtual double energy() = 0;
00127 virtual const RefSCVector& ef12(SpinCase2 S) const {};
00128
00129 virtual double emp2f12tot(SpinCase2 S) const = 0;
00130 virtual double ef12tot(SpinCase2 S) const = 0;
00131
00132 #if MP2R12ENERGY_CAN_COMPUTE_PAIRFUNCTION
00133
00134 virtual void compute_pair_function(unsigned int i, unsigned int j, SpinCase2 spincase2,
00135 const Ref<TwoBodyGrid>& tbgrid) {};
00136 #endif
00137
00139 virtual void compute() = 0;
00142 virtual RefSCMatrix C(SpinCase2 S) = 0;
00145 virtual RefSCMatrix T2(SpinCase2 S) = 0;
00146 };
00147
00153 class MP2R12Energy_SpinOrbital : public MP2R12Energy
00154 {
00155 private:
00156 RefSCVector ef12_[NSpinCases2], emp2f12_[NSpinCases2];
00157
00158 RefSCMatrix C_[NSpinCases2];
00159
00160 double emp2f12tot(SpinCase2 S) const;
00161 double ef12tot(SpinCase2 S) const;
00162
00163
00164 void init_();
00165
00170 RefSCVector compute_2body_values_(bool equiv, const Ref<OrbitalSpace>& space1, const Ref<OrbitalSpace>& space2,
00171 const SCVector3& r1, const SCVector3& r2) const;
00172 public:
00173 MP2R12Energy_SpinOrbital(StateIn&);
00174 MP2R12Energy_SpinOrbital(Ref<R12EnergyIntermediates> &r12intermediates, int debug);
00175 ~MP2R12Energy_SpinOrbital();
00176
00177 void save_data_state(StateOut&);
00178 void compute();
00179
00180
00181 void print_pair_energies(bool spinadapted, std::ostream&so=ExEnv::out0());
00182
00183 #if MP2R12ENERGY_CAN_COMPUTE_PAIRFUNCTION
00184
00185 void compute_pair_function(unsigned int i, unsigned int j, SpinCase2 spincase2,
00186 const Ref<TwoBodyGrid>& tbgrid);
00187 #endif
00189 const RefSCVector& emp2f12(SpinCase2 S) const;
00191 const RefSCVector& ef12(SpinCase2 S) const;
00193 double energy();
00194
00197 RefSCMatrix C(SpinCase2 S);
00200 RefSCMatrix T2(SpinCase2 S);
00201 };
00202
00212 class MP2R12Energy_SpinOrbital_new : public MP2R12Energy
00213 {
00214 private:
00215 RefSCVector ef12_[NSpinCases2], emp2f12_[NSpinCases2];
00216
00217 RefSCMatrix C_[NSpinCases2];
00218
00219 double emp2f12tot(SpinCase2 S) const;
00220 double ef12tot(SpinCase2 S) const;
00221
00222
00223 void init_();
00224
00229 RefSCVector compute_2body_values_(bool equiv, const Ref<OrbitalSpace>& space1, const Ref<OrbitalSpace>& space2,
00230 const SCVector3& r1, const SCVector3& r2) const;
00231
00232 RefSymmSCMatrix compute_B_non_pairspecific(const RefSymmSCMatrix &B,
00233 const RefSymmSCMatrix &X,
00234 const RefSCMatrix &V,
00235 const RefSCMatrix &A,
00236 const SpinCase2 &spincase2);
00237 RefSymmSCMatrix compute_B_pairspecific(const SpinMOPairIter &ij_iter,
00238 const RefSymmSCMatrix &B,
00239 const RefSymmSCMatrix &X,
00240 const RefSCMatrix &V,
00241 const RefSCMatrix &A,
00242 const SpinCase2 &spincase2);
00243 void determine_C_non_pairspecific(const RefSymmSCMatrix &B_ij,
00244 const RefSCMatrix &V,
00245 const SpinCase2 &spincase2,
00246 const Ref<MP2R12EnergyUtil_Diag> &util);
00247 void determine_C_pairspecific(const int ij,
00248 const RefSymmSCMatrix &B_ij,
00249 const RefSCMatrix &V,
00250 const SpinCase2 &spincase2);
00251 void determine_C_fixed_non_pairspecific(const SpinCase2 &spincase2);
00252 void determine_ef12_hylleraas(const RefSymmSCMatrix &B_ij,
00253 const RefSCMatrix &V,
00254 const SpinCase2 &spincase2,
00255 const Ref<MP2R12EnergyUtil_Diag> &util);
00256 void compute_MP2R12_nondiag();
00257 void compute_MP2R12_diag_fullopt();
00258 void compute_MP2R12_diag_nonfullopt();
00259
00260
00261 bool diag() const;
00262 bool fixedcoeff() const;
00263
00264 public:
00265 MP2R12Energy_SpinOrbital_new(StateIn&);
00266 MP2R12Energy_SpinOrbital_new(Ref<R12EnergyIntermediates> &r12intermediates,
00267 int debug);
00268 ~MP2R12Energy_SpinOrbital_new();
00269
00270 void save_data_state(StateOut&);
00271 void compute();
00272
00273
00274 void print_pair_energies(bool spinadapted, std::ostream&so=ExEnv::out0());
00275
00276 #if MP2R12ENERGY_CAN_COMPUTE_PAIRFUNCTION
00277
00278 void compute_pair_function(unsigned int i, unsigned int j, SpinCase2 spincase2,
00279 const Ref<TwoBodyGrid>& tbgrid);
00280 #endif
00282 const RefSCVector& emp2f12(SpinCase2 S) const;
00284 const RefSCVector& ef12(SpinCase2 S) const;
00286 double energy();
00287
00290 RefSCMatrix C(SpinCase2 S);
00293 RefSCMatrix T2(SpinCase2 S);
00294 };
00295
00296 Ref<MP2R12Energy> construct_MP2R12Energy(Ref<R12EnergyIntermediates> &r12intermediates,
00297 int debug,
00298 bool use_new_version);
00299
00300 }
00301
00302 #endif
00303
00304
00305
00306
00307
00308
00309