9
1
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-12-25 13:03:28 +01:00
qp2/plugins/local/tc_int/jast_utils_bh.irp.f

44 lines
854 B
Fortran
Raw Normal View History

2024-06-26 11:15:30 +02:00
! ---
2024-06-26 17:55:56 +02:00
2024-06-26 11:15:30 +02:00
subroutine jBH_elem_fct_grad(alpha, r1, r2, fct, grad1_fct)
implicit none
double precision, intent(in) :: alpha, r1(3), r2(3)
double precision, intent(out) :: fct, grad1_fct(3)
2024-06-26 17:55:56 +02:00
double precision :: dist, tmp1, tmp2, dist_inv
dist = (r1(1) - r2(1)) * (r1(1) - r2(1)) &
+ (r1(2) - r2(2)) * (r1(2) - r2(2)) &
+ (r1(3) - r2(3)) * (r1(3) - r2(3))
2024-06-26 11:15:30 +02:00
2024-06-26 17:55:56 +02:00
if(dist .ge. 1d-15) then
dist_inv = 1.d0/dsqrt( dist )
dist = dist_inv * dist
2024-06-26 11:15:30 +02:00
tmp1 = 1.d0 / (1.d0 + alpha * dist)
fct = alpha * dist * tmp1
2024-06-26 17:55:56 +02:00
tmp2 = alpha * tmp1 * tmp1 * dist_inv
2024-06-26 11:15:30 +02:00
grad1_fct(1) = tmp2 * (r1(1) - r2(1))
grad1_fct(2) = tmp2 * (r1(2) - r2(2))
grad1_fct(3) = tmp2 * (r1(3) - r2(3))
2024-06-26 17:55:56 +02:00
2024-06-26 11:15:30 +02:00
else
2024-06-26 17:55:56 +02:00
2024-06-26 11:15:30 +02:00
grad1_fct(1) = 0.d0
grad1_fct(2) = 0.d0
grad1_fct(3) = 0.d0
fct = 0.d0
2024-06-26 17:55:56 +02:00
2024-06-26 11:15:30 +02:00
endif
return
2024-06-26 17:55:56 +02:00
end
2024-06-26 11:15:30 +02:00
! ---