2
c -----------------------------------------------------------------------
3
c Uniform electron gas exchange functional for the erfc(r)/r interaction
4
c as implemented in the following paper:
5
c "A well-tempered density functional theory of electrons in molecules"
6
c Ester Livshits & Roi Baer, Phys. Chem. Chem. Phys., 9, 2932 (2007)
7
c The other relevant publication is:
8
c R. Baer, D. Neuhauser, Phys. Rev. Lett., 94, 043002 (2005)
9
c -----------------------------------------------------------------------
12
subroutine xc_bnl(tol_rho, fac, lfac, nlfac, rho, Amat, nq,
13
& ipol, Ex, qwght, ldew, func)
15
c For locations of 2nd derivatives of functionals in array
17
subroutine xc_bnl_d2(tol_rho, fac, lfac, nlfac, rho, Amat,
18
& Amat2, nq, ipol, Ex, qwght, ldew, func)
31
double precision fac, Ex, total
32
logical ldew, lfac, nlfac
33
double precision func(*) ! value of the functional [output]
34
double precision tol_rho
35
double precision rho(nq,(ipol*(ipol+1))/2) ! charge density
36
double precision qwght(nq) ! quadrature weights
37
double precision Amat(nq,ipol) ! partial first derivatives
38
double precision F(nq),RA(nq),RB(nq)
39
double precision rhoA, rhoB, rhoTotal, rhoA1, rhoB1
40
double precision gamma
41
double precision fA, fB, fpA, fpB, fppA, fppB
43
double precision EpsXprime
44
double precision EpsTwoXprime
47
double precision Amat2(nq,NCOL_AMAT2) ! partial second derivatives
50
c -----------------------------------------------------------------------
52
c -----------------------------------------------------------------------
57
if (ipol.eq.1) then ! spin-restricted
60
else ! spin-unrestricted
66
c -----------------------------------------------------------------------
67
c Calculate the first and second derivatives
68
c -----------------------------------------------------------------------
74
rhoTotal = rhoA + rhoB ! total density at point
75
if (rhoTotal.gt.tol_rho) then
77
if (ipol.eq.1) then ! spin-restricted
80
else ! spin-unrestricted
85
fA = EpsX(rhoA1,gamma)
86
fB = EpsX(rhoB1,gamma)
87
fpA = EpsXprime(rhoA1,gamma)
88
fpB = EpsXprime(rhoB1,gamma)
90
f(n) = fA * rhoA + fB * rhoB
91
Amat(n,1) = Amat(n,1) + (fpA*rhoA1+fA)*fac
93
Amat(n,2) = Amat(n,2) + (fpB*rhoB1+fB)*fac
97
fppA = EpsTwoXprime(rhoA1,gamma)
98
fppB = EpsTwoXprime(rhoB1,gamma)
101
Amat2(n,D2_RA_RA) = Amat2(n,D2_RA_RA) +
102
& (fppA*rhoA+2.0d0*fpA)*fac*2.0d0
104
Amat2(n,D2_RA_RA) = Amat2(n,D2_RA_RA) +
105
& (fppA*rhoA+fpA)*fac*4.0d0
106
c Guard against case of no beta electrons, e.g. H atom
107
if (rho(n,3).gt.tol_rho) then
108
Amat2(n,D2_RB_RB) = Amat2(n,D2_RB_RB) +
109
& (fppB*rhoB+fpB)*fac*4.0d0
113
if (ldew) func(n) = func(n) + f(n)*fac
114
total = total + f(n)*qwght(n)
128
c ---------------------------------------------------------------------------------------
130
c ---------------------------------------------------------------------------------------
132
c ---------------------------------------------------------------------------------------
133
c Return the value of pi
134
c ---------------------------------------------------------------------------------------
136
double precision function ValueOfPi()
139
#include "xc_params.fh"
146
c ---------------------------------------------------------------------------------------
147
c Evaluates the actual function
148
c ---------------------------------------------------------------------------------------
150
double precision function HqBNL(q)
153
#include "xc_params.fh"
155
double precision q,TwoSqrtPi,OneOverQ,q2,DERF
158
TwoSqrtPi = 2.0d0*dsqrt(pi)
161
if (q .lt. 1D-15) then
166
if (q .lt. 0.1d0) then
167
HqBNL=1.0d0-q*2.0d0/3.0d0*(TwoSqrtPi-q+q*(q2-2.0d0))
171
HqBNL=1.0d0-q*2.0d0/3.0d0*(TwoSqrtPi*DERF(OneOverQ)-q+
172
$ q*(q2-2.0d0)*(1.0d0-exp(-OneOverQ*OneOverQ)))
177
c ---------------------------------------------------------------------------------------
178
c Calculate the local Fermi vector for the provided density
179
c ---------------------------------------------------------------------------------------
181
double precision function FermiK(den)
184
#include "xc_params.fh"
186
double precision F13, den
189
FermiK = (3.d0*pi*pi*den)**F13
194
c ---------------------------------------------------------------------------------------
195
c Calculate the function EpsX at the given density value and gamma
196
c ---------------------------------------------------------------------------------------
198
double precision function EpsX(Rho,gamma)
201
#include "xc_params.fh"
203
double precision kF,RHO,gamma,Cs
204
double precision HqBNL
205
double precision FermiK
213
Cs = -3.0D0/(4.0d0*pi)
214
EpsX = Cs * kF * HqBNL(gamma/kF)
219
c ---------------------------------------------------------------------------------------
220
c Calculate the first derivative of the function
221
c ---------------------------------------------------------------------------------------
223
double precision function HqBNLPrime(q)
226
#include "xc_params.fh"
228
double precision q,OneOverQ,q2,q3,DERF
234
if (q .lt. 0.1d0) then
235
HqBNLPrime = -4.0d0/3.0d0*(dsqrt(Pi)+2.0d0*q3-3.0d0*q)
239
HqBNLPrime = 4.0d0/3.0d0*(q*(exp(-OneOverQ*OneOverQ)*(2.0d0*q2
240
$ -1.0d0)+(3.0d0-2.0d0*q2))-dsqrt(Pi)*DERF(OneOverQ))
245
c ---------------------------------------------------------------------------------------
246
c Calculate the first derivative of the local Fermi vector (it depends on the density)
247
c ---------------------------------------------------------------------------------------
249
double precision function FermiKPrime(den)
252
#include "xc_params.fh"
254
double precision F23, den
257
FermiKPrime = (Pi/(3.0d0*den))**F23
262
c ---------------------------------------------------------------------------------------
263
c Calculate the first derivative of q (q=gamma/kf) (it implicitly depends on the density)
264
c ---------------------------------------------------------------------------------------
266
double precision function QPrime(gamma,kF)
270
double precision kF, FermiK2, gamma
273
QPrime = -gamma/FermiK2
278
c ---------------------------------------------------------------------------------------
279
c Calculate the first derivative of EpsX
280
c ---------------------------------------------------------------------------------------
282
double precision function EpsXprime(Rho,gamma)
285
#include "xc_params.fh"
287
double precision Rho,gamma
288
double precision Cs,kF,CsPrime
290
double precision HqBNL
291
double precision HqBNLPrime
292
double precision QPrime
293
double precision FermiK
294
double precision FermiKPrime
297
CsPrime = -3.0D0/(4.0d0*Pi)
305
EpsXprime = FermiKPrime(Rho)*(CsPrime*HqBNL(gamma/kF)+
306
$ QPrime(gamma,kF)*HqBNLPrime(gamma/kF)*Cs)
311
c ---------------------------------------------------------------------------------------
312
c Calculate the second derivative of the main function that consititutes the functional
313
c ---------------------------------------------------------------------------------------
315
double precision function HqBNLTwoPrime(q)
318
#include "xc_params.fh"
320
double precision q,OneOverQ,q2
325
if (q .lt. 0.1d0) then
326
HqBNLTwoPrime = 4.0d0-8.0d0*q2
330
HqBNLTwoPrime = exp(-OneOverQ*OneOverQ)*(4.0d0+8.0d0*q2)
336
c ---------------------------------------------------------------------------------------
337
c Calculate the second derivative of the local Fermi vector
338
c ---------------------------------------------------------------------------------------
340
double precision function FermiKTwoPrime(den)
343
#include "xc_params.fh"
345
double precision F13, den
348
FermiKTwoPrime = -(8.0d0*Pi**2.0d0/(243.0d0*den**5.0d0))**F13
353
c ---------------------------------------------------------------------------------------
354
c Calculate the second derivative of q
355
c ---------------------------------------------------------------------------------------
357
double precision function QTwoPrime(gamma,kF)
361
double precision gamma, kF, FermiK3
364
QTwoPrime = (2.0d0*gamma)/FermiK3
369
c ---------------------------------------------------------------------------------------
370
c Calculate the second derivative of EpsX
371
c ---------------------------------------------------------------------------------------
373
double precision function EpsTwoXprime(Rho,gamma)
376
#include "xc_params.fh"
378
double precision Rho,gamma
379
double precision kF,kFPrim,kFprim2,kF2prim
380
double precision q,qprim,qprim2,q2prim
381
double precision g,gprim,g2prim
382
double precision Cs,CsPrim
384
double precision FermiK
385
double precision FermiKPrime
386
double precision FermiKTwoPrime
387
double precision QPrime
388
double precision QTwoPrime
389
double precision HqBNL
390
double precision HqBNLPrime
391
double precision HqBNLTwoPrime
399
kFPrim = FermiKPrime(Rho)
400
kFPrim2=kFPrim**2.0d0
401
kF2prim = FermiKTwoPrime(Rho)
402
CsPrim = -3.0d0/(4.0d0*Pi)
405
qprim = QPrime(gamma,kF)
407
q2prim = QTwoPrime(gamma,kF)
409
gprim = HqBNLPrime(q)
410
g2prim = HqBNLTwoPrime(q)
413
$ kFPrim2*(2.0d0*CsPrim*gprim*qprim
414
$ +Cs*(QPrim2*g2prim+gprim*Q2Prim))
415
$ +kF2Prim*(g*CsPrim+Cs*gprim*qprim)
421
c $Id: xc_bnl.F 24192 2013-05-04 20:14:33Z niri $