~ubuntu-branches/ubuntu/precise/psicode/precise

« back to all changes in this revision

Viewing changes to src/bin/cints/OEProp_Ints/moment_ints.cc

  • Committer: Bazaar Package Importer
  • Author(s): Michael Banck, Michael Banck, Daniel Leidert
  • Date: 2009-02-23 00:12:02 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090223001202-rutldoy3dimfpesc
Tags: 3.4.0-1
* New upstream release.

[ Michael Banck ]
* debian/patches/01_DESTDIR.dpatch: Refreshed.
* debian/patches/02_FHS.dpatch: Removed, applied upstream.
* debian/patches/03_debian_docdir: Likewise.
* debian/patches/04_man.dpatch: Likewise.
* debian/patches/06_466828_fix_gcc_43_ftbfs.dpatch: Likewise.
* debian/patches/07_464867_move_executables: Fixed and refreshed.
* debian/patches/00list: Adjusted.
* debian/control: Improved description.
* debian/patches-held: Removed.
* debian/rules (install/psi3): Do not ship the ruby bindings for now.

[ Daniel Leidert ]
* debian/rules: Fix txtdir via DEB_MAKE_INSTALL_TARGET.
* debian/patches/01_DESTDIR.dpatch: Refreshed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*! \file
 
2
    \ingroup CINTS
 
3
    \brief Enter brief description of file here 
 
4
*/
 
5
#include<cmath>
 
6
#include<cstdio>
 
7
#include<cstdlib>
 
8
#include<cstring>
 
9
#include<libipv1/ip_lib.h>
 
10
#include<libiwl/iwl.h>
 
11
#include<libciomr/libciomr.h>
 
12
#include<libint/libint.h>
 
13
#include<psifiles.h>
 
14
 
 
15
#include"defines.h"
 
16
#define EXTERN
 
17
#include"global.h"
 
18
#include <stdexcept>
 
19
#include"oe_osrr.h"
 
