This function compute the coulomb kernel for the distance vector dr and its derivative up to the value required by maxder.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rp), | intent(in) | :: | dr(3) |
Distance vector from atom i to atom j |
||
integer(kind=ip), | intent(in) | :: | maxder |
Maximum derivative to be computed |
||
real(kind=rp), | intent(out), | dimension(maxder+1) | :: | res |
Results vector |
subroutine coulomb_kernel(dr, maxder, res)
!! This function compute the coulomb kernel for the distance vector dr and
!! its derivative up to the value required by maxder.
use mod_memory, only: ip, rp
use mod_io, only: fatal_error
use mod_constants, only: eps_rp
implicit none
real(rp), intent(in) :: dr(3)
!! Distance vector from atom i to atom j
integer(ip), intent(in) :: maxder
!! Maximum derivative to be computed
real(rp), intent(out), dimension(maxder+1) :: res
!! Results vector
integer(ip) :: ii
real(rp) :: norm2_r, inv_norm_sq
if(maxder < 0) then
! Strange request, maybe a warning should be printed
return
end if
norm2_r = sqrt(dr(1)*dr(1) + dr(2)*dr(2) + dr(3)*dr(3))
if(norm2_r < eps_rp) then
call fatal_error("Requesting Coulomb kernel for two atoms &
&placed in the same point, this could be &
&an internal bug or a problem in your input &
&file, please check.")
end if
res(1) = 1.0_rp / norm2_r
inv_norm_sq = res(1) * res(1)
do ii = 1, maxder
res(ii+1) = res(ii) * inv_norm_sq
end do
end subroutine coulomb_kernel