9
1
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-11-07 22:13:38 +01:00
qp2/src/dft_utils_one_e/ec_lyp.irp.f

126 lines
3.3 KiB
Fortran
Raw Normal View History

2019-05-28 19:31:47 +02:00
subroutine give_all_stuffs_in_r_for_lyp_88(r,rho,rho_a,rho_b,grad_rho_a_2,grad_rho_b_2,grad_rho_2)
implicit none
double precision, intent(in) :: r(3)
double precision, intent(out) :: rho_a(N_states),rho_b(N_states),grad_rho_a_2(N_states),grad_rho_b_2(N_states),grad_rho_2(N_states),rho(N_states)
double precision :: grad_rho_a(3,N_states),grad_rho_b(3,N_states),grad_rho_a_b(N_states)
double precision :: grad_aos_array(3,ao_num),aos_array(ao_num)
call density_and_grad_alpha_beta_and_all_aos_and_grad_aos_at_r(r,rho_a,rho_b, grad_rho_a, grad_rho_b, aos_array, grad_aos_array)
integer :: i,istate
rho = rho_a + rho_b
grad_rho_a_2 = 0.d0
grad_rho_b_2 = 0.d0
grad_rho_a_b = 0.d0
do istate = 1, N_states
do i = 1, 3
grad_rho_a_2(istate) += grad_rho_a(i,istate) * grad_rho_a(i,istate)
grad_rho_b_2(istate) += grad_rho_b(i,istate) * grad_rho_b(i,istate)
grad_rho_a_b(istate) += grad_rho_a(i,istate) * grad_rho_b(i,istate)
enddo
enddo
grad_rho_2 = grad_rho_a_2 + grad_rho_b_2 + 2.d0 * grad_rho_a_b
end
double precision function ec_lyp_88(rho,rho_a,rho_b,grad_rho_a_2,grad_rho_b_2,grad_rho_2)
implicit none
BEGIN_DOC
! LYP functional of the Lee, Yan, Parr, Phys. Rev B 1988, Vol 37, page 785.
! The expression used is the one by Miehlich, Savin, Stoll, Preuss, CPL, 1989 which gets rid of the laplacian of the density
END_DOC
include 'constants.include.F'
! Input variables
double precision, intent(in) :: rho,rho_a,rho_b,grad_rho_a_2,grad_rho_b_2,grad_rho_2
! Local variables
double precision :: a,b,c,d,c_f,omega,delta
double precision :: rho_13,rho_inv_13,rho_83,rho_113,rho_inv_113,denom
2019-06-08 16:39:12 +02:00
double precision :: thr,huge_num,rho_inv
2019-05-28 19:31:47 +02:00
double precision :: cst_2_113,cst_8_3,rho_2,rho_a_2,rho_b_2
double precision :: tmp1,tmp2,tmp3,tmp4
double precision :: big1,big2,big3
! Constants of the LYP correlation functional
a = 0.04918d0
b = 0.132d0
c = 0.2533d0
d = 0.349d0
2019-06-13 15:58:04 +02:00
ec_lyp_88 = 0.d0
thr = 1d-15
2019-05-28 19:31:47 +02:00
huge_num = 1.d0/thr
2019-06-13 15:58:04 +02:00
if(dabs(rho_a).lt.thr)then
return
endif
if(dabs(rho_b).lt.thr)then
return
endif
2019-05-28 19:31:47 +02:00
2019-06-08 16:39:12 +02:00
if(rho.lt.0.d0)then
print*,'pb !! rho.lt.0.d0'
stop
endif
2019-06-13 15:58:04 +02:00
rho_13 = rho**(1.d0/3.d0)
rho_113 = rho**(11.d0/3.d0)
2019-05-28 19:31:47 +02:00
2019-06-08 16:39:12 +02:00
if(dabs(rho_13) < thr) then
2019-05-28 19:31:47 +02:00
rho_inv_13 = huge_num
else
rho_inv_13 = 1.d0/rho_13
endif
2019-06-08 16:39:12 +02:00
if (dabs(rho_113) < thr) then
2019-05-28 19:31:47 +02:00
rho_inv_113 = huge_num
else
2019-06-13 15:58:04 +02:00
rho_inv_113 = 1.d0/rho_113
2019-05-28 19:31:47 +02:00
endif
2019-06-08 16:39:12 +02:00
if (dabs(rho) < thr) then
rho_inv = huge_num
else
2019-06-13 15:58:04 +02:00
rho_inv = 1.d0/rho
2019-06-08 16:39:12 +02:00
endif
2019-05-28 19:31:47 +02:00
! Useful quantities to predefine
denom = 1d0/(1d0 + d*rho_inv_13)
omega = rho_inv_113*exp(-c*rho_inv_13)*denom
delta = c*rho_inv_13 + d*rho_inv_13*denom
2019-06-13 15:58:04 +02:00
c_f = 0.3d0*(3.d0*pi*pi)**(2.d0/3.d0)
2019-05-28 19:31:47 +02:00
rho_2 = rho *rho
rho_a_2 = rho_a*rho_a
rho_b_2 = rho_b*rho_b
2019-06-13 15:58:04 +02:00
cst_2_113 = 2.d0**(11.d0/3.d0)
cst_8_3 = 8.d0/3.d0
2019-05-28 19:31:47 +02:00
! first term in the equation (2) of Preuss CPL, 1989
2019-06-13 15:58:04 +02:00
big1 = 4.d0*denom*rho_a*rho_b*rho_inv
2019-05-28 19:31:47 +02:00
tmp1 = cst_2_113*c_f*(rho_a**cst_8_3 + rho_b**cst_8_3)
2019-06-13 15:58:04 +02:00
tmp2 = (47.d0/18.d0 - 7.d0/18.d0*delta)*grad_rho_2
2019-05-28 19:31:47 +02:00
tmp3 = - (5d0/2d0 - 1.d0/18d0*delta)*(grad_rho_a_2 + grad_rho_b_2)
2019-06-08 16:39:12 +02:00
tmp4 = - (delta - 11d0)/9d0*(rho_a*rho_inv*grad_rho_a_2 + rho_b*rho_inv*grad_rho_b_2)
2019-05-28 19:31:47 +02:00
big2 = rho_a*rho_b*(tmp1 + tmp2 + tmp3 + tmp4)
tmp1 = -2d0/3d0*rho_2*grad_rho_2
tmp2 = grad_rho_b_2*(2d0/3d0*rho_2 - rho_a_2)
tmp3 = grad_rho_a_2*(2d0/3d0*rho_2 - rho_b_2)
big3 = tmp1 + tmp2 + tmp3
ec_lyp_88 = -a*big1 -a*b*omega*big2 -a*b*omega*big3
end