20
 
 
21
namespace psi {
 
22
  namespace CINTS {
 
23
 
 
24
/*!---------------------------------------------------------------------------
 
25
  This function computes AO overlap, dipole and quadrupole moment integrals,
 
26
  and nabla integrals and writes them out to disk
 
27
 ---------------------------------------------------------------------------*/
 
28
void moment_ints()
 
29
{
 
30
   struct coordinates PA, PB, AB, A, B;
 
31
   struct shell_pair *sp;
 
32
   struct unique_shell_pair *usp;
 
33
   register int i, j, k, l, ii, jj, kk, ll;
 
34
   int count;
 
35
   int si, sj;
 
36
   int np_i, np_j;
 
37
   int sz;
 
38
   int l1, l2, m1, m2, n1, n2;
 
39
   int ioffset, joffset ;
 
40
   int ij;
 
41
   int h1;
 
42
   int am;
 
43
   int dimension ;
 
44
   int ni,nj,ai,aj;
 
45
   int am_i, am_j;
 
46
   double a1, a2;
 
47
   double ab2, oog, gam;
 
48
   double x00, y00, z00;
 
49
   double x10, y10, z10;
 
50
   double x01, y01, z01;
 
51
   double x11, y11, z11;
 
52
   double nx, ny, nz;
 
53
   double **stemp, **mxtemp, **mytemp, **mztemp, **qxxtemp, **qxytemp, **qxztemp,
 
54
     **qyytemp, **qyztemp, **qzztemp, **nxtemp, **nytemp, **nztemp,
 
55
     **temp, **tmp_dptr;
 
56
   double *S, *MX, *MY, *MZ, *QXX, *QXY, *QXZ, *QYY, *QYZ, *QZZ, *NX, *NY, *NZ;
 
57
   double inorm, jnorm, over_pf;
 
58
   double *ptr1, *ptr2, norm1, norm12;
 
59
   double **OIX, **OIY, **OIZ;
 
60
   struct coordinates C;
 
61
 
 
62
 
 
63
  /*--- allocate room for the one-e matrices ---*/
 
64
  dimension = ioff[BasisSet.num_ao];
 
65
  S = init_array(dimension);
 
66
  MX = init_array(dimension);
 
67
  MY = init_array(dimension);
 
68
  MZ = init_array(dimension);
 
69
  QXX = init_array(dimension);
 
70
  QXY = init_array(dimension);
 
71
  QXZ = init_array(dimension);
 
72
  QYY = init_array(dimension);
 
73
  QYZ = init_array(dimension);
 
74
  QZZ = init_array(dimension);
 
75
  NX = init_array(dimension);
 
76
  NY = init_array(dimension);
 
77
  NZ = init_array(dimension);
 
78
 
 
79
  /*--- allocate storage for shell blocks of one electron integrals ---*/
 
80
  dimension = ioff[BasisSet.max_am];
 
81
  stemp = block_matrix(dimension,dimension);
 
82
  mxtemp = block_matrix(dimension,dimension);
 
83
  mytemp = block_matrix(dimension,dimension);
 
84
  mztemp = block_matrix(dimension,dimension);
 
85
  qxxtemp = block_matrix(dimension,dimension);
 
86
  qxytemp = block_matrix(dimension,dimension);
 
87
  qxztemp = block_matrix(dimension,dimension);
 
88
  qyytemp = block_matrix(dimension,dimension);
 
89
  qyztemp = block_matrix(dimension,dimension);
 
90
  qzztemp = block_matrix(dimension,dimension);
 
91
  nxtemp = block_matrix(dimension,dimension);
 
92
  nytemp = block_matrix(dimension,dimension);
 
93
  nztemp = block_matrix(dimension,dimension);
 
94
 
 
95
  /* Note the "+1" -- we are computing dipole and quadrupole moment integrals here */
 
96
  OIX = block_matrix(BasisSet.max_am+1,BasisSet.max_am+1);
 
97
  OIY = block_matrix(BasisSet.max_am+1,BasisSet.max_am+1);
 
98
  OIZ = block_matrix(BasisSet.max_am+1,BasisSet.max_am+1);
 
99
  
 
100
  C = UserOptions.origin;
 
101
  if(UserOptions.print_lvl >= PRINT_OEI) 
 
102
    fprintf(outfile, "    Reference point for elec. mom. ints. = (%5.3f, %5.3f, %5.3f)\n", C.x, C.y, C.z);
 
103
 
 
104
  for (si=0; si<BasisSet.num_shells; si++){
 
105
    am_i = BasisSet.shells[si].am-1;
 
106
    ni = ioff[BasisSet.shells[si].am];
 
107
    A = Molecule.centers[BasisSet.shells[si].center-1];
 
108
    ioffset = BasisSet.shells[si].fao - 1;
 
109
    for (sj=0; sj<=si; sj++){
 
110
      nj = ioff[BasisSet.shells[sj].am];
 
111
      am_j = BasisSet.shells[sj].am-1;
 
112
      B = Molecule.centers[BasisSet.shells[sj].center-1];
 
113
      joffset = BasisSet.shells[sj].fao - 1;
 
114
 
 
115
      sp = &(BasisSet.shell_pairs[si][sj]);
 
116
      AB.x = sp->AB[0];
 
117
      AB.y = sp->AB[1];
 
118
      AB.z = sp->AB[2];
 
119
      ab2 = AB.x * AB.x;
 
120
      ab2 += AB.y * AB.y;
 
121
      ab2 += AB.z * AB.z;
 
122
        
 
123
      /*--- zero the temporary storage for accumulating contractions ---*/
 
124
      memset(stemp[0],0,sizeof(double)*dimension*dimension);
 
125
      memset(mxtemp[0],0,sizeof(double)*dimension*dimension);
 
126
      memset(mytemp[0],0,sizeof(double)*dimension*dimension);
 
127
      memset(mztemp[0],0,sizeof(double)*dimension*dimension);
 
128
      memset(qxxtemp[0],0,sizeof(double)*dimension*dimension);
 
129
      memset(qxytemp[0],0,sizeof(double)*dimension*dimension);
 
130
      memset(qxztemp[0],0,sizeof(double)*dimension*dimension);
 
131
      memset(qyytemp[0],0,sizeof(double)*dimension*dimension);
 
132
      memset(qyztemp[0],0,sizeof(double)*dimension*dimension);
 
133
      memset(qzztemp[0],0,sizeof(double)*dimension*dimension);
 
134
      memset(nxtemp[0],0,sizeof(double)*dimension*dimension);
 
135
      memset(nytemp[0],0,sizeof(double)*dimension*dimension);
 
136
      memset(nztemp[0],0,sizeof(double)*dimension*dimension);
 
137
      
 
138
      /*--- contract by primitives here ---*/
 
139
      for (i = 0; i < BasisSet.shells[si].n_prims; i++) {
 
140
        a1 = sp->a1[i];
 
141
        inorm = sp->inorm[i];
 
142
        for (j = 0; j < BasisSet.shells[sj].n_prims; j++) {
 
143
          a2 = sp->a2[j];
 
144
          gam = sp->gamma[i][j];
 
145
          jnorm = sp->jnorm[j];
 
146
          PA.x = sp->PA[i][j][0];
 
147
          PA.y = sp->PA[i][j][1];
 
148
          PA.z = sp->PA[i][j][2];
 
149
          PB.x = sp->PB[i][j][0];
 
150
          PB.y = sp->PB[i][j][1];
 
151
          PB.z = sp->PB[i][j][2];
 
152
          oog = 1.0/gam;
 
153
          over_pf = exp(-a1*a2*ab2*oog)*sqrt(M_PI*oog)*M_PI*oog*inorm*jnorm;
 
154
 
 
155
          OI_OSrecurs(OIX,OIY,OIZ,PA,PB,gam,am_i+1,am_j+1);
 
156
 
 
157
          /*--- create all am components of si ---*/
 
158
          ai = 0;
 
159
          for(ii = 0; ii <= am_i; ii++){
 
160
            l1 = am_i - ii;
 
161
            for(jj = 0; jj <= ii; jj++){
 
162
              m1 = ii - jj;
 
163
              n1 = jj;
 
164
              /*--- create all am components of sj ---*/
 
165
              aj = 0;
 
166
              for(kk = 0; kk <= am_j; kk++){
 
167
                l2 = am_j - kk;
 
168
                for(ll = 0; ll <= kk; ll++){
 
169
                  m2 = kk - ll;
 
170
                  n2 = ll;
 
171
 
 
172
                  x00 = OIX[l1][l2];   y00 = OIY[m1][m2];    z00 = OIZ[n1][n2];
 
173
                  x01 = OIX[l1][l2+1]; y01 = OIY[m1][m2+1];  z01 = OIZ[n1][n2+1];
 
174
                  x10 = OIX[l1+1][l2]; y10 = OIY[m1+1][m2];  z10 = OIZ[n1+1][n2];
 
175
                  x11 = OIX[l1+1][l2+1]; y11 = OIY[m1+1][m2+1];  z11 = OIZ[n1+1][n2+1];
 
176
                  stemp[ai][aj] += over_pf*x00*y00*z00;
 
177
                  /*--- electrons have negative charge ---*/
 
178
                  mxtemp[ai][aj] -= over_pf*(x01+x00*(B.x-C.x))*y00*z00;
 
179
                  mytemp[ai][aj] -= over_pf*x00*(y01+y00*(B.y-C.y))*z00;
 
180
                  mztemp[ai][aj] -= over_pf*x00*y00*(z01+z00*(B.z-C.z));
 
181
                  qxxtemp[ai][aj] -= over_pf*(x11 + x10*(B.x-C.x) + x01*(A.x-C.x)
 
182
                                              + x00*(A.x-C.x)*(B.x-C.x))*y00*z00;
 
183
                  qyytemp[ai][aj] -= over_pf*(y11 + y10*(B.y-C.y) + y01*(A.y-C.y)
 
184
                                              + y00*(A.y-C.y)*(B.y-C.y))*x00*z00;
 
185
                  qzztemp[ai][aj] -= over_pf*(z11 + z10*(B.z-C.z) + z01*(A.z-C.z)
 
186
                                              + z00*(A.z-C.z)*(B.z-C.z))*x00*y00;
 
187
                  qxytemp[ai][aj] -= over_pf*(x01+x00*(B.x-C.x))*(y01+y00*(B.y-C.y))*z00;
 
188
                  qxztemp[ai][aj] -= over_pf*(x01+x00*(B.x-C.x))*y00*(z01+z00*(B.z-C.z));
 
189
                  qyztemp[ai][aj] -= over_pf*x00*(y01+y00*(B.y-C.y))*(z01+z00*(B.z-C.z));
 
190
 
 
191
                  nx = -2.0*a2*x01;
 
192
                  if (l2 >= 1)
 
193
                    nx += l2*OIX[l1][l2-1];
 
194
                  nxtemp[ai][aj] += nx*y00*z00*over_pf;
 
195
                  ny = -2.0*a2*y01;
 
196
                  if (m2 >= 1)
 
197
                    ny += m2*OIY[m1][m2-1];
 
198
                  nytemp[ai][aj] += x00*ny*z00*over_pf;
 
199
                  nz = -2.0*a2*z01;
 
200
                  if (n2 >= 1)
 
201
                    nz += n2*OIZ[n1][n2-1];
 
202
                  nztemp[ai][aj] += x00*y00*nz*over_pf;
 
203
                  
 
204
                  aj++;
 
205
                }
 
206
              }
 
207
              ai++;
 
208
            }
 
209
          } /*--- end cartesian components for (si,sj) with primitives (i,j) ---*/
 
210
        }
 
211
      } /*--- end primitive contraction ---*/
 
212
    
 
213
      /*--- Normalize the contracted integrals ---*/
 
214
      ptr1 = GTOs.bf_norm[am_i];
 
215
      ptr2 = GTOs.bf_norm[am_j];
 
216
      for(i=0; i<ni; i++) {
 
217
        norm1 = ptr1[i];
 
218
        for(j=0; j<nj; j++) {
 
219
          norm12 = norm1*ptr2[j];
 
220
          stemp[i][j] *= norm12;
 
221
          mxtemp[i][j] *= norm12;
 
222
          mytemp[i][j] *= norm12;
 
223
          mztemp[i][j] *= norm12;
 
224
          qxxtemp[i][j] *= norm12;
 
225
          qxytemp[i][j] *= norm12;
 
226
          qxztemp[i][j] *= norm12;
 
227
          qyytemp[i][j] *= norm12;
 
228
          qyztemp[i][j] *= norm12;
 
229
          qzztemp[i][j] *= norm12;
 
230
          nxtemp[i][j] *= norm12;
 
231
          nytemp[i][j] *= norm12;
 
232
          nztemp[i][j] *= norm12;
 
233
        }
 
234
      }
 
235
 
 
236
      for(i=0;i<ni;i++)
 
237
        for(j=0;j<nj;j++) {
 
238
          ij = INDEX(ioffset + i, joffset + j);
 
239
          S[ij] = stemp[i][j];
 
240
          MX[ij] = mxtemp[i][j];
 
241
          MY[ij] = mytemp[i][j];
 
242
          MZ[ij] = mztemp[i][j];
 
243
          QXX[ij] = qxxtemp[i][j];
 
244
          QXY[ij] = qxytemp[i][j];
 
245
          QXZ[ij] = qxztemp[i][j];
 
246
          QYY[ij] = qyytemp[i][j];
 
247
          QYZ[ij] = qyztemp[i][j];
 
248
          QZZ[ij] = qzztemp[i][j];
 
249
          NX[ij] = nxtemp[i][j];
 
250
          NY[ij] = nytemp[i][j];
 
251
          NZ[ij] = nztemp[i][j];
 
252
        }
 
253
    }
 
254
  }  /*--- This shell pair is done ---*/
 
255
 
 
256
  /*--- flush it all away ---*/
 
257
  fflush(outfile);
 
258
  free_block(OIX);
 
259
  free_block(OIY);
 
260
  free_block(OIZ);
 
261
  dimension=ioff[BasisSet.num_ao];
 
262
  iwl_wrtone(IOUnits.itapS_AO, PSIF_AO_S, dimension,S);
 
263
  iwl_wrtone(IOUnits.itapMX_AO,PSIF_AO_MX,dimension,MX);
 
264
  iwl_wrtone(IOUnits.itapMY_AO,PSIF_AO_MY,dimension,MY);
 
265
  iwl_wrtone(IOUnits.itapMZ_AO,PSIF_AO_MZ,dimension,MZ);
 
266
  iwl_wrtone(IOUnits.itapQXX_AO,PSIF_AO_QXX,dimension,QXX);
 
267
  iwl_wrtone(IOUnits.itapQXY_AO,PSIF_AO_QXY,dimension,QXY);
 
268
  iwl_wrtone(IOUnits.itapQXZ_AO,PSIF_AO_QXZ,dimension,QXZ);
 
269
  iwl_wrtone(IOUnits.itapQYY_AO,PSIF_AO_QYY,dimension,QYY);
 
270
  iwl_wrtone(IOUnits.itapQYZ_AO,PSIF_AO_QYZ,dimension,QYZ);
 
271
  iwl_wrtone(IOUnits.itapQZZ_AO,PSIF_AO_QZZ,dimension,QZZ);
 
272
  iwl_wrtone(IOUnits.itapNablaX_AO,PSIF_AO_NablaX,dimension,NX);
 
273
  iwl_wrtone(IOUnits.itapNablaY_AO,PSIF_AO_NablaY,dimension,NY);
 
274
  iwl_wrtone(IOUnits.itapNablaZ_AO,PSIF_AO_NablaZ,dimension,NZ);
 
275
  if (UserOptions.print_lvl >= PRINT_OEI) {
 
276
    fprintf(outfile,"  -Overlap AO integrals:\n\n");
 
277
    print_array(S,BasisSet.num_ao,outfile);
 
278
    fprintf(outfile,"  -mu(x) AO integrals:\n\n");
 
279
    print_array(MX,BasisSet.num_ao,outfile);
 
280
    fprintf(outfile,"  -mu(y) AO integrals:\n\n");
 
281
    print_array(MY,BasisSet.num_ao,outfile);
 
282
    fprintf(outfile,"  -mu(z) AO integrals:\n\n");
 
283
    print_array(MZ,BasisSet.num_ao,outfile);
 
284
    fprintf(outfile,"  -q(xx) AO integrals:\n\n");
 
285
    print_array(QXX,BasisSet.num_ao,outfile);
 
286
    fprintf(outfile,"  -q(xy) AO integrals:\n\n");
 
287
    print_array(QXY,BasisSet.num_ao,outfile);
 
288
    fprintf(outfile,"  -q(xz) AO integrals:\n\n");
 
289
    print_array(QXZ,BasisSet.num_ao,outfile);
 
290
    fprintf(outfile,"  -q(yy) AO integrals:\n\n");
 
291
    print_array(QYY,BasisSet.num_ao,outfile);
 
292
    fprintf(outfile,"  -q(yz) AO integrals:\n\n");
 
293
    print_array(QYZ,BasisSet.num_ao,outfile);
 
294
    fprintf(outfile,"  -q(zz) AO integrals:\n\n");
 
295
    print_array(QZZ,BasisSet.num_ao,outfile);
 
296
    fprintf(outfile,"  -Nabla_x AO integrals:\n\n");
 
297
    print_array(NX,BasisSet.num_ao,outfile);
 
298
    fprintf(outfile,"  -Nabla_y AO integrals:\n\n");
 
299
    print_array(NY,BasisSet.num_ao,outfile);
 
300
    fprintf(outfile,"  -Nabla_z AO integrals:\n\n");
 
301
    print_array(NZ,BasisSet.num_ao,outfile);
 
302
    fprintf(outfile,"\n");
 
303
  }
 
304
 
 
305
  free_block(stemp);
 
306
  free_block(mxtemp);
 
307
  free_block(mytemp);
 
308
  free_block(mztemp);
 
309
  free_block(qxxtemp);
 
310
  free_block(qxytemp);
 
311
  free_block(qxztemp);
 
312
  free_block(qyytemp);
 
313
  free_block(qyztemp);
 
314
  free_block(qzztemp);
 
315
  free_block(nxtemp);
 
316
  free_block(nytemp);
 
317
  free_block(nztemp);
 
318
 
 
319
  free(S);
 
320
  free(MX);
 
321
  free(MY);
 
322
  free(MZ);
 
323
  free(QXX);
 
324
  free(QXY);
 
325
  free(QXZ);
 
326
  free(QYY);
 
327
  free(QYZ);
 
328
  free(QZZ);
 
329
  free(NX);
 
330
  free(NY);
 
331
  free(NZ);
 
332
 
 
333
  return;
 
334
}   
 
335
  }
 
336
}