| 1 | //
 | 
|---|
| 2 | // int2e.cc
 | 
|---|
| 3 | //
 | 
|---|
| 4 | // Copyright (C) 2001 Edward Valeev
 | 
|---|
| 5 | //
 | 
|---|
| 6 | // Author: Edward Valeev <edward.valeev@chemistry.gatech.edu>
 | 
|---|
| 7 | // Maintainer: EV
 | 
|---|
| 8 | //
 | 
|---|
| 9 | // This file is part of the SC Toolkit.
 | 
|---|
| 10 | //
 | 
|---|
| 11 | // The SC Toolkit is free software; you can redistribute it and/or modify
 | 
|---|
| 12 | // it under the terms of the GNU Library General Public License as published by
 | 
|---|
| 13 | // the Free Software Foundation; either version 2, or (at your option)
 | 
|---|
| 14 | // any later version.
 | 
|---|
| 15 | //
 | 
|---|
| 16 | // The SC Toolkit is distributed in the hope that it will be useful,
 | 
|---|
| 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
|---|
| 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
|---|
| 19 | // GNU Library General Public License for more details.
 | 
|---|
| 20 | //
 | 
|---|
| 21 | // You should have received a copy of the GNU Library General Public License
 | 
|---|
| 22 | // along with the SC Toolkit; see the file COPYING.LIB.  If not, write to
 | 
|---|
| 23 | // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 | 
|---|
| 24 | //
 | 
|---|
| 25 | // The U.S. Government is granted a limited license as per AL 91-7.
 | 
|---|
| 26 | //
 | 
|---|
| 27 | 
 | 
|---|
| 28 | #ifdef __GNUG__
 | 
|---|
| 29 | #pragma implementation
 | 
|---|
| 30 | #endif
 | 
|---|
| 31 | 
 | 
|---|
| 32 | #include <util/misc/formio.h>
 | 
|---|
| 33 | #include <chemistry/qc/basis/integral.h>
 | 
|---|
| 34 | #include <chemistry/qc/cints/int2e.h>
 | 
|---|
| 35 | 
 | 
|---|
| 36 | using namespace std;
 | 
|---|
| 37 | using namespace sc;
 | 
|---|
| 38 | 
 | 
|---|
| 39 | inline int max(int a,int b) { return (a > b) ? a : b;}
 | 
|---|
| 40 | inline void fail()
 | 
|---|
| 41 | {
 | 
|---|
| 42 |   ExEnv::errn() << scprintf("failing module:\n%s",__FILE__) << endl;
 | 
|---|
| 43 |   abort();
 | 
|---|
| 44 | }
 | 
|---|
| 45 | 
 | 
|---|
| 46 | Int2eCints::Int2eCints(Integral *integral,
 | 
|---|
| 47 |                  const Ref<GaussianBasisSet>& b1,
 | 
|---|
| 48 |                  const Ref<GaussianBasisSet>& b2,
 | 
|---|
| 49 |                  const Ref<GaussianBasisSet>& b3,
 | 
|---|
| 50 |                  const Ref<GaussianBasisSet>& b4,
 | 
|---|
| 51 |                  size_t storage) :
 | 
|---|
| 52 |   integral_(integral),
 | 
|---|
| 53 |   grp_(integral->messagegrp()),
 | 
|---|
| 54 |   permute_(0)
 | 
