|
MPQC
3.0.0-alpha
|
00001 // 00002 // obint.h 00003 // 00004 // Copyright (C) 1996 Limit Point Systems, Inc. 00005 // 00006 // Author: Curtis Janssen <cljanss@limitpt.com> 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_basis_obint_h 00029 #define _chemistry_qc_basis_obint_h 00030 00031 #include <util/ref/ref.h> 00032 #include <util/state/state.h> 00033 #include <util/container/stdarray.h> 00034 #include <math/scmat/matrix.h> 00035 #include <math/scmat/elemop.h> 00036 00037 #include <chemistry/qc/basis/gaussbas.h> 00038 #include <chemistry/qc/basis/dercent.h> 00039 00040 namespace sc { 00041 00042 class Integral; 00043 00044 // ////////////////////////////////////////////////////////////////////////// 00045 00046 class EfieldDotVectorData: public RefCount 00047 { 00048 public: 00049 EfieldDotVectorData() {}; 00050 ~EfieldDotVectorData(); 00051 00052 double position[3]; 00053 double vector[3]; 00054 00055 void set_position(double*); 00056 void set_vector(double*); 00057 }; 00058 00059 00060 class DipoleData: public RefCount 00061 { 00062 public: 00063 double origin[3]; 00064 00065 DipoleData(double *d) {origin[0]=d[0]; origin[1]=d[1]; origin[2]=d[2];} 00066 DipoleData() {origin[0]=origin[1]=origin[2]=0.0;} 00067 ~DipoleData(); 00068 void set_origin(double*); 00069 }; 00070 00071 00072 class PointChargeData: public RefCount 00073 { 00074 private: 00075 int ncharges_; 00076 const double *charges_; 00077 const double *const*positions_; 00078 double *alloced_charges_; 00079 double **alloced_positions_; 00080 00081 public: 00082 // If copy_data is 0, the passed positions and charges will 00083 // be stored (but not freed). 00084 PointChargeData(int ncharge, 00085 const double *const*positions, const double *charges, 00086 int copy_data = 0); 00087 ~PointChargeData(); 00088 00089 int ncharges() const { return ncharges_; } 00090 const double *charges() const { return charges_; } 00091 const double *const*positions() const { return positions_; } 00092 }; 00093 00094 00097 class OneBodyInt : public RefCount { 00098 protected: 00099 // this is who created me 00100 Integral *integral_; 00101 00102 Ref<GaussianBasisSet> bs1_; 00103 Ref<GaussianBasisSet> bs2_; 00104 00105 double *buffer_; 00106 00107 OneBodyInt(Integral *integral, 00108 const Ref<GaussianBasisSet>&b1, 00109 const Ref<GaussianBasisSet>&b2 = 0); 00110 00111 public: 00112 virtual ~OneBodyInt(); 00113 00115 int nbasis() const; 00116 00118 int nbasis1() const; 00120 int nbasis2() const; 00121 00123 int nshell() const; 00124 00126 int nshell1() const; 00128 int nshell2() const; 00129 00131 Ref<GaussianBasisSet> basis(); 00132 00134 Ref<GaussianBasisSet> basis1(); 00136 Ref<GaussianBasisSet> basis2(); 00137 00139 const double * buffer() const; 00140 00143 virtual void compute_shell(int,int) = 0; 00144 00148 std::pair<const double *, std::array<unsigned long, 2> > compute_shell_array(int,int); 00149 00152 virtual void reinitialize(); 00153 00156 virtual bool cloneable(); 00157 00160 virtual Ref<OneBodyInt> clone(); 00161 00162 Integral *integral() const { return integral_; } 00163 }; 00164 00165 // ////////////////////////////////////////////////////////////////////////// 00166 00169 class OneBodyOneCenterInt : public RefCount { 00170 protected: 00171 // this is who created me 00172 Integral *integral_; 00173 00174 Ref<GaussianBasisSet> bs1_; 00175 00176 double *buffer_; 00177 00178 OneBodyOneCenterInt(Integral *integral, 00179 const Ref<GaussianBasisSet>&b1); 00180 00181 public: 00182 virtual ~OneBodyOneCenterInt(); 00183 00185 int nbasis() const; 00186 00188 int nbasis1() const; 00189 00191 int nshell() const; 00192 00194 int nshell1() const; 00195 00197 Ref<GaussianBasisSet> basis(); 00198 00200 Ref<GaussianBasisSet> basis1(); 00201 00203 const double * buffer() const; 00204 00207 virtual void compute_shell(int) = 0; 00208 00211 virtual void reinitialize(); 00212 00215 virtual bool cloneable(); 00216 00219 virtual Ref<OneBodyOneCenterInt> clone(); 00220 00221 Integral *integral() const { return integral_; } 00222 }; 00223 00224 // ////////////////////////////////////////////////////////////////////////// 00225 00226 class OneBodyOneCenterWrapper : public OneBodyOneCenterInt { 00227 Ref<OneBodyInt> ob_; 00228 int jsh_; 00229 public: 00230 OneBodyOneCenterWrapper(const Ref<OneBodyInt>& ob, 00231 int sh2 = 0); 00232 void compute_shell(int); 00233 }; 00234 00235 // ////////////////////////////////////////////////////////////////////////// 00236 00237 class ShellPairIter { 00238 private: 00239 const double * buf; 00240 double scale_; 00241 00242 int e12; 00243 00244 int index; 00245 00246 int ioffset; 00247 int joffset; 00248 00249 int iend; 00250 int jend; 00251 00252 int icur; 00253 int jcur; 00254 00255 public: 00256 ShellPairIter(); 00257 ~ShellPairIter(); 00258 00259 void init(const double * buffer, int ishell, int jshell, 00260 int ioff, int joff, int nfunci, int nfuncj, int redund=0, 00261 double scale=1.0); 00262 00263 void start() { icur=jcur=index=0; } 00264 int ready() const { return (icur < iend); } 00265 00266 void next() { 00267 if (jcur < ((e12)?(icur):((jend)-1))) { 00268 index++; 00269 jcur++; 00270 return; 00271 } 00272 00273 jcur=0; 00274 icur++; 00275 00276 index = icur*jend; 00277 } 00278 00279 int current_i() const { return icur; } 00280 int current_j() const { return jcur; } 00281 00282 int i() const { return icur+ioffset; } 00283 int j() const { return jcur+joffset; } 00284 00285 int nint() const { return iend*jend; } 00286 00287 double val() const { return buf[index]*scale_; } 00288 }; 00289 00290 // ////////////////////////////////////////////////////////////////////////// 00291 00292 class OneBodyIntIter : public RefCount { 00293 protected: 00294 Ref<OneBodyInt> obi; // help me obi wan 00295 ShellPairIter spi; 00296 00297 int redund; 00298 00299 int istart; 00300 int jstart; 00301 00302 int iend; 00303 int jend; 00304 00305 int icur; 00306 int jcur; 00307 00308 int ij; 00309 00310 public: 00311 OneBodyIntIter(); 00312 OneBodyIntIter(const Ref<OneBodyInt>&); 00313 virtual ~OneBodyIntIter(); 00314 00315 virtual void start(int ist=0, int jst=0, int ien=0, int jen=0); 00316 virtual void next(); 00317 00318 int ready() const { return (icur < iend); } 00319 00320 int ishell() const { return icur; } 00321 int jshell() const { return jcur; } 00322 00323 int ijshell() const { return ij; } 00324 00325 int redundant() const { return redund; } 00326 void set_redundant(int i) { redund=i; } 00327 00328 virtual double scale() const; 00329 00330 Ref<OneBodyInt> one_body_int() { return obi; } 00331 00332 ShellPairIter& current_pair(); 00333 00334 virtual bool cloneable(); 00335 virtual Ref<OneBodyIntIter> clone(); 00336 }; 00337 00338 00339 00340 // ////////////////////////////////////////////////////////////////////////// 00341 00342 class OneBodyIntOp: public SCElementOp { 00343 protected: 00344 Ref<OneBodyIntIter> iter; 00345 00346 public: 00347 OneBodyIntOp(const Ref<OneBodyInt>&); 00348 OneBodyIntOp(const Ref<OneBodyIntIter>&); 00349 virtual ~OneBodyIntOp(); 00350 00351 void process(SCMatrixBlockIter&); 00352 void process_spec_rect(SCMatrixRectBlock*); 00353 void process_spec_ltri(SCMatrixLTriBlock*); 00354 void process_spec_rectsub(SCMatrixRectSubBlock*); 00355 void process_spec_ltrisub(SCMatrixLTriSubBlock*); 00356 00357 bool cloneable(); 00358 Ref<SCElementOp> clone(); 00359 00360 int has_side_effects(); 00361 }; 00362 00363 class OneBody3IntOp: public SCElementOp3 { 00364 private: 00365 Ref<OneBodyIntIter> iter; 00366 00367 public: 00368 OneBody3IntOp(const Ref<OneBodyInt>&b); 00369 OneBody3IntOp(const Ref<OneBodyIntIter>&); 00370 virtual ~OneBody3IntOp(); 00371 00372 void process(SCMatrixBlockIter&, 00373 SCMatrixBlockIter&, 00374 SCMatrixBlockIter&); 00375 void process_spec_rect(SCMatrixRectBlock*, 00376 SCMatrixRectBlock*, 00377 SCMatrixRectBlock*); 00378 void process_spec_ltri(SCMatrixLTriBlock*, 00379 SCMatrixLTriBlock*, 00380 SCMatrixLTriBlock*); 00381 00382 int has_side_effects(); 00383 int has_side_effects_in_arg1(); 00384 int has_side_effects_in_arg2(); 00385 00386 }; 00387 00388 // ////////////////////////////////////////////////////////////////////////// 00389 00392 class OneBodyDerivInt : public RefCount { 00393 protected: 00394 // this is who created me 00395 Integral *integral_; 00396 00397 Ref<GaussianBasisSet> bs1; 00398 Ref<GaussianBasisSet> bs2; 00399 00400 double *buffer_; 00401 00402 public: 00403 OneBodyDerivInt(Integral *, const Ref<GaussianBasisSet>&b); 00404 OneBodyDerivInt(Integral *, 00405 const Ref<GaussianBasisSet>&b1, 00406 const Ref<GaussianBasisSet>&b2); 00407 virtual ~OneBodyDerivInt(); 00408 00410 int nbasis() const; 00412 int nbasis1() const; 00414 int nbasis2() const; 00415 00417 int nshell() const; 00419 int nshell1() const; 00421 int nshell2() const; 00422 00424 Ref<GaussianBasisSet> basis(); 00426 Ref<GaussianBasisSet> basis1(); 00428 Ref<GaussianBasisSet> basis2(); 00429 00432 const double * buffer() const; 00433 00436 virtual void compute_shell(int ish, int jsh, DerivCenters&) = 0; 00439 virtual void compute_shell(int ish, int jsh, int center) = 0; 00440 00443 virtual void reinitialize(); 00444 00446 Integral *integral() const { return integral_; } 00447 }; 00448 00449 // ////////////////////////////////////////////////////////////////////////// 00450 00453 class OneBodyOneCenterDerivInt : public RefCount { 00454 protected: 00455 // this is who created me 00456 Integral *integral_; 00457 00458 Ref<GaussianBasisSet> bs1; 00459 00460 double *buffer_; 00461 00462 public: 00463 OneBodyOneCenterDerivInt(Integral *, const Ref<GaussianBasisSet>&b); 00464 virtual ~OneBodyOneCenterDerivInt(); 00465 00467 int nbasis() const; 00469 int nbasis1() const; 00470 00472 int nshell() const; 00474 int nshell1() const; 00475 00477 Ref<GaussianBasisSet> basis(); 00479 Ref<GaussianBasisSet> basis1(); 00480 00483 const double * buffer() const; 00484 00487 virtual void compute_shell(int ish, DerivCenters&) = 0; 00490 virtual void compute_shell(int ish, int center) = 0; 00491 00494 virtual void reinitialize(); 00495 00497 Integral *integral() const { return integral_; } 00498 }; 00499 00500 } 00501 00502 #endif 00503 00504 // Local Variables: 00505 // mode: c++ 00506 // c-file-style: "ETS" 00507 // End: