~ubuntu-branches/ubuntu/vivid/psicode/vivid

« back to all changes in this revision

Viewing changes to src/bin/ccsort/scf_check.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
 
#include <stdio.h>
2
 
#include <stdlib.h>
3
 
#include <libciomr/libciomr.h>
4
 
#include <libdpd/dpd.h>
5
 
#include "MOInfo.h"
6
 
#include "Params.h"
7
 
#define EXTERN
8
 
#include "globals.h"
9
 
 
10
 
void scf_check_uhf(void);
11
 
void scf_check_rhf(void);
12
 
 
13
 
void scf_check(void)
14
 
{
15
 
  if(params.ref == 2) scf_check_uhf();
16
 
  else scf_check_rhf();
17
 
}
18
 
 
19
 
void scf_check_uhf(void)
20
 
{
21
 
  int h, nirreps, i, j, I, J, IJ, Gi, Gj;
22
 
  int *aoccpi, *boccpi, *aocc_off, *bocc_off;
23
 
  double E1A, E1B, E2AA, E2BB, E2AB;
24
 
  dpdfile2 hIJ, hij;
25
 
  dpdbuf4 A;
26
 
 
27
 
  nirreps = moinfo.nirreps;
28
 
  aoccpi = moinfo.aoccpi;
29
 
  boccpi = moinfo.boccpi;
30
 
  aocc_off = moinfo.aocc_off;
31
 
  bocc_off = moinfo.bocc_off;
32
 
 
33
 
  dpd_file2_init(&hIJ, CC_OEI, 0, 0, 0, "h(I,J)");
34
 
  dpd_file2_init(&hij, CC_OEI, 0, 2, 2, "h(i,j)");
35
 
  dpd_file2_mat_init(&hIJ);
36
 
  dpd_file2_mat_init(&hij);
37
 
  dpd_file2_mat_rd(&hIJ);
38
 
  dpd_file2_mat_rd(&hij);
39
 
 
40
 
  E1A = E1B = 0.0;
41
 
  for(h=0; h < nirreps; h++) {
42
 
    for(i=0; i < aoccpi[h]; i++)
43
 
      E1A += hIJ.matrix[h][i][i];
44
 
 
45
 
    for(i=0; i < boccpi[h]; i++)
46
 
      E1B += hij.matrix[h][i][i];
47
 
  }
48
 
 
49
 
  dpd_file2_mat_close(&hIJ);
50
 
  dpd_file2_mat_close(&hij);
51
 
 
52
 
  dpd_buf4_init(&A, CC_AINTS, 0, 0, 0, 0, 0, 1, "A <IJ|KL>");
53
 
  E2AA = 0.0;
54
 
  for(h=0; h < nirreps; h++) {
55
 
    dpd_buf4_mat_irrep_init(&A, h);
56
 
    dpd_buf4_mat_irrep_rd(&A, h);
57
 
    for(Gi=0; Gi < nirreps; Gi++) {
58
 
      Gj = Gi ^ h;
59
 
      for(i=0; i < aoccpi[Gi]; i++) {
60
 
        I = aocc_off[Gi] + i;
61
 
        for(j=0; j < aoccpi[Gj]; j++) {
62
 
          J = aocc_off[Gj] + j;
63
 
          IJ = A.params->rowidx[I][J];
64
 
          E2AA += 0.5 * A.matrix[h][IJ][IJ];
65
 
        }
66
 
      }
67
 
    }
68
 
    dpd_buf4_mat_irrep_close(&A, h);
69
 
  }
70
 
  dpd_buf4_close(&A);
71
 
 
72
 
  dpd_buf4_init(&A, CC_AINTS, 0, 10, 10, 10, 10, 1, "A <ij|kl>");
73
 
  E2BB = 0.0;
74
 
  for(h=0; h < nirreps; h++) {
75
 
    dpd_buf4_mat_irrep_init(&A, h);
76
 
    dpd_buf4_mat_irrep_rd(&A, h);
77
 
    for(Gi=0; Gi < nirreps; Gi++) {
78
 
      Gj = Gi ^ h;
79
 
      for(i=0; i < boccpi[Gi]; i++) {
80
 
        I = bocc_off[Gi] + i;
81
 
        for(j=0; j < boccpi[Gj]; j++) {
82
 
          J = bocc_off[Gj] + j;
83
 
          IJ = A.params->rowidx[I][J];
84
 
          E2BB += 0.5 * A.matrix[h][IJ][IJ];
85
 
        }
86
 
      }
87
 
    }
88
 
    dpd_buf4_mat_irrep_close(&A, h);
89
 
  }
90
 
  dpd_buf4_close(&A);
91
 
 
92
 
  dpd_buf4_init(&A, CC_AINTS, 0, 22, 22, 22, 22, 0, "A <Ij|Kl>");
93
 
  E2AB = 0.0;
94
 
  for(h=0; h < nirreps; h++) {
95
 
    dpd_buf4_mat_irrep_init(&A, h);
96
 
    dpd_buf4_mat_irrep_rd(&A, h);
97
 
    for(Gi=0; Gi < nirreps; Gi++) {
98
 
      Gj = Gi ^ h;
99
 
      for(i=0; i < aoccpi[Gi]; i++) {
100
 
        I = aocc_off[Gi] + i;
101
 
        for(j=0; j < boccpi[Gj]; j++) {
102
 
          J = bocc_off[Gj] + j;
103
 
          IJ = A.params->rowidx[I][J];
104
 
          E2AB += A.matrix[h][IJ][IJ];
105
 
        }
106
 
      }
107
 
    }
108
 
    dpd_buf4_mat_irrep_close(&A, h);
109
 
  }
110
 
  dpd_buf4_close(&A);
111
 
 
112
 
  moinfo.eref = E1A+ E1B+ E2AA+ E2BB+ E2AB + moinfo.enuc + moinfo.efzc;
113
 
 
114
 
  fprintf(outfile, "\tOne-electron energy          =  %20.14f\n", E1A + E1B);
115
 
  fprintf(outfile, "\tTwo-electron (AA) energy     =  %20.14f\n", E2AA);
116
 
  fprintf(outfile, "\tTwo-electron (BB) energy     =  %20.14f\n", E2BB);
117
 
  fprintf(outfile, "\tTwo-electron (AB) energy     =  %20.14f\n", E2AB);
118
 
  fprintf(outfile, "\tTwo-electron energy          =  %20.14f\n", E2AA + E2BB + E2AB);
119
 
  fprintf(outfile, "\tFrozen-core energy (transqt) =  %20.14f\n", moinfo.efzc);
120
 
  fprintf(outfile, "\tReference energy             =  %20.14f\n", moinfo.eref);
121
 
}
122
 
 
123
 
