subroutine electrostatics_init(eel_obj, amoeba, pol_atoms, top_obj)
use mod_memory, only: mallocate
use mod_constants, only: OMMP_MATV_DEFAULT, &
OMMP_SOLVER_DEFAULT, &
OMMP_FMM_DEFAULT_MAXL, &
OMMP_FMM_DEFAULT_MAXL_POL, &
OMMP_FMM_MIN_CELLSIZE, &
OMMP_FMM_FAR_THR, &
OMMP_FMM_ENABLE_THR
implicit none
logical(lp), intent(in) :: amoeba
integer(ip), intent(in) :: pol_atoms
type(ommp_topology_type), intent(in), target :: top_obj
type(ommp_electrostatics_type), intent(inout) :: eel_obj
integer(ip) :: mm_atoms
mm_atoms = top_obj%mm_atoms
eel_obj%amoeba = amoeba
eel_obj%pol_atoms = pol_atoms
eel_obj%top => top_obj
eel_obj%def_solver = OMMP_SOLVER_DEFAULT
eel_obj%def_matv = OMMP_MATV_DEFAULT
if(amoeba) then
eel_obj%ld_cart = 10_ip
eel_obj%ld_cder = 19_ip
eel_obj%n_ipd = 2_ip
else
eel_obj%ld_cart = 1_ip
eel_obj%ld_cder = 3_ip
eel_obj%n_ipd = 1_ip
endif
if(mm_atoms > OMMP_FMM_ENABLE_THR) then
eel_obj%use_fmm = .true.
eel_obj%fmm_maxl_static = OMMP_FMM_DEFAULT_MAXL
eel_obj%fmm_maxl_pol = OMMP_FMM_DEFAULT_MAXL_POL
eel_obj%fmm_distance = OMMP_FMM_FAR_THR
eel_obj%fmm_min_cell_size = OMMP_FMM_MIN_CELLSIZE
allocate(eel_obj%tree)
allocate(eel_obj%fmm_static)
eel_obj%fmm_static_done = .false.
allocate(eel_obj%fmm_ipd(eel_obj%n_ipd))
allocate(eel_obj%fmm_ipd_done(eel_obj%n_ipd))
eel_obj%fmm_ipd_done = .false.
end if
call mallocate('electrostatics_init [q]', eel_obj%ld_cart, &
mm_atoms, eel_obj%q)
call mallocate('electrostatics_init [pol]', eel_obj%pol_atoms, &
eel_obj%pol)
call mallocate('electrostatics_init [cpol]', 3_ip, eel_obj%pol_atoms, &
eel_obj%cpol)
call mallocate('electrostatics_init [polar_mm]', eel_obj%pol_atoms, &
eel_obj%polar_mm)
call mallocate('electrostatics_init [mm_polar]', mm_atoms, &
eel_obj%mm_polar)
call mallocate('electrostatics_init [thole]', mm_atoms, &
eel_obj%thole)
call mallocate('electrostatics_init [idp]', 3_ip, eel_obj%pol_atoms, &
eel_obj%n_ipd, eel_obj%ipd)
eel_obj%ipd_done = .false.
eel_obj%ipd = 0.0_rp
if (eel_obj%amoeba) then
! Extra quantities that should be allocated only
! for AMOEBA
call mallocate('electrostatics_init [q0]', eel_obj%ld_cart, &
mm_atoms, eel_obj%q0)
call mallocate('electrostatics_init [mmat_polgrp]', &
mm_atoms, eel_obj%mmat_polgrp)
call mallocate('electrostatics_init [mol_frame]', &
mm_atoms, eel_obj%mol_frame)
call mallocate('electrostatics_init [ix]', mm_atoms, eel_obj%ix)
call mallocate('electrostatics_init [iy]', mm_atoms, eel_obj%iy)
call mallocate('electrostatics_init [iz]', mm_atoms, eel_obj%iz)
end if
end subroutine electrostatics_init