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_basis_obint_h
00029 #define _chemistry_qc_basis_obint_h
00030
00031 #ifdef __GNUC__
00032 #pragma interface
00033 #endif
00034
00035 #include <util/ref/ref.h>
00036 #include <util/state/state.h>
00037 #include <math/scmat/matrix.h>
00038 #include <math/scmat/elemop.h>
00039
00040 #include <chemistry/qc/basis/gaussbas.h>
00041 #include <chemistry/qc/basis/dercent.h>
00042
00043 namespace sc {
00044
00045 class Integral;
00046
00047
00048
00049 class EfieldDotVectorData: public RefCount
00050 {
00051 public:
00052 EfieldDotVectorData() {};
00053 ~EfieldDotVectorData();
00054
00055 double position[3];
00056 double vector[3];
00057
00058 void set_position(double*);
00059 void set_vector(double*);
00060 };
00061
00062
00063 class DipoleData: public RefCount
00064 {
00065 public:
00066 double origin[3];
00067
00068 DipoleData(double *d) {origin[0]=d[0]; origin[1]=d[1]; origin[2]=d[2];}
00069 DipoleData() {origin[0]=origin[1]=origin[2]=0.0;}
00070 ~DipoleData();
00071 void set_origin(double*);
00072 };
00073
00074
00075 class PointChargeData: public RefCount
00076 {
00077 private:
00078 int ncharges_;
00079 const double *charges_;
00080 const double *const*positions_;
00081 double *alloced_charges_;
00082 double **alloced_positions_;
00083
00084 public:
00085
00086
00087 PointChargeData(int ncharge,
00088 const double *const*positions, const double *charges,
00089 int copy_data = 0);
00090 ~PointChargeData();
00091
00092 int ncharges() const { return ncharges_; }
00093 const double *charges() const { return charges_; }
00094 const double *const*positions() const { return positions_; }
00095 };
00096
00097
00100 class OneBodyInt : public RefCount {
00101 protected:
00102
00103 Integral *integral_;
00104
00105 Ref<GaussianBasisSet> bs1_;
00106 Ref<GaussianBasisSet> bs2_;
00107
00108 double *buffer_;
00109
00110 OneBodyInt(Integral *integral,
00111 const Ref<GaussianBasisSet>&b1,
00112 const Ref<GaussianBasisSet>&b2 = 0);
00113
00114 public:
00115 virtual ~OneBodyInt();
00116
00118 int nbasis() const;
00119
00121 int nbasis1() const;
00123 int nbasis2() const;
00124
00126 int nshell() const;
00127
00129 int nshell1() const;
00131 int nshell2() const;
00132
00134 Ref<GaussianBasisSet> basis();
00135
00137 Ref<GaussianBasisSet> basis1();
00139 Ref<GaussianBasisSet> basis2();
00140
00142 const double * buffer() const;
00143
00146 virtual void compute_shell(int,int) = 0;
00147
00151 std::pair<const double *,unsigned long[2]> compute_shell_array(int,int);
00152
00155 virtual void reinitialize();
00156
00159 virtual bool cloneable();
00160
00163 virtual Ref<OneBodyInt> clone();
00164
00165 Integral *integral() const { return integral_; }
00166 };
00167
00168
00169
00172 class OneBodyOneCenterInt : public RefCount {
00173 protected:
00174
00175 Integral *integral_;
00176
00177 Ref<GaussianBasisSet> bs1_;
00178
00179 double *buffer_;
00180
00181 OneBodyOneCenterInt(Integral *integral,
00182 const Ref<GaussianBasisSet>&b1);
00183
00184 public:
00185 virtual ~OneBodyOneCenterInt();
00186
00188 int nbasis() const;
00189
00191 int nbasis1() const;
00192
00194 int nshell() const;
00195
00197 int nshell1() const;
00198
00200 Ref<GaussianBasisSet> basis();
00201
00203 Ref<GaussianBasisSet> basis1();
00204
00206 const double * buffer() const;
00207
00210 virtual void compute_shell(int) = 0;
00211
00214 virtual void reinitialize();
00215
00218 virtual bool cloneable();
00219
00222 virtual Ref<OneBodyOneCenterInt> clone();
00223
00224 Integral *integral() const { return integral_; }
00225 };
00226
00227
00228
00229 class OneBodyOneCenterWrapper : public OneBodyOneCenterInt {
00230 Ref<OneBodyInt> ob_;
00231 int jsh_;
00232 public:
00233 OneBodyOneCenterWrapper(const Ref<OneBodyInt>& ob,
00234 int sh2 = 0);
00235 void compute_shell(int);
00236 };
00237
00238
00239
00240 class ShellPairIter {
00241 private:
00242 const double * buf;
00243 double scale_;
00244
00245 int e12;
00246
00247 int index;
00248
00249 int ioffset;
00250 int joffset;
00251
00252 int iend;
00253 int jend;
00254
00255 int icur;
00256 int jcur;
00257
00258 public:
00259 ShellPairIter();
00260 ~ShellPairIter();
00261
00262 void init(const double * buffer, int ishell, int jshell,
00263 int ioff, int joff, int nfunci, int nfuncj, int redund=0,
00264 double scale=1.0);
00265
00266 void start() { icur=jcur=index=0; }
00267 int ready() const { return (icur < iend); }
00268
00269 void next() {
00270 if (jcur < ((e12)?(icur):((jend)-1))) {
00271 index++;
00272 jcur++;
00273 return;
00274 }
00275
00276 jcur=0;
00277 icur++;
00278
00279 index = icur*jend;
00280 }
00281
00282 int current_i() const { return icur; }
00283 int current_j() const { return jcur; }
00284
00285 int i() const { return icur+ioffset; }
00286 int j() const { return jcur+joffset; }
00287
00288 int nint() const { return iend*jend; }
00289
00290 double val() const { return buf[index]*scale_; }
00291 };
00292
00293
00294
00295 class OneBodyIntIter : public RefCount {
00296 protected:
00297 Ref<OneBodyInt> obi;
00298 ShellPairIter spi;
00299
00300 int redund;
00301
00302 int istart;
00303 int jstart;
00304
00305 int iend;
00306 int jend;
00307
00308 int icur;
00309 int jcur;
00310
00311 int ij;
00312
00313 public:
00314 OneBodyIntIter();
00315 OneBodyIntIter(const Ref<OneBodyInt>&);
00316 virtual ~OneBodyIntIter();
00317
00318 virtual void start(int ist=0, int jst=0, int ien=0, int jen=0);
00319 virtual void next();
00320
00321 int ready() const { return (icur < iend); }
00322
00323 int ishell() const { return icur; }
00324 int jshell() const { return jcur; }
00325
00326 int ijshell() const { return ij; }
00327
00328 int redundant() const { return redund; }
00329 void set_redundant(int i) { redund=i; }
00330
00331 virtual double scale() const;
00332
00333 Ref<OneBodyInt> one_body_int() { return obi; }
00334
00335 ShellPairIter& current_pair();
00336
00337 virtual bool cloneable();
00338 virtual Ref<OneBodyIntIter> clone();
00339 };
00340
00341
00342
00343
00344
00345 class OneBodyIntOp: public SCElementOp {
00346 protected:
00347 Ref<OneBodyIntIter> iter;
00348
00349 public:
00350 OneBodyIntOp(const Ref<OneBodyInt>&);
00351 OneBodyIntOp(const Ref<OneBodyIntIter>&);
00352 virtual ~OneBodyIntOp();
00353
00354 void process(SCMatrixBlockIter&);
00355 void process_spec_rect(SCMatrixRectBlock*);
00356 void process_spec_ltri(SCMatrixLTriBlock*);
00357 void process_spec_rectsub(SCMatrixRectSubBlock*);
00358 void process_spec_ltrisub(SCMatrixLTriSubBlock*);
00359
00360 bool cloneable();
00361 Ref<SCElementOp> clone();
00362
00363 int has_side_effects();
00364 };
00365
00366 class OneBody3IntOp: public SCElementOp3 {
00367 private:
00368 Ref<OneBodyIntIter> iter;
00369
00370 public:
00371 OneBody3IntOp(const Ref<OneBodyInt>&b);
00372 OneBody3IntOp(const Ref<OneBodyIntIter>&);
00373 virtual ~OneBody3IntOp();
00374
00375 void process(SCMatrixBlockIter&,
00376 SCMatrixBlockIter&,
00377 SCMatrixBlockIter&);
00378 void process_spec_rect(SCMatrixRectBlock*,
00379 SCMatrixRectBlock*,
00380 SCMatrixRectBlock*);
00381 void process_spec_ltri(SCMatrixLTriBlock*,
00382 SCMatrixLTriBlock*,
00383 SCMatrixLTriBlock*);
00384
00385 int has_side_effects();
00386 int has_side_effects_in_arg1();
00387 int has_side_effects_in_arg2();
00388
00389 };
00390
00391
00392
00395 class OneBodyDerivInt : public RefCount {
00396 protected:
00397
00398 Integral *integral_;
00399
00400 Ref<GaussianBasisSet> bs1;
00401 Ref<GaussianBasisSet> bs2;
00402
00403 double *buffer_;
00404
00405 public:
00406 OneBodyDerivInt(Integral *, const Ref<GaussianBasisSet>&b);
00407 OneBodyDerivInt(Integral *,
00408 const Ref<GaussianBasisSet>&b1,
00409 const Ref<GaussianBasisSet>&b2);
00410 virtual ~OneBodyDerivInt();
00411
00413 int nbasis() const;
00415 int nbasis1() const;
00417 int nbasis2() const;
00418
00420 int nshell() const;
00422 int nshell1() const;
00424 int nshell2() const;
00425
00427 Ref<GaussianBasisSet> basis();
00429 Ref<GaussianBasisSet> basis1();
00431 Ref<GaussianBasisSet> basis2();
00432
00435 const double * buffer() const;
00436
00439 virtual void compute_shell(int ish, int jsh, DerivCenters&) = 0;
00442 virtual void compute_shell(int ish, int jsh, int center) = 0;
00443 };
00444
00445
00446
00449 class OneBodyOneCenterDerivInt : public RefCount {
00450 protected:
00451
00452 Integral *integral_;
00453
00454 Ref<GaussianBasisSet> bs1;
00455
00456 double *buffer_;
00457
00458 public:
00459 OneBodyOneCenterDerivInt(Integral *, const Ref<GaussianBasisSet>&b);
00460 virtual ~OneBodyOneCenterDerivInt();
00461
00463 int nbasis() const;
00465 int nbasis1() const;
00466
00468 int nshell() const;
00470 int nshell1() const;
00471
00473 Ref<GaussianBasisSet> basis();
00475 Ref<GaussianBasisSet> basis1();
00476
00479 const double * buffer() const;
00480
00483 virtual void compute_shell(int ish, DerivCenters&) = 0;
00486 virtual void compute_shell(int ish, int center) = 0;
00487 };
00488
00489 }
00490
00491 #endif
00492
00493
00494
00495
00496