| 1 | // | 
|---|
| 2 | // primpairs.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 <util/misc/formio.h> | 
|---|
| 35 | #include <util/ref/ref.h> | 
|---|
| 36 | #include <chemistry/qc/basis/gaussshell.h> | 
|---|
| 37 | #include <chemistry/qc/basis/integral.h> | 
|---|
| 38 | #include <chemistry/qc/cints/primpairs.h> | 
|---|
| 39 |  | 
|---|
| 40 | using namespace std; | 
|---|
| 41 | using namespace sc; | 
|---|
| 42 |  | 
|---|
| 43 | inline int max(int a,int b) { return (a > b) ? a : b;} | 
|---|
| 44 | inline void fail() | 
|---|
| 45 | { | 
|---|
| 46 | ExEnv::errn() << scprintf("failing module:\n%s",__FILE__) << endl; | 
|---|
| 47 | abort(); | 
|---|
| 48 | } | 
|---|
| 49 |  | 
|---|
| 50 | PrimPairsCints::PrimPairsCints(const Ref<GaussianBasisSet>& bs1, | 
|---|
| 51 | const Ref<GaussianBasisSet>& bs2) | 
|---|
| 52 | { | 
|---|
| 53 | bs1_ = bs1; | 
|---|
| 54 | bs2_ = bs2; | 
|---|
| 55 | nprim1_ = bs1_->nprimitive(); | 
|---|
| 56 | nprim2_ = bs2_->nprimitive(); | 
|---|
| 57 | prim_pair_ = new prim_pair_t[nprim1_*nprim2_]; | 
|---|
| 58 |  | 
|---|
| 59 | int nshell1 = bs1_->nshell(); | 
|---|
| 60 | int nshell2 = bs2_->nshell(); | 
|---|
| 61 |  | 
|---|
| 62 | double A[3], B[3]; | 
|---|
| 63 | for(int s1=0; s1<nshell1; s1++) { | 
|---|
| 64 | GaussianShell& shell1 = bs1_->shell(s1); | 
|---|
| 65 | int np1 = shell1.nprimitive(); | 
|---|
| 66 | int p1_offset = bs1_->shell_to_primitive(s1); | 
|---|
| 67 |  | 
|---|
| 68 | for(int xyz=0; xyz<3; xyz++) | 
|---|
| 69 | A[xyz] = bs1_->molecule()->r(bs1_->shell_to_center(s1),xyz); | 
|---|
| 70 |  | 
|---|
| 71 | for(int s2=0; s2<nshell2; s2++) { | 
|---|
| 72 | GaussianShell& shell2 = bs2_->shell(s2); | 
|---|
| 73 | int np2 = shell2.nprimitive(); | 
|---|
| 74 | int p2_offset = bs2_->shell_to_primitive(s2); | 
|---|
| 75 |  | 
|---|
| 76 | for(int xyz=0; xyz<3; xyz++) | 
|---|
| 77 | B[xyz] = bs2_->molecule()->r(bs2_->shell_to_center(s2),xyz); | 
|---|
| 78 |  | 
|---|
| 79 | double AB2 = (A[0]-B[0])*(A[0]-B[0]) + | 
|---|
| 80 | (A[1]-B[1])*(A[1]-B[1]) + | 
|---|
| 81 | (A[2]-B[2])*(A[2]-B[2]); | 
|---|
| 82 |  | 
|---|
| 83 | /*--- compute primitive pair data ---*/ | 
|---|
| 84 | int p12_offset = nprim2_*p1_offset + p2_offset; | 
|---|
| 85 | prim_pair_t *row_offset = &(prim_pair_[p12_offset]); | 
|---|
| 86 | for(int p1=0; p1<np1; p1++, row_offset+=nprim2_) { | 
|---|
| 87 | prim_pair_t *pair_ptr = row_offset; | 
|---|
| 88 | for(int p2=0; p2<np2; p2++, pair_ptr++) { | 
|---|
| 89 | double exp1, exp2, gamma, oog, t; | 
|---|
| 90 | exp1 = shell1.exponent(p1); | 
|---|
| 91 | exp2 = shell2.exponent(p2); | 
|---|
| 92 | gamma = exp1 + exp2; | 
|---|
| 93 | oog = 1.0 / gamma; | 
|---|
| 94 | t = M_PI*oog; | 
|---|
| 95 |  | 
|---|
| 96 | pair_ptr->gamma = gamma; | 
|---|
| 97 | pair_ptr->ovlp = t*sqrt(t)*exp(-exp1*exp2*AB2*oog); | 
|---|
| 98 | for(int xyz=0; xyz<3; xyz++) | 
|---|
| 99 | pair_ptr->P[xyz] = (exp1*A[xyz] + exp2*B[xyz])*oog; | 
|---|
| 100 | } | 
|---|
| 101 | } | 
|---|
| 102 | } | 
|---|
| 103 | } | 
|---|
| 104 | } | 
|---|
| 105 |  | 
|---|
| 106 | PrimPairsCints::~PrimPairsCints() | 
|---|
| 107 | { | 
|---|
| 108 | delete[] prim_pair_; | 
|---|
| 109 | } | 
|---|
| 110 |  | 
|---|
| 111 | ///////////////////////////////////////////////////////////////////////////// | 
|---|
| 112 |  | 
|---|
| 113 | // Local Variables: | 
|---|
| 114 | // mode: c++ | 
|---|
| 115 | // c-file-style: "CLJ-CONDENSED" | 
|---|
| 116 | // End: | 
|---|