<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head><meta name="robots" content="noindex"> <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>lgbuild.h Source File</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body bgcolor="#ffffff"> <!-- Generated by Doxygen 1.2.5 on Mon Oct 14 14:16:37 2002 --> <center> <a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="pages.html">Related Pages</a> </center> <hr><h1>lgbuild.h</h1><div class="fragment"><pre>00001 <font class="comment">//</font> 00002 <font class="comment">// lgbuild.h --- definition of the local G matrix builder</font> 00003 <font class="comment">//</font> 00004 <font class="comment">// Copyright (C) 1996 Limit Point Systems, Inc.</font> 00005 <font class="comment">//</font> 00006 <font class="comment">// Author: Edward Seidl <seidl@janed.com></font> 00007 <font class="comment">// Maintainer: LPS</font> 00008 <font class="comment">//</font> 00009 <font class="comment">// This file is part of the SC Toolkit.</font> 00010 <font class="comment">//</font> 00011 <font class="comment">// The SC Toolkit is free software; you can redistribute it and/or modify</font> 00012 <font class="comment">// it under the terms of the GNU Library General Public License as published by</font> 00013 <font class="comment">// the Free Software Foundation; either version 2, or (at your option)</font> 00014 <font class="comment">// any later version.</font> 00015 <font class="comment">//</font> 00016 <font class="comment">// The SC Toolkit is distributed in the hope that it will be useful,</font> 00017 <font class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</font> 00018 <font class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</font> 00019 <font class="comment">// GNU Library General Public License for more details.</font> 00020 <font class="comment">//</font> 00021 <font class="comment">// You should have received a copy of the GNU Library General Public License</font> 00022 <font class="comment">// along with the SC Toolkit; see the file COPYING.LIB. If not, write to</font> 00023 <font class="comment">// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.</font> 00024 <font class="comment">//</font> 00025 <font class="comment">// The U.S. Government is granted a limited license as per AL 91-7.</font> 00026 <font class="comment">//</font> 00027 00028 <font class="preprocessor">#ifndef _chemistry_qc_scf_lgbuild_h</font> 00029 <font class="preprocessor"></font><font class="preprocessor">#define _chemistry_qc_scf_lgbuild_h</font> 00030 <font class="preprocessor"></font> 00031 <font class="preprocessor">#ifdef __GNUC__</font> 00032 <font class="preprocessor"></font><font class="preprocessor">#pragma interface</font> 00033 <font class="preprocessor"></font><font class="preprocessor">#endif</font> 00034 <font class="preprocessor"></font> 00035 <font class="preprocessor">#undef SCF_CHECK_INTS</font> 00036 <font class="preprocessor"></font><font class="preprocessor">#undef SCF_CHECK_BOUNDS</font> 00037 <font class="preprocessor"></font><font class="preprocessor">#undef SCF_DONT_USE_BOUNDS</font> 00038 <font class="preprocessor"></font> 00039 <font class="preprocessor">#include <chemistry/qc/scf/gbuild.h></font> 00040 00041 <font class="keyword">namespace </font>sc { 00042 00043 template<class T> 00044 <font class="keyword">class </font>LocalGBuild : <font class="keyword">public</font> GBuild<T> { 00045 <font class="keyword">public</font>: 00046 <font class="keywordtype">double</font> tnint; 00047 00048 <font class="keyword">protected</font>: 00049 MessageGrp *grp_; 00050 TwoBodyInt *tbi_; 00051 GaussianBasisSet *gbs_; 00052 PetiteList *rpl_; 00053 00054 <font class="keywordtype">signed</font> <font class="keywordtype">char</font> *pmax; 00055 <font class="keywordtype">int</font> threadno_; 00056 <font class="keywordtype">int</font> nthread_; 00057 <font class="keywordtype">double</font> accuracy_; 00058 00059 <font class="keyword">public</font>: 00060 LocalGBuild(T& t, <font class="keyword">const</font> Ref<TwoBodyInt>& tbi, <font class="keyword">const</font> Ref<PetiteList>& rpl, 00061 <font class="keyword">const</font> Ref<GaussianBasisSet>& bs, <font class="keyword">const</font> Ref<MessageGrp>& g, 00062 <font class="keywordtype">signed</font> <font class="keywordtype">char</font> *pm, <font class="keywordtype">double</font> acc, <font class="keywordtype">int</font> nt=1, <font class="keywordtype">int</font> tn=0) : 00063 GBuild<T>(t), 00064 pmax(pm), nthread_(nt), threadno_(tn), accuracy_(acc) 00065 { 00066 grp_ = g.pointer(); 00067 tbi_ = tbi.pointer(); 00068 rpl_ = rpl.pointer(); 00069 gbs_ = bs.pointer(); 00070 } 00071 ~LocalGBuild()<font class="keyword"> </font>{} 00072 00073 <font class="keywordtype">void</font> run()<font class="keyword"> </font>{ 00074 <font class="keywordtype">int</font> tol = (<font class="keywordtype">int</font>) (log(accuracy_)/log(2.0)); 00075 <font class="keywordtype">int</font> me=grp_->me(); 00076 <font class="keywordtype">int</font> nproc = grp_->n(); 00077 00078 <font class="comment">// grab references for speed</font> 00079 GaussianBasisSet& gbs = *gbs_; 00080 PetiteList& pl = *rpl_; 00081 TwoBodyInt& tbi = *tbi_; 00082 00083 tbi.set_redundant(0); 00084 <font class="keyword">const</font> <font class="keywordtype">double</font> *intbuf = tbi.buffer(); 00085 00086 tnint=0; 00087 sc_int_least64_t threadind=0; 00088 sc_int_least64_t ijklind=0; 00089 00090 <font class="keywordflow">for</font> (<font class="keywordtype">int</font> i=0; i < gbs.nshell(); i++) { 00091 <font class="keywordflow">if</font> (!pl.in_p1(i)) 00092 <font class="keywordflow">continue</font>; 00093 00094 <font class="keywordtype">int</font> fi=gbs.shell_to_function(i); 00095 <font class="keywordtype">int</font> ni=gbs(i).nfunction(); 00096 00097 <font class="keywordflow">for</font> (<font class="keywordtype">int</font> j=0; j <= i; j++) { 00098 <font class="keywordtype">int</font> oij = i_offset(i)+j; 00099 00100 <font class="keywordflow">if</font> (!pl.in_p2(oij)) 00101 <font class="keywordflow">continue</font>; 00102 00103 <font class="keywordtype">int</font> fj=gbs.shell_to_function(j); 00104 <font class="keywordtype">int</font> nj=gbs(j).nfunction(); 00105 <font class="keywordtype">int</font> pmaxij = pmax[oij]; 00106 00107 <font class="keywordflow">for</font> (<font class="keywordtype">int</font> k=0; k <= i; k++, ijklind++) { 00108 <font class="keywordflow">if</font> (ijklind%nproc != me) 00109 <font class="keywordflow">continue</font>; 00110 00111 threadind++; 00112 <font class="keywordflow">if</font> (threadind % nthread_ != threadno_) 00113 <font class="keywordflow">continue</font>; 00114 00115 <font class="keywordtype">int</font> fk=gbs.shell_to_function(k); 00116 <font class="keywordtype">int</font> nk=gbs(k).nfunction(); 00117 00118 <font class="keywordtype">int</font> pmaxijk=pmaxij, ptmp; 00119 <font class="keywordflow">if</font> ((ptmp=pmax[i_offset(i)+k]-1) > pmaxijk) pmaxijk=ptmp; 00120 <font class="keywordflow">if</font> ((ptmp=pmax[ij_offset(j,k)]-1) > pmaxijk) pmaxijk=ptmp; 00121 00122 <font class="keywordtype">int</font> okl = i_offset(k); 00123 <font class="keywordflow">for</font> (<font class="keywordtype">int</font> l=0; l <= (k==i?j:k); l++,okl++) { 00124 <font class="keywordtype">int</font> pmaxijkl = pmaxijk; 00125 <font class="keywordflow">if</font> ((ptmp=pmax[okl]) > pmaxijkl) pmaxijkl=ptmp; 00126 <font class="keywordflow">if</font> ((ptmp=pmax[i_offset(i)+l]-1) > pmaxijkl) pmaxijkl=ptmp; 00127 <font class="keywordflow">if</font> ((ptmp=pmax[ij_offset(j,l)]-1) > pmaxijkl) pmaxijkl=ptmp; 00128 00129 <font class="keywordtype">int</font> qijkl = pl.in_p4(oij,okl,i,j,k,l); 00130 <font class="keywordflow">if</font> (!qijkl) 00131 <font class="keywordflow">continue</font>; 00132 00133 <font class="preprocessor">#ifdef SCF_CHECK_BOUNDS</font> 00134 <font class="preprocessor"></font> <font class="keywordtype">double</font> intbound = pow(2.0,<font class="keywordtype">double</font>(tbi.log2_shell_bound(i,j,k,l))); 00135 <font class="keywordtype">double</font> pbound = pow(2.0,<font class="keywordtype">double</font>(pmaxijkl)); 00136 intbound *= qijkl; 00137 GBuild<T>::contribution.set_bound(intbound, pbound); 00138 <font class="preprocessor">#else</font> 00139 <font class="preprocessor"></font><font class="preprocessor"># ifndef SCF_DONT_USE_BOUNDS</font> 00140 <font class="preprocessor"></font> <font class="keywordflow">if</font> (tbi.log2_shell_bound(i,j,k,l)+pmaxijkl < tol) 00141 <font class="keywordflow">continue</font>; 00142 <font class="preprocessor"># endif</font> 00143 <font class="preprocessor"></font><font class="preprocessor">#endif</font> 00144 <font class="preprocessor"></font> 00145 <font class="comment">//tim_enter_default();</font> 00146 tbi.compute_shell(i,j,k,l); 00147 <font class="comment">//tim_exit_default();</font> 00148 00149 <font class="keywordtype">int</font> e12 = (i==j); 00150 <font class="keywordtype">int</font> e34 = (k==l); 00151 <font class="keywordtype">int</font> e13e24 = (i==k) && (j==l); 00152 <font class="keywordtype">int</font> e_any = e12||e34||e13e24; 00153 00154 <font class="keywordtype">int</font> fl=gbs.shell_to_function(l); 00155 <font class="keywordtype">int</font> nl=gbs(l).nfunction(); 00156 00157 <font class="keywordtype">int</font> ii,jj,kk,ll; 00158 <font class="keywordtype">int</font> I,J,K,L; 00159 <font class="keywordtype">int</font> index=0; 00160 00161 <font class="keywordflow">for</font> (I=0, ii=fi; I < ni; I++, ii++) { 00162 <font class="keywordflow">for</font> (J=0, jj=fj; J <= (e12 ? I : nj-1); J++, jj++) { 00163 <font class="keywordflow">for</font> (K=0, kk=fk; K <= (e13e24 ? I : nk-1); K++, kk++) { 00164 <font class="keywordtype">int</font> lend = (e34 ? ((e13e24)&&(K==I) ? J : K) 00165 : ((e13e24)&&(K==I)) ? J : nl-1); 00166 00167 <font class="keywordflow">for</font> (L=0, ll=fl; L <= lend; L++, ll++, index++) { 00168 00169 <font class="keywordtype">double</font> pki_int = intbuf[index]; 00170 00171 <font class="keywordflow">if</font> ((pki_int>0?pki_int:-pki_int) < 1.0e-15) 00172 <font class="keywordflow">continue</font>; 00173 00174 <font class="preprocessor">#ifdef SCF_CHECK_INTS</font> 00175 <font class="preprocessor"></font> <font class="keywordflow">if</font> (isnan(pki_int)) 00176 abort(); 00177 <font class="preprocessor">#endif</font> 00178 <font class="preprocessor"></font> 00179 <font class="keywordflow">if</font> (qijkl > 1) 00180 pki_int *= qijkl; 00181 00182 <font class="keywordflow">if</font> (e_any) { 00183 <font class="keywordtype">int</font> ij,kl; 00184 <font class="keywordtype">double</font> val; 00185 00186 <font class="keywordflow">if</font> (jj == kk) { 00187 <font class="comment">/*</font> 00188 <font class="comment"> * if i=j=k or j=k=l, then this integral contributes</font> 00189 <font class="comment"> * to J, K1, and K2 of G(ij), so</font> 00190 <font class="comment"> * pkval = (ijkl) - 0.25 * ((ikjl)-(ilkj))</font> 00191 <font class="comment"> * = 0.5 * (ijkl)</font> 00192 <font class="comment"> */</font> 00193 <font class="keywordflow">if</font> (ii == jj || kk == ll) { 00194 ij = i_offset(ii)+jj; 00195 kl = i_offset(kk)+ll; 00196 val = (ij==kl) ? 0.5*pki_int : pki_int; 00197 00198 GBuild<T>::contribution.cont5(ij,kl,val); 00199 00200 } <font class="keywordflow">else</font> { 00201 <font class="comment">/*</font> 00202 <font class="comment"> * if j=k, then this integral contributes</font> 00203 <font class="comment"> * to J and K1 of G(ij)</font> 00204 <font class="comment"> *</font> 00205 <font class="comment"> * pkval = (ijkl) - 0.25 * (ikjl)</font> 00206 <font class="comment"> * = 0.75 * (ijkl)</font> 00207 <font class="comment"> */</font> 00208 ij = i_offset(ii)+jj; 00209 kl = i_offset(kk)+ll; 00210 val = (ij==kl) ? 0.5*pki_int : pki_int; 00211 00212 GBuild<T>::contribution.cont4(ij,kl,val); 00213 00214 <font class="comment">/*</font> 00215 <font class="comment"> * this integral also contributes to K1 and K2 of</font> 00216 <font class="comment"> * G(il)</font> 00217 <font class="comment"> *</font> 00218 <font class="comment"> * pkval = -0.25 * ((ijkl)+(ikjl))</font> 00219 <font class="comment"> * = -0.5 * (ijkl)</font> 00220 <font class="comment"> */</font> 00221 ij = ij_offset(ii,ll); 00222 kl = ij_offset(kk,jj); 00223 val = (ij==kl) ? 0.5*pki_int : pki_int; 00224 00225 GBuild<T>::contribution.cont3(ij,kl,val); 00226 } 00227 } <font class="keywordflow">else</font> <font class="keywordflow">if</font> (ii == kk || jj == ll) { 00228 <font class="comment">/*</font> 00229 <font class="comment"> * if i=k or j=l, then this integral contributes</font> 00230 <font class="comment"> * to J and K2 of G(ij)</font> 00231 <font class="comment"> *</font> 00232 <font class="comment"> * pkval = (ijkl) - 0.25 * (ilkj)</font> 00233 <font class="comment"> * = 0.75 * (ijkl)</font> 00234 <font class="comment"> */</font> 00235 ij = i_offset(ii)+jj; 00236 kl = i_offset(kk)+ll; 00237 val = (ij==kl) ? 0.5*pki_int : pki_int; 00238 00239 GBuild<T>::contribution.cont4(ij,kl,val); 00240 00241 <font class="comment">/*</font> 00242 <font class="comment"> * this integral also contributes to K1 and K2 of</font> 00243 <font class="comment"> * G(ik)</font> 00244 <font class="comment"> *</font> 00245 <font class="comment"> * pkval = -0.25 * ((ijkl)+(ilkj))</font> 00246 <font class="comment"> * = -0.5 * (ijkl)</font> 00247 <font class="comment"> */</font> 00248 ij = ij_offset(ii,kk); 00249 kl = ij_offset(jj,ll); 00250 val = (ij==kl) ? 0.5*pki_int : pki_int; 00251 00252 GBuild<T>::contribution.cont3(ij,kl,val); 00253 00254 } <font class="keywordflow">else</font> { 00255 <font class="comment">/*</font> 00256 <font class="comment"> * This integral contributes to J of G(ij)</font> 00257 <font class="comment"> *</font> 00258 <font class="comment"> * pkval = (ijkl)</font> 00259 <font class="comment"> */</font> 00260 ij = i_offset(ii)+jj; 00261 kl = i_offset(kk)+ll; 00262 val = (ij==kl) ? 0.5*pki_int : pki_int; 00263 00264 GBuild<T>::contribution.cont1(ij,kl,val); 00265 00266 <font class="comment">/*</font> 00267 <font class="comment"> * and to K1 of G(ik)</font> 00268 <font class="comment"> *</font> 00269 <font class="comment"> * pkval = -0.25 * (ijkl)</font> 00270 <font class="comment"> */</font> 00271 ij = ij_offset(ii,kk); 00272 kl = ij_offset(jj,ll); 00273 val = (ij==kl) ? 0.5*pki_int : pki_int; 00274 00275 GBuild<T>::contribution.cont2(ij,kl,val); 00276 00277 <font class="keywordflow">if</font> ((ii != jj) && (kk != ll)) { 00278 <font class="comment">/*</font> 00279 <font class="comment"> * if i!=j and k!=l, then this integral also</font> 00280 <font class="comment"> * contributes to K2 of G(il)</font> 00281 <font class="comment"> *</font> 00282 <font class="comment"> * pkval = -0.25 * (ijkl)</font> 00283 <font class="comment"> *</font> 00284 <font class="comment"> * note: if we get here, then ik can't equal jl,</font> 00285 <font class="comment"> * so pkval wasn't multiplied by 0.5 above.</font> 00286 <font class="comment"> */</font> 00287 ij = ij_offset(ii,ll); 00288 kl = ij_offset(kk,jj); 00289 00290 GBuild<T>::contribution.cont2(ij,kl,val); 00291 } 00292 } 00293 } <font class="keywordflow">else</font> { <font class="comment">// !e_any</font> 00294 <font class="keywordflow">if</font> (jj == kk) { 00295 <font class="comment">/*</font> 00296 <font class="comment"> * if j=k, then this integral contributes</font> 00297 <font class="comment"> * to J and K1 of G(ij)</font> 00298 <font class="comment"> *</font> 00299 <font class="comment"> * pkval = (ijkl) - 0.25 * (ikjl)</font> 00300 <font class="comment"> * = 0.75 * (ijkl)</font> 00301 <font class="comment"> */</font> 00302 GBuild<T>::contribution.cont4(i_offset(ii)+jj,i_offset(kk)+ll,pki_int); 00303 00304 <font class="comment">/*</font> 00305 <font class="comment"> * this integral also contributes to K1 and K2 of</font> 00306 <font class="comment"> * G(il)</font> 00307 <font class="comment"> *</font> 00308 <font class="comment"> * pkval = -0.25 * ((ijkl)+(ikjl))</font> 00309 <font class="comment"> * = -0.5 * (ijkl)</font> 00310 <font class="comment"> */</font> 00311 GBuild<T>::contribution.cont3(ij_offset(ii,ll),ij_offset(kk,jj),pki_int); 00312 00313 } <font class="keywordflow">else</font> <font class="keywordflow">if</font> (ii == kk || jj == ll) { 00314 <font class="comment">/*</font> 00315 <font class="comment"> * if i=k or j=l, then this integral contributes</font> 00316 <font class="comment"> * to J and K2 of G(ij)</font> 00317 <font class="comment"> *</font> 00318 <font class="comment"> * pkval = (ijkl) - 0.25 * (ilkj)</font> 00319 <font class="comment"> * = 0.75 * (ijkl)</font> 00320 <font class="comment"> */</font> 00321 GBuild<T>::contribution.cont4(i_offset(ii)+jj,i_offset(kk)+ll,pki_int); 00322 00323 <font class="comment">/*</font> 00324 <font class="comment"> * this integral also contributes to K1 and K2 of</font> 00325 <font class="comment"> * G(ik)</font> 00326 <font class="comment"> *</font> 00327 <font class="comment"> * pkval = -0.25 * ((ijkl)+(ilkj))</font> 00328 <font class="comment"> * = -0.5 * (ijkl)</font> 00329 <font class="comment"> */</font> 00330 GBuild<T>::contribution.cont3(ij_offset(ii,kk),ij_offset(jj,ll),pki_int); 00331 00332 } <font class="keywordflow">else</font> { 00333 <font class="comment">/*</font> 00334 <font class="comment"> * This integral contributes to J of G(ij)</font> 00335 <font class="comment"> *</font> 00336 <font class="comment"> * pkval = (ijkl)</font> 00337 <font class="comment"> */</font> 00338 GBuild<T>::contribution.cont1(i_offset(ii)+jj,i_offset(kk)+ll,pki_int); 00339 00340 <font class="comment">/*</font> 00341 <font class="comment"> * and to K1 of G(ik)</font> 00342 <font class="comment"> *</font> 00343 <font class="comment"> * pkval = -0.25 * (ijkl)</font> 00344 <font class="comment"> */</font> 00345 GBuild<T>::contribution.cont2(ij_offset(ii,kk),ij_offset(jj,ll),pki_int); 00346 00347 <font class="comment">/*</font> 00348 <font class="comment"> * and to K2 of G(il)</font> 00349 <font class="comment"> *</font> 00350 <font class="comment"> * pkval = -0.25 * (ijkl)</font> 00351 <font class="comment"> */</font> 00352 GBuild<T>::contribution.cont2(ij_offset(ii,ll),ij_offset(kk,jj),pki_int); 00353 } 00354 } 00355 } 00356 } 00357 } 00358 } 00359 00360 tnint += (<font class="keywordtype">double</font>) ni*nj*nk*nl; 00361 } 00362 } 00363 } 00364 } 00365 } 00366 }; 00367 00368 } 00369 00370 <font class="preprocessor">#endif</font> 00371 <font class="preprocessor"></font> 00372 <font class="comment">// Local Variables:</font> 00373 <font class="comment">// mode: c++</font> 00374 <font class="comment">// c-file-style: "ETS"</font> 00375 <font class="comment">// End:</font> </div></pre><hr> <address> <small> Generated at Mon Oct 14 14:16:37 2002 for <a href="http://aros.ca.sandia.gov/~cljanss/mpqc">MPQC</a> 2.1.2 using the documentation package <a href="http://www.stack.nl/~dimitri/doxygen/index.html">Doxygen</a> 1.2.5. </small> </address> </body> </html>