|---|
| 55 | {
 | 
|---|
| 56 |   bs1_ = b1;
 | 
|---|
| 57 |   bs2_ = b2;
 | 
|---|
| 58 |   bs3_ = b3;
 | 
|---|
| 59 |   bs4_ = b4;
 | 
|---|
| 60 | 
 | 
|---|
| 61 |   if (bs2_.null()) bs2_ = bs1_;
 | 
|---|
| 62 |   if (bs3_.null()) bs3_ = bs2_;
 | 
|---|
| 63 |   if (bs4_.null()) bs4_ = bs3_;
 | 
|---|
| 64 | 
 | 
|---|
| 65 |   /*--- Initialize storage ---*/
 | 
|---|
| 66 |   init_storage(storage);
 | 
|---|
| 67 | 
 | 
|---|
| 68 |   /*--- allocate scratch for transformation ---*/
 | 
|---|
| 69 |   if (bs1_->has_pure() || bs2_->has_pure() || bs3_->has_pure() || bs4_->has_pure() ||
 | 
|---|
| 70 |       bs1_->max_ncontraction() != 1 || bs2_->max_ncontraction() != 1 ||
 | 
|---|
| 71 |       bs3_->max_ncontraction() != 1 || bs4_->max_ncontraction() != 1) {
 | 
|---|
| 72 |     // compute how much space one contraction quartet may need
 | 
|---|
| 73 |     int nshell1 = bs1_->nshell();
 | 
|---|
| 74 |     int maxncart1 = 0;
 | 
|---|
| 75 |     for(int sh1=0; sh1<nshell1;sh1++) {
 | 
|---|
| 76 |       int maxncart = bs1_->shell(sh1).max_cartesian();
 | 
|---|
| 77 |       if (maxncart > maxncart1) maxncart1 = maxncart;
 | 
|---|
| 78 |     }
 | 
|---|
| 79 |     int nshell2 = bs2_->nshell();
 | 
|---|
| 80 |     int maxncart2 = 0;
 | 
|---|
| 81 |     for(int sh2=0; sh2<nshell2;sh2++) {
 | 
|---|
| 82 |       int maxncart = bs2_->shell(sh2).max_cartesian();
 | 
|---|
| 83 |       if (maxncart > maxncart2) maxncart2 = maxncart;
 | 
|---|
| 84 |     }
 | 
|---|
| 85 |     int nshell3 = bs3_->nshell();
 | 
|---|
| 86 |     int maxncart3 = 0;
 | 
|---|
| 87 |     for(int sh3=0; sh3<nshell3;sh3++) {
 | 
|---|
| 88 |       int maxncart = bs3_->shell(sh3).max_cartesian();
 | 
|---|
| 89 |       if (maxncart > maxncart3) maxncart3 = maxncart;
 | 
|---|
| 90 |     }
 | 
|---|
| 91 |     int nshell4 = bs4_->nshell();
 | 
|---|
| 92 |     int maxncart4 = 0;
 | 
|---|
| 93 |     for(int sh4=0; sh4<nshell4;sh4++) {
 | 
|---|
| 94 |       int maxncart = bs4_->shell(sh4).max_cartesian();
 | 
|---|
| 95 |       if (maxncart > maxncart4) maxncart4 = maxncart;
 | 
|---|
| 96 |     }
 | 
|---|
| 97 |     tformbuf_ = new double[maxncart1*maxncart2*maxncart3*maxncart4];
 | 
|---|
| 98 |   }
 | 
|---|
| 99 |   else {
 | 
|---|
| 100 |     tformbuf_ = 0;
 | 
|---|
| 101 |   }
 | 
|---|
| 102 | }
 | 
|---|
| 103 | 
 | 
|---|
| 104 | 
 | 
|---|
| 105 | Int2eCints::~Int2eCints()
 | 
|---|
| 106 | { 
 | 
|---|
| 107 |   if (tformbuf_)
 | 
|---|
| 108 |     delete[] tformbuf_;
 | 
|---|
| 109 |   done_storage();
 | 
|---|
| 110 | }
 | 
|---|
| 111 | 
 | 
|---|
| 112 | size_t
 | 
|---|
| 113 | Int2eCints::storage_required_(const Ref<GaussianBasisSet>& b1,
 | 
|---|
| 114 |                              const Ref<GaussianBasisSet>& b2,
 | 
|---|
| 115 |                              const Ref<GaussianBasisSet>& b3,
 | 
|---|
| 116 |                              const Ref<GaussianBasisSet>& b4)
 | 
