00001 // 00002 // psiwfn.h 00003 // 00004 // Copyright (C) 2002 Edward Valeev 00005 // 00006 // Author: Edward Valeev <evaleev@vt.edu> 00007 // Maintainer: EV 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 #ifdef __GNUC__ 00029 #pragma interface 00030 #endif 00031 00032 #ifndef _chemistry_qc_psi_psiwfn_h 00033 #define _chemistry_qc_psi_psiwfn_h 00034 00035 #include <chemistry/qc/wfn/wfn.h> 00036 #include <chemistry/qc/wfn/obwfn.h> 00037 #include <chemistry/qc/psi/psiexenv.h> 00038 #include <chemistry/qc/mbptr12/spin.h> 00039 #include <chemistry/qc/mbptr12/orbitalspace.h> 00040 00041 namespace sc { 00042 00044 00049 class PsiWavefunction : public Wavefunction { 00050 00051 Ref<PsiExEnv> exenv_; 00053 int value_implemented() const { 00054 return 1; 00055 } 00056 00057 protected: 00058 int nirrep_; 00059 char *memory_; 00061 virtual void write_input(int conv) =0; 00062 00063 std::vector<int> read_occ(const Ref<KeyVal> &keyval, const char *name, 00064 int nirrep); 00065 00067 int debug() const; 00068 00069 public: 00084 PsiWavefunction(const Ref<KeyVal>&); 00085 PsiWavefunction(StateIn&); 00086 ~PsiWavefunction(); 00087 00088 void save_data_state(StateOut&); 00089 00091 static Integral::CartesianOrdering cartesian_ordering(); 00092 00095 virtual void write_basic_input(int conv); 00096 void compute(); 00097 void print(std::ostream&o=ExEnv::out0()) const; 00098 RefSymmSCMatrix density(); 00099 int nirrep() const { return nirrep_; } 00100 00102 Ref<PsiExEnv> exenv() const { 00103 return exenv_; 00104 } 00105 00107 Ref<PsiInput> get_psi_input() const { 00108 return exenv_->get_psi_input(); 00109 } 00110 00112 std::vector< std::pair<unsigned int,unsigned int> > shell_map(); 00114 std::vector<unsigned int> ao_map(); 00115 00116 }; 00117 00120 00121 class PsiSCF : public PsiWavefunction { 00122 RefDiagSCMatrix evals_[NSpinCases1]; 00123 RefSCMatrix coefs_[NSpinCases1]; 00124 std::vector<unsigned int> occpi_[NSpinCases1]; 00125 std::vector<unsigned int> uoccpi_[NSpinCases1]; 00126 std::vector<unsigned int> mopi_; 00127 00128 protected: 00129 std::vector<int> docc_; 00130 std::vector<int> socc_; 00131 int multp_; 00132 int charge_; 00133 static const int maxiter = 100; 00134 00136 Ref<OneBodyWavefunction> guess_wfn_; 00137 00138 public: 00139 PsiSCF(const Ref<KeyVal>&); 00140 PsiSCF(StateIn&); 00141 ~PsiSCF(); 00142 void save_data_state(StateOut&); 00143 00146 void import_occupations(const Ref<OneBodyWavefunction>& obwfn); 00147 // use spin datatypes defined in spin.h 00148 typedef sc::SpinCase1 SpinCase1; 00149 enum RefType {rhf, hsoshf, uhf}; 00151 virtual PsiSCF::RefType reftype() const =0; 00153 virtual const RefDiagSCMatrix& evals(SpinCase1 spin = Alpha); 00155 virtual const RefSCMatrix& coefs(SpinCase1 spin = Alpha); 00157 const std::vector<unsigned int>& occpi(SpinCase1 S); 00159 const std::vector<unsigned int>& uoccpi(SpinCase1 S); 00161 const std::vector<unsigned int>& mopi(); 00163 int nelectron(); 00164 00166 unsigned int nmo(); 00168 unsigned int nocc(SpinCase1 spin); 00169 }; 00170 00173 00174 class PsiCLHF : public PsiSCF { 00175 protected: 00176 void write_input(int conv); 00177 public: 00178 PsiCLHF(const Ref<KeyVal>&); 00179 PsiCLHF(StateIn&); 00180 ~PsiCLHF(); 00181 00182 void write_basic_input(int conv); 00183 int spin_polarized() { 00184 return 0; 00185 } 00186 ; 00187 int gradient_implemented() const { 00188 return 1; 00189 } 00190 ; 00191 PsiSCF::RefType reftype() const { 00192 return rhf; 00193 } 00194 ; 00195 }; 00196 00199 00200 class PsiHSOSHF : public PsiSCF { 00201 protected: 00202 void write_input(int conv); 00203 public: 00204 PsiHSOSHF(const Ref<KeyVal>&); 00205 PsiHSOSHF(StateIn&); 00206 ~PsiHSOSHF(); 00207 00208 void write_basic_input(int conv); 00209 int spin_polarized() { 00210 return 0; 00211 } 00212 ; 00213 int gradient_implemented() const { 00214 return 1; 00215 } 00216 ; 00217 PsiSCF::RefType reftype() const { 00218 return hsoshf; 00219 } 00220 ; 00221 }; 00222 00225 00226 class PsiUHF : public PsiSCF { 00227 protected: 00228 void write_input(int conv); 00229 public: 00230 PsiUHF(const Ref<KeyVal>&); 00231 PsiUHF(StateIn&); 00232 ~PsiUHF(); 00233 00234 void write_basic_input(int conv); 00235 int spin_polarized() { 00236 return 1; 00237 } 00238 ; 00239 int gradient_implemented() const { 00240 return 1; 00241 } 00242 ; 00243 PsiSCF::RefType reftype() const { 00244 return uhf; 00245 } 00246 ; 00247 }; 00248 00251 00252 class PsiCorrWavefunction : public PsiWavefunction { 00253 protected: 00254 Ref<PsiSCF> reference_; 00255 Ref<OrbitalSpace> occ_act_sb_[NSpinCases1]; 00256 Ref<OrbitalSpace> vir_act_sb_[NSpinCases1]; 00257 unsigned int nfzc_; 00258 unsigned int nfzv_; 00259 mutable std::vector<unsigned int> frozen_docc_; 00260 mutable std::vector<unsigned int> frozen_uocc_; 00261 void write_input(int conv); 00262 00263 double valacc_to_refacc() const { return 100.0; } 00264 00265 public: 00266 PsiCorrWavefunction(const Ref<KeyVal>&); 00267 PsiCorrWavefunction(StateIn&); 00268 ~PsiCorrWavefunction(); 00269 void save_data_state(StateOut&); 00270 int spin_polarized() { 00271 return reference_->spin_polarized(); 00272 } 00274 void set_desired_value_accuracy(double acc); 00275 00276 const Ref<PsiSCF>& reference() const { return reference_; } 00278 int nelectron(); 00280 const Ref<OrbitalSpace>& occ_act_sb(SpinCase1); 00282 const Ref<OrbitalSpace>& vir_act_sb(SpinCase1); 00284 unsigned int nfzc() const; 00286 unsigned int nfzv() const; 00288 const std::vector<unsigned int>& frozen_docc() const; 00290 const std::vector<unsigned int>& frozen_uocc() const; 00291 00293 virtual double reference_energy(); 00294 00295 }; 00296 00297 } 00298 #endif