TODO Computes the electric potential of a charge at position from the charge itself. Pre-computed kernel should be provided as input. The result is added to .
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rp), | intent(in) | :: | q |
Charge |
||
real(kind=rp), | intent(in) | :: | dr(3) |
Distance vector |
||
real(kind=rp), | intent(in) | :: | kernel(:) |
Array of coulomb kernel (either damped or undamped) |
||
logical, | intent(in) | :: | do_V |
Flags to enable/disable calculation of different electrostatic properties |
||
real(kind=rp), | intent(inout) | :: | V |
Electric potential |
||
logical, | intent(in) | :: | do_E |
Flags to enable/disable calculation of different electrostatic properties |
||
real(kind=rp), | intent(inout) | :: | E(3) |
Electric potential |
||
logical, | intent(in) | :: | do_grdE |
Flags to enable/disable calculation of different electrostatic properties |
||
real(kind=rp), | intent(inout) | :: | grdE(6) |
Electric potential |
||
logical, | intent(in) | :: | do_HE |
Flags to enable/disable calculation of different electrostatic properties |
||
real(kind=rp), | intent(inout) | :: | HE(10) |
Electric potential |
subroutine q_elec_prop(q, dr, kernel, &
do_V, V, do_E, E, do_grdE, grdE, do_HE, HE)
!! TODO
!! Computes the electric potential of a charge \(q\) at position
!! \(\mathbf{dr}\) from the charge itself. Pre-computed kernel should
!! be provided as input.
!! The result is added to \(V\).
!! $$ V_q = q \frac{f(r)}{||\mathbf{dr}||} $$
implicit none
real(rp), intent(in) :: q
!! Charge
real(rp), intent(in) :: dr(3)
!! Distance vector
real(rp), intent(in) :: kernel(:)
!! Array of coulomb kernel (either damped or undamped)
logical, intent(in) :: do_V, do_E, do_grdE, do_HE
!! Flags to enable/disable calculation of different electrostatic
!! properties
real(rp), intent(inout) :: V, E(3), grdE(6), HE(10)
!! Electric potential
if(do_V) then
V = V + kernel(1) * q
end if
if(do_E) then
E = E + q * kernel(2) * dr
end if
if(do_grdE) then
! xx
grdE(1) = grdE(1) + q * 3.0_rp * kernel(3) * dr(1) * dr(1) - q * kernel(2)
! xy
grdE(2) = grdE(2) + q * 3.0_rp * kernel(3) * dr(1) * dr(2)
! yy
grdE(3) = grdE(3) + q * 3.0_rp * kernel(3) * dr(2) * dr(2) - q * kernel(2)
! xz
grdE(4) = grdE(4) + q * 3.0_rp * kernel(3) * dr(1) * dr(3)
! yz
grdE(5) = grdE(5) + q * 3.0_rp * kernel(3) * dr(2) * dr(3)
! zz
grdE(6) = grdE(6) + q * 3.0_rp * kernel(3) * dr(3) * dr(3) - q * kernel(2)
end if
if(do_HE) then
! xxx
HE(1) = HE(1) + (15.0_rp * kernel(4) * dr(1) * dr(1) * dr(1) - &
9.0_rp * kernel(3) * dr(1)) * q
! xxy
HE(2) = HE(2) + (15.0_rp * kernel(4) * dr(1) * dr(1) * dr(2) - &
3.0_rp * kernel(3) * dr(2)) * q
! xxz
HE(3) = HE(3) + (15.0_rp * kernel(4) * dr(1) * dr(1) * dr(3) - &
3.0_rp * kernel(3) * dr(3)) * q
! xyy
HE(4) = HE(4) + (15.0_rp * kernel(4) * dr(2) * dr(2) * dr(1) - &
3.0_rp * kernel(3) * dr(1)) * q
! xyz
HE(5) = HE(5) + 15.0_rp * kernel(4) * dr(1) * dr(2) * dr(3) * q
! xzz
HE(6) = HE(6) + (15.0_rp * kernel(4) * dr(3) * dr(3) * dr(1) - &
3.0_rp * kernel(3) * dr(1)) * q
! yyy
HE(7) = HE(7) + (15.0_rp * kernel(4) * dr(2) * dr(2) * dr(2) - &
9.0_rp * kernel(3) * dr(2)) * q
! yyz
HE(8) = HE(8) + (15.0_rp * kernel(4) * dr(2) * dr(2) * dr(3) - &
3.0_rp * kernel(3) * dr(3)) * q
! yzz
HE(9) = HE(9) + (15.0_rp * kernel(4) * dr(3) * dr(3) * dr(2) - &
3.0_rp * kernel(3) * dr(2)) * q
! zzz
HE(10) = HE(10) + (15.0_rp * kernel(4) * dr(3) * dr(3) * dr(3) - &
9.0_rp * kernel(3) * dr(3)) * q
end if
end subroutine q_elec_prop