|---|
| 117 | {
 | 
|---|
| 118 |   size_t storage_required = 0;
 | 
|---|
| 119 |   
 | 
|---|
| 120 |   Ref<GaussianBasisSet> bs1 = b1;
 | 
|---|
| 121 |   Ref<GaussianBasisSet> bs2 = b2;
 | 
|---|
| 122 |   Ref<GaussianBasisSet> bs3 = b3;
 | 
|---|
| 123 |   Ref<GaussianBasisSet> bs4 = b4;
 | 
|---|
| 124 | 
 | 
|---|
| 125 |   if (bs2.null())
 | 
|---|
| 126 |     bs2 = bs1;
 | 
|---|
| 127 |   if (bs3.null())
 | 
|---|
| 128 |     bs3 = bs1;
 | 
|---|
| 129 |   if (bs4.null())
 | 
|---|
| 130 |     bs4 = bs1;
 | 
|---|
| 131 | 
 | 
|---|
| 132 |   if (bs1->has_pure() || bs2->has_pure() || bs3->has_pure() || bs4->has_pure() ||
 | 
|---|
| 133 |       bs1->max_ncontraction() != 1 || bs2->max_ncontraction() != 1 ||
 | 
|---|
| 134 |       bs3->max_ncontraction() != 1 || bs4->max_ncontraction() != 1) {
 | 
|---|
| 135 |     // compute how much space one contraction quartet may need
 | 
|---|
| 136 |     int nshell1 = bs1->nshell();
 | 
|---|
| 137 |     int maxncart1 = 0;
 | 
|---|
| 138 |     for(int sh1=0; sh1<nshell1;sh1++) {
 | 
|---|
| 139 |       int maxncart = bs1->shell(sh1).max_cartesian();
 | 
|---|
| 140 |       if (maxncart > maxncart1) maxncart1 = maxncart;
 | 
|---|
| 141 |     }
 | 
|---|
| 142 |     int nshell2 = bs2->nshell();
 | 
|---|
| 143 |     int maxncart2 = 0;
 | 
|---|
| 144 |     for(int sh2=0; sh2<nshell2;sh2++) {
 | 
|---|
| 145 |       int maxncart = bs2->shell(sh2).max_cartesian();
 | 
|---|
| 146 |       if (maxncart > maxncart2) maxncart2 = maxncart;
 | 
|---|
| 147 |     }
 | 
|---|
| 148 |     int nshell3 = bs3->nshell();
 | 
|---|
| 149 |     int maxncart3 = 0;
 | 
|---|
| 150 |     for(int sh3=0; sh3<nshell3;sh3++) {
 | 
|---|
| 151 |       int maxncart = bs3->shell(sh3).max_cartesian();
 | 
|---|
| 152 |       if (maxncart > maxncart3) maxncart3 = maxncart;
 | 
|---|
| 153 |     }
 | 
|---|
| 154 |     int nshell4 = bs4->nshell();
 | 
|---|
| 155 |     int maxncart4 = 0;
 | 
|---|
| 156 |     for(int sh4=0; sh4<nshell4;sh4++) {
 | 
|---|
| 157 |       int maxncart = bs4->shell(sh4).max_cartesian();
 | 
|---|
| 158 |       if (maxncart > maxncart4) maxncart4 = maxncart;
 | 
|---|
| 159 |     }
 | 
|---|
| 160 |     storage_required = maxncart1*maxncart2*maxncart3*maxncart4*sizeof(double);
 | 
|---|
| 161 |   }
 | 
|---|
| 162 |   else {
 | 
|---|
| 163 |     storage_required = 0;
 | 
|---|
| 164 |   }
 | 
|---|
| 165 | 
 | 
|---|
| 166 |   return storage_required;
 | 
|---|
| 167 | }
 | 
|---|
| 168 | 
 | 
|---|
| 169 | /////////////////////////////////////////////////////////////////////////////
 | 
|---|
| 170 | 
 | 
|---|
| 171 | // Local Variables:
 | 
|---|
| 172 | // mode: c++
 | 
|---|
| 173 | // c-file-style: "CLJ-CONDENSED"
 | 
|---|
| 174 | // End:
 | 
|---|