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 #ifndef _chemistry_qc_intv3_int2e_h
00033 #define _chemistry_qc_intv3_int2e_h
00034
00035 #include <limits.h>
00036
00037 #include <util/ref/ref.h>
00038 #include <chemistry/qc/basis/basis.h>
00039 #include <chemistry/qc/oint3/build.h>
00040 #include <chemistry/qc/intv3/fjt.h>
00041 #include <chemistry/qc/intv3/types.h>
00042 #include <chemistry/qc/intv3/storage.h>
00043 #include <chemistry/qc/intv3/array.h>
00044 #include <chemistry/qc/intv3/macros.h>
00045
00046 class Integral;
00047
00048 #define CHECK_INTEGRAL_ALGORITHM 0
00049
00053 class Int2eV3: public RefCount {
00054 protected:
00055 Integral *integral_;
00056
00057 BuildIntV3 build;
00058 Ref<IntegralStorer> storer;
00059
00060 Ref<GaussianBasisSet> bs1_;
00061 Ref<GaussianBasisSet> bs2_;
00062 Ref<GaussianBasisSet> bs3_;
00063 Ref<GaussianBasisSet> bs4_;
00064
00065 Ref<MessageGrp> grp_;
00066
00067 int bs1_shell_offset_;
00068 int bs2_shell_offset_;
00069 int bs3_shell_offset_;
00070 int bs4_shell_offset_;
00071 int bs1_func_offset_;
00072 int bs2_func_offset_;
00073 int bs3_func_offset_;
00074 int bs4_func_offset_;
00075 int bs1_prim_offset_;
00076 int bs2_prim_offset_;
00077 int bs3_prim_offset_;
00078 int bs4_prim_offset_;
00079
00080
00081 public:
00082 enum { STORAGE_CHUNK = 4096 };
00083 protected:
00084 struct store_list {
00085 void* data[STORAGE_CHUNK];
00086 struct store_list* p;
00087 };
00088 typedef struct store_list store_list_t;
00089 int n_store_last;
00090 store_list_t* store;
00091 typedef int (BuildIntV3::*intfunc)();
00092 intfunc build_routine[4][4][4][4][2];
00093
00094 int osh1, osh2, osh3, osh4;
00095
00096 int opr1, opr2, opr3, opr4;
00097
00098 int saved_am12,saved_am34,saved_ncon;
00099
00100 IntV3Arrayint3 contract_length;
00101
00102
00103 protected:
00104
00105 int g1,g2,g3,g4;
00106
00107 double AmB[3];
00108
00109 double CmD[3];
00110 int eAB;
00111 double *buf34;
00112 double *buf12;
00113 double *bufshared;
00114
00115 int redundant_;
00116 int permute_;
00117
00118 protected:
00119 Ref<FJT> fjt_;
00120
00121 int *int_shell_to_prim;
00122 IntV3Arraydouble2 int_shell_r;
00123 IntV3Arraydouble2 int_prim_zeta;
00124 IntV3Arraydouble2 int_prim_k;
00125 IntV3Arraydouble2 int_prim_oo2zeta;
00126 IntV3Arraydouble3 int_prim_p;
00127
00128 double *int_buffer;
00129 double *int_derint_buffer;
00130
00131 Ref<GaussianBasisSet> int_cs1;
00132 Ref<GaussianBasisSet> int_cs2;
00133 Ref<GaussianBasisSet> int_cs3;
00134 Ref<GaussianBasisSet> int_cs4;
00135
00136 GaussianShell *int_shell1;
00137 GaussianShell *int_shell2;
00138 GaussianShell *int_shell3;
00139 GaussianShell *int_shell4;
00140
00141 IntV3Arraydoublep2 ****e0f0_con_ints_array;
00142
00143 int int_expweight1;
00144 int int_expweight2;
00145 int int_expweight3;
00146 int int_expweight4;
00147
00148
00149
00150
00151
00152
00153
00154 int int_unit2;
00155 int int_unit4;
00156 GaussianShell* int_unit_shell;
00157
00158 int int_integral_storage;
00159 int int_store1;
00160 int int_store2;
00161 int int_derivative_bounds;
00162
00163
00164 protected:
00165 void add_store(void *p);
00166 void free_store();
00167 void _free_store(store_list_t* s, int n);
00168 void build_not_using_gcs(int nc1, int nc2, int nc3, int nc4,
00169 int minam1, int minam3, int maxam12, int maxam34,
00170 int dam1, int dam2, int dam3, int dam4, int eAB);
00171 void build_using_gcs(int nc1, int nc2, int nc3, int nc4,
00172 int minam1, int minam3, int maxam12, int maxam34,
00173 int dam1, int dam2, int dam3, int dam4, int eAB);
00174 void gen_prim_intermediates(int pr1, int pr2, int pr3, int pr4, int am);
00175 void gen_prim_intermediates_with_norm(int pr1, int pr2, int pr3, int pr4,
00176 int am, double norm);
00177 void gen_shell_intermediates(int sh1, int sh2, int sh3, int sh4);
00178 void blockbuildprim(int minam1, int maxam12, int minam3, int maxam34);
00179 void blockbuildprim_1(int am12min, int am12max, int am34, int m);
00180 void blockbuildprim_3(int am34min, int am34max, int m);
00181
00182
00183 protected:
00184 void int_init_buildgc(int order,
00185 int am1, int am2, int am3, int am4,
00186 int nc1, int nc2, int nc3, int nc4);
00187 void int_done_buildgc();
00188 void int_buildgcam(int minam1, int minam2, int minam3, int minam4,
00189 int maxam1, int maxam2, int maxam3, int maxam4,
00190 int dam1, int dam2, int dam3, int dam4,
00191 int sh1, int sh2, int sh3, int sh4,
00192 int eAB);
00193
00194
00195 protected:
00196 void int_offset_print(std::ostream &,
00197 double *buffer,
00198 Ref<GaussianBasisSet> c1, int s1,
00199 Ref<GaussianBasisSet> c2, int s2,
00200 Ref<GaussianBasisSet> c3, int s3,
00201 Ref<GaussianBasisSet> c4, int s4);
00202 void int_offset_print_n(std::ostream &, double *buffer,
00203 int n1, int n2, int n3, int n4,
00204 int o1, int o2, int o3, int o4,
00205 int e12, int e13e24, int e34);
00206 void int_print(std::ostream &, double *buffer,
00207 Ref<GaussianBasisSet> c1, int s1,
00208 Ref<GaussianBasisSet> c2, int s2,
00209 Ref<GaussianBasisSet> c3, int s3,
00210 Ref<GaussianBasisSet> c4, int s4);
00211 void int_print_n(std::ostream &, double *buffer,
00212 int n1, int n2, int n3, int n4,
00213 int e12, int e13e24, int e34);
00214 void int_print_intermediates(std::ostream &);
00215
00216
00217 protected:
00218 void shiftam_12(double *I0100, double *I1000, double *I0000,
00219 int am1, int am2, int am3, int am4);
00220 void shiftam_12eAB(double *I0100, double *I1000, double *I0000,
00221 int am1, int am2, int am3, int am4);
00222 void shiftam_34(double *I0001, double *I0010, double *I0000,
00223 int am1, int am2, int am3, int am4);
00224
00225
00226 protected:
00227 void int_init_shiftgc(int order, int am1, int am2, int am3, int am4);
00228 void int_done_shiftgc();
00229 double *int_shiftgcam(int gc1, int gc2, int gc3, int gc4,
00230 int tam1, int tam2, int tam3, int tam4, int peAB);
00231
00232
00233 protected:
00234 void alloc_inter(int nprim,int nshell);
00235 void compute_shell_1(Ref<GaussianBasisSet> cs, int, int);
00236 void compute_prim_1(Ref<GaussianBasisSet> cs1);
00237 void compute_shell_2(Ref<GaussianBasisSet> cs1,Ref<GaussianBasisSet> cs2);
00238 void compute_prim_2(Ref<GaussianBasisSet> cs1,Ref<GaussianBasisSet> cs2);
00239
00240
00241
00242 protected:
00243 double *int_initialize_erep(int storage, int order,
00244 const Ref<GaussianBasisSet> &cs1,
00245 const Ref<GaussianBasisSet> &cs2,
00246 const Ref<GaussianBasisSet> &cs3,
00247 const Ref<GaussianBasisSet> &cs4);
00248 void int_done_erep();
00249
00250
00251 protected:
00252 double *source;
00253 double *target;
00254 double *scratch;
00255 int nsourcemax;
00256
00257 void transform_init();
00258 void transform_done();
00259 void source_space(int nsource);
00260 void copy_to_source(double *integrals, int nsource);
00261 void do_gencon_sparse_transform_2e(Integral*integ,
00262 double *integrals, double *target,
00263 int index,
00264 GaussianShell *sh1, GaussianShell *sh2,
00265 GaussianShell *sh3, GaussianShell *sh4);
00266
00267
00268 void transform_2e_slow(Integral *,
00269 double *integrals, double *target,
00270 GaussianShell *sh1, GaussianShell *sh2,
00271 GaussianShell *sh3, GaussianShell *sh4);
00272 void transform_2e(Integral *,
00273 double *integrals, double *target,
00274 GaussianShell *sh1, GaussianShell *sh2,
00275 GaussianShell *sh3, GaussianShell *sh4);
00276
00277
00278 protected:
00279 void compute_erep(int flags, int *psh1, int *psh2, int *psh3, int *psh4,
00280 int dam1, int dam2, int dam3, int dam4);
00281 void compute_erep_1der(int flags, double *buffer,
00282 int *psh1, int *psh2, int *psh3, int *psh4,
00283 int dercenter);
00284 void nonredundant_erep(double *buffer, int e12, int e34, int e13e24,
00285 int n1, int n2, int n3, int n4,
00286 int *red_off, int *nonred_off);
00287 void compute_erep_bound1der(int flags, double *buffer,
00288 int *psh1, int *psh2, int *psh3, int *psh4);
00289
00290
00291 protected:
00292 void int_erep_bound1der(int flags, int bsh1, int bsh2, int *size);
00293
00294
00295
00296 protected:
00297 typedef signed char int_bound_t;
00298 enum { int_bound_min = SCHAR_MIN, int_bound_max = SCHAR_MAX };
00299 int_bound_t int_Q;
00300 int_bound_t int_R;
00301 int_bound_t *int_Qvec;
00302 int_bound_t *int_Rvec;
00303
00304
00305 protected:
00306 void int_init_bounds_nocomp();
00307 void int_init_bounds_1der_nocomp();
00308 void int_bounds_comp(int s1, int s2);
00309 void int_bounds_1der_comp(int s1, int s2);
00310 int int_erep_2bound(int s1, int s2);
00311 int int_erep_0bound_1der();
00312 int int_erep_2bound_1der(int s1, int s2);
00313
00314
00315 protected:
00316 void compute_bounds(int_bound_t *overall, int_bound_t *vec, int flag);
00317 void compute_bounds_shell(int_bound_t *overall, int_bound_t *vec,
00318 int flag, int sh1, int sh2);
00319
00320
00321 protected:
00322 int int_have_stored_integral(int sh1,int sh2,int sh3,int sh4,
00323 int p12,int p34,int p13p24);
00324 void int_store_integral(int sh1,int sh2,int sh3,int sh4,
00325 int p12,int p34,int p13p24,
00326 int size);
00327
00328
00329 protected:
00330 void int_initialize_offsets2();
00331 void int_done_offsets2();
00332
00333
00334 protected:
00335 void make_int_unit_shell();
00336 void delete_int_unit_shell();
00337
00338 protected:
00339
00340 int used_storage_;
00341 int used_storage_build_;
00342 int used_storage_shift_;
00343
00344 public:
00345 Int2eV3(Integral *,
00346 const Ref<GaussianBasisSet>&,
00347 const Ref<GaussianBasisSet>&,
00348 const Ref<GaussianBasisSet>&,
00349 const Ref<GaussianBasisSet>&,
00350 int order, int storage);
00351 ~Int2eV3();
00352
00353
00354 void init_storage(int size);
00355 void done_storage();
00356
00357
00358 int storage_used() { return used_storage_; }
00359
00360
00361 void init_bounds();
00362 void init_bounds_1der();
00363 void done_bounds();
00364 void done_bounds_1der();
00365
00366
00367
00368
00369
00370 static double logbound_to_bound(int);
00371 static int bound_to_logbound(double value);
00372
00373
00374
00375
00376 int redundant() { return redundant_; }
00377 void set_redundant(int i) { redundant_ = i; }
00378
00379
00380
00381 int permute() { return permute_; }
00382 void set_permute(int i) { permute_ = i; }
00383
00384 int used_storage() const { return used_storage_; }
00385
00386
00387 void erep(int &psh1, int &psh2, int &psh3, int &psh4);
00388 void erep(int *shells, int *sizes);
00389 void erep_all1der(int &psh1, int &psh2, int &psh3, int &psh4,
00390 der_centersv3_t *der_centers);
00391 void erep_all1der(int *shells, int *sizes,
00392 der_centersv3_t *dercenters);
00393
00394
00395 void erep_2center(int &psh1, int &psh2);
00396 void erep_2center(int *shells, int *sizes);
00397 void erep_3center(int &psh1, int &psh2, int &psh3);
00398 void erep_3center(int *shells, int *sizes);
00399
00400
00401 int erep_4bound(int s1, int s2, int s3, int s4);
00402 int erep_4bound_1der(int s1, int s2, int s3, int s4);
00403
00404 double *buffer() { return int_buffer; }
00405
00406 Ref<GaussianBasisSet> basis()
00407 {
00408 if (bs1_==bs2_ && bs1_ == bs3_ && bs1_ == bs4_) return bs1_;
00409 return 0;
00410 }
00411 Ref<GaussianBasisSet> basis1() { return bs1_; }
00412 Ref<GaussianBasisSet> basis2() { return bs2_; }
00413 Ref<GaussianBasisSet> basis3() { return bs3_; }
00414 Ref<GaussianBasisSet> basis4() { return bs4_; }
00415
00416 Ref<GaussianBasisSet> cs1() const { return int_cs1; }
00417 Ref<GaussianBasisSet> cs2() const { return int_cs2; }
00418 Ref<GaussianBasisSet> cs3() const { return int_cs3; }
00419 Ref<GaussianBasisSet> cs4() const { return int_cs4; }
00420
00421 GaussianBasisSet * pcs1() const { return int_cs1.pointer(); }
00422 GaussianBasisSet * pcs2() const { return int_cs2.pointer(); }
00423 GaussianBasisSet * pcs3() const { return int_cs3.pointer(); }
00424 GaussianBasisSet * pcs4() const { return int_cs4.pointer(); }
00425 };
00426
00427
00428 #endif
00429
00430
00431
00432
00433