12 |
|
implicit none |
13 |
|
|
14 |
|
PRIVATE |
15 |
< |
real(kind=dp), save :: ecr = 0.0 |
16 |
< |
real(kind=dp), save :: rt = 0.0 |
17 |
< |
real(kind=dp), save :: pre = 0.0 |
18 |
< |
logical, save :: haveCutoffs = .false. |
15 |
> |
|
16 |
> |
real(kind=dp), parameter :: pre = 14.38362_dp |
17 |
|
logical, save :: haveMomentMap = .false. |
18 |
|
|
21 |
– |
public::setCutoffsDipole |
19 |
|
public::do_dipole_pair |
20 |
|
|
21 |
|
type :: MomentList |
25 |
|
type(MomentList), dimension(:),allocatable :: MomentMap |
26 |
|
|
27 |
|
contains |
31 |
– |
|
32 |
– |
subroutine setCutoffsDipole(this_ecr, this_rt) |
33 |
– |
real(kind=dp), intent(in) :: this_ecr, this_rt |
34 |
– |
ecr = this_ecr |
35 |
– |
rt = this_rt |
28 |
|
|
37 |
– |
! pre converts from mu in units of debye to kcal/mol |
38 |
– |
pre = 14.38362_dp |
39 |
– |
|
40 |
– |
haveCutoffs = .true. |
41 |
– |
|
42 |
– |
return |
43 |
– |
end subroutine setCutoffsDipole |
44 |
– |
|
29 |
|
subroutine createMomentMap(status) |
30 |
|
integer :: nAtypes |
31 |
|
integer :: status |
59 |
|
|
60 |
|
haveMomentMap = .true. |
61 |
|
|
62 |
< |
end subroutine createMomentMap |
62 |
> |
end subroutine createMomentMap |
63 |
|
|
64 |
< |
|
65 |
< |
subroutine do_dipole_pair(atom1, atom2, d, rij, r2, pot, u_l, f, t, & |
82 |
< |
do_pot, do_stress) |
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, do_stress |
67 |
> |
logical :: do_pot |
68 |
|
|
69 |
|
integer atom1, atom2, me1, me2, id1, id2 |
70 |
|
integer :: localError |
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) :: taper, dtdr, vterm |
75 |
> |
real(kind=dp) :: sw, vpair, vterm |
76 |
|
|
77 |
|
real( kind = dp ) :: pot |
78 |
< |
real( kind = dp ), dimension(3) :: d |
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 |
83 |
|
real (kind = dp), dimension(3) :: ul1 |
84 |
|
real (kind = dp), dimension(3) :: ul2 |
85 |
|
|
103 |
– |
if (.not. haveCutoffs) then |
104 |
– |
write(default_error,*) 'Dipole-dipole does not have cutoffs set!' |
105 |
– |
return |
106 |
– |
endif |
107 |
– |
|
86 |
|
if (.not.haveMomentMap) then |
87 |
|
localError = 0 |
88 |
|
call createMomentMap(localError) |
116 |
|
|
117 |
|
mu1 = MomentMap(me1)%dipole_moment |
118 |
|
mu2 = MomentMap(me2)%dipole_moment |
119 |
< |
|
120 |
< |
if (rij.le.ecr) then |
121 |
< |
|
122 |
< |
if (rij.lt.rt) then |
123 |
< |
taper = 1.0d0 |
124 |
< |
dtdr = 0.0d0 |
125 |
< |
else |
126 |
< |
taper = (ecr + 2.0d0*rij - 3.0d0*rt)*(ecr-rij)**2/ ((ecr-rt)**3) |
127 |
< |
dtdr = 6.0d0*(rij*rij - rij*rt - rij*ecr +ecr*rt)/((ecr-rt)**3) |
128 |
< |
endif |
129 |
< |
|
130 |
< |
r3 = r2*rij |
131 |
< |
r5 = r3*r2 |
132 |
< |
|
133 |
< |
rdotu1 = d(1)*ul1(1) + d(2)*ul1(2) + d(3)*ul1(3) |
134 |
< |
rdotu2 = d(1)*ul2(1) + d(2)*ul2(2) + d(3)*ul2(3) |
135 |
< |
u1dotu2 = ul1(1)*ul2(1) + ul1(2)*ul2(2) + ul1(3)*ul2(3) |
158 |
< |
|
159 |
< |
dip2 = pre * mu1 * mu2 |
160 |
< |
dfact1 = 3.0d0*dip2 / r2 |
161 |
< |
dfact2 = 3.0d0*dip2 / r5 |
162 |
< |
|
163 |
< |
vterm = dip2*((u1dotu2/r3) - 3.0d0*(rdotu1*rdotu2/r5)) |
164 |
< |
|
165 |
< |
if (do_pot) then |
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*taper |
138 |
< |
pot_col(atom2) = pot_col(atom2) + 0.5d0*vterm*taper |
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*taper |
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))*taper + & |
147 |
< |
vterm*dtdr*d(1)/rij |
148 |
< |
|
149 |
< |
dudy = (-dfact1 * d(2) * ((u1dotu2/r3) - & |
150 |
< |
(5.0d0*(rdotu1*rdotu2)/r5)) - & |
151 |
< |
dfact2*(ul1(2)*rdotu2 + ul2(2)*rdotu1))*taper + & |
152 |
< |
vterm*dtdr*d(2)/rij |
153 |
< |
|
154 |
< |
dudz = (-dfact1 * d(3) * ((u1dotu2/r3) - & |
155 |
< |
(5.0d0*(rdotu1*rdotu2)/r5)) - & |
156 |
< |
dfact2*(ul1(3)*rdotu2 + ul2(3)*rdotu1))*taper + & |
157 |
< |
vterm*dtdr*d(3)/rij |
158 |
< |
|
159 |
< |
dudu1x = (dip2*((ul2(1)/r3) - (3.0d0*d(1)*rdotu2/r5)))*taper |
160 |
< |
dudu1y = (dip2*((ul2(2)/r3) - (3.0d0*d(2)*rdotu2/r5)))*taper |
161 |
< |
dudu1z = (dip2*((ul2(3)/r3) - (3.0d0*d(3)*rdotu2/r5)))*taper |
162 |
< |
|
163 |
< |
dudu2x = (dip2*((ul1(1)/r3) - (3.0d0*d(1)*rdotu1/r5)))*taper |
164 |
< |
dudu2y = (dip2*((ul1(2)/r3) - (3.0d0*d(2)*rdotu1/r5)))*taper |
195 |
< |
dudu2z = (dip2*((ul1(3)/r3) - (3.0d0*d(3)*rdotu1/r5)))*taper |
196 |
< |
|
197 |
< |
|
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 |
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 |
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 |
< |
|
232 |
< |
if (do_stress) then |
233 |
< |
|
198 |
> |
|
199 |
|
#ifdef IS_MPI |
200 |
< |
id1 = tagRow(atom1) |
201 |
< |
id2 = tagColumn(atom2) |
200 |
> |
id1 = tagRow(atom1) |
201 |
> |
id2 = tagColumn(atom2) |
202 |
|
#else |
203 |
< |
id1 = atom1 |
204 |
< |
id2 = atom2 |
205 |
< |
#endif |
241 |
< |
if (molMembershipList(id1) .ne. molMembershipList(id2)) then |
203 |
> |
id1 = atom1 |
204 |
> |
id2 = atom2 |
205 |
> |
#endif |
206 |
|
|
207 |
< |
! because the d vector is the rj - ri vector, and |
244 |
< |
! because dudx, dudy, dudz are the (positive) force on |
245 |
< |
! atom i (negative on atom j) we need a negative sign here: |
246 |
< |
|
247 |
< |
tau_Temp(1) = tau_Temp(1) - d(1) * dudx |
248 |
< |
tau_Temp(2) = tau_Temp(2) - d(1) * dudy |
249 |
< |
tau_Temp(3) = tau_Temp(3) - d(1) * dudz |
250 |
< |
tau_Temp(4) = tau_Temp(4) - d(2) * dudx |
251 |
< |
tau_Temp(5) = tau_Temp(5) - d(2) * dudy |
252 |
< |
tau_Temp(6) = tau_Temp(6) - d(2) * dudz |
253 |
< |
tau_Temp(7) = tau_Temp(7) - d(3) * dudx |
254 |
< |
tau_Temp(8) = tau_Temp(8) - d(3) * dudy |
255 |
< |
tau_Temp(9) = tau_Temp(9) - d(3) * dudz |
256 |
< |
|
257 |
< |
virial_Temp = virial_Temp + & |
258 |
< |
(tau_Temp(1) + tau_Temp(5) + tau_Temp(9)) |
259 |
< |
|
260 |
< |
endif |
261 |
< |
endif |
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 |
< |
|
214 |
> |
|
215 |
|
return |
216 |
|
end subroutine do_dipole_pair |
217 |
|
|