-
Notifications
You must be signed in to change notification settings - Fork 1
/
dfock2.f
300 lines (300 loc) · 8.12 KB
/
dfock2.f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
SUBROUTINE DFOCK2(F, PTOT, P, W, NUMAT, NFIRST,
1NMIDLE, NLAST, NATI)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
INCLUDE 'SIZES'
DIMENSION F(*), PTOT(*), NFIRST(*), NMIDLE(*),
1 NLAST(*), P(*), W(*)
C***********************************************************************
C
C DFOCK2 ADDS THE 2-ELECTRON 2-CENTER REPULSION CONTRIBUTION TO
C THE FOCK MATRIX DERIVATIVE WITHIN THE NDDO OR MINDO FORMALISMS.
C INPUT
C F : 1-ELECTRON CONTRIBUTIONS DERIVATIVES.
C PTOT : TOTAL DENSITY MATRIX.
C P : ALPHA OR BETA DENSITY MATRIX. = 0.5 * PTOT
C W : NON VANISHING TWO-ELECTRON INTEGRAL DERIVATIVES
C (ORDERED AS DEFINED IN DHCORE).
C NATI : # OF THE ATOM SUPPORTING THE VARYING CARTESIAN COORDINATE.
C OUTPUT
C F : FOCK MATRIX DERIVATIVE WITH RESPECT TO THE CART. COORD.
C
C***********************************************************************
COMMON /NUMCAL/ NUMCAL
COMMON /WORK4 / PTOT2
COMMON /KEYWRD/ KEYWRD
SAVE IFACT,I1FACT, ITYPE
DIMENSION IFACT(MAXORB),
1I1FACT(MAXORB), JINDEX(256), KINDEX(256), IJPERM(10), LLPERM(10),
2PK(16), PJA(16), PJB(16), MMPERM(10),
3PTOT2(NUMATM,16), JJNDEX(256)
CHARACTER*241 KEYWRD
DATA ITYPE /1/
DATA ICALCN/0/
IF(ICALCN.NE.NUMCAL)THEN
ICALCN=NUMCAL
ITYPE=0
ENDIF
10 CONTINUE
GOTO (20,270,70) ITYPE
20 CONTINUE
C
C SET UP ARRAY OF LOWER HALF TRIANGLE INDICES (PASCAL'S TRIANGLE)
C
DO 30 I=1,MAXORB
IFACT(I)=(I*(I-1))/2
30 I1FACT(I)=IFACT(I)+I
C
C SET UP GATHER-SCATTER TYPE ARRAYS FOR USE WITH TWO-ELECTRON
C INTEGRALS. JINDEX ARE THE INDICES OF THE J-INTEGRALS FOR ATOM I
C INTEGRALS. JJNDEX ARE THE INDICES OF THE J-INTEGRALS FOR ATOM J
C KINDEX ARE THE INDICES OF THE K-INTEGRALS
C
M=0
DO 40 I=1,4
DO 40 J=1,4
IJ=MIN(I,J)
JI=I+J-IJ
DO 40 K=1,4
IK=MIN(I,K)
KI=I+K-IK
DO 40 L=1,4
M=M+1
KL=MIN(K,L)
LK=K+L-KL
JL=MIN(J,L)
LJ=J+L-JL
KINDEX(M)= IFACT(LJ) +JL + 10*( IFACT(KI) +IK) -10
40 JINDEX(M)=(IFACT(JI) + IJ)*10 + IFACT(LK) + KL - 10
L=0
DO 50 I=1,4
I1=(I-1)*4
DO 50 J=1,I
I1=I1+1
L=L+1
IJPERM(L)=I1
MMPERM(L)=IJPERM(L)-16
LLPERM(L)=(I1-1)*16
50 CONTINUE
L=0
DO 60 I=1,10
M=MMPERM(I)
L=LLPERM(I)
DO 60 K=1,16
L=L+1
M=M+16
60 JJNDEX(L)=JINDEX(M)
IF(INDEX(KEYWRD,'MINDO') .NE. 0) THEN
ITYPE=2
ELSE
ITYPE=3
ENDIF
GOTO 10
70 KK=0
L=0
DO 90 I=1,NUMAT
IA=NFIRST(I)
IB=NLAST(I)
M=0
DO 80 J=IA,IB
DO 80 K=IA,IB
M=M+1
JK=MIN(J,K)
KJ=K+J-JK
JK=JK+(KJ*(KJ-1))/2
PTOT2(I,M)=PTOT(JK)
80 CONTINUE
90 CONTINUE
II=NATI
IA=NFIRST(II)
IB=NLAST(II)
DO 260 JJ=1,NUMAT
IF(II.EQ.JJ) GOTO 260
JA=NFIRST(JJ)
JB=NLAST(JJ)
JC=NMIDLE(JJ)
IF(IB-IA.GE.3.AND.JB-JA.GE.3)THEN
C
C HEAVY-ATOM - HEAVY-ATOM
C
C EXTRACT COULOMB TERMS
C
DO 100 I=1,16
PJA(I)=PTOT2(II,I)
100 PJB(I)=PTOT2(JJ,I)
C
C COULOMB TERMS
C
CALL JAB(IA,JA,LLPERM,JINDEX, JJNDEX, PJA,PJB,W(KK+1),
1F)
C
C EXCHANGE TERMS
C
C
C EXTRACT INTERSECTION OF ATOMS II AND JJ IN THE SPIN DENSITY MATRIX
C
IF(IA.GT.JA)THEN
L=0
DO 110 I=IA,IB
DO 110 J=JA,JB
L=L+1
110 PK(L)=P(IFACT(I)+J)
ELSE
L=0
DO 120 I=IA,IB
DO 120 J=JA,JB
L=L+1
120 PK(L)=P(IFACT(J)+I)
ENDIF
I1=IA
J1=JA
CALL KAB(IA,JA, PK, W(KK+1), KINDEX, F)
IA=I1
JA=J1
KK=KK+100
ELSEIF(IB-IA.GE.3)THEN
C
C LIGHT-ATOM - HEAVY-ATOM
C
C
C COULOMB TERMS
C
SUMDIA=0.D0
SUMOFF=0.D0
LL=I1FACT(JA)
K=0
DO 140 I=0,3
J1=IFACT(IA+I)+IA-1
DO 130 J=0,I-1
K=K+1
J1=J1+1
F(J1)=F(J1)+PTOT(LL)*W(KK+K)
130 SUMOFF=SUMOFF+PTOT(J1)*W(KK+K)
J1=J1+1
K=K+1
F(J1)=F(J1)+PTOT(LL)*W(KK+K)
140 SUMDIA=SUMDIA+PTOT(J1)*W(KK+K)
F(LL)=F(LL)+SUMOFF*2.D0+SUMDIA
C
C EXCHANGE TERMS
C
C
C EXTRACT INTERSECTION OF ATOMS II AND JJ IN THE SPIN DENSITY MATRIX
C
IF(IA.GT.JA)THEN
K=0
DO 160 I=IA,IB
I1=IFACT(I)+JA
SUM=0.D0
DO 150 J=IA,IB
K=K+1
J1=IFACT(J)+JA
150 SUM=SUM+P(J1)*W(KK+JINDEX(K))
160 F(I1)=F(I1)-SUM
ELSE
K=0
DO 180 I=IA,IB
I1=IFACT(JA)+I
SUM=0.D0
DO 170 J=IA,IB
K=K+1
J1=IFACT(JA)+J
170 SUM=SUM+P(J1)*W(KK+JINDEX(K))
180 F(I1)=F(I1)-SUM
ENDIF
KK=KK+10
ELSEIF(JB-JA.GE.3)THEN
C
C HEAVY-ATOM - LIGHT-ATOM
C
C
C COULOMB TERMS
C
SUMDIA=0.D0
SUMOFF=0.D0
LL=I1FACT(IA)
K=0
DO 200 I=0,3
J1=IFACT(JA+I)+JA-1
DO 190 J=0,I-1
K=K+1
J1=J1+1
F(J1)=F(J1)+PTOT(LL)*W(KK+K)
190 SUMOFF=SUMOFF+PTOT(J1)*W(KK+K)
J1=J1+1
K=K+1
F(J1)=F(J1)+PTOT(LL)*W(KK+K)
200 SUMDIA=SUMDIA+PTOT(J1)*W(KK+K)
F(LL)=F(LL)+SUMOFF*2.D0+SUMDIA
C
C EXCHANGE TERMS
C
C
C EXTRACT INTERSECTION OF ATOMS II AND JJ IN THE SPIN DENSITY MATRIX
C
IF(IA.GT.JA)THEN
K=IFACT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