Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > media > contrib > by-pkgid > 263386785cefb9ae5d63b926d214d809 > files > 1254

mpqc-2.1.2-4mdk.ppc.rpm

<!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>ltbgrad.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> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; </center>
<hr><h1>ltbgrad.h</h1><div class="fragment"><pre>00001 <font class="comment">//</font>
00002 <font class="comment">// ltbgrad.h --- definition of the local two-electron gradient 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 &lt;seidl@janed.com&gt;</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_ltbgrad_h</font>
00029 <font class="preprocessor"></font><font class="preprocessor">#define _chemistry_qc_scf_ltbgrad_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">#include &lt;math.h&gt;</font>
00036 
00037 <font class="preprocessor">#include &lt;util/misc/timer.h&gt;</font>
00038 <font class="preprocessor">#include &lt;math/scmat/offset.h&gt;</font>
00039 
00040 <font class="preprocessor">#include &lt;chemistry/qc/basis/tbint.h&gt;</font>
00041 <font class="preprocessor">#include &lt;chemistry/qc/basis/petite.h&gt;</font>
00042 
00043 <font class="preprocessor">#include &lt;chemistry/qc/scf/tbgrad.h&gt;</font>
00044 
00045 <font class="keyword">namespace </font>sc {
00046   
00047 template&lt;class T&gt;
00048 <font class="keyword">class </font>LocalTBGrad : <font class="keyword">public</font> TBGrad&lt;T&gt; {
00049   <font class="keyword">public</font>:
00050     <font class="keywordtype">double</font> *tbgrad;
00051 
00052   <font class="keyword">protected</font>:
00053     MessageGrp *grp_;
00054     TwoBodyDerivInt *tbi_;
00055     GaussianBasisSet *gbs_;
00056     PetiteList *rpl_;
00057     Molecule *mol_;
00058 
00059     <font class="keywordtype">double</font> pmax_;
00060     <font class="keywordtype">double</font> accuracy_;
00061 
00062     <font class="keywordtype">int</font> threadno_;
00063     <font class="keywordtype">int</font> nthread_;
00064 
00065   <font class="keyword">public</font>:
00066     LocalTBGrad(T&amp; t, <font class="keyword">const</font> Ref&lt;TwoBodyDerivInt&gt;&amp; tbdi, <font class="keyword">const</font> Ref&lt;PetiteList&gt;&amp; pl,
00067                 <font class="keyword">const</font> Ref&lt;GaussianBasisSet&gt;&amp; bs, <font class="keyword">const</font> Ref&lt;MessageGrp&gt;&amp; g,
00068                 <font class="keywordtype">double</font> *tbg, <font class="keywordtype">double</font> pm, <font class="keywordtype">double</font> a, <font class="keywordtype">int</font> nt = 1, <font class="keywordtype">int</font> tn = 0,
00069                 <font class="keywordtype">double</font> exchange_fraction = 1.0) :
00070       TBGrad&lt;T&gt;(t,exchange_fraction),
00071       tbgrad(tbg), pmax_(pm), accuracy_(a), threadno_(tn), nthread_(nt)
00072     {
00073       grp_ = g.pointer();
00074       gbs_ = bs.pointer();
00075       rpl_ = pl.pointer();
00076       tbi_ = tbdi.pointer();
00077       mol_ = gbs_-&gt;molecule().pointer();
00078     }
00079 
00080     ~LocalTBGrad()<font class="keyword"> </font>{}
00081     
00082     <font class="keywordtype">void</font> run()<font class="keyword"> </font>{
00083       <font class="keywordtype">int</font> me = grp_-&gt;me();
00084       <font class="keywordtype">int</font> nproc = grp_-&gt;n();
00085       
00086       <font class="comment">// grab ref for convenience</font>
00087       GaussianBasisSet&amp; gbs = *gbs_;
00088       Molecule&amp; mol = *mol_;
00089       PetiteList&amp; pl = *rpl_;
00090       TwoBodyDerivInt&amp; tbi = *tbi_;
00091       
00092       <font class="comment">// create vector to hold skeleton gradient</font>
00093       <font class="keywordtype">double</font> *tbint = <font class="keyword">new</font> <font class="keywordtype">double</font>[mol.natom()*3];
00094       memset(tbint, 0, <font class="keyword">sizeof</font>(<font class="keywordtype">double</font>)*mol.natom()*3);
00095 
00096       <font class="comment">// for bounds checking</font>
00097       <font class="keywordtype">int</font> PPmax = (<font class="keywordtype">int</font>) (log(6.0*pmax_*pmax_)/log(2.0));
00098       <font class="keywordtype">int</font> threshold = (<font class="keywordtype">int</font>) (log(accuracy_)/log(2.0));
00099   
00100       <font class="keywordtype">int</font> kindex=0;
00101       <font class="keywordtype">int</font> threadind=0;
00102       <font class="keywordflow">for</font> (<font class="keywordtype">int</font> i=0; i &lt; gbs.nshell(); i++) {
00103         <font class="keywordflow">if</font> (!pl.in_p1(i))
00104           <font class="keywordflow">continue</font>;
00105     
00106         <font class="keywordtype">int</font> ni=gbs(i).nfunction();
00107         <font class="keywordtype">int</font> fi=gbs.shell_to_function(i);
00108     
00109         <font class="keywordflow">for</font> (<font class="keywordtype">int</font> j=0; j &lt;= i; j++) {
00110           <font class="keywordtype">int</font> ij=i_offset(i)+j;
00111           <font class="keywordflow">if</font> (!pl.in_p2(ij))
00112             <font class="keywordflow">continue</font>;
00113       
00114           <font class="keywordflow">if</font> (tbi.log2_shell_bound(i,j,-1,-1)+PPmax &lt; threshold)
00115             <font class="keywordflow">continue</font>;
00116       
00117           <font class="keywordtype">int</font> nj=gbs(j).nfunction();
00118           <font class="keywordtype">int</font> fj=gbs.shell_to_function(j);
00119     
00120           <font class="keywordflow">for</font> (<font class="keywordtype">int</font> k=0; k &lt;= i; k++,kindex++) {
00121             <font class="keywordflow">if</font> (kindex%nproc != me)
00122               <font class="keywordflow">continue</font>;
00123             
00124             threadind++;
00125             <font class="keywordflow">if</font> (threadind % nthread_ != threadno_)
00126               <font class="keywordflow">continue</font>;
00127             
00128             <font class="keywordtype">int</font> nk=gbs(k).nfunction();
00129             <font class="keywordtype">int</font> fk=gbs.shell_to_function(k);
00130     
00131             <font class="keywordflow">for</font> (<font class="keywordtype">int</font> l=0; l &lt;= ((i==k)?j:k); l++) {
00132               <font class="keywordflow">if</font> (tbi.log2_shell_bound(i,j,k,l)+PPmax &lt; threshold)
00133                 <font class="keywordflow">continue</font>;
00134           
00135               <font class="keywordtype">int</font> kl=i_offset(k)+l;
00136               <font class="keywordtype">int</font> qijkl;
00137               <font class="keywordflow">if</font> (!(qijkl=pl.in_p4(ij,kl,i,j,k,l)))
00138                 <font class="keywordflow">continue</font>;
00139           
00140               <font class="keywordtype">int</font> nl=gbs(l).nfunction();
00141               <font class="keywordtype">int</font> fl=gbs.shell_to_function(l);
00142 
00143               DerivCenters cent;
00144               tbi.compute_shell(i,j,k,l,cent);
00145 
00146               <font class="keyword">const</font> <font class="keywordtype">double</font> * buf = tbi.buffer();
00147           
00148               <font class="keywordtype">double</font> cscl, escl;
00149 
00150               set_scale(cscl, escl, i, j, k, l);
00151 
00152               <font class="keywordtype">int</font> indijkl=0;
00153               <font class="keywordtype">int</font> nx=cent.n();
00154               <font class="comment">//if (cent.has_omitted_center()) nx--;</font>
00155               <font class="keywordflow">for</font> (<font class="keywordtype">int</font> x=0; x &lt; nx; x++) {
00156                 <font class="keywordtype">int</font> ix=cent.atom(x);
00157                 <font class="keywordtype">int</font> io=cent.omitted_atom();
00158                 <font class="keywordflow">for</font> (<font class="keywordtype">int</font> ixyz=0; ixyz &lt; 3; ixyz++) {
00159                   <font class="keywordtype">double</font> tx = tbint[ixyz+ix*3];
00160                   <font class="keywordtype">double</font> to = tbint[ixyz+io*3];
00161                   
00162                   <font class="keywordflow">for</font> (<font class="keywordtype">int</font> ip=0, ii=fi; ip &lt; ni; ip++, ii++) {
00163                     <font class="keywordflow">for</font> (<font class="keywordtype">int</font> jp=0, jj=fj; jp &lt; nj; jp++, jj++) {
00164                       <font class="keywordflow">for</font> (<font class="keywordtype">int</font> kp=0, kk=fk; kp &lt; nk; kp++, kk++) {
00165                         <font class="keywordflow">for</font> (<font class="keywordtype">int</font> lp=0, ll=fl; lp &lt; nl; lp++, ll++, indijkl++) {
00166                           <font class="keywordtype">double</font> contrib;
00167                           <font class="keywordtype">double</font> qint = buf[indijkl]*qijkl;
00168 
00169                           contrib = cscl*qint*
00170                             TBGrad&lt;T&gt;::contribution.cont1(ij_offset(ii,jj),
00171                                                ij_offset(kk,ll));
00172 
00173                           tx += contrib;
00174                           to -= contrib;
00175 
00176                           contrib = escl*qint*
00177                             TBGrad&lt;T&gt;::contribution.cont2(ij_offset(ii,kk),
00178                                                ij_offset(jj,ll));
00179 
00180                           tx += contrib;
00181                           to -= contrib;
00182 
00183                           <font class="keywordflow">if</font> (i!=j &amp;&amp; k!=l) {
00184                             contrib = escl*qint*
00185                               TBGrad&lt;T&gt;::contribution.cont2(ij_offset(ii,ll),
00186                                                  ij_offset(jj,kk));
00187 
00188                             tx += contrib;
00189                             to -= contrib;
00190                           }
00191                         }
00192                       }
00193                     }
00194                   }
00195 
00196                   tbint[ixyz+ix*3] = tx;
00197                   tbint[ixyz+io*3] = to;
00198                 }
00199               }
00200             }
00201           }
00202         }
00203       }
00204       
00205       CharacterTable ct = mol.point_group()-&gt;char_table();
00206       SymmetryOperation so;
00207 
00208       <font class="keywordflow">for</font> (<font class="keywordtype">int</font> alpha=0; alpha &lt; mol.natom(); alpha++) {
00209         <font class="keywordtype">double</font> tbx = tbint[alpha*3+0];
00210         <font class="keywordtype">double</font> tby = tbint[alpha*3+1];
00211         <font class="keywordtype">double</font> tbz = tbint[alpha*3+2];
00212         
00213         <font class="keywordflow">for</font> (<font class="keywordtype">int</font> g=1; g &lt; ct.order(); g++) {
00214           so = ct.symm_operation(g);
00215           <font class="keywordtype">int</font> ap = pl.atom_map(alpha,g);
00216 
00217           tbx += tbint[ap*3+0]*so(0,0) + tbint[ap*3+1]*so(1,0) +
00218                  tbint[ap*3+2]*so(2,0);
00219           tby += tbint[ap*3+0]*so(0,1) + tbint[ap*3+1]*so(1,1) +
00220                  tbint[ap*3+2]*so(2,1);
00221           tbz += tbint[ap*3+0]*so(0,2) + tbint[ap*3+1]*so(1,2) +
00222                  tbint[ap*3+2]*so(2,2);
00223         }
00224         <font class="keywordtype">double</font> scl = 1.0/(<font class="keywordtype">double</font>)ct.order();
00225         tbgrad[alpha*3+0] += tbx*scl;
00226         tbgrad[alpha*3+1] += tby*scl;
00227         tbgrad[alpha*3+2] += tbz*scl;
00228       }
00229     
00230       <font class="keyword">delete</font>[] tbint;
00231     }
00232 };
00233 
00234 }
00235 
00236 <font class="preprocessor">#endif</font>
00237 <font class="preprocessor"></font>
00238 <font class="comment">// Local Variables:</font>
00239 <font class="comment">// mode: c++</font>
00240 <font class="comment">// c-file-style: "ETS"</font>
00241 <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>