-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAFdiag.f
372 lines (370 loc) · 16.5 KB
/
AFdiag.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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
c***********************************************************************
SUBROUTINE AFdiag(RDIST,NCMM,NCMMax,MMLR,PSEL,De,Cm,rhoAB,sVSR2,
1 IDSTT,ULR,dULRdCm,dULRdR,dULRdDe)
c***********************************************************************
c** Aubert-Frecon Potential Model for u_{LR}(r)
c***********************************************************************
c** Subroutine to generate, at the onee distance RDIST, an eigenvalue
c of the 2x2 or 3x3 long-range interaction matrix described by Eqs.1
c and 10, resp., of J.Mol.Spec.188, 182 (1998) (Aubert-Frecon et al)
c** and its derivatives w.r.t. the C_m long-range parameters.
c***********************************************************************
c==> Input: r= RDIST, NCMM, m=MMLR & Cm's, rhoAB, sVSR2, IDSTT
c==> Output: ULR, partial derivatives dULRdCm & radial derivative dULRdR
c-----------------------------------------------------------------------
c** Summer 2008 Original Version from Nike Dattani for 3x3 case
c** July 2014 incorporated 2x2 case, removed retardation terms and
c incorporate damping ... by Kai Slaughter
c-----------------------------------------------------------------------
INTEGER NCMMax
c-----------------------------------------------------------------------
REAL*8 RDIST,Cm(NCMMax),ULR,dULRdCm(NCMMax),dULRdR,R2,R3,R5,
1 R6,R8,R9,T1,T0,T2,T0P,T0P23,DDe1,DDe2,DDe3,DELTAE,Modulus,Z,
2 Dm(NCMMax),Dmp(NCMMax),De,DDe(3,3),Dmpp(NCMMax),rhoAB,A(3,3),
3 DR(3,3),Q(3,3),DMx(NCMMax,3,3),DMtemp(3,3),DEIGMx(NCMMax,1,1),
4 DEIGMtemp(1,1),DEIGR(1,1),DEIGdDe(1,1),EIGVEC(3,1),RESID(3,1),
5 W(3),RPOW(NCMMax), dULRdDe
INTEGER H,I,J,K,L,M,X,NCMM,MMLR(NCMMax),sVSR2,IDSTT,PSEL
c-----------------------------------------------------------------------
DELTAE=Cm(1)
R2= 1.d0/RDIST**2
R3= R2/RDIST
R5= R2*R3
R6= R3*R3
R8= R6*R2
c-----------------------------------------------------------------------
c....... for rhoAB.le.0.0 returns Dm(m)=1 & Dmp(m)=Dmpp(m)=0
CALL dampF(RDIST,rhoAB,NCMM,NCMMAX,MMLR,sVSR2,IDSTT,Dm,Dmp,Dmpp)
c-----------------------------------------------------------------------
IF(MMLR(1).GE.-1) THEN !! For the A (0) or b (-1) state
c***********************************************************************
c************* Aubert Frecon 2x2 case NCMM= 7 and ...
c*** Cm(1) = DELTAE
c*** Cm(2) = C3Sig
c*** Cm(3) = C3Pi
c*** Cm(4) = C6Sig
c*** Cm(5) = C6Pi
c*** Cm(6) = C8Sig
c*** Cm(7) = C8Pi
c***********************************************************************
T1= R3*(Dm(2)*(Cm(2)-Cm(3)) + R3*Dm(4)*(Cm(4)-Cm(5)) +
1 R5*Dm(6)*(Cm(6)-Cm(7)))/3.d0
T0= DSQRT((T1 - Cm(1))**2 + 8.d0*T1**2)
ULR= 0.5d0*(-Cm(1) + R3*(Dm(2)*(Cm(2)+Cm(3)) +
1 R3*Dm(4)*(Cm(4)+Cm(5)) + R5*Dm(6)*(Cm(6)+Cm(7))) + T0)
c-----------------------------------------------------------------------
IF(MMLR(1).EQ.0) THEN
ULR= ULR + Cm(8)*R3*R6 !! add C9{adj correction
ENDIF
c... adjustment for the b-state
IF(MMLR(1).EQ.-1) THEN
ULR=ULR-T0
ULR= ULR + Cm(9)*R3*R6 !! add C9{adj correction
ENDIF
c... now get derivatives
T0P= 0.5d0*(9.d0*T1 - Cm(1))/T0
T0P23= 0.5d0 + T0P/3.d0
c... another adjustment for the b-state
IF(MMLR(1).EQ.-1) T0P23=T0P23-2.d0*T0P/3.d0
dULRdCm(1)= 0.d0
dULRdCm(2)= R3*(T0P23)
dULRdCm(3)= R3*(1.d0-T0P23)
dULRdCm(4)= R6*(T0P23)
dULRdCm(5)= R6*(1.d0 - T0P23)
dULRdCm(6)= R8*T0P23
dULRdCm(7)= R8*(1.d0-T0P23)
T2 =-T0P*R3*((Dm(2)*(Cm(2)-Cm(3))+R3*(Dm(4)*2.d0*(Cm(4)
1 -Cm(5))+R2*Dm(6)*8.d0/3.d0*(Cm(6)-Cm(7))))/RDIST
2 +(Dmp(2)*(Cm(2)-Cm(3))+R3*Dmp(4)*(Cm(4)-Cm(5))+
3 R2*R3*Dmp(6)*(Cm(6)-Cm(7)))/3.d0)
dULRdR = -R3*((1.5d0*Dm(2)*(Cm(2)+Cm(3)) + R3*(Dm(4)*3.d0*
1 (Cm(4)+Cm(5))+4.d0*Dm(6)*R2*(Cm(6)+Cm(7))))/RDIST
2 + 0.5d0*(Dmp(2)*(Cm(2)+Cm(3)) + Dmp(4)*R3*(Cm(4)+
3 Cm(5)) + Dmp(6)*R3*R2*(Cm(6)+Cm(7)))) + T2
c... and a final adjustment for the b-state
IF(MMLR(1).EQ.-1) dULRdR= dULRdR- 2.d0*T2
c-----------------------------------------------------------------------
ELSE
c***********************************************************************
c********* Aubert Frecon 3x3 case NCMM= 10 and ...
c********* Cm(1) = DELTAE
c********* Cm(2) = C3Sig
c********* Cm(3) = C3Pi1
c********* Cm(4) = C3Pi3
c********* Cm(5) = C6Sig
c********* Cm(6) = C6Pi1
c********* Cm(7) = C6Pi3
c********* Cm(8) = C8Sig
c********* Cm(9) = C8Pi1
c********* Cm(10)= C8Pi3
c***********************************************************************
c... Initialize interaction matrix to 0.d0
DO I= 1,3
DO J= 1,3
A(I,J)=0.0D0
DR(I,J)=0.d0
DO K= 1,NCMMax
DMx(K,I,J)=0.d0
ENDDO
ENDDO
ENDDO
c... Prepare interaction matrix A
DO I= 2,NCMM,3
RPOW(I)= RDIST**MMLR(I)
A(1,1)=A(1,1)-Dm(I)*(Cm(I)+Cm(I+1)+Cm(I+2))/(3.d0*RPOW(I))
A(1,2)=A(1,2)-Dm(I)*(Cm(I+2)+Cm(I+1)-2.d0*Cm(I))/(RPOW(I))
A(1,3)=A(1,3)-Dm(I)*(Cm(I+2)-Cm(I+1))/(RPOW(I))
A(2,2)= A(2,2)-Dm(I)*(Cm(I+2)+Cm(I+1)+4.d0*Cm(I))
1 /(6.d0*RPOW(I))
A(3,3)= A(3,3) - Dm(I)*(Cm(I+2)+Cm(I+1))/(2.d0*RPOW(I))
ENDDO
A(1,2) = A(1,2)/(3.d0*DSQRT(2.d0))
A(2,1) = A(1,2)
A(2,2) = A(2,2) + DELTAE
A(2,3) = A(1,3)/(2.d0*DSQRT(3.d0))
A(1,3) = A(1,3)/(DSQRT(6.d0))
A(3,1) = A(1,3)
A(3,2) = A(2,3)
A(3,3) = A(3,3) + DELTAE
c... Prepare radial derivative of interaction matrix (? is it needed ?)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(1.d0 + Dm(J)*Cm(J)/
1 (2.d0*De*RPOW(J)))
DMx(J,3,1)= DMx(J,3,1)
DMx(J,3,3)= DMx(J,3,3)*(1.d0 + Dm(J)*Cm(J)/
1 (2.d0*De*RPOW(J)))
ENDDO
c!! and finally ... derivatives w.r.t. De
DDE1= ((Dm(I-3)*Cm(I-3)/2.d0*De)**2/RPOW(I)
DDE2= ((Dm(I-2)*Cm(I-2)/2.d0*De)**2/RPOW(I)
DDE3= ((Dm(I-1)*Cm(I-1)/2.d0*De)**2/RPOW(I)
DDe(1,1)= (DDe1 + DDe2 + DDe3)/3.d0
DDe(1,2)= (-2.d0*DDe1 + DDe2 + DDe3)/(3.d0*SQRT(2.d0))
DDe(2,1)= DDe(1,2)
DDe(1,3)= (-DDe2 + Dde3)/SQRT(6.d0)
DDe(3,1)= DDe(1,3)
DDe(2,2)= (4.d0*DDe1 + DDe2 + DDe3)/6.d0
DDe(2,3)= DDe(1,3)/SQRT(2.d0)
DDe(3,2)- DDe(2,3)
DDe(3,3)= (DDe2 + DDe3)/2.d0
ENDIF
ENDDO
c... Call subroutine to prepare and invert interaction matrix A
CALL DSYEVJ3(A,Q,W)
L=1
c... Now - identify the lowest eigenvalue of A and label it L
DO J=2,3
IF (W(J) .LT. W(L)) THEN
L=J
ENDIF
ENDDO
c... Identifiy the highest eigenvalue of A and label it H
H=1
DO J=2,3
IF(W(J).GT.W(H)) THEN
H=J
ENDIF
ENDDO
c... Identify the middle eigenvalue of A and label it M
M=1
DO J=2,3
IF((J.NE.L).AND.(J.NE.H)) M= J
ENDDO
c... Select which eigenvalue to use based on user input
IF(MMLR(1).EQ.-2) THEN
X = L
ELSEIF(MMLR(1).EQ.-3) THEN
X = M
ELSE
X = H
ENDIF
c... determine ULR and eigenvectors
ULR= -W(X)
IF(MMLR(1).EQ.-2) ULR= ULR+ Cm(11)*R3*R6 !! C9adj term
IF((MMLR(1).EQ.-3).OR.(MMLR(1).EQ.-4)) ULR = ULR + DELTAE
IF(MMLR(1).EQ.-3) ULR= ULR+ Cm(12)*R3*R6 !! C9adj term
IF(MMLR(1).EQ.-4) ULR= ULR+ Cm(13)*R3*R6 !! C9adj term
!!!!! print for testing !! print for testing !! print for testing
cc WRITE(25,600) RDIST ,ULR, W(1),W(2),W(3) !! print for testing
cc600 FORMAT(F12.4,1P,D16.7,2x,3D15.7) !! print for testing
!!!!! print for testing !! print for testing !! print for testing
DO I=1,3
EIGVEC(I,1) = Q(I,X)
ENDDO
cc loop over values of m to determine partial derivatives w.r.t. each Cm
DO I=2,NCMM
DMtemp(1:3,1:3) = DMx(I,1:3,1:3)
DEIGMtemp= -MATMUL(TRANSPOSE(EIGVEC),MATMUL(DMtemp,EIGVEC))
dULRdCm(I)= DEIGMtemp(1,1)
ENDDO
DEIGR = -MATMUL(TRANSPOSE(EIGVEC),MATMUL(DR,EIGVEC))
dULRdR= DEIGR(1,1) !! radial derivative w.r.t. r (I think!)
DEIGDe = -MATMUL(TRANSPOSE(EIGVEC),MATMUL(DDe,EIGVEC))
dULRdDe= DEIGDe(1,1) !! derivatives w.r.t. De ???
c------------------------------------------------------------------------
ENDIF
c------------------------------------------------------------------------
RETURN
CONTAINS
c=======================================================================
SUBROUTINE DSYEVJ3(A, Q, W)
c ----------------------------------------------------------------------
c** Subroutine to setup and diagonalize the matrix A and return
c eigenvalues W and eigenvector matrix Q
INTEGER N, I, X, Y, R
PARAMETER (N=3)
REAL*8 A(3,3), Q(3,3), W(3)
REAL*8 SD, SO, S, C, T, G, H, Z, THETA, THRESH
c Initialize Q to the identitity matrix
c --- This loop can be omitted if only the eigenvalues are desired ---
DO X = 1, N
Q(X,X) = 1.0D0
DO Y = 1, X-1
Q(X, Y) = 0.0D0
Q(Y, X) = 0.0D0
ENDDO
ENDDO
c Initialize W to diag(A)
DO X = 1, N
W(X) = A(X, X)
ENDDO
c Calculate SQR(tr(A))
SD = 0.0D0
DO X = 1, N
SD = SD + ABS(W(X))
ENDDO
SD = SD**2
c Main iteration loop
DO 40 I = 1, 50
c Test for convergence
SO = 0.0D0
DO X = 1, N
DO Y = X+1, N
SO = SO + ABS(A(X, Y))
ENDDO
ENDDO
IF(SO .EQ. 0.0D0) RETURN
IF(I .LT. 4) THEN
THRESH = 0.2D0 * SO / N**2
ELSE
THRESH = 0.0D0
END IF
c Do sweep
DO 60 X = 1, N
DO 61 Y = X+1, N
G = 100.0D0 * ( ABS(A(X, Y)) )
IF ( I .GT. 4 .AND. ABS(W(X)) + G .EQ. ABS(W(X))
$ .AND. ABS(W(Y)) + G .EQ. ABS(W(Y))) THEN
A(X, Y) = 0.0D0
ELSE IF (ABS(A(X, Y)) .GT. THRESH) THEN
c Calculate Jacobi transformation
H = W(Y) - W(X)
IF ( ABS(H) + G .EQ. ABS(H) ) THEN
T = A(X, Y) / H
ELSE
THETA = 0.5D0 * H / A(X, Y)
IF (THETA .LT. 0.0D0) THEN
T= -1.0D0/(SQRT(1.0D0 + THETA**2)-THETA)
ELSE
T= 1.0D0/(SQRT(1.0D0 + THETA**2) + THETA)
END IF
END IF
C = 1.0D0 / SQRT( 1.0D0 + T**2 )
S = T * C
Z = T * A(X, Y)
c Apply Jacobi transformation
A(X, Y) = 0.0D0
W(X) = W(X) - Z
W(Y) = W(Y) + Z
DO R = 1, X-1
T = A(R, X)
A(R, X) = C * T - S * A(R, Y)
A(R, Y) = S * T + C * A(R, Y)
ENDDO
DO R = X+1, Y-1
T = A(X, R)
A(X, R) = C * T - S * A(R, Y)
A(R, Y) = S * T + C * A(R, Y)
ENDDO
DO R = Y+1, N
T = A(X, R)
A(X, R) = C * T - S * A(Y, R)
A(Y, R) = S * T + C * A(Y, R)
ENDDO
c Update eigenvectors
c --- This loop can be omitted if only the eigenvalues are desired ---
DO R = 1, N
T = Q(R, X)
Q(R, X) = C * T - S * Q(R, Y)
Q(R, Y) = S * T + C * Q(R, Y)
ENDDO
END IF
61 CONTINUE
60 CONTINUE
40 CONTINUE
WRITE(6,'("DSYEVJ3: No convergence.")')
END SUBROUTINE DSYEVJ3
END SUBROUTINE AFdiag
c23456789 123456789 123456789 123456789 123456789 123456789 123456789 12