ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/calc_charge_charge.F90
(Generate patch)

Comparing trunk/OOPSE/libmdtools/calc_charge_charge.F90 (file contents):
Revision 1144 by tim, Sat May 1 18:52:38 2004 UTC vs.
Revision 1150 by gezelter, Fri May 7 21:35:05 2004 UTC

# Line 100 | Line 100 | contains
100    end subroutine createChargeMap
101    
102    
103 <  subroutine do_charge_pair(atom1, atom2, d, rij, r2, dc, rcij, rc2, mfact, &
104 <       pot, f, do_pot, do_stress, molecular_cutoffs)
103 >  subroutine do_charge_pair(atom1, atom2, d, rij, r2, sw, vpair, &
104 >       pot, f, do_pot, do_stress)
105      
106 <    logical :: do_pot, do_stress, molecular_cutoffs
106 >    logical :: do_pot, do_stress
107  
108      integer atom1, atom2, me1, me2, id1, id2
109      integer :: localError
110 <    real(kind=dp) :: rij, r2, q1, q2, rcij, rc2
110 >    real(kind=dp) :: rij, r2, q1, q2, sw, vpair
111      real(kind=dp) :: drdx, drdy, drdz, dudr, fx, fy, fz
112 <    real(kind=dp) :: taper, dtdr, vterm
112 >    real(kind=dp) :: vterm
113  
114      real( kind = dp ) :: pot
115 <    real( kind = dp ), dimension(3) :: d, dc
115 >    real( kind = dp ), dimension(3) :: d
116      real( kind = dp ), dimension(3,nLocal) :: f
117 <    real( kind = dp ), dimension(nLocal) :: mfact
118 <    real( kind = dp ) :: theR, term1, term2
119 <    real( kind = dp ) :: fxab, fyab, fzab, fxba, fyba, fzba
117 >
118      
119      if (.not. haveCutoffs) then
120         write(default_error,*) 'charge-charge does not have cutoffs set!'
# Line 143 | Line 141 | contains
141      q1 = ChargeMap(me1)%charge
142      q2 = ChargeMap(me2)%charge
143  
144 <    if (molecular_cutoffs) then
147 <       theR = rcij
148 <    else
149 <       theR = rij
150 <    endif
144 >    vterm = sw * pre * q1 * q2 / rij
145  
146 <    if (theR.le.ecr) then
147 <      
148 <       if (theR.lt.rt) then
149 <          taper = 1.0d0
150 <          dtdr = 0.0d0
151 <       else
152 <          taper = (ecr + 2.0d0*theR - 3.0d0*rt)*(ecr-theR)**2/ ((ecr-rt)**3)
153 <          dtdr = 6.0d0*(theR*theR - theR*rt - theR*ecr +ecr*rt)/((ecr-rt)**3)
160 <       endif
146 >    dudr =  -vterm  / rij
147 >    drdx = d(1) / rij
148 >    drdy = d(2) / rij
149 >    drdz = d(3) / rij
150 >    
151 >    fx = dudr * drdx
152 >    fy = dudr * drdy
153 >    fz = dudr * drdz          
154  
155 <       vterm = pre * q1 * q2 / rij
156 <
164 <       if (molecular_cutoffs) then
165 <
166 <          term1 = -vterm * (taper / rij)
167 <
168 <          fx = term1 * d(1) / rij
169 <          fy = term1 * d(2) / rij
170 <          fz = term1 * d(3) / rij
171 <
172 <          !term2 = vterm * dtdr * mfact(atom1)
173 <          term2 = vterm * dtdr
174 <
175 <          fxab = term2 * dc(1) / rcij
176 <          fyab = term2 * dc(2) / rcij
177 <          fzab = term2 * dc(3) / rcij
178 <
179 <          !term2 = vterm * dtdr * mfact(atom2)
180 <          term2 = vterm * dtdr
181 <
182 <          fxba = term2 * dc(1) / rcij
183 <          fyba = term2 * dc(2) / rcij
184 <          fzba = term2 * dc(3) / rcij
185 <
186 <       else
187 <
188 <          dudr =  vterm * (dtdr  - taper / rij)
189 <          drdx = d(1) / rij
190 <          drdy = d(2) / rij
191 <          drdz = d(3) / rij
192 <          
193 <          fx = dudr * drdx
194 <          fy = dudr * drdy
195 <          fz = dudr * drdz          
196 <
197 <       endif
198 <
199 <
155 >    vpair = vpair + vterm
156 >    
157   #ifdef IS_MPI
158 <       if (do_pot) then
159 <          pot_Row(atom1) = pot_Row(atom1) + vterm*taper*0.5
160 <          pot_Col(atom2) = pot_Col(atom2) + vterm*taper*0.5
161 <       endif
162 <
163 <       f_Row(1,atom1) = f_Row(1,atom1) + fx
164 <       f_Row(2,atom1) = f_Row(2,atom1) + fy
165 <       f_Row(3,atom1) = f_Row(3,atom1) + fz
166 <
167 <       f_Col(1,atom2) = f_Col(1,atom2) - fx
168 <       f_Col(2,atom2) = f_Col(2,atom2) - fy
169 <       f_Col(3,atom2) = f_Col(3,atom2) - fz
170 <
214 <       if (molecular_cutoffs) then
215 <          f_Row(1,atom1) = f_Row(1,atom1) + fxab
216 <          f_Row(2,atom1) = f_Row(2,atom1) + fyab
217 <          f_Row(3,atom1) = f_Row(3,atom1) + fzab
218 <          
219 <          f_Col(1,atom2) = f_Col(1,atom2) - fxba
220 <          f_Col(2,atom2) = f_Col(2,atom2) - fyba
221 <          f_Col(3,atom2) = f_Col(3,atom2) - fzba
222 <       endif
223 <
158 >    if (do_pot) then
159 >       pot_Row(atom1) = pot_Row(atom1) + vterm*0.5
160 >       pot_Col(atom2) = pot_Col(atom2) + vterm*0.5
161 >    endif
162 >    
163 >    f_Row(1,atom1) = f_Row(1,atom1) + fx
164 >    f_Row(2,atom1) = f_Row(2,atom1) + fy
165 >    f_Row(3,atom1) = f_Row(3,atom1) + fz
166 >    
167 >    f_Col(1,atom2) = f_Col(1,atom2) - fx
168 >    f_Col(2,atom2) = f_Col(2,atom2) - fy
169 >    f_Col(3,atom2) = f_Col(3,atom2) - fz
170 >    
171   #else
172  
173 <       if (do_pot) pot = pot + vterm*taper
174 <
175 <       f(1,atom1) = f(1,atom1) + fx
176 <       f(2,atom1) = f(2,atom1) + fy
177 <       f(3,atom1) = f(3,atom1) + fz
178 <
179 <       f(1,atom2) = f(1,atom2) - fx
180 <       f(2,atom2) = f(2,atom2) - fy
181 <       f(3,atom2) = f(3,atom2) - fz
182 <
236 <       if (molecular_cutoffs) then
237 <
238 <          f(1,atom1) = f(1,atom1) + fxab
239 <          f(2,atom1) = f(2,atom1) + fyab
240 <          f(3,atom1) = f(3,atom1) + fzab
241 <          
242 <          f(1,atom2) = f(1,atom2) - fxba
243 <          f(2,atom2) = f(2,atom2) - fyba
244 <          f(3,atom2) = f(3,atom2) - fzba
245 <       endif
246 <
173 >    if (do_pot) pot = pot + vterm
174 >    
175 >    f(1,atom1) = f(1,atom1) + fx
176 >    f(2,atom1) = f(2,atom1) + fy
177 >    f(3,atom1) = f(3,atom1) + fz
178 >    
179 >    f(1,atom2) = f(1,atom2) - fx
180 >    f(2,atom2) = f(2,atom2) - fy
181 >    f(3,atom2) = f(3,atom2) - fz
182 >        
183   #endif
184 <
185 <       if (do_stress) then
186 <
184 >    
185 >    if (do_stress) then
186 >      
187   #ifdef IS_MPI
188 <          id1 = tagRow(atom1)
189 <          id2 = tagColumn(atom2)
188 >       id1 = tagRow(atom1)
189 >       id2 = tagColumn(atom2)
190   #else
191 <          id1 = atom1
192 <          id2 = atom2
191 >       id1 = atom1
192 >       id2 = atom2
193   #endif
258
259
260          if (molMembershipList(id1) .ne. molMembershipList(id2)) then
261
262             ! because the d vector is the rj - ri vector, and
263             ! because fx, fy, fz are the force on atom i, we need a
264             ! negative sign here:
265            
266             tau_Temp(1) = tau_Temp(1) - d(1) * fx
267             tau_Temp(2) = tau_Temp(2) - d(1) * fy
268             tau_Temp(3) = tau_Temp(3) - d(1) * fz
269             tau_Temp(4) = tau_Temp(4) - d(2) * fx
270             tau_Temp(5) = tau_Temp(5) - d(2) * fy
271             tau_Temp(6) = tau_Temp(6) - d(2) * fz
272             tau_Temp(8) = tau_Temp(8) - d(3) * fy
273             tau_Temp(9) = tau_Temp(9) - d(3) * fz
274
275             if (molecular_cutoffs) then
276                
277                tau_Temp(1) = tau_Temp(1) - d(1) * fxab
278                tau_Temp(2) = tau_Temp(2) - d(1) * fyab
279                tau_Temp(3) = tau_Temp(3) - d(1) * fzab
280                tau_Temp(4) = tau_Temp(4) - d(2) * fxab
281                tau_Temp(5) = tau_Temp(5) - d(2) * fyab
282                tau_Temp(6) = tau_Temp(6) - d(2) * fzab
283                tau_Temp(8) = tau_Temp(8) - d(3) * fyab
284                tau_Temp(9) = tau_Temp(9) - d(3) * fzab
285             endif
286            
287             virial_Temp = virial_Temp + &
288                  (tau_Temp(1) + tau_Temp(5) + tau_Temp(9))
289            
290          endif
291       endif
194        
195 +      
196 +       if (molMembershipList(id1) .ne. molMembershipList(id2)) then
197 +          
198 +          ! because the d vector is the rj - ri vector, and
199 +          ! because fx, fy, fz are the force on atom i, we need a
200 +          ! negative sign here:
201 +          
202 +          tau_Temp(1) = tau_Temp(1) - d(1) * fx
203 +          tau_Temp(2) = tau_Temp(2) - d(1) * fy
204 +          tau_Temp(3) = tau_Temp(3) - d(1) * fz
205 +          tau_Temp(4) = tau_Temp(4) - d(2) * fx
206 +          tau_Temp(5) = tau_Temp(5) - d(2) * fy
207 +          tau_Temp(6) = tau_Temp(6) - d(2) * fz
208 +          tau_Temp(8) = tau_Temp(8) - d(3) * fy
209 +          tau_Temp(9) = tau_Temp(9) - d(3) * fz
210 +          
211 +          
212 +          virial_Temp = virial_Temp + &
213 +               (tau_Temp(1) + tau_Temp(5) + tau_Temp(9))
214 +          
215 +       endif
216      endif
217 +    
218 +    
219      return
220    end subroutine do_charge_pair
221    

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines