4
#include <libciomr/libciomr.h>
11
/*--- External function declaration ---*/
12
extern void OI_OSrecurs(double **OIX, double **OIY, double **OIZ, struct coordinates PA, struct coordinates PB,
13
double gamma, int lmaxi, int lmaxj);
15
/*------------------------------------------------------
16
This function computes the overlap matrix S12 between
17
the new and old bases (in SO basis)
18
------------------------------------------------------*/
19
double **overlap_new_old()
21
struct coordinates A, B, P, PA, PB;
25
int x1, x2, y1, y2, z1, z2;
26
int s1, s2, ao1, ao2, l1, l2, n1, n2, p1, p2,
27
prim1, prim2, fprim1, fprim2, nprim1, nprim2, atom1, atom2, bf1, bf2;
28
double exp1, exp2, cc1, cc2, norm1;
29
double ab2, pfac, gam, oog;
31
double **stemp, **S12_AO, **S12, **OIX, **OIY, **OIZ;
34
S12_AO = block_matrix(num_ao, Oldcalc.num_ao);
35
maxsz1 = ioff[max_angmom+1];
36
maxsz2 = ioff[Oldcalc.max_angmom+1];
37
stemp = block_matrix(maxsz1,maxsz2);
39
OIX = block_matrix(max_angmom+1,Oldcalc.max_angmom+1);
40
OIY = block_matrix(max_angmom+1,Oldcalc.max_angmom+1);
41
OIZ = block_matrix(max_angmom+1,Oldcalc.max_angmom+1);
43
/*--- Loop over shells ---*/
44
for(s1=0;s1<num_shells;s1++) {
45
ao1 = first_ao_shell[s1];
46
nprim1 = nprim_in_shell[s1];
47
fprim1 = first_prim_shell[s1];
48
bf1 = first_ao_shell[s1];
49
l1 = shell_ang_mom[s1];
51
atom1 = shell_nucleus[s1];
52
A.x = geometry[atom1][0];
53
A.y = geometry[atom1][1];
54
A.z = geometry[atom1][2];
55
for(s2=0;s2<Oldcalc.num_shells;s2++) {
56
ao2 = Oldcalc.first_ao_shell[s2];
57
nprim2 = Oldcalc.nprim_in_shell[s2];
58
fprim2 = Oldcalc.first_prim_shell[s2];
59
bf2 = Oldcalc.first_ao_shell[s2];
60
l2 = Oldcalc.shell_ang_mom[s2];
62
atom2 = Oldcalc.shell_nucleus[s2];
63
B.x = Oldcalc.geometry[atom2][0];
64
B.y = Oldcalc.geometry[atom2][1];
65
B.z = Oldcalc.geometry[atom2][2];
67
ab2 = (A.x-B.x)*(A.x-B.x);
68
ab2 += (A.y-B.y)*(A.y-B.y);
69
ab2 += (A.z-B.z)*(A.z-B.z);
71
/*--- zero the temporary storage for accumulating contractions ---*/
72
memset(stemp[0],0,sizeof(double)*maxsz1*maxsz2);
74
/*--- Loop over primitives here ---*/
75
for(p1=0,prim1=fprim1;p1<nprim1;p1++,prim1++) {
76
exp1 = exponents[prim1];
77
cc1 = contr_coeff[prim1];
78
for(p2=0,prim2=fprim2;p2<nprim2;p2++,prim2++) {
79
exp2 = Oldcalc.exponents[prim2];
80
cc2 = Oldcalc.contr_coeff[prim2][l2];
84
P.x = (exp1*A.x + exp2*B.x)*oog;
85
P.y = (exp1*A.y + exp2*B.y)*oog;
86
P.z = (exp1*A.z + exp2*B.z)*oog;
94
pfac = exp(-exp1*exp2*ab2*oog)*sqrt(M_PI*oog)*M_PI*oog*cc1*cc2;
96
OI_OSrecurs(OIX,OIY,OIZ,PA,PB,gam,l1,l2);
98
/*--- create all am components of si ---*/
100
for(ii = 0; ii <= l1; ii++){
102
for(jj = 0; jj <= ii; jj++){
105
/*--- create all am components of sj ---*/
107
for(kk = 0; kk <= l2; kk++){
109
for(ll = 0; ll <= kk; ll++){
113
stemp[ao1][ao2] += pfac*OIX[x1][x2]*OIY[y1][y2]*OIZ[z1][z2];
120
} /*--- end cartesian components for (si,sj) with primitives (i,j) ---*/
122
} /*--- end primitive contraction ---*/
124
/*--- Normalize the contracted integrals and put them into S12 ---*/
125
ptr1 = GTOs.bf_norm[l1];
126
ptr2 = GTOs.bf_norm[l2];
127
for(ii=0; ii<n1; ii++) {
129
for(jj=0; jj<n2; jj++) {
130
S12_AO[bf1+ii][bf2+jj] = stemp[ii][jj]*norm1*ptr2[jj];
135
} /*--- This shell pair is done ---*/
142
/*--- transform to SO basis ---*/
143
tmpmat = block_matrix(num_so,Oldcalc.num_ao);
144
mmult(usotao,0,S12_AO,0,tmpmat,0,num_so,num_ao,Oldcalc.num_ao,0);
146
S12 = block_matrix(num_so,Oldcalc.num_so);
147
mmult(tmpmat,0,Oldcalc.usotao,1,S12,0,num_so,Oldcalc.num_ao,Oldcalc.num_so,0);
150
if (print_lvl >= DEBUGPRINT) {
151
fprintf(outfile," -Overlap matrix between the new and old basis (in SO basis):\n");
152
print_mat(S12,num_so,Oldcalc.num_so,outfile);
159
/*--------------------------------------------------
160
This function computes the overlap matrix S11 for
161
the new basis set (in SO basis)
162
--------------------------------------------------*/
165
struct coordinates A, B, P, PA, PB;
169
int x1, x2, y1, y2, z1, z2;
170
int s1, s2, ao1, ao2, l1, l2, n1, n2, p1, p2,
171
prim1, prim2, fprim1, fprim2, nprim1, nprim2, atom1, atom2, bf1, bf2;
172
double exp1, exp2, cc1, cc2, norm1;
173
double ab2, pfac, gam, oog;
175
double **stemp, **S11_AO, **S11, **OIX, **OIY, **OIZ;
178
S11_AO = block_matrix(num_ao, num_ao);
179
maxsz1 = ioff[max_angmom+1];
180
maxsz2 = ioff[max_angmom+1];
181
stemp = block_matrix(maxsz1,maxsz2);
183
OIX = block_matrix(max_angmom+1,max_angmom+1);
184
OIY = block_matrix(max_angmom+1,max_angmom+1);
185
OIZ = block_matrix(max_angmom+1,max_angmom+1);
187
/*--- Loop over shells ---*/
188
for(s1=0;s1<num_shells;s1++) {
189
ao1 = first_ao_shell[s1];
190
nprim1 = nprim_in_shell[s1];
191
fprim1 = first_prim_shell[s1];
192
bf1 = first_ao_shell[s1];
193
l1 = shell_ang_mom[s1];
195
atom1 = shell_nucleus[s1];
196
A.x = geometry[atom1][0];
197
A.y = geometry[atom1][1];
198
A.z = geometry[atom1][2];
199
for(s2=0;s2<num_shells;s2++) {
200
ao2 = first_ao_shell[s2];
201
nprim2 = nprim_in_shell[s2];
202
fprim2 = first_prim_shell[s2];
203
bf2 = first_ao_shell[s2];
204
l2 = shell_ang_mom[s2];
206
atom2 = shell_nucleus[s2];
207
B.x = geometry[atom2][0];
208
B.y = geometry[atom2][1];
209
B.z = geometry[atom2][2];
211
ab2 = (A.x-B.x)*(A.x-B.x);
212
ab2 += (A.y-B.y)*(A.y-B.y);
213
ab2 += (A.z-B.z)*(A.z-B.z);
215
/*--- zero the temporary storage for accumulating contractions ---*/
216
memset(stemp[0],0,sizeof(double)*maxsz1*maxsz2);
218
/*--- Loop over primitives here ---*/
219
for(p1=0,prim1=fprim1;p1<nprim1;p1++,prim1++) {
220
exp1 = exponents[prim1];
221
cc1 = contr_coeff[prim1];
222
for(p2=0,prim2=fprim2;p2<nprim2;p2++,prim2++) {
223
exp2 = exponents[prim2];
224
cc2 = contr_coeff[prim2];
228
P.x = (exp1*A.x + exp2*B.x)*oog;
229
P.y = (exp1*A.y + exp2*B.y)*oog;
230
P.z = (exp1*A.z + exp2*B.z)*oog;
238
pfac = exp(-exp1*exp2*ab2*oog)*sqrt(M_PI*oog)*M_PI*oog*cc1*cc2;
240
OI_OSrecurs(OIX,OIY,OIZ,PA,PB,gam,l1,l2);
242
/*--- create all am components of si ---*/
244
for(ii = 0; ii <= l1; ii++){
246
for(jj = 0; jj <= ii; jj++){
249
/*--- create all am components of sj ---*/
251
for(kk = 0; kk <= l2; kk++){
253
for(ll = 0; ll <= kk; ll++){
257
stemp[ao1][ao2] += pfac*OIX[x1][x2]*OIY[y1][y2]*OIZ[z1][z2];
264
} /*--- end cartesian components for (si,sj) with primitives (i,j) ---*/
266
} /*--- end primitive contraction ---*/
268
/*--- Normalize the contracted integrals and put them into S11 ---*/
269
ptr1 = GTOs.bf_norm[l1];
270
ptr2 = GTOs.bf_norm[l2];
271
for(ii=0; ii<n1; ii++) {
273
for(jj=0; jj<n2; jj++) {
274
S11_AO[bf1+ii][bf2+jj] = stemp[ii][jj]*norm1*ptr2[jj];
278
} /*--- This shell pair is done ---*/
285
/*--- transform to SO basis ---*/
286
tmpmat = block_matrix(num_so,num_ao);
287
mmult(usotao,0,S11_AO,0,tmpmat,0,num_so,num_ao,num_ao,0);
289
S11 = block_matrix(num_so,num_so);
290
mmult(tmpmat,0,usotao,1,S11,0,num_so,num_ao,num_so,0);
293
if (print_lvl >= DEBUGPRINT) {
294
fprintf(outfile," -Overlap matrix in the new basis (in SO basis):\n");
295
print_mat(S11,num_so,num_so,outfile);