void scf_check_rhf(void)
124
 
{
125
 
  int h, Gi, Gj;
126
 
  int i, j, I, J, IJ;
127
 
  int nirreps;
128
 
  int *occpi, *virtpi;
129
 
  int *occ_off, *vir_off;
130
 
  int *occ_sym, *vir_sym;
131
 
  int *openpi;
132
 
  dpdbuf4 AInts_anti, AInts;
133
 
  dpdfile2 Hoo;
134
 
  double E1A, E1B, E2AA, E2BB, E2AB;
135
 
 
136
 
  nirreps = moinfo.nirreps;
137
 
  occpi = moinfo.occpi; virtpi = moinfo.virtpi;
138
 
  occ_off = moinfo.occ_off; vir_off = moinfo.vir_off;
139
 
  occ_sym = moinfo.occ_sym; vir_sym = moinfo.vir_sym;
140
 
  openpi = moinfo.openpi;
141
 
 
142
 
  /* One-electron (frozen-core) contributions */
143
 
  dpd_file2_init(&Hoo, CC_OEI, 0, 0, 0, "h(i,j)");
144
 
  dpd_file2_mat_init(&Hoo);
145
 
  dpd_file2_mat_rd(&Hoo);
146
 
 
147
 
  E1A = E1B = 0.0;
148
 
  for(h=0; h < nirreps; h++) {
149
 
 
150
 
      for(i=0; i < occpi[h]; i++) 
151
 
              E1A += Hoo.matrix[h][i][i];   
152
 
 
153
 
      for(i=0; i < (occpi[h]-openpi[h]); i++) 
154
 
              E1B += Hoo.matrix[h][i][i];   
155
 
    }
156
 
 
157
 
  dpd_file2_mat_close(&Hoo);
158
 
  dpd_file2_close(&Hoo);
159
 
 
160
 
  /* Two-electron contributions */
161
 
 
162
 
  /* Prepare the A integral buffers */
163
 
  dpd_buf4_init(&AInts_anti, CC_AINTS, 0, 0, 0, 0, 0, 1, "A <ij|kl>");
164
 
  dpd_buf4_init(&AInts, CC_AINTS, 0, 0, 0, 0, 0, 0, "A <ij|kl>");
165
 
 
166
 
  E2AA = E2BB = E2AB = 0.0;
167
 
  for(h=0; h < nirreps; h++) {
168
 
 
169
 
      dpd_buf4_mat_irrep_init(&AInts_anti, h);
170
 
      dpd_buf4_mat_irrep_rd(&AInts_anti, h);
171
 
 
172
 
      /* Loop over irreps of the target */
173
 
      for(Gi=0; Gi < nirreps; Gi++) {
174
 
          Gj=Gi^h;
175
 
 
176
 
          /* Loop over the orbitals of the target */
177
 
          for(i=0; i < occpi[Gi]; i++) {
178
 
              I = occ_off[Gi] + i;
179
 
              for(j=0; j < occpi[Gj]; j++) {
180
 
                  J = occ_off[Gj] + j;
181
 
 
182
 
                  IJ = AInts_anti.params->rowidx[I][J];
183
 
 
184
 
                  E2AA += AInts_anti.matrix[h][IJ][IJ];
185
 
 
186
 
                }
187
 
            }
188
 
 
189
 
          /* Loop over the orbitals of the target */
190
 
          for(i=0; i < (occpi[Gi] - openpi[Gi]); i++) {
191
 
              I = occ_off[Gi] + i;
192
 
              for(j=0; j < (occpi[Gj] - openpi[Gj]); j++) {
193
 
                  J = occ_off[Gj] + j;
194
 
 
195
 
                  IJ = AInts_anti.params->rowidx[I][J];
196
 
 
197
 
                  E2BB += AInts_anti.matrix[h][IJ][IJ];
198
 
                }
199
 
            }
200
 
 
201
 
        }
202
 
      
203
 
      dpd_buf4_mat_irrep_close(&AInts_anti, h);
204
 
 
205
 
      dpd_buf4_mat_irrep_init(&AInts, h);
206
 
      dpd_buf4_mat_irrep_rd(&AInts, h);
207
 
 
208
 
      /* Loop over irreps of the target */
209
 
      for(Gi=0; Gi < nirreps; Gi++) {
210
 
          Gj=Gi^h;
211
 
 
212
 
          /* Loop over the orbitals of the target */
213
 
          for(i=0; i < occpi[Gi]; i++) {
214
 
              I = occ_off[Gi] + i;
215
 
              for(j=0; j < (occpi[Gj] - openpi[Gj]); j++) {
216
 
                  J = occ_off[Gj] + j;
217
 
 
218
 
                  IJ = AInts.params->rowidx[I][J];
219
 
 
220
 
                  E2AB += AInts.matrix[h][IJ][IJ];
221
 
                }
222
 
            }
223
 
 
224
 
        }
225
 
      
226
 
      dpd_buf4_mat_irrep_close(&AInts, h);
227
 
 
228
 
    }
229
 
 
230
 
  /* Close the A Integral buffers */
231
 
  dpd_buf4_close(&AInts_anti);
232
 
  dpd_buf4_close(&AInts);
233
 
 
234
 
  /*
235
 
  fprintf(outfile, "\n\tEFZC = %20.15f\n", moinfo.efzc);
236
 
  fprintf(outfile, "\n\tE1A = %20.15f\n", E1A);
237
 
  fprintf(outfile,   "\tE1B = %20.15f\n", E1B);
238
 
  fprintf(outfile,   "\tE2AA = %20.15f\n", E2AA);
239
 
  fprintf(outfile,   "\tE2BB = %20.15f\n", E2BB);
240
 
  fprintf(outfile,   "\tE2AB = %20.15f\n", E2AB);
241
 
  */
242
 
 
243
 
  moinfo.eref = E1A+E1B+0.5*(E2AA+E2BB)+E2AB + moinfo.enuc + moinfo.efzc;
244
 
 
245
 
  fprintf(outfile, "\tOne-electron energy          =  %20.14f\n", E1A+E1B);
246
 
  fprintf(outfile, "\tTwo-electron (AA) energy     =  %20.14f\n", E2AA);
247
 
  fprintf(outfile, "\tTwo-electron (BB) energy     =  %20.14f\n", E2BB);
248
 
  fprintf(outfile, "\tTwo-electron (AB) energy     =  %20.14f\n", E2AB);
249
 
  fprintf(outfile, "\tTwo-electron energy          =  %20.14f\n", 0.5*(E2AA+E2BB)+E2AB);
250
 
  fprintf(outfile, "\tFrozen-core energy (transqt) =  %20.14f\n", moinfo.efzc);
251
 
  fprintf(outfile, "\tReference energy             =  %20.14f\n", moinfo.eref);
252
 
 
253
 
}