1
#if defined(FUJITSU_VPP)
5
Subroutine xc_cams12x(tol_rho, fac, lfac, nlfac, rho, delrho,
6
& Amat, Cmat, nq, ipol, Ex, qwght,ldew,func,is12x)
8
Subroutine xc_cams12x_d2(tol_rho, fac, lfac, nlfac, rho, delrho,
9
& Amat, Amat2, Cmat, Cmat2, nq, ipol, Ex,
10
& qwght,ldew,func,is12x)
13
C$Id: xc_cams12x.F 20247 2011-04-28 18:58:49Z d3y133 $
19
double precision tol_rho, fac, Ex
20
integer nq, ipol, is12x
21
logical lfac, nlfac,ldew
22
double precision func(*) ! value of the functional [output]
26
double precision rho(nq,ipol*(ipol+1)/2)
28
c Charge Density Gradient
30
double precision delrho(nq,3,ipol)
34
double precision qwght(nq)
36
c Sampling Matrices for the XC Potential
38
double precision Amat(nq,ipol), Cmat(nq,*)
39
double precision Atmp, Ctmp, Etmp
40
double precision A2tmp, C2tmp, C3tmp
44
c Second Derivatives of the Exchange Energy Functional
46
double precision Amat2(nq,NCOL_AMAT2), Cmat2(nq,NCOL_CMAT2)
49
double precision rB, rC, rD, rA, rK, rE, rH, rG2, rH2
50
double precision ums, vms, dudx, dvdx, d2udx2, d2vdx2
54
c Swart, J. Chem. Phys. (2012/2013)
56
c***************************************************************************
59
double precision C, rho13, rho43, gamma, x, g, gdenom, dg
60
double precision dgdenom, t, x2, x3, x4, g1, g2
61
double precision g1h1, g2h1, g1h2, g2h2, g1h3, g3h1
62
double precision hdenom, dhdenom, d2hdenom, PI, rM
63
double precision gc4, dgc4, d2gc4
64
parameter (rM=60.770665d0)
65
parameter (PI = 3.1415926535897932385d0)
67
double precision rhom23, d2g, d2gdenom, d2g1, d2g2, d2g3
72
cswar1 1.03323556 0.00417251 0.00115216 0.75700000 0.00000000
73
cswar2 0.00706184 1.20250451 0.86124355 0.00000000 0.34485046
74
cswar3 1.00000000 0.00000000 0.00000000 0.00000000 1.00000000 1.52420731
81
elseif (is12x.eq.2) then
83
cswar1 1.02149642 0.00825905 0.00235804 0.75700000 0.25000000
84
cswar2 0.00654977 1.08034183 0.37999939 0.00000000 0.35897845
85
cswar3 1.00000000 0.00000000 0.00000000 0.00000000 1.00000000 0.48516891
93
stop 'error in xc_cams12x.F'
97
c Uniform electron gas constant
99
C = -(1.5d0)*(0.75d0/acos(-1d0))**(1d0/3d0)
103
c ======> SPIN-RESTRICTED <======
106
if (rho(n,1).lt.tol_rho) goto 10
110
rho13 = (0.5d0*rho(n,1))**(1.d0/3.d0)
117
Etmp = rA * 2d0*rho43*C*fac
118
Atmp = rA * (4d0/3d0)*rho13*C*fac
121
gamma = delrho(n,1,1)*delrho(n,1,1) +
122
& delrho(n,2,1)*delrho(n,2,1) +
123
& delrho(n,3,1)*delrho(n,3,1)
124
if (dsqrt(gamma).gt.tol_rho)then
125
gamma = 0.25d0 * gamma
126
x = dsqrt(gamma) / rho43
133
gdenom = 1d0 + rC*x2 + rD*x2*x2
135
ums = 1d0 - 1d0 / gdenom
136
vms = 1d0 - 1d0 / hdenom
139
dudx = (2d0*rC*x + 4d0*rD*x2*x)/(gdenom**2)
140
dvdx = 2d0*rE*x/(hdenom**2)
141
dg = C*rB*(dudx*vms + ums*dvdx)
144
Etmp = Etmp + 2d0*rho43*g*fac
145
Atmp = Atmp + (4d0/3d0)*rho13*(g-x*dg)*fac
148
if (x.gt.tol_rho) then
149
Ctmp = 0.5d0 * dg / sqrt(gamma) * fac
154
c Add local contribution back to g
156
if(lfac) g = g + rA * C
158
rhom23 = rho13 / (0.5d0*rho(n,1))
160
d2udx2 = (2d0*rC-6d0*rC*rC*x2+12d0*rD*x2-18d0*rC*rD*x2*x2
161
& -20d0*rD*rD*x2*x2*x2)/(gdenom**3)
162
d2vdx2 = (2d0*rE - 6d0*rE*rE*x2)/(hdenom**3)
163
d2g = C*rB*(d2udx2*vms + 2d0*dudx*dvdx + ums*d2vdx2)
165
A2tmp = (4d0/9d0)*rhom23*(g-x*dg+4d0*x*x*d2g)*fac
166
C2tmp = - (4d0/3d0)*(rhom23**2/rho(n,1))*d2g*fac
167
if (x.gt.tol_rho) then
168
C3tmp = - 0.25d0*gamma**(-1.5d0)*(dg-x*d2g)*fac
173
call xc_att_xc_d2(rho(n,1),ipol,Etmp,Atmp,Ctmp,A2tmp,
175
Amat2(n,D2_RA_RA) = Amat2(n,D2_RA_RA) + A2tmp
176
Cmat2(n,D2_RA_GAA) = Cmat2(n,D2_RA_GAA) + C2tmp
177
Cmat2(n,D2_GAA_GAA) = Cmat2(n,D2_GAA_GAA) + C3tmp
179
call xc_att_xc(rho(n,1),ipol,Etmp,Atmp,Ctmp)
181
Ex = Ex + qwght(n)*Etmp
182
if (ldew) func(n) = func(n) + Etmp
183
Amat(n,1) = Amat(n,1) + Atmp
184
Cmat(n,D1_GAA) = Cmat(n,D1_GAA) + Ctmp
190
c ======> SPIN-UNRESTRICTED <======
193
if (rho(n,1).lt.tol_rho) goto 20
194
if (rho(n,2).lt.tol_rho) goto 25
198
rho13 = rho(n,2)**(1.d0/3.d0)
199
rho43 = rho13*rho(n,2)
205
Etmp = rA * rho43*C*fac
206
Atmp = rA * (4d0/3d0)*rho13*C*fac
209
gamma = delrho(n,1,1)*delrho(n,1,1) +
210
& delrho(n,2,1)*delrho(n,2,1) +
211
& delrho(n,3,1)*delrho(n,3,1)
212
if (dsqrt(gamma).gt.tol_rho)then
213
x = dsqrt(gamma) / rho43
220
gdenom = 1d0 + rC*x2 + rD*x2*x2
222
ums = 1d0 - 1d0 / gdenom
223
vms = 1d0 - 1d0 / hdenom
226
dudx = (2d0*rC*x + 4d0*rD*x2*x)/(gdenom**2)
227
dvdx = 2d0*rE*x/(hdenom**2)
228
dg = C*rB*(dudx*vms + ums*dvdx)
231
Etmp = Etmp + rho43*g*fac
232
Atmp = Atmp + (4d0/3d0)*rho13*(g-x*dg)*fac
235
if (x.gt.tol_rho) then
236
t = dg / sqrt(gamma) * fac
242
c Add local contribution back to g
244
if (lfac) g = g + rA * C
246
rhom23 = rho13 / rho(n,2)
248
d2udx2 = (2d0*rC-6d0*rC*rC*x2+12d0*rD*x2-18d0*rC*rD*x2*x2
249
& -20d0*rD*rD*x2*x2*x2)/(gdenom**3)
250
d2vdx2 = (2d0*rE - 6d0*rE*rE*x2)/(hdenom**3)
251
d2g = C*rB*(d2udx2*vms + 2d0*dudx*dvdx + ums*d2vdx2)
253
A2tmp = (4d0/9d0)*rhom23*(g-x*dg+4d0*x*x*d2g)*fac
254
C2tmp = - (2d0/3d0)*(rhom23**2/rho(n,2))*d2g*fac
255
if (x.gt.tol_rho) then
256
C3tmp = - 0.25d0*gamma**(-1.5d0)*(dg-x*d2g)*fac
261
call xc_att_xc_d2(rho(n,2),ipol,Etmp,Atmp,Ctmp,A2tmp,
263
Amat2(n,D2_RA_RA) = Amat2(n,D2_RA_RA) + A2tmp
264
Cmat2(n,D2_RA_GAA) = Cmat2(n,D2_RA_GAA) + C2tmp
265
Cmat2(n,D2_GAA_GAA) = Cmat2(n,D2_GAA_GAA) + C3tmp
267
call xc_att_xc(rho(n,2),ipol,Etmp,Atmp,Ctmp)
269
Ex = Ex + qwght(n)*Etmp
270
if (ldew) func(n) = func(n) + Etmp
271
Amat(n,1) = Amat(n,1) + Atmp
272
Cmat(n,D1_GAA) = Cmat(n,D1_GAA) + Ctmp
278
if (rho(n,3).lt.tol_rho) goto 20
280
rho13 = rho(n,3)**(1.d0/3.d0)
281
rho43 = rho13*rho(n,3)
287
Etmp = rA * rho43*C*fac
288
Atmp = rA * (4d0/3d0)*rho13*C*fac
291
gamma = delrho(n,1,2)*delrho(n,1,2) +
292
& delrho(n,2,2)*delrho(n,2,2) +
293
& delrho(n,3,2)*delrho(n,3,2)
294
if (dsqrt(gamma).gt.tol_rho)then
295
x = dsqrt(gamma) / rho43
302
gdenom = 1d0 + rC*x2 + rD*x2*x2
304
ums = 1d0 - 1d0 / gdenom
305
vms = 1d0 - 1d0 / hdenom
308
dudx = (2d0*rC*x + 4d0*rD*x2*x)/(gdenom**2)
309
dvdx = 2d0*rE*x/(hdenom**2)
310
dg = C*rB*(dudx*vms + ums*dvdx)
313
Etmp = Etmp + rho43*g*fac
314
Atmp = Atmp + (4d0/3d0)*rho13*(g-x*dg)*fac
317
if (x.gt.tol_rho) then
318
t = dg / sqrt(gamma) * fac
324
c Add local contribution back to g
326
if (lfac) g = g + rA * C
328
rhom23 = rho13 / rho(n,3)
330
d2udx2 = (2d0*rC-6d0*rC*rC*x2+12d0*rD*x2-18d0*rC*rD*x2*x2
331
& -20d0*rD*rD*x2*x2*x2)/(gdenom**3)
332
d2vdx2 = (2d0*rE - 6d0*rE*rE*x2)/(hdenom**3)
333
d2g = C*rB*(d2udx2*vms + 2d0*dudx*dvdx + ums*d2vdx2)
336
A2tmp = (4d0/9d0)*rhom23*(g-x*dg+4d0*x*x*d2g)*fac
337
C2tmp = -(2d0/3d0)*(rhom23**2/rho(n,3))*d2g*fac
338
if (x.gt.tol_rho) then
339
C3tmp = - 0.25d0*gamma**(-1.5d0)*(dg-x*d2g)*fac
344
call xc_att_xc_d2(rho(n,3),ipol,Etmp,Atmp,Ctmp,A2tmp,
346
Amat2(n,D2_RB_RB) = Amat2(n,D2_RB_RB) + A2tmp
347
Cmat2(n,D2_RB_GBB) = Cmat2(n,D2_RB_GBB) + C2tmp
348
Cmat2(n,D2_GBB_GBB) = Cmat2(n,D2_GBB_GBB) + C3tmp
350
call xc_att_xc(rho(n,3),ipol,Etmp,Atmp,Ctmp)
352
Ex = Ex + qwght(n)*Etmp
353
if (ldew) func(n) = func(n) + Etmp
354
Amat(n,2) = Amat(n,2) + Atmp
355
Cmat(n,D1_GBB) = Cmat(n,D1_GBB) + Ctmp
366
c Compile source again for the 2nd derivative case
368
#include "xc_cams12x.F"