Main Page   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

int2e.h

00001 //
00002 // int2e.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 #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     // statics from vrr.cc
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     /* Offset shell numbers. */
00094     int osh1, osh2, osh3, osh4;
00095     /* Offset primitive numbers. */
00096     int opr1, opr2, opr3, opr4;
00097     /* Saved initialization parameters used to free data. */
00098     int saved_am12,saved_am34,saved_ncon;
00099     /* Stores the length of the inner loop for integral contraction. */
00100     IntV3Arrayint3 contract_length;
00101 
00102     // statics from hrr.cc
00103   protected:
00104     /* The general contraction numbers. */
00105     int g1,g2,g3,g4;
00106     /* A[] - B[] */
00107     double AmB[3];
00108     /* C[] - D[] */
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;  /* The contr. int. inter. */
00142 
00143     int int_expweight1; // For exponent weighted contractions.
00144     int int_expweight2; // For exponent weighted contractions.
00145     int int_expweight3; // For exponent weighted contractions.
00146     int int_expweight4; // For exponent weighted contractions.
00147 
00148     // These are used to compute two and three center electron repulsion
00149     // integrals.  int_unit2 is 1 if shell 2 is to have value one everywhere
00150     // and int_unit4 is 1 if shell4 is to be a unit function.  Otherwise,
00151     // they should be zero.
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     // locals from vrr.cc
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     // globals from vrr.cc
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     // globals from print2e.cc
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     // locals from hrr.cc
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     // globals from hrr.cc
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     // locals from init2e.cc
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     // globals from init2e.cc
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     // from tformv3.cc
00251   protected:
00252     double *source;
00253     double *target;
00254     double *scratch;
00255     int nsourcemax;
00256     // transform implementation functions:
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     // functions for general use outside of tformv3.cc:
00267     // integrals and target may overlap
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     // locals from comp2e.cc
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     // globals from comp2e.cc
00291   protected:
00292     void int_erep_bound1der(int flags, int bsh1, int bsh2, int *size);
00293 
00294 
00295     // global vars from bounds.h
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     // global routines from bounds.cc
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     // local routines from bounds.cc
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     // global routines from storage.cc
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     // from offsets.cc
00329   protected:
00330     void int_initialize_offsets2();
00331     void int_done_offsets2();
00332 
00333     // from comp2e3c.cc
00334   protected:
00335     void make_int_unit_shell();
00336     void delete_int_unit_shell();
00337 
00338   protected:
00339     // for intermediate storage:
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     // storage.cc: for the storage of integrals
00354     void init_storage(int size);
00355     void done_storage();
00356 
00357     // for intermediate storage
00358     int storage_used() { return used_storage_; }
00359 
00360     // bounds.cc
00361     void init_bounds();
00362     void init_bounds_1der();
00363     void done_bounds();
00364     void done_bounds_1der();
00365     // Covert a bound to/from the log of the bound (returns 2^bound)
00366     // replace:
00367     //double int_bound_to_double(int bound);
00368     //double int_bound_double(int value);
00369     //int int_bound_log(double value);
00370     static double logbound_to_bound(int);
00371     static int bound_to_logbound(double value);
00372 
00373     // If redundant is false the redundant integrals that arise
00374     // when a shell index is repeated are stored.
00375     // The default is true.
00376     int redundant() { return redundant_; }
00377     void set_redundant(int i) { redundant_ = i; }
00378 
00379     // If permute is true the routines are allowed to permute indices.
00380     // The default is false.
00381     int permute() { return permute_; }
00382     void set_permute(int i) { permute_ = i; }
00383 
00384     int used_storage() const { return used_storage_; }
00385 
00386     // from comp2e.cc
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     // from comp2e3c.cc
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     // from bounds.cc
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 // Local Variables:
00431 // mode: c++
00432 // c-file-style: "CLJ"
00433 // End:

Generated at Thu Oct 4 18:08:44 2001 for MPQC 2.0.0 using the documentation package Doxygen 1.2.5.