~ubuntu-branches/ubuntu/quantal/psicode/quantal

« back to all changes in this revision

Viewing changes to src/lib/libiwl/buf_rd_all_mp2r12a.c

  • 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
 
/*!
2
 
  \file buf_rd_all_mp2r12a.c
3
 
  \ingroup (IWL)
4
 
*/
5
 
#include <stdio.h>
6
 
#include <math.h>
7
 
#include <libciomr/libciomr.h>
8
 
#include "iwl.h"
9
 
 
10
 
#define MIN0(a,b) (((a)<(b)) ? (a) : (b))
11
 
#define MAX0(a,b) (((a)>(b)) ? (a) : (b))
12
 
#define INDEX(i,j) ((i>j) ? (((i)*((i)+1))/2+(j)) : (((j)*((j)+1))/2+(i)))
13
 
 
14
 
 
15
 
/*!
16
 
** iwl_buf_rd_all_mp2r12a()
17
 
**
18
 
** Read from an Integrals With Labels formatted buffer.
19
 
** The buffer must have been initialized with iwl_buf_init().
20
 
**
21
 
**    \param Buf           =  IWL Buffer to read from (already initialized)
22
 
**    \param ints          =  memory buffer to put integrals into
23
 
**    \param ioff_lt       =  ioff array for the left pair of indices (p and q)
24
 
**    \param ioff_rt       =  ioff array for the right pair of indices (r and s)
25
 
**    \param bra_ket_symm  =  if 1, then these are ERI or R12 integrals, read
26
 
**                     them in as usual, else these are [r12,T2] integrals -
27
 
**                     form [T1+T2,r12] out of these.
28
 
**
29
 
**    WARNING - if bra_ket_symm = 0 - ints must be zeroed out!
30
 
**
31
 
**    \param ioff          =  the ioff array to figure the total index pqrs 
32
 
**                            from the pair indices pq and rs
33
 
**    \param printflg      =  if 1, print integrals as they are read
34
 
**    \param outfile       =  pointer to output file for printing
35
 
**
36
 
** Returns: 0 if end of file, otherwise 1
37
 
** \ingroup (IWL)
38
 
*/
39
 
int iwl_buf_rd_all_mp2r12a(struct iwlbuf *Buf, double *ints,
40
 
                           int *ioff_lt, int *ioff_rt, int bra_ket_symm, 
41
 
                           int *ioff, int printflg, FILE *outfile)
42
 
{
43
 
  int lastbuf;
44
 
  Label *lblptr;
45
 
  Value *valptr;
46
 
  int idx, p, q, r, s;
47
 
  long int pq, rs, pqrs;
48
 
  
49
 
  lblptr = Buf->labels;
50
 
  valptr = Buf->values;
51
 
  
52
 
  lastbuf = Buf->lastbuf;
53
 
  
54
 
  for (idx=4*Buf->idx; Buf->idx<Buf->inbuf; Buf->idx++) {
55
 
    p = (int) lblptr[idx++];
56
 
    q = (int) lblptr[idx++];
57
 
    r = (int) lblptr[idx++];
58
 
    s = (int) lblptr[idx++];
59
 
 
60
 
    pq = ioff_lt[p] + q;
61
 
    rs = ioff_rt[r] + s;
62
 
 
63
 
    pqrs = INDEX(pq,rs);
64
 
 
65
 
    if (bra_ket_symm) /*! ERIs or R12-integrals */
66
 
      ints[pqrs] = (double) valptr[Buf->idx];
67
 
    else { /*! (ip|[T1+T2,r12]|jq) = -[(ip|[r12,T1]|jq) + (jq|[r12,T2]|ip)] */
68
 
      if (pq != rs)
69
 
        ints[pqrs] -= (double) valptr[Buf->idx];
70
 
      else
71
 
        ints[pqrs] -= (double) 2.0*valptr[Buf->idx];
72
 
    }
73
 
    
74
 
    if (printflg) 
75
 
      fprintf(outfile, "<%2d %2d %2d %2d [%2ld][%2ld] [[%3ld]] = %20.10lf\n",
76
 
              p, q, r, s, pq, rs, pqrs, ints[pqrs]) ;
77
 
    
78
 
  } /*! end loop through current buffer */
79
 
  
80
 
   /*! read new PSI buffers */
81
 
  while (!lastbuf) {
82
 
    iwl_buf_fetch(Buf);
83
 
    lastbuf = Buf->lastbuf;
84
 
    
85
 
    for (idx=4*Buf->idx; Buf->idx<Buf->inbuf; Buf->idx++) {
86
 
      p = (int) lblptr[idx++];
87
 
      q = (int) lblptr[idx++];
88
 
      r = (int) lblptr[idx++];
89
 
      s = (int) lblptr[idx++];
90
 
 
91
 
      pq = ioff_lt[p] + q;
92
 
      rs = ioff_rt[r] + s;
93
 
 
94
 
      pqrs = INDEX(pq,rs);
95
 
 
96
 
      if (bra_ket_symm) /*! ERIs or R12-integrals */
97
 
        ints[pqrs] = (double) valptr[Buf->idx];
98
 
      else { /*! (ip|[T1+T2,r12]|jq) = -[(ip|[r12,T2]|jq)+(jq|[r12,T2]|ip)] */
99
 
        if (pq != rs)
100
 
          ints[pqrs] -= (double) valptr[Buf->idx];
101
 
        else
102
 
          ints[pqrs] -= (double) 2.0*valptr[Buf->idx];
103
 
      }
104
 
      
105
 
      if (printflg) 
106
 
        fprintf(outfile, "<%d %d %d %d [%ld][%ld] [[%ld]] = %20.10lf\n",
107
 
                p, q, r, s, pq, rs, pqrs, ints[pqrs]) ;
108
 
      
109
 
    } /*! end loop through current buffer */
110
 
    
111
 
  } /*! end loop over reading buffers */
112
 
  
113
 
  return(0); /*! we must have reached the last buffer at this point */
114
 
}
115