3
#include <libipv1/ip_lib.h>
4
#include <libdpd/dpd.h>
9
int converged(int L_irr)
11
int row,col,h,nirreps;
16
nirreps = moinfo.nirreps;
18
dpd_file2_init(&L1, CC_LAMBDA, L_irr, 0, 1, "New LIA");
19
dpd_file2_mat_init(&L1);
20
dpd_file2_mat_rd(&L1);
21
dpd_file2_init(&L1old, CC_LAMBDA, L_irr, 0, 1, "LIA");
22
dpd_file2_mat_init(&L1old);
23
dpd_file2_mat_rd(&L1old);
25
for(h=0; h < nirreps; h++)
26
for(row=0; row < L1.params->rowtot[h]; row++)
27
for(col=0; col < L1.params->coltot[h^L_irr]; col++)
28
rms += (L1.matrix[h][row][col] - L1old.matrix[h][row][col]) *
29
(L1.matrix[h][row][col] - L1old.matrix[h][row][col]);
31
dpd_file2_mat_close(&L1);
33
dpd_file2_mat_close(&L1old);
34
dpd_file2_close(&L1old);
36
if(params.ref == 0) rms *= 2.0;
38
if(params.ref == 1) { /** ROHF **/
40
dpd_file2_init(&L1, CC_LAMBDA, L_irr, 0, 1, "New Lia");
41
dpd_file2_mat_init(&L1);
42
dpd_file2_mat_rd(&L1);
43
dpd_file2_init(&L1old, CC_LAMBDA, L_irr, 0, 1, "Lia");
44
dpd_file2_mat_init(&L1old);
45
dpd_file2_mat_rd(&L1old);
48
else if(params.ref == 2) { /** UHF **/
50
dpd_file2_init(&L1, CC_LAMBDA, L_irr, 2, 3, "New Lia");
51
dpd_file2_mat_init(&L1);
52
dpd_file2_mat_rd(&L1);
53
dpd_file2_init(&L1old, CC_LAMBDA, L_irr, 2, 3, "Lia");
54
dpd_file2_mat_init(&L1old);
55
dpd_file2_mat_rd(&L1old);
59
if(params.ref == 1 || params.ref == 2) {
60
for(h=0; h < nirreps; h++)
61
for(row=0; row < L1.params->rowtot[h]; row++)
62
for(col=0; col < L1.params->coltot[h^L_irr]; col++)
63
rms += (L1.matrix[h][row][col] - L1old.matrix[h][row][col]) *
64
(L1.matrix[h][row][col] - L1old.matrix[h][row][col]);
66
dpd_file2_mat_close(&L1);
68
dpd_file2_mat_close(&L1old);
69
dpd_file2_close(&L1old);
72
if(params.ref == 1 || params.ref == 2) {
73
dpd_buf4_init(&L2, CC_LAMBDA, L_irr, 2, 7, 2, 7, 0, "New LIJAB");
74
dpd_buf4_init(&L2old, CC_LAMBDA, L_irr, 2, 7, 2, 7, 0, "LIJAB");
75
for(h=0; h < nirreps; h++) {
76
dpd_buf4_mat_irrep_init(&L2, h);
77
dpd_buf4_mat_irrep_rd(&L2, h);
78
dpd_buf4_mat_irrep_init(&L2old, h);
79
dpd_buf4_mat_irrep_rd(&L2old, h);
80
for(row=0; row < L2.params->rowtot[h]; row++)
81
for(col=0; col < L2.params->coltot[h^L_irr]; col++)
82
rms += (L2.matrix[h][row][col] - L2old.matrix[h][row][col]) *
83
(L2.matrix[h][row][col] - L2old.matrix[h][row][col]);
84
dpd_buf4_mat_irrep_close(&L2, h);
85
dpd_buf4_mat_irrep_close(&L2old, h);
87
dpd_buf4_close(&L2old);
91
if(params.ref == 1) { /** ROHF **/
92
dpd_buf4_init(&L2, CC_LAMBDA, L_irr, 2, 7, 2, 7, 0, "New Lijab");
93
dpd_buf4_init(&L2old, CC_LAMBDA, L_irr, 2, 7, 2, 7, 0, "Lijab");
95
else if(params.ref == 2) { /** UHF **/
96
dpd_buf4_init(&L2, CC_LAMBDA, L_irr, 12, 17, 12, 17, 0, "New Lijab");
97
dpd_buf4_init(&L2old, CC_LAMBDA, L_irr, 12, 17, 12, 17, 0, "Lijab");
100
if(params.ref == 1 || params.ref == 2) {
101
for(h=0; h < nirreps; h++) {
102
dpd_buf4_mat_irrep_init(&L2, h);
103
dpd_buf4_mat_irrep_rd(&L2, h);
104
dpd_buf4_mat_irrep_init(&L2old, h);
105
dpd_buf4_mat_irrep_rd(&L2old, h);
106
for(row=0; row < L2.params->rowtot[h]; row++)
107
for(col=0; col < L2.params->coltot[h^L_irr]; col++)
108
rms += (L2.matrix[h][row][col] - L2old.matrix[h][row][col]) *
109
(L2.matrix[h][row][col] - L2old.matrix[h][row][col]);
110
dpd_buf4_mat_irrep_close(&L2, h);
111
dpd_buf4_mat_irrep_close(&L2old, h);
113
dpd_buf4_close(&L2old);
117
if(params.ref == 0 || params.ref == 1) { /** RHF/ROHF **/
118
dpd_buf4_init(&L2, CC_LAMBDA, L_irr, 0, 5, 0, 5, 0, "New LIjAb");
119
dpd_buf4_init(&L2old, CC_LAMBDA, L_irr, 0, 5, 0, 5, 0, "LIjAb");
121
else if(params.ref == 2) { /** UHF **/
122
dpd_buf4_init(&L2, CC_LAMBDA, L_irr, 22, 28, 22, 28, 0, "New LIjAb");
123
dpd_buf4_init(&L2old, CC_LAMBDA, L_irr, 22, 28, 22, 28, 0, "LIjAb");
126
for(h=0; h < nirreps; h++) {
127
dpd_buf4_mat_irrep_init(&L2, h);
128
dpd_buf4_mat_irrep_rd(&L2, h);
129
dpd_buf4_mat_irrep_init(&L2old, h);
130
dpd_buf4_mat_irrep_rd(&L2old, h);
131
for(row=0; row < L2.params->rowtot[h]; row++)
132
for(col=0; col < L2.params->coltot[h^L_irr]; col++)
133
rms += (L2.matrix[h][row][col] - L2old.matrix[h][row][col]) *
134
(L2.matrix[h][row][col] - L2old.matrix[h][row][col]);
135
dpd_buf4_mat_irrep_close(&L2, h);
136
dpd_buf4_mat_irrep_close(&L2old, h);
138
dpd_buf4_close(&L2old);
144
if(rms < params.convergence) return 1;