~ubuntu-branches/ubuntu/karmic/psicode/karmic

« back to all changes in this revision

Viewing changes to src/bin/mp2/check_energy.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 <libdpd/dpd.h>
2
 
#define EXTERN
3
 
#include "globals.h"
4
 
 
5
 
void rhf_check_energy(int);
6
 
void uhf_check_energy(int);
7
 
 
8
 
void check_energy(int chk)
9
 
{
10
 
  if(params.ref == 0) return(rhf_check_energy(chk));
11
 
  else if(params.ref == 2) return(uhf_check_energy(chk));
12
 
}
13
 
 
14
 
void rhf_check_energy(int chk) 
15
 
{
16
 
  int h,i,a;
17
 
  double E_opdm = 0.0;
18
 
  double E_tpdm = 0.0;
19
 
  dpdfile2 D, F;
20
 
  dpdbuf4 G, I, I2;
21
 
 
22
 
  if(chk == 1) {
23
 
    fprintf(outfile, "\n\tEnergies re-computed from MP2 density:\n");
24
 
    fprintf(outfile,   "\t-------------------------------------\n");
25
 
    dpd_file2_init(&D, CC_OEI, 0, 0, 0, "DIJ");
26
 
    dpd_file2_init(&F, CC_OEI, 0, 0, 0, "fIJ");
27
 
    E_opdm += dpd_file2_dot(&D, &F);
28
 
    dpd_file2_close(&F);
29
 
    dpd_file2_close(&D);
30
 
  
31
 
    dpd_file2_init(&D, CC_OEI, 0, 1, 1, "DAB");
32
 
    dpd_file2_init(&F, CC_OEI, 0, 1, 1, "fAB");
33
 
    E_opdm += dpd_file2_dot(&D, &F);
34
 
    dpd_file2_close(&F);
35
 
    dpd_file2_close(&D);
36
 
 
37
 
    dpd_buf4_init(&G, CC_GAMMA, 0, 0, 5, 0, 5, 0, "GIjAb");
38
 
    dpd_buf4_init(&I, CC_DINTS, 0, 0, 5, 0, 5, 0, "D 2<ij|ab> - <ij|ba>");
39
 
    E_tpdm += 2 * dpd_buf4_dot(&G, &I);
40
 
    dpd_buf4_close(&I);
41
 
    dpd_buf4_close(&G);
42
 
  }
43
 
  else if(chk == 2) {
44
 
    fprintf(outfile, "\n\tEnergies re-computed from Fock-adjusted MP2 density:\n");
45
 
    fprintf(outfile,   "\t----------------------------------------------------\n");
46
 
    dpd_file2_init(&D, CC_OEI, 0, 0, 0, "DIJ");
47
 
    dpd_file2_init(&F, CC_OEI, 0, 0, 0, "h(i,j)");
48
 
    E_opdm += dpd_file2_dot(&D, &F);
49
 
    dpd_file2_close(&F);
50
 
    dpd_file2_close(&D);
51
 
 
52
 
    dpd_file2_init(&D, CC_OEI, 0, 1, 1, "DAB");
53
 
    dpd_file2_init(&F, CC_OEI, 0, 1, 1, "h(a,b)");
54
 
    E_opdm += dpd_file2_dot(&D, &F);
55
 
    dpd_file2_close(&F);
56
 
    dpd_file2_close(&D);
57
 
 
58
 
    dpd_file2_init(&D, CC_OEI, 0, 1, 0, "DAI");
59
 
    dpd_file2_mat_init(&D);
60
 
    dpd_file2_mat_rd(&D);
61
 
    dpd_file2_init(&F, CC_OEI, 0, 0, 1, "h(i,a)");
62
 
    dpd_file2_mat_init(&F);
63
 
    dpd_file2_mat_rd(&F);
64
 
    for(h=0; h < mo.nirreps; h++)
65
 
      for(a=0; a < mo.virtpi[h]; a++)
66
 
        for(i=0; i < mo.doccpi[h]; i++)  
67
 
          E_opdm += 2*D.matrix[h][a][i]*F.matrix[h][i][a];
68
 
    dpd_file2_mat_close(&F);
69
 
    dpd_file2_mat_close(&D);
70
 
    dpd_file2_close(&F);
71
 
    dpd_file2_close(&D);
72
 
 
73
 
    dpd_buf4_init(&G, CC_GAMMA, 0, 0, 0, 0, 0, 0, "GIjKl");
74
 
    dpd_buf4_init(&I, CC_AINTS, 0, 0, 0, 0, 0, 0, "A <ij|kl>");
75
 
    dpd_buf4_scmcopy(&I, CC_AINTS, "A 2<ij|kl> - <ij|lk>", 2);
76
 
    dpd_buf4_sort_axpy(&I, CC_AINTS, pqsr, 0, 0, "A 2<ij|kl> - <ij|lk>", -1);
77
 
    dpd_buf4_close(&I);
78
 
    dpd_buf4_init(&I, CC_AINTS, 0, 0, 0, 0, 0, 0, "A 2<ij|kl> - <ij|lk>");
79
 
    E_tpdm += 0.5 * dpd_buf4_dot(&I, &G);
80
 
    dpd_buf4_close(&I);
81
 
    dpd_buf4_close(&G);
82
 
 
83
 
    dpd_buf4_init(&G, CC_GAMMA, 0, 11, 0, 11, 0, 0, "GAiJk");
84
 
    dpd_buf4_init(&I, CC_EINTS, 0, 11, 0, 11, 0, 0, "E 2<ai|jk> - <ai|kj>");
85
 
    E_tpdm += 2*dpd_buf4_dot(&I, &G);
86
 
    dpd_buf4_close(&I);
87
 
    dpd_buf4_close(&G);
88
 
    
89
 
    dpd_buf4_init(&G, CC_GAMMA, 0, 10, 10, 10, 10, 0, "GIbJa");
90
 
    dpd_buf4_init(&I, CC_CINTS, 0, 10, 10, 10, 10, 0, "C <ia||jb>");
91
 
    E_tpdm += dpd_buf4_dot(&I, &G);
92
 
    dpd_buf4_close(&I);
93
 
    dpd_buf4_init(&I, CC_CINTS, 0, 10, 10, 10, 10, 0, "C <ia|jb>");
94
 
    E_tpdm += dpd_buf4_dot(&I, &G);
95
 
    dpd_buf4_close(&I);
96
 
    dpd_buf4_close(&G);
97
 
 
98
 
    dpd_buf4_init(&G, CC_GAMMA, 0, 0, 5, 0, 5, 0, "GIjAb");
99
 
    dpd_buf4_init(&I, CC_DINTS, 0, 0, 5, 0, 5, 0, "D 2<ij|ab> - <ij|ba>");
100
 
    E_tpdm += 2*dpd_buf4_dot(&G, &I);
101
 
    dpd_buf4_close(&I);
102
 
    dpd_buf4_close(&G);
103
 
  }
104
 
  else if(chk == 3) {
105
 
    fprintf(outfile, "\n\tEnergies re-computed from MP2 Mulliken density:\n");
106
 
    fprintf(outfile,   "\t-----------------------------------------------\n");
107
 
    dpd_file2_init(&D, CC_OEI, 0, 0, 0, "DIJ");
108
 
    dpd_file2_init(&F, CC_OEI, 0, 0, 0, "h(i,j)");
109
 
    E_opdm += dpd_file2_dot(&D, &F);
110
 
    dpd_file2_close(&F);
111
 
    dpd_file2_close(&D);
112
 
 
113
 
    dpd_file2_init(&D, CC_OEI, 0, 1, 1, "DAB");
114
 
    dpd_file2_init(&F, CC_OEI, 0, 1, 1, "h(a,b)");
115
 
    E_opdm += dpd_file2_dot(&D, &F);
116
 
    dpd_file2_close(&F);
117
 
    dpd_file2_close(&D);
118
 
 
119
 
    dpd_file2_init(&D, CC_OEI, 0, 1, 0, "DAI");
120
 
    dpd_file2_mat_init(&D);
121
 
    dpd_file2_mat_rd(&D);
122
 
    dpd_file2_init(&F, CC_OEI, 0, 0, 1, "h(i,a)");
123
 
    dpd_file2_mat_init(&F);
124
 
    dpd_file2_mat_rd(&F);
125
 
    for(h=0; h < mo.nirreps; h++)
126
 
      for(a=0; a < mo.virtpi[h]; a++)
127
 
        for(i=0; i < mo.doccpi[h]; i++)  
128
 
          E_opdm += 2 * D.matrix[h][a][i] * F.matrix[h][i][a];
129
 
    dpd_file2_mat_close(&F);
130
 
    dpd_file2_mat_close(&D);
131
 
    dpd_file2_close(&F);
132
 
    dpd_file2_close(&D);
133
 
 
134
 
    dpd_buf4_init(&G, CC_GAMMA, 0, 0, 0, 0, 0, 0, "GIjKl");
135
 
    dpd_buf4_init(&I, CC_AINTS, 0, 0, 0, 0, 0, 0, "A <ij|kl>");
136
 
    E_tpdm += 0.5 * dpd_buf4_dot(&I, &G);
137
 
    dpd_buf4_close(&I);
138
 
    dpd_buf4_close(&G);
139
 
    
140
 
    dpd_buf4_init(&G, CC_GAMMA, 0, 11, 0, 11, 0, 0, "GAiJk");
141
 
    dpd_buf4_init(&I, CC_EINTS, 0, 11, 0, 11, 0, 0, "E <ai|jk>");
142
 
    E_tpdm += 2*dpd_buf4_dot(&I, &G);
143
 
    dpd_buf4_close(&I);
144
 
    dpd_buf4_close(&G);
145
 
 
146
 
    dpd_buf4_init(&G, CC_GAMMA, 0, 10, 10, 10, 10, 0, "GIbJa");
147
 
    dpd_buf4_init(&I, CC_CINTS, 0, 10, 10, 10, 10, 0, "C <ia|jb>");
148
 
    E_tpdm += dpd_buf4_dot(&I, &G);
149
 
    dpd_buf4_close(&I);
150
 
    dpd_buf4_close(&G);
151
 
    
152
 
    dpd_buf4_init(&G, CC_GAMMA, 0, 0, 5, 0, 5, 0, "GIjAb");
153
 
    dpd_buf4_init(&I, CC_DINTS, 0, 0, 5, 0, 5, 0, "D <ij|ab>");
154
 
    E_tpdm += 2*dpd_buf4_dot(&G, &I);
155
 
    dpd_buf4_close(&I);
156
 
    dpd_buf4_close(&G);
157
 
  }
158
 
  else {
159
 
 
160
 
  }
161
 
 
162
 
  fprintf(outfile,"\n");
163
 
  fprintf(outfile,"\tE_OPDM                  = %20.15f\n",E_opdm);
164
 
  fprintf(outfile,"\tE_TPDM                  = %20.15f\n",E_tpdm);
165
 
  fprintf(outfile,"\tMP2 correlation energy  = %20.15f\n",E_opdm+E_tpdm);
166
 
  fflush(outfile);
167
 
}
168
 
 
169
 
void uhf_check_energy(int chk)
170
 
{
171
 
 
172
 
}