User Tools

Site Tools


crawdad:programming:project3:hint7.2

The following code illustrates the basic algorithm for build the Fock matrix (F) using the core Hamiltonian matrix (H), the density matrix (D), and the two-electron integrals stored in a one-dimensional array (TEI):

for(int i=0; i < nao; i++)
  for(int j=0; j < nao; j++) {
    F[i][j] = H[i][j];
    for(int k=0; k < nao; k++)
      for(int l=0; l < nao; l++) {
        ij = INDEX(i,j);
        kl = INDEX(k,l);
        ijkl = INDEX(ij,kl);
        ik = INDEX(i,k);
        jl = INDEX(j,l);
        ikjl = INDEX(ik,jl);
 
        F[i][j] += D[k][l] * (2.0 * TEI[ijkl] - TEI[ikjl]);
     }
  }

The “INDEX” function is most easily defined as a macro using the ioff array explained in an earlier hint, e.g.:

#define INDEX(i,j) (i>j) ? (ioff[i]+j) : (ioff[j]+i)
crawdad/programming/project3/hint7.2.txt · Last modified: 2012/11/20 16:40 by crawdad