This function computes the interaction energy of static electric multipoles
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(ommp_electrostatics_type), | intent(inout) | :: | eel |
Electrostatics data structure |
||
real(kind=rp), | intent(inout) | :: | ene |
Energy (results will be added) |
subroutine energy_MM_MM(eel, ene)
!! This function computes the interaction energy of
!! static electric multipoles
use mod_memory, only: mallocate, mfree
implicit none
type(ommp_electrostatics_type), intent(inout) :: eel
!! Electrostatics data structure
real(rp), intent(inout) :: ene
!! Energy (results will be added)
real(rp) :: eMM
integer(ip) :: i
call prepare_fixedelec(eel)
eMM = 0.0
if(eel%amoeba) then
eMM = eMM + dot_product(eel%q(1,:), eel%V_M2M)
do i=1, 3
eMM = eMM - dot_product(eel%q(i+1,:), eel%E_M2M(i,:))
end do
do i=1,6
if(i == _xx_ .or. i == _yy_ .or. i == _zz_) then
! diagonal elements
eMM = eMM + dot_product(eel%q(i+4,:), eel%Egrd_M2M(i,:))
else
! off-diagonal elements (are stored once, but
! should be counted twice
eMM = eMM + 2.0 * dot_product(eel%q(i+4,:), eel%Egrd_M2M(i,:))
end if
end do
else
eMM = eMM + dot_product(eel%q(1,:), eel%V_M2M)
end if
! Since potential is computed using all the sites each
! interaction is counted twice
ene = ene + 0.5_rp * eMM
end subroutine energy_MM_MM