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

« back to all changes in this revision

Viewing changes to src/bin/ccenergy/converged.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 CCENERGY
 
3
    \brief Enter brief description of file here 
 
4
*/
 
5
#include <cstdio>
 
6
#include <cstdlib>
 
7
#include <cmath>
 
8
#include <libipv1/ip_lib.h>
 
9
#include <libdpd/dpd.h>
 
10
#include <libqt/qt.h>
 
11
#include "MOInfo.h"
 
12
#include "Params.h"
 
13
#define EXTERN
 
14
#include "globals.h"
 
15
 
 
16
namespace psi { namespace ccenergy {
 
17
 
 
18
int converged(void)
 
19
{
 
20
  int row,col,h,nirreps;
 
21
  double rms=0.0;
 
22
  dpdfile2 T1, T1old;
 
23
  dpdbuf4 T2, T2old;
 
24
 
 
25
  nirreps = moinfo.nirreps;
 
26
 
 
27
  if(params.ref == 0) { /** RHF **/
 
28
 
 
29
    dpd_file2_init(&T1, CC_OEI, 0, 0, 1, "New tIA");
 
30
    dpd_file2_mat_init(&T1);
 
31
    dpd_file2_mat_rd(&T1);
 
32
    dpd_file2_init(&T1old, CC_OEI, 0, 0, 1, "tIA");
 
33
    dpd_file2_mat_init(&T1old);
 
34
    dpd_file2_mat_rd(&T1old);
 
35
    for(h=0; h < nirreps; h++)
 
36
      for(row=0; row < T1.params->rowtot[h]; row++)
 
37
        for(col=0; col < T1.params->coltot[h]; col++)
 
38
          rms += (T1.matrix[h][row][col] - T1old.matrix[h][row][col]) *
 
39
            (T1.matrix[h][row][col] - T1old.matrix[h][row][col]);
 
40
 
 
41
    dpd_file2_mat_close(&T1);
 
42
    dpd_file2_close(&T1);
 
43
    dpd_file2_mat_close(&T1old);
 
44
    dpd_file2_close(&T1old);
 
45
 
 
46
    dpd_buf4_init(&T2, CC_TAMPS, 0, 0, 5, 0, 5, 0, "New tIjAb");
 
47
    dpd_buf4_init(&T2old, CC_TAMPS, 0, 0, 5, 0, 5, 0, "tIjAb");
 
48
    for(h=0; h < nirreps; h++) {
 
49
      dpd_buf4_mat_irrep_init(&T2, h);
 
50
      dpd_buf4_mat_irrep_rd(&T2, h);
 
51
      dpd_buf4_mat_irrep_init(&T2old, h);
 
52
      dpd_buf4_mat_irrep_rd(&T2old, h);
 
53
      for(row=0; row < T2.params->rowtot[h]; row++)
 
54
        for(col=0; col < T2.params->coltot[h]; col++)
 
55
          rms += (T2.matrix[h][row][col] - T2old.matrix[h][row][col]) *
 
56
            (T2.matrix[h][row][col] - T2old.matrix[h][row][col]);
 
57
      dpd_buf4_mat_irrep_close(&T2, h);
 
58
      dpd_buf4_mat_irrep_close(&T2old, h);
 
59
    }
 
60
    dpd_buf4_close(&T2old);
 
61
    dpd_buf4_close(&T2);
 
62
 
 
63
  }
 
64
  else if(params.ref == 1) { /** ROHF **/
 
65
 
 
66
    dpd_file2_init(&T1, CC_OEI, 0, 0, 1, "New tIA");
 
67
    dpd_file2_mat_init(&T1);
 
68
    dpd_file2_mat_rd(&T1);
 
69
    dpd_file2_init(&T1old, CC_OEI, 0, 0, 1, "tIA");
 
70
    dpd_file2_mat_init(&T1old);
 
71
    dpd_file2_mat_rd(&T1old);
 
72
    for(h=0; h < nirreps; h++)
 
73
      for(row=0; row < T1.params->rowtot[h]; row++)
 
74
        for(col=0; col < T1.params->coltot[h]; col++)
 
75
          rms += (T1.matrix[h][row][col] - T1old.matrix[h][row][col]) *
 
76
            (T1.matrix[h][row][col] - T1old.matrix[h][row][col]);
 
77
 
 
78
    dpd_file2_mat_close(&T1);
 
79
    dpd_file2_close(&T1);
 
80
    dpd_file2_mat_close(&T1old);
 
81
    dpd_file2_close(&T1old);
 
82
 
 
83
    dpd_file2_init(&T1, CC_OEI, 0, 0, 1, "New tia");
 
84
    dpd_file2_mat_init(&T1);
 
85
    dpd_file2_mat_rd(&T1);
 
86
    dpd_file2_init(&T1old, CC_OEI, 0, 0, 1, "tia");
 
87
    dpd_file2_mat_init(&T1old);
 
88
    dpd_file2_mat_rd(&T1old);
 
89
    for(h=0; h < nirreps; h++)
 
90
      for(row=0; row < T1.params->rowtot[h]; row++)
 
91
        for(col=0; col < T1.params->coltot[h]; col++)
 
92
          rms += (T1.matrix[h][row][col] - T1old.matrix[h][row][col]) *
 
93
            (T1.matrix[h][row][col] - T1old.matrix[h][row][col]);
 
94
 
 
95
    dpd_file2_mat_close(&T1);
 
96
    dpd_file2_close(&T1);
 
97
    dpd_file2_mat_close(&T1old);
 
98
    dpd_file2_close(&T1old);
 
99
 
 
100
    dpd_buf4_init(&T2, CC_TAMPS, 0, 2, 7, 2, 7, 0, "New tIJAB");
 
101
    dpd_buf4_init(&T2old, CC_TAMPS, 0, 2, 7, 2, 7, 0, "tIJAB");
 
102
    for(h=0; h < nirreps; h++) {
 
103
      dpd_buf4_mat_irrep_init(&T2, h);
 
104
      dpd_buf4_mat_irrep_rd(&T2, h);
 
105
      dpd_buf4_mat_irrep_init(&T2old, h);
 
106
      dpd_buf4_mat_irrep_rd(&T2old, h);
 
107
      for(row=0; row < T2.params->rowtot[h]; row++)
 
108
        for(col=0; col < T2.params->coltot[h]; col++)
 
109
          rms += (T2.matrix[h][row][col] - T2old.matrix[h][row][col]) *
 
110
            (T2.matrix[h][row][col] - T2old.matrix[h][row][col]);
 
111
      dpd_buf4_mat_irrep_close(&T2, h);
 
112
      dpd_buf4_mat_irrep_close(&T2old, h);
 
113
    }
 
114
    dpd_buf4_close(&T2old);
 
115
    dpd_buf4_close(&T2);
 
116
 
 
117
    dpd_buf4_init(&T2, CC_TAMPS, 0, 2, 7, 2, 7, 0, "New tijab");
 
118
    dpd_buf4_init(&T2old, CC_TAMPS, 0, 2, 7, 2, 7, 0, "tijab");
 
119
    for(h=0; h < nirreps; h++) {
 
120
      dpd_buf4_mat_irrep_init(&T2, h);
 
121
      dpd_buf4_mat_irrep_rd(&T2, h);
 
122
      dpd_buf4_mat_irrep_init(&T2old, h);
 
123
      dpd_buf4_mat_irrep_rd(&T2old, h);
 
124
      for(row=0; row < T2.params->rowtot[h]; row++)
 
125
        for(col=0; col < T2.params->coltot[h]; col++)
 
126
          rms += (T2.matrix[h][row][col] - T2old.matrix[h][row][col]) *
 
127
            (T2.matrix[h][row][col] - T2old.matrix[h][row][col]);
 
128
      dpd_buf4_mat_irrep_close(&T2, h);
 
129
      dpd_buf4_mat_irrep_close(&T2old, h);
 
130
    }
 
131
    dpd_buf4_close(&T2old);
 
132
    dpd_buf4_close(&T2);
 
133
 
 
134
    dpd_buf4_init(&T2, CC_TAMPS, 0, 0, 5, 0, 5, 0, "New tIjAb");
 
135
    dpd_buf4_init(&T2old, CC_TAMPS, 0, 0, 5, 0, 5, 0, "tIjAb");
 
136
    for(h=0; h < nirreps; h++) {
 
137
      dpd_buf4_mat_irrep_init(&T2, h);
 
138
      dpd_buf4_mat_irrep_rd(&T2, h);
 
139
      dpd_buf4_mat_irrep_init(&T2old, h);
 
140
      dpd_buf4_mat_irrep_rd(&T2old, h);
 
141
      for(row=0; row < T2.params->rowtot[h]; row++)
 
142
        for(col=0; col < T2.params->coltot[h]; col++)
 
143
          rms += (T2.matrix[h][row][col] - T2old.matrix[h][row][col]) *
 
144
            (T2.matrix[h][row][col] - T2old.matrix[h][row][col]);
 
145
      dpd_buf4_mat_irrep_close(&T2, h);
 
146
      dpd_buf4_mat_irrep_close(&T2old, h);
 
147
    }
 
148
    dpd_buf4_close(&T2old);
 
149
    dpd_buf4_close(&T2);
 
150
  }
 
151
  else if(params.ref == 2) { /** UHF **/
 
152
 
 
153
    dpd_file2_init(&T1, CC_OEI, 0, 0, 1, "New tIA");
 
154
    dpd_file2_mat_init(&T1);
 
155
    dpd_file2_mat_rd(&T1);
 
156
    dpd_file2_init(&T1old, CC_OEI, 0, 0, 1, "tIA");
 
157
    dpd_file2_mat_init(&T1old);
 
158
    dpd_file2_mat_rd(&T1old);
 
159
    for(h=0; h < nirreps; h++)
 
160
      for(row=0; row < T1.params->rowtot[h]; row++)
 
161
        for(col=0; col < T1.params->coltot[h]; col++)
 
162
          rms += (T1.matrix[h][row][col] - T1old.matrix[h][row][col]) *
 
163
            (T1.matrix[h][row][col] - T1old.matrix[h][row][col]);
 
164
 
 
165
    dpd_file2_mat_close(&T1);
 
166
    dpd_file2_close(&T1);
 
167
    dpd_file2_mat_close(&T1old);
 
168
    dpd_file2_close(&T1old);
 
169
 
 
170
    dpd_file2_init(&T1, CC_OEI, 0, 2, 3, "New tia");
 
171
    dpd_file2_mat_init(&T1);
 
172
    dpd_file2_mat_rd(&T1);
 
173
    dpd_file2_init(&T1old, CC_OEI, 0, 2, 3, "tia");
 
174
    dpd_file2_mat_init(&T1old);
 
175
    dpd_file2_mat_rd(&T1old);
 
176
    for(h=0; h < nirreps; h++)
 
177
      for(row=0; row < T1.params->rowtot[h]; row++)
 
178
        for(col=0; col < T1.params->coltot[h]; col++)
 
179
          rms += (T1.matrix[h][row][col] - T1old.matrix[h][row][col]) *
 
180
            (T1.matrix[h][row][col] - T1old.matrix[h][row][col]);
 
181
 
 
182
    dpd_file2_mat_close(&T1);
 
183
    dpd_file2_close(&T1);
 
184
    dpd_file2_mat_close(&T1old);
 
185
    dpd_file2_close(&T1old);
 
186
 
 
187
    dpd_buf4_init(&T2, CC_TAMPS, 0, 2, 7, 2, 7, 0, "New tIJAB");
 
188
    dpd_buf4_init(&T2old, CC_TAMPS, 0, 2, 7, 2, 7, 0, "tIJAB");
 
189
    for(h=0; h < nirreps; h++) {
 
190
      dpd_buf4_mat_irrep_init(&T2, h);
 
191
      dpd_buf4_mat_irrep_rd(&T2, h);
 
192
      dpd_buf4_mat_irrep_init(&T2old, h);
 
193
      dpd_buf4_mat_irrep_rd(&T2old, h);
 
194
      for(row=0; row < T2.params->rowtot[h]; row++)
 
195
        for(col=0; col < T2.params->coltot[h]; col++)
 
196
          rms += (T2.matrix[h][row][col] - T2old.matrix[h][row][col]) *
 
197
            (T2.matrix[h][row][col] - T2old.matrix[h][row][col]);
 
198
      dpd_buf4_mat_irrep_close(&T2, h);
 
199
      dpd_buf4_mat_irrep_close(&T2old, h);
 
200
    }
 
201
    dpd_buf4_close(&T2old);
 
202
    dpd_buf4_close(&T2);
 
203
 
 
204
    dpd_buf4_init(&T2, CC_TAMPS, 0, 12, 17, 12, 17, 0, "New tijab");
 
205
    dpd_buf4_init(&T2old, CC_TAMPS, 0, 12, 17, 12, 17, 0, "tijab");
 
206
    for(h=0; h < nirreps; h++) {
 
207
      dpd_buf4_mat_irrep_init(&T2, h);
 
208
      dpd_buf4_mat_irrep_rd(&T2, h);
 
209
      dpd_buf4_mat_irrep_init(&T2old, h);
 
210
      dpd_buf4_mat_irrep_rd(&T2old, h);
 
211
      for(row=0; row < T2.params->rowtot[h]; row++)
 
212
        for(col=0; col < T2.params->coltot[h]; col++)
 
213
          rms += (T2.matrix[h][row][col] - T2old.matrix[h][row][col]) *
 
214
            (T2.matrix[h][row][col] - T2old.matrix[h][row][col]);
 
215
      dpd_buf4_mat_irrep_close(&T2, h);
 
216
      dpd_buf4_mat_irrep_close(&T2old, h);
 
217
    }
 
218
    dpd_buf4_close(&T2old);
 
219
    dpd_buf4_close(&T2);
 
220
 
 
221
    dpd_buf4_init(&T2, CC_TAMPS, 0, 22, 28, 22, 28, 0, "New tIjAb");
 
222
    dpd_buf4_init(&T2old, CC_TAMPS, 0, 22, 28, 22, 28, 0, "tIjAb");
 
223
    for(h=0; h < nirreps; h++) {
 
224
      dpd_buf4_mat_irrep_init(&T2, h);
 
225
      dpd_buf4_mat_irrep_rd(&T2, h);
 
226
      dpd_buf4_mat_irrep_init(&T2old, h);
 
227
      dpd_buf4_mat_irrep_rd(&T2old, h);
 
228
      for(row=0; row < T2.params->rowtot[h]; row++)
 
229
        for(col=0; col < T2.params->coltot[h]; col++)
 
230
          rms += (T2.matrix[h][row][col] - T2old.matrix[h][row][col]) *
 
231
            (T2.matrix[h][row][col] - T2old.matrix[h][row][col]);
 
232
      dpd_buf4_mat_irrep_close(&T2, h);
 
233
      dpd_buf4_mat_irrep_close(&T2old, h);
 
234
    }
 
235
    dpd_buf4_close(&T2old);
 
236
    dpd_buf4_close(&T2);
 
237
  }
 
238
 
 
239
  rms = sqrt(rms);
 
240
  moinfo.conv = rms;
 
241
 
 
242
  if(rms < params.convergence) return 1;
 
243
  else return 0;
 
244
}
 
245
}} // namespace psi::ccenergy