| 1 |
gezelter |
1447 |
module dipole_dipole |
| 2 |
|
|
|
| 3 |
|
|
use force_globals |
| 4 |
|
|
use definitions |
| 5 |
|
|
use atype_module |
| 6 |
|
|
use vector_class |
| 7 |
|
|
use simulation |
| 8 |
|
|
use status |
| 9 |
|
|
#ifdef IS_MPI |
| 10 |
|
|
use mpiSimulation |
| 11 |
|
|
#endif |
| 12 |
|
|
implicit none |
| 13 |
|
|
|
| 14 |
|
|
PRIVATE |
| 15 |
|
|
|
| 16 |
|
|
real(kind=dp), parameter :: pre = 14.38362_dp |
| 17 |
|
|
logical, save :: haveMomentMap = .false. |
| 18 |
|
|
|
| 19 |
|
|
public::do_dipole_pair |
| 20 |
|
|
|
| 21 |
|
|
type :: MomentList |
| 22 |
|
|
real(kind=DP) :: dipole_moment = 0.0_DP |
| 23 |
|
|
end type MomentList |
| 24 |
|
|
|
| 25 |
|
|
type(MomentList), dimension(:),allocatable :: MomentMap |
| 26 |
|
|
|
| 27 |
|
|
contains |
| 28 |
|
|
|
| 29 |
|
|
subroutine createMomentMap(status) |
| 30 |
|
|
integer :: nAtypes |
| 31 |
|
|
integer :: status |
| 32 |
|
|
integer :: i |
| 33 |
|
|
real (kind=DP) :: thisDP |
| 34 |
|
|
logical :: thisProperty |
| 35 |
|
|
|
| 36 |
|
|
status = 0 |
| 37 |
|
|
|
| 38 |
|
|
nAtypes = getSize(atypes) |
| 39 |
|
|
|
| 40 |
|
|
if (nAtypes == 0) then |
| 41 |
|
|
status = -1 |
| 42 |
|
|
return |
| 43 |
|
|
end if |
| 44 |
|
|
|
| 45 |
|
|
if (.not. allocated(MomentMap)) then |
| 46 |
|
|
allocate(MomentMap(nAtypes)) |
| 47 |
|
|
endif |
| 48 |
|
|
|
| 49 |
|
|
do i = 1, nAtypes |
| 50 |
|
|
|
| 51 |
|
|
call getElementProperty(atypes, i, "is_DP", thisProperty) |
| 52 |
|
|
|
| 53 |
|
|
if (thisProperty) then |
| 54 |
|
|
call getElementProperty(atypes, i, "dipole_moment", thisDP) |
| 55 |
|
|
MomentMap(i)%dipole_moment = thisDP |
| 56 |
|
|
endif |
| 57 |
|
|
|
| 58 |
|
|
end do |
| 59 |
|
|
|
| 60 |
|
|
haveMomentMap = .true. |
| 61 |
|
|
|
| 62 |
|
|
end subroutine createMomentMap |
| 63 |
|
|
|
| 64 |
|
|
subroutine do_dipole_pair(atom1, atom2, d, rij, r2, sw, vpair, fpair, & |
| 65 |
|
|
pot, u_l, f, t, do_pot) |
| 66 |
|
|
|
| 67 |
|
|
logical :: do_pot |
| 68 |
|
|
|
| 69 |
|
|
integer atom1, atom2, me1, me2, id1, id2 |
| 70 |
|
|
integer :: localError |
| 71 |
|
|
real(kind=dp) :: rij, mu1, mu2 |
| 72 |
|
|
real(kind=dp) :: dfact1, dfact2, dip2, r2, r3, r5 |
| 73 |
|
|
real(kind=dp) :: dudx, dudy, dudz, dudu1x, dudu1y, dudu1z |
| 74 |
|
|
real(kind=dp) :: dudu2x, dudu2y, dudu2z, rdotu1, rdotu2, u1dotu2 |
| 75 |
|
|
real(kind=dp) :: sw, vpair, vterm |
| 76 |
|
|
|
| 77 |
|
|
real( kind = dp ) :: pot |
| 78 |
|
|
real( kind = dp ), dimension(3) :: d, fpair |
| 79 |
|
|
real( kind = dp ), dimension(3,nLocal) :: u_l |
| 80 |
|
|
real( kind = dp ), dimension(3,nLocal) :: f |
| 81 |
|
|
real( kind = dp ), dimension(3,nLocal) :: t |
| 82 |
|
|
|
| 83 |
|
|
real (kind = dp), dimension(3) :: ul1 |
| 84 |
|
|
real (kind = dp), dimension(3) :: ul2 |
| 85 |
|
|
|
| 86 |
|
|
if (.not.haveMomentMap) then |
| 87 |
|
|
localError = 0 |
| 88 |
|
|
call createMomentMap(localError) |
| 89 |
|
|
if ( localError .ne. 0 ) then |
| 90 |
|
|
call handleError("dipole-dipole", "MomentMap creation failed!") |
| 91 |
|
|
return |
| 92 |
|
|
end if |
| 93 |
|
|
endif |
| 94 |
|
|
|
| 95 |
|
|
#ifdef IS_MPI |
| 96 |
|
|
me1 = atid_Row(atom1) |
| 97 |
|
|
ul1(1) = u_l_Row(1,atom1) |
| 98 |
|
|
ul1(2) = u_l_Row(2,atom1) |
| 99 |
|
|
ul1(3) = u_l_Row(3,atom1) |
| 100 |
|
|
|
| 101 |
|
|
me2 = atid_Col(atom2) |
| 102 |
|
|
ul2(1) = u_l_Col(1,atom2) |
| 103 |
|
|
ul2(2) = u_l_Col(2,atom2) |
| 104 |
|
|
ul2(3) = u_l_Col(3,atom2) |
| 105 |
|
|
#else |
| 106 |
|
|
me1 = atid(atom1) |
| 107 |
|
|
ul1(1) = u_l(1,atom1) |
| 108 |
|
|
ul1(2) = u_l(2,atom1) |
| 109 |
|
|
ul1(3) = u_l(3,atom1) |
| 110 |
|
|
|
| 111 |
|
|
me2 = atid(atom2) |
| 112 |
|
|
ul2(1) = u_l(1,atom2) |
| 113 |
|
|
ul2(2) = u_l(2,atom2) |
| 114 |
|
|
ul2(3) = u_l(3,atom2) |
| 115 |
|
|
#endif |
| 116 |
|
|
|
| 117 |
|
|
mu1 = MomentMap(me1)%dipole_moment |
| 118 |
|
|
mu2 = MomentMap(me2)%dipole_moment |
| 119 |
|
|
|
| 120 |
|
|
r3 = r2*rij |
| 121 |
|
|
r5 = r3*r2 |
| 122 |
|
|
|
| 123 |
|
|
rdotu1 = d(1)*ul1(1) + d(2)*ul1(2) + d(3)*ul1(3) |
| 124 |
|
|
rdotu2 = d(1)*ul2(1) + d(2)*ul2(2) + d(3)*ul2(3) |
| 125 |
|
|
u1dotu2 = ul1(1)*ul2(1) + ul1(2)*ul2(2) + ul1(3)*ul2(3) |
| 126 |
|
|
|
| 127 |
|
|
dip2 = pre * mu1 * mu2 |
| 128 |
|
|
dfact1 = 3.0d0*dip2 / r2 |
| 129 |
|
|
dfact2 = 3.0d0*dip2 / r5 |
| 130 |
|
|
|
| 131 |
|
|
vterm = dip2*((u1dotu2/r3) - 3.0d0*(rdotu1*rdotu2/r5)) |
| 132 |
|
|
|
| 133 |
|
|
vpair = vpair + vterm |
| 134 |
|
|
|
| 135 |
|
|
if (do_pot) then |
| 136 |
|
|
#ifdef IS_MPI |
| 137 |
|
|
pot_row(atom1) = pot_row(atom1) + 0.5d0*vterm*sw |
| 138 |
|
|
pot_col(atom2) = pot_col(atom2) + 0.5d0*vterm*sw |
| 139 |
|
|
#else |
| 140 |
|
|
pot = pot + vterm*sw |
| 141 |
|
|
#endif |
| 142 |
|
|
endif |
| 143 |
|
|
|
| 144 |
|
|
dudx = (-dfact1 * d(1) * ((u1dotu2/r3) - & |
| 145 |
|
|
(5.0d0*(rdotu1*rdotu2)/r5)) - & |
| 146 |
|
|
dfact2*(ul1(1)*rdotu2 + ul2(1)*rdotu1))*sw |
| 147 |
|
|
|
| 148 |
|
|
dudy = (-dfact1 * d(2) * ((u1dotu2/r3) - & |
| 149 |
|
|
(5.0d0*(rdotu1*rdotu2)/r5)) - & |
| 150 |
|
|
dfact2*(ul1(2)*rdotu2 + ul2(2)*rdotu1))*sw |
| 151 |
|
|
|
| 152 |
|
|
dudz = (-dfact1 * d(3) * ((u1dotu2/r3) - & |
| 153 |
|
|
(5.0d0*(rdotu1*rdotu2)/r5)) - & |
| 154 |
|
|
dfact2*(ul1(3)*rdotu2 + ul2(3)*rdotu1))*sw |
| 155 |
|
|
|
| 156 |
|
|
dudu1x = (dip2*((ul2(1)/r3) - (3.0d0*d(1)*rdotu2/r5)))*sw |
| 157 |
|
|
dudu1y = (dip2*((ul2(2)/r3) - (3.0d0*d(2)*rdotu2/r5)))*sw |
| 158 |
|
|
dudu1z = (dip2*((ul2(3)/r3) - (3.0d0*d(3)*rdotu2/r5)))*sw |
| 159 |
|
|
|
| 160 |
|
|
dudu2x = (dip2*((ul1(1)/r3) - (3.0d0*d(1)*rdotu1/r5)))*sw |
| 161 |
|
|
dudu2y = (dip2*((ul1(2)/r3) - (3.0d0*d(2)*rdotu1/r5)))*sw |
| 162 |
|
|
dudu2z = (dip2*((ul1(3)/r3) - (3.0d0*d(3)*rdotu1/r5)))*sw |
| 163 |
|
|
|
| 164 |
|
|
|
| 165 |
|
|
#ifdef IS_MPI |
| 166 |
|
|
f_Row(1,atom1) = f_Row(1,atom1) + dudx |
| 167 |
|
|
f_Row(2,atom1) = f_Row(2,atom1) + dudy |
| 168 |
|
|
f_Row(3,atom1) = f_Row(3,atom1) + dudz |
| 169 |
|
|
|
| 170 |
|
|
f_Col(1,atom2) = f_Col(1,atom2) - dudx |
| 171 |
|
|
f_Col(2,atom2) = f_Col(2,atom2) - dudy |
| 172 |
|
|
f_Col(3,atom2) = f_Col(3,atom2) - dudz |
| 173 |
|
|
|
| 174 |
|
|
t_Row(1,atom1) = t_Row(1,atom1) - ul1(2)*dudu1z + ul1(3)*dudu1y |
| 175 |
|
|
t_Row(2,atom1) = t_Row(2,atom1) - ul1(3)*dudu1x + ul1(1)*dudu1z |
| 176 |
|
|
t_Row(3,atom1) = t_Row(3,atom1) - ul1(1)*dudu1y + ul1(2)*dudu1x |
| 177 |
|
|
|
| 178 |
|
|
t_Col(1,atom2) = t_Col(1,atom2) - ul2(2)*dudu2z + ul2(3)*dudu2y |
| 179 |
|
|
t_Col(2,atom2) = t_Col(2,atom2) - ul2(3)*dudu2x + ul2(1)*dudu2z |
| 180 |
|
|
t_Col(3,atom2) = t_Col(3,atom2) - ul2(1)*dudu2y + ul2(2)*dudu2x |
| 181 |
|
|
#else |
| 182 |
|
|
f(1,atom1) = f(1,atom1) + dudx |
| 183 |
|
|
f(2,atom1) = f(2,atom1) + dudy |
| 184 |
|
|
f(3,atom1) = f(3,atom1) + dudz |
| 185 |
|
|
|
| 186 |
|
|
f(1,atom2) = f(1,atom2) - dudx |
| 187 |
|
|
f(2,atom2) = f(2,atom2) - dudy |
| 188 |
|
|
f(3,atom2) = f(3,atom2) - dudz |
| 189 |
|
|
|
| 190 |
|
|
t(1,atom1) = t(1,atom1) - ul1(2)*dudu1z + ul1(3)*dudu1y |
| 191 |
|
|
t(2,atom1) = t(2,atom1) - ul1(3)*dudu1x + ul1(1)*dudu1z |
| 192 |
|
|
t(3,atom1) = t(3,atom1) - ul1(1)*dudu1y + ul1(2)*dudu1x |
| 193 |
|
|
|
| 194 |
|
|
t(1,atom2) = t(1,atom2) - ul2(2)*dudu2z + ul2(3)*dudu2y |
| 195 |
|
|
t(2,atom2) = t(2,atom2) - ul2(3)*dudu2x + ul2(1)*dudu2z |
| 196 |
|
|
t(3,atom2) = t(3,atom2) - ul2(1)*dudu2y + ul2(2)*dudu2x |
| 197 |
|
|
#endif |
| 198 |
|
|
|
| 199 |
|
|
#ifdef IS_MPI |
| 200 |
|
|
id1 = AtomRowToGlobal(atom1) |
| 201 |
|
|
id2 = AtomColToGlobal(atom2) |
| 202 |
|
|
#else |
| 203 |
|
|
id1 = atom1 |
| 204 |
|
|
id2 = atom2 |
| 205 |
|
|
#endif |
| 206 |
|
|
|
| 207 |
|
|
if (molMembershipList(id1) .ne. molMembershipList(id2)) then |
| 208 |
|
|
|
| 209 |
|
|
fpair(1) = fpair(1) + dudx |
| 210 |
|
|
fpair(2) = fpair(2) + dudy |
| 211 |
|
|
fpair(3) = fpair(3) + dudz |
| 212 |
|
|
|
| 213 |
|
|
endif |
| 214 |
|
|
|
| 215 |
|
|
return |
| 216 |
|
|
end subroutine do_dipole_pair |
| 217 |
|
|
|
| 218 |
|
|
end module dipole_dipole |