This function allocate and populate array of electrostatic properties of static multipoles at static multipoles sites. It should be called blindly before any calculation that requires V_M2M etc.
TODO Improve logic
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(ommp_electrostatics_type), | intent(inout) | :: | eel | |||
logical, | intent(in), | optional | :: | arg_dogg |
subroutine prepare_fixedelec(eel, arg_dogg)
!! This function allocate and populate array of electrostatic
!! properties of static multipoles at static multipoles sites.
!! It should be called blindly before any calculation that requires
!! V_M2M etc.
use mod_memory, only: mallocate
implicit none
type(ommp_electrostatics_type), intent(inout) :: eel
logical, optional, intent(in) :: arg_dogg
integer(ip) :: mm_atoms
logical :: do_gg
mm_atoms = eel%top%mm_atoms
!! TODO Improve logic
do_gg = .false.
if(present(arg_dogg)) then
if(arg_dogg) do_gg = .true.
end if
if(.not. do_gg .and. eel%M2M_done) return
if(do_gg .and. eel%M2M_done .and. eel%M2Mgg_done) return
if(eel%amoeba) then
if(.not. allocated(eel%V_M2M)) then
call mallocate('prepare_fixedelec [V_M2M]', mm_atoms, eel%V_M2M)
end if
if(.not. allocated(eel%E_M2M)) then
call mallocate('prepare_fixedelec [E_M2M]', 3_ip, mm_atoms, eel%E_M2M)
end if
if(.not. allocated(eel%Egrd_M2M)) then
call mallocate('prepare_fixedelec [Egrd_M2M]', 6_ip, mm_atoms, eel%Egrd_M2M)
end if
if(do_gg .and. .not. allocated(eel%EHes_M2M)) then
call mallocate('prepare_fixedelec [EHes_M2M]', 10_ip, mm_atoms, eel%EHes_M2M)
end if
eel%V_M2M = 0.0_rp
eel%E_M2M = 0.0_rp
eel%Egrd_M2M = 0.0_rp
if(do_gg) eel%EHes_M2M = 0.0_rp
if(do_gg) then
call time_push
call elec_prop_M2M(eel, .true., .true., .true., .true.)
call time_pull('elec prop M2M')
else
call elec_prop_M2M(eel, .true., .true., .true., .false.)
end if
else
if(.not. allocated(eel%V_M2M)) then
call mallocate('prepare_fixedelec [V_M2M]', mm_atoms, eel%V_M2M)
end if
if(do_gg .and. .not. allocated(eel%E_M2M)) then
call mallocate('prepare_fixedelec [E_M2M]', 3_ip, mm_atoms, eel%E_M2M)
end if
eel%V_M2M = 0.0_rp
if(do_gg) eel%E_M2M = 0.0_rp
if(do_gg) then
call elec_prop_M2M(eel, .true., .true., .false., .false.)
else
call elec_prop_M2M(eel, .true., .false., .false., .false.)
end if
end if
eel%M2M_done = .true.
if(do_gg) eel%M2Mgg_done = .true.
end subroutine prepare_fixedelec