| [0b990d] | 1 | // | 
|---|
|  | 2 | // kinetic.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/math.h> | 
|---|
|  | 33 |  | 
|---|
|  | 34 | #include <chemistry/qc/cints/int1e.h> | 
|---|
|  | 35 | #include <chemistry/qc/cints/macros.h> | 
|---|
|  | 36 |  | 
|---|
|  | 37 | using namespace sc; | 
|---|
|  | 38 |  | 
|---|
|  | 39 | void Int1eCints::kinetic(int sh1, int sh2) | 
|---|
|  | 40 | { | 
|---|
|  | 41 | zero_buffers_(); | 
|---|
|  | 42 | compute_doublet_info_(sh1, sh2); | 
|---|
|  | 43 |  | 
|---|
|  | 44 | int maxam1 = int_shell1_->max_am(); | 
|---|
|  | 45 | int minam1 = int_shell1_->min_am(); | 
|---|
|  | 46 | int maxam2 = int_shell2_->max_am(); | 
|---|
|  | 47 | int minam2 = int_shell2_->min_am(); | 
|---|
|  | 48 |  | 
|---|
|  | 49 | if (maxam1 != minam1 || maxam2 != minam2) { | 
|---|
|  | 50 | // fail(); | 
|---|
|  | 51 | kinetic_full_general_(); | 
|---|
|  | 52 | } | 
|---|
|  | 53 | else { | 
|---|
|  | 54 | kinetic_full_general_(); | 
|---|
|  | 55 | } | 
|---|
|  | 56 | } | 
|---|
|  | 57 |  | 
|---|
|  | 58 |  | 
|---|
|  | 59 | void Int1eCints::kinetic_full_general_() | 
|---|
|  | 60 | { | 
|---|
|  | 61 | int maxam1 = int_shell1_->max_am(); | 
|---|
|  | 62 | int maxam2 = int_shell2_->max_am(); | 
|---|
|  | 63 |  | 
|---|
|  | 64 | /* See if need to transform to spherical harmonics */ | 
|---|
|  | 65 | bool need_cart2sph_transform = false; | 
|---|
|  | 66 | if (int_shell1_->has_pure() || | 
|---|
|  | 67 | int_shell2_->has_pure()) | 
|---|
|  | 68 | need_cart2sph_transform = true; | 
|---|
|  | 69 |  | 
|---|
|  | 70 | /* See if contraction quartets need to be resorted into a shell quartet */ | 
|---|
|  | 71 | bool need_sort_to_shell_doublet = false; | 
|---|
|  | 72 | int num_gen_shells = 0; | 
|---|
|  | 73 | if (int_shell1_->ncontraction() > 1) | 
|---|
|  | 74 | num_gen_shells++; | 
|---|
|  | 75 | if (int_shell2_->ncontraction() > 1) | 
|---|
|  | 76 | num_gen_shells++; | 
|---|
|  | 77 | if (maxam1 + maxam2 && num_gen_shells >= 1) | 
|---|
|  | 78 | need_sort_to_shell_doublet = true; | 
|---|
|  | 79 |  | 
|---|
|  | 80 | /* Determine where integrals need to go at each stage */ | 
|---|
|  | 81 | if (need_sort_to_shell_doublet) { | 
|---|
|  | 82 | prim_ints_ = cart_ints_; | 
|---|
|  | 83 | if (need_cart2sph_transform) | 
|---|
|  | 84 | contr_doublets_ = sphharm_ints_; | 
|---|
|  | 85 | else | 
|---|
|  | 86 | contr_doublets_ = cart_ints_; | 
|---|
|  | 87 | shell_doublet_ = target_ints_buffer_; | 
|---|
|  | 88 | } | 
|---|
|  | 89 | else { | 
|---|
|  | 90 | if (need_cart2sph_transform) { | 
|---|
|  | 91 | prim_ints_ = cart_ints_; | 
|---|
|  | 92 | contr_doublets_ = target_ints_buffer_; | 
|---|
|  | 93 | shell_doublet_ = target_ints_buffer_; | 
|---|
|  | 94 | } | 
|---|
|  | 95 | else { | 
|---|
|  | 96 | prim_ints_ = target_ints_buffer_; | 
|---|
|  | 97 | shell_doublet_ = target_ints_buffer_; | 
|---|
|  | 98 | } | 
|---|
|  | 99 | } | 
|---|
|  | 100 |  | 
|---|
|  | 101 | /* Begin loops over primitives. */ | 
|---|
|  | 102 | for (int p1=0; p1<int_shell1_->nprimitive(); p1++) { | 
|---|
|  | 103 | double a1 = int_shell1_->exponent(p1); | 
|---|
|  | 104 | for (int p2=0; p2<int_shell2_->nprimitive(); p2++) { | 
|---|
|  | 105 | double a2 = int_shell2_->exponent(p2); | 
|---|
|  | 106 |  | 
|---|
|  | 107 | double gamma = a1+a2; | 
|---|
|  | 108 | double oog = 1.0/gamma; | 
|---|
|  | 109 | double over_pf = exp(-a1*a2*doublet_info_.AB2*oog)*sqrt(M_PI*oog)*M_PI*oog; | 
|---|
|  | 110 |  | 
|---|
|  | 111 | double P[3], PA[3], PB[3], PC[3]; | 
|---|
|  | 112 | for(int xyz=0; xyz<3; xyz++) { | 
|---|
|  | 113 | P[xyz] = (a1*doublet_info_.A[xyz] + a2*doublet_info_.B[xyz])*oog; | 
|---|
|  | 114 | PA[xyz] = P[xyz] - doublet_info_.A[xyz]; | 
|---|
|  | 115 | PB[xyz] = P[xyz] - doublet_info_.B[xyz]; | 
|---|
|  | 116 | } | 
|---|
|  | 117 |  | 
|---|
|  | 118 | OI_OSrecurs_(OIX_,OIY_,OIZ_,PA,PB,gamma,maxam1+2,maxam2+2); | 
|---|
|  | 119 |  | 
|---|
|  | 120 | /*--- contract each buffer into appropriate location ---*/ | 
|---|
|  | 121 | double *ints_buf = prim_ints_; | 
|---|
|  | 122 | for (int gc1=0; gc1<int_shell1_->ncontraction(); gc1++) { | 
|---|
|  | 123 | double norm1 = int_shell1_->coefficient_unnorm(gc1,p1); | 
|---|
|  | 124 | int am1 = int_shell1_->am(gc1); | 
|---|
|  | 125 | for (int gc2=0; gc2<int_shell2_->ncontraction(); gc2++) { | 
|---|
|  | 126 | double norm2 = int_shell2_->coefficient_unnorm(gc2,p2); | 
|---|
|  | 127 | int am2 = int_shell2_->am(gc2); | 
|---|
|  | 128 | double total_pf = over_pf * norm1 * norm2; | 
|---|
|  | 129 |  | 
|---|
|  | 130 | int k1,l1,m1,k2,l2,m2; | 
|---|
|  | 131 | FOR_CART(k1,l1,m1,am1) | 
|---|
|  | 132 | FOR_CART(k2,l2,m2,am2) | 
|---|
|  | 133 | double x0 = OIX_[k1][k2]; | 
|---|
|  | 134 | double y0 = OIY_[l1][l2]; | 
|---|
|  | 135 | double z0 = OIZ_[m1][m2]; | 
|---|
|  | 136 | double tx = a2*(2*k2+1)*OIX_[k1][k2] - 2*a2*a2*OIX_[k1][k2+2]; | 
|---|
|  | 137 | if (k2 >= 2) | 
|---|
|  | 138 | tx -= 0.5*k2*(k2-1)*OIX_[k1][k2-2]; | 
|---|
|  | 139 | double ty = a2*(2*l2+1)*OIY_[l1][l2] - 2*a2*a2*OIY_[l1][l2+2]; | 
|---|
|  | 140 | if (l2 >= 2) | 
|---|
|  | 141 | ty -= 0.5*l2*(l2-1)*OIY_[l1][l2-2]; | 
|---|
|  | 142 | double tz = a2*(2*m2+1)*OIZ_[m1][m2] - 2*a2*a2*OIZ_[m1][m2+2]; | 
|---|
|  | 143 | if (m2 >= 2) | 
|---|
|  | 144 | tz -= 0.5*m2*(m2-1)*OIZ_[m1][m2-2]; | 
|---|
|  | 145 | *(ints_buf++) += total_pf*(tx*y0*z0 + x0*ty*z0 + x0*y0*tz); | 
|---|
|  | 146 | END_FOR_CART | 
|---|
|  | 147 | END_FOR_CART | 
|---|
|  | 148 |  | 
|---|
|  | 149 | } | 
|---|
|  | 150 | } | 
|---|
|  | 151 | } | 
|---|
|  | 152 | } | 
|---|
|  | 153 |  | 
|---|
|  | 154 | if (need_cart2sph_transform) | 
|---|
|  | 155 | transform_contrquartets_(prim_ints_,contr_doublets_); | 
|---|
|  | 156 |  | 
|---|
|  | 157 | if (need_sort_to_shell_doublet) | 
|---|
|  | 158 | sort_contrdoublets_to_shelldoublet_(contr_doublets_,shell_doublet_); | 
|---|
|  | 159 | } | 
|---|
|  | 160 |  | 
|---|
|  | 161 |  | 
|---|
|  | 162 | void Int1eCints::kinetic_sameam_general_() | 
|---|
|  | 163 | { | 
|---|
|  | 164 | int tam1 = int_shell1_->am(0); | 
|---|
|  | 165 | int tam2 = int_shell2_->am(0); | 
|---|
|  | 166 |  | 
|---|
|  | 167 | /* Begin loops over primitives. */ | 
|---|
|  | 168 | for (int p1=0; p1<int_shell1_->nprimitive(); p1++) { | 
|---|
|  | 169 | double a1 = int_shell1_->exponent(p1); | 
|---|
|  | 170 | for (int p2=0; p2<int_shell2_->nprimitive(); p2++) { | 
|---|
|  | 171 | double a2 = int_shell2_->exponent(p2); | 
|---|
|  | 172 |  | 
|---|
|  | 173 | double gamma = a1+a2; | 
|---|
|  | 174 | double oog = 1.0/gamma; | 
|---|
|  | 175 | double over_pf = exp(-a1*a2*doublet_info_.AB2*oog)*sqrt(M_PI*oog)*M_PI*oog; | 
|---|
|  | 176 |  | 
|---|
|  | 177 | double P[3], PA[3], PB[3], PC[3]; | 
|---|
|  | 178 | for(int xyz=0; xyz<3; xyz++) { | 
|---|
|  | 179 | P[xyz] = (a1*doublet_info_.A[xyz] + a2*doublet_info_.B[xyz])*oog; | 
|---|
|  | 180 | PA[xyz] = P[xyz] - doublet_info_.A[xyz]; | 
|---|
|  | 181 | PB[xyz] = P[xyz] - doublet_info_.B[xyz]; | 
|---|
|  | 182 | } | 
|---|
|  | 183 |  | 
|---|
|  | 184 | OI_OSrecurs_(OIX_,OIY_,OIZ_,PA,PB,gamma,tam1+2,tam2+2); | 
|---|
|  | 185 |  | 
|---|
|  | 186 | /*--- contract each buffer into appropriate location ---*/ | 
|---|
|  | 187 | double *ints_buf = cart_ints_; | 
|---|
|  | 188 | for (int gc1=0; gc1<int_shell1_->ncontraction(); gc1++) { | 
|---|
|  | 189 | double norm1 = int_shell1_->coefficient_unnorm(gc1,p1); | 
|---|
|  | 190 | for (int gc2=0; gc2<int_shell2_->ncontraction(); gc2++) { | 
|---|
|  | 191 | double norm2 = int_shell2_->coefficient_unnorm(gc2,p2); | 
|---|
|  | 192 | double total_pf = over_pf * norm1 * norm2; | 
|---|
|  | 193 |  | 
|---|
|  | 194 | int k1,l1,m1,k2,l2,m2; | 
|---|
|  | 195 | FOR_CART(k1,l1,m1,tam1) | 
|---|
|  | 196 | FOR_CART(k2,l2,m2,tam2) | 
|---|
|  | 197 | double x0 = OIX_[k1][k2]; | 
|---|
|  | 198 | double y0 = OIY_[l1][l2]; | 
|---|
|  | 199 | double z0 = OIZ_[m1][m2]; | 
|---|
|  | 200 | double tx = a2*(2*k2+1)*OIX_[k1][k2] - 2*a2*a2*OIX_[k1][k2+2]; | 
|---|
|  | 201 | if (k2 >= 2) | 
|---|
|  | 202 | tx -= 0.5*k2*(k2-1)*OIX_[k1][k2-2]; | 
|---|
|  | 203 | double ty = a2*(2*l2+1)*OIY_[l1][l2] - 2*a2*a2*OIY_[l1][l2+2]; | 
|---|
|  | 204 | if (l2 >= 2) | 
|---|
|  | 205 | ty -= 0.5*l2*(l2-1)*OIY_[l1][l2-2]; | 
|---|
|  | 206 | double tz = a2*(2*m2+1)*OIZ_[m1][m2] - 2*a2*a2*OIZ_[m1][m2+2]; | 
|---|
|  | 207 | if (m2 >= 2) | 
|---|
|  | 208 | tz -= 0.5*m2*(m2-1)*OIZ_[m1][m2-2]; | 
|---|
|  | 209 | *(ints_buf++) += total_pf*(tx*y0*z0 + x0*ty*z0 + x0*y0*tz); | 
|---|
|  | 210 | END_FOR_CART | 
|---|
|  | 211 | END_FOR_CART | 
|---|
|  | 212 |  | 
|---|
|  | 213 | } | 
|---|
|  | 214 | } | 
|---|
|  | 215 | } | 
|---|
|  | 216 | } | 
|---|
|  | 217 |  | 
|---|
|  | 218 | /*---------------------------------------------------------------------- | 
|---|
|  | 219 | transform to spherical harmonics and/or resort to the target ordering | 
|---|
|  | 220 | ----------------------------------------------------------------------*/ | 
|---|
|  | 221 |  | 
|---|
|  | 222 | /*--- sort to the target ordering ---*/ | 
|---|
|  | 223 | double *source_ints_buf = cart_ints_; | 
|---|
|  | 224 | double *target_ints_buf = target_ints_buffer_; | 
|---|
|  | 225 | int target_bf1_offset = 0; | 
|---|
|  | 226 | int target_bf2_offset = 0; | 
|---|
|  | 227 | int nbf2 = int_shell2_->nfunction(); | 
|---|
|  | 228 | for (int gc1=0; gc1<int_shell1_->ncontraction(); gc1++) { | 
|---|
|  | 229 | int tsize1 = INT_NCART_NN(tam1); | 
|---|
|  | 230 | for (int gc2=0; gc2<int_shell2_->ncontraction(); gc2++) { | 
|---|
|  | 231 | int tsize2 = INT_NCART_NN(tam2); | 
|---|
|  | 232 |  | 
|---|
|  | 233 | int k1,l1,m1,k2,l2,m2; | 
|---|
|  | 234 | int bf1 = 0; | 
|---|
|  | 235 | FOR_CART(k1,l1,m1,tam1) | 
|---|
|  | 236 | double *target_ints_buf = target_ints_buffer_ + (target_bf1_offset+bf1)*nbf2 + | 
|---|
|  | 237 | target_bf2_offset; | 
|---|
|  | 238 | FOR_CART(k2,l2,m2,tam2) | 
|---|
|  | 239 | *(target_ints_buf++) = *(source_ints_buf++); | 
|---|
|  | 240 | END_FOR_CART | 
|---|
|  | 241 | bf1++; | 
|---|
|  | 242 | END_FOR_CART | 
|---|
|  | 243 | target_bf2_offset += tsize2; | 
|---|
|  | 244 | } | 
|---|
|  | 245 | target_bf1_offset += tsize1; | 
|---|
|  | 246 | } | 
|---|
|  | 247 | } | 
|---|
|  | 248 |  | 
|---|
|  | 249 | ///////////////////////////////////////////////////////////////////////////// | 
|---|
|  | 250 |  | 
|---|
|  | 251 | // Local Variables: | 
|---|
|  | 252 | // mode: c++ | 
|---|
|  | 253 | // c-file-style: "CLJ" | 
|---|
|  | 254 | // End: | 
|---|