This function get an external field and solve the polarization system in the presence of the provided external field.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(ommp_system), | intent(inout), | target | :: | sys_obj | ||
real(kind=ommp_real), | intent(in) | :: | ext_field(3,sys_obj%eel%pol_atoms) | |||
integer(kind=ommp_integer), | intent(in), | value | :: | solver | ||
integer(kind=ommp_integer), | intent(in), | value | :: | matv | ||
logical, | intent(in), | optional, | value | :: | add_mm_field |
subroutine ommp_set_external_field(sys_obj, ext_field, solver, matv, &
add_mm_field)
!! This function get an external field and solve the polarization
!! system in the presence of the provided external field.
use mod_polarization, only: polarization
use mod_electrostatics, only: prepare_polelec
use mod_memory, only: mallocate, mfree
implicit none
type(ommp_system), intent(inout), target :: sys_obj
real(ommp_real), intent(in) :: ext_field(3,sys_obj%eel%pol_atoms)
integer(ommp_integer), intent(in), value :: solver
integer(ommp_integer), intent(in), value :: matv
logical, intent(in), value, optional :: add_mm_field
type(ommp_electrostatics_type), pointer :: eel
real(ommp_real), allocatable :: ef(:,:,:)
integer :: i
logical :: do_mm_f
eel => sys_obj%eel
if(present(add_mm_field)) then
do_mm_f = add_mm_field
else
do_mm_f = .true.
end if
eel%ipd_done = .false.
if(do_mm_f) then
call mallocate('ommp_get_polelec_energy [ef]', &
3_ommp_integer, eel%pol_atoms, eel%n_ipd, ef)
call prepare_polelec(eel)
do i=1, eel%n_ipd
ef(:,:,i) = eel%e_m2d(:,:,i) + ext_field
end do
call polarization(sys_obj, ef, solver)
call mfree('ommp_get_polelec_energy [ef]', ef)
else
call mallocate('ommp_get_polelec_energy [ef]', &
3_ommp_integer, eel%pol_atoms, eel%n_ipd, ef)
ef(:,:,1) = ext_field
call polarization(sys_obj, ef, solver, matv, [.true., .false.] )
call mfree('ommp_get_polelec_energy [ef]', ef)
end if
end subroutine ommp_set_external_field