43 |
|
!! Calculates Long Range forces Lennard-Jones interactions. |
44 |
|
!! @author Charles F. Vardeman II |
45 |
|
!! @author Matthew Meineke |
46 |
< |
!! @version $Id: LJ.F90,v 1.13 2005-08-09 22:33:48 gezelter Exp $, $Date: 2005-08-09 22:33:48 $, $Name: not supported by cvs2svn $, $Revision: 1.13 $ |
46 |
> |
!! @version $Id: LJ.F90,v 1.19 2005-11-21 22:59:01 gezelter Exp $, $Date: 2005-11-21 22:59:01 $, $Name: not supported by cvs2svn $, $Revision: 1.19 $ |
47 |
|
|
48 |
|
|
49 |
|
module lj |
58 |
|
|
59 |
|
implicit none |
60 |
|
PRIVATE |
61 |
+ |
#define __FORTRAN90 |
62 |
+ |
#include "UseTheForce/DarkSide/fInteractionMap.h" |
63 |
|
|
64 |
|
integer, parameter :: DP = selected_real_kind(15) |
65 |
|
|
79 |
|
end type LJtype |
80 |
|
|
81 |
|
type, private :: LJList |
82 |
< |
integer :: nLJtypes = 0 |
82 |
> |
integer :: Nljtypes = 0 |
83 |
|
integer :: currentLJtype = 0 |
84 |
|
type(LJtype), pointer :: LJtypes(:) => null() |
85 |
|
integer, pointer :: atidToLJtype(:) => null() |
102 |
|
|
103 |
|
public :: newLJtype |
104 |
|
public :: setLJDefaultCutoff |
103 |
– |
public :: setLJUniformCutoff |
104 |
– |
public :: setLJCutoffByTypes |
105 |
|
public :: getSigma |
106 |
|
public :: getEpsilon |
107 |
|
public :: useGeometricMixing |
157 |
|
defaultCutoff = thisRcut |
158 |
|
defaultShift = shiftedPot |
159 |
|
haveDefaultCutoff = .true. |
160 |
< |
end subroutine setLJDefaultCutoff |
161 |
< |
|
162 |
< |
subroutine setLJUniformCutoff(thisRcut, shiftedPot) |
163 |
< |
real(kind=dp), intent(in) :: thisRcut |
164 |
< |
logical, intent(in) :: shiftedPot |
165 |
< |
integer :: nLJtypes, i, j |
166 |
< |
|
167 |
< |
if (LJMap%currentLJtype == 0) then |
168 |
< |
call handleError("LJ", "No members in LJMap") |
169 |
< |
return |
160 |
> |
!we only want to build LJ Mixing map if LJ is being used. |
161 |
> |
if(LJMap%nLJTypes /= 0) then |
162 |
> |
call createMixingMap() |
163 |
|
end if |
164 |
< |
|
172 |
< |
nLJtypes = LJMap%nLJtypes |
173 |
< |
if (.not. allocated(MixingMap)) then |
174 |
< |
allocate(MixingMap(nLJtypes, nLJtypes)) |
175 |
< |
endif |
176 |
< |
|
177 |
< |
do i = 1, nLJtypes |
178 |
< |
do j = 1, nLJtypes |
179 |
< |
MixingMap(i,j)%rCut = thisRcut |
180 |
< |
MixingMap(i,j)%shiftedPot = shiftedPot |
181 |
< |
MixingMap(i,j)%rCutWasSet = .true. |
182 |
< |
enddo |
183 |
< |
enddo |
184 |
< |
call createMixingMap() |
185 |
< |
end subroutine setLJUniformCutoff |
186 |
< |
|
187 |
< |
subroutine setLJCutoffByTypes(atid1, atid2, thisRcut, shiftedPot) |
188 |
< |
integer, intent(in) :: atid1, atid2 |
189 |
< |
real(kind=dp), intent(in) :: thisRcut |
190 |
< |
logical, intent(in) :: shiftedPot |
191 |
< |
integer :: nLJtypes, ljt1, ljt2 |
192 |
< |
|
193 |
< |
if (LJMap%currentLJtype == 0) then |
194 |
< |
call handleError("LJ", "No members in LJMap") |
195 |
< |
return |
196 |
< |
end if |
197 |
< |
|
198 |
< |
nLJtypes = LJMap%nLJtypes |
199 |
< |
if (.not. allocated(MixingMap)) then |
200 |
< |
allocate(MixingMap(nLJtypes, nLJtypes)) |
201 |
< |
endif |
202 |
< |
|
203 |
< |
ljt1 = LJMap%atidToLJtype(atid1) |
204 |
< |
ljt2 = LJMap%atidToLJtype(atid2) |
205 |
< |
|
206 |
< |
MixingMap(ljt1,ljt2)%rCut = thisRcut |
207 |
< |
MixingMap(ljt1,ljt2)%shiftedPot = shiftedPot |
208 |
< |
MixingMap(ljt1,ljt2)%rCutWasSet = .true. |
209 |
< |
MixingMap(ljt2,ljt1)%rCut = thisRcut |
210 |
< |
MixingMap(ljt2,ljt1)%shiftedPot = shiftedPot |
211 |
< |
MixingMap(ljt2,ljt1)%rCutWasSet = .true. |
212 |
< |
|
213 |
< |
call createMixingMap() |
214 |
< |
end subroutine setLJCutoffByTypes |
164 |
> |
end subroutine setLJDefaultCutoff |
165 |
|
|
166 |
|
function getSigma(atid) result (s) |
167 |
|
integer, intent(in) :: atid |
203 |
|
integer :: nLJtypes, i, j |
204 |
|
real ( kind = dp ) :: s1, s2, e1, e2 |
205 |
|
real ( kind = dp ) :: rcut6, tp6, tp12 |
206 |
< |
logical :: isSoftCore1, isSoftCore2 |
206 |
> |
logical :: isSoftCore1, isSoftCore2, doShift |
207 |
|
|
208 |
|
if (LJMap%currentLJtype == 0) then |
209 |
|
call handleError("LJ", "No members in LJMap") |
241 |
|
|
242 |
|
MixingMap(i,j)%sigma6 = (MixingMap(i,j)%sigma)**6 |
243 |
|
|
244 |
< |
if (MixingMap(i,j)%rCutWasSet) then |
245 |
< |
rcut6 = (MixingMap(i,j)%rcut)**6 |
244 |
> |
if (haveDefaultCutoff) then |
245 |
> |
rcut6 = defaultCutoff**6 |
246 |
> |
tp6 = MixingMap(i,j)%sigma6/rcut6 |
247 |
> |
tp12 = tp6**2 |
248 |
> |
MixingMap(i,j)%delta =-4.0_DP*MixingMap(i,j)%epsilon*(tp12 - tp6) |
249 |
> |
MixingMap(i,j)%shiftedPot = defaultShift |
250 |
|
else |
251 |
< |
if (haveDefaultCutoff) then |
252 |
< |
rcut6 = defaultCutoff**6 |
253 |
< |
else |
254 |
< |
call handleError("LJ", "No specified or default cutoff value!") |
255 |
< |
endif |
251 |
> |
MixingMap(i,j)%delta = 0.0_DP |
252 |
> |
MixingMap(i,j)%shiftedPot = defaultShift |
253 |
> |
endif |
254 |
> |
|
255 |
> |
if (i.ne.j) then |
256 |
> |
MixingMap(j,i)%sigma = MixingMap(i,j)%sigma |
257 |
> |
MixingMap(j,i)%epsilon = MixingMap(i,j)%epsilon |
258 |
> |
MixingMap(j,i)%sigma6 = MixingMap(i,j)%sigma6 |
259 |
> |
MixingMap(j,i)%rCut = MixingMap(i,j)%rCut |
260 |
> |
MixingMap(j,i)%delta = MixingMap(i,j)%delta |
261 |
> |
MixingMap(j,i)%rCutWasSet = MixingMap(i,j)%rCutWasSet |
262 |
> |
MixingMap(j,i)%shiftedPot = MixingMap(i,j)%shiftedPot |
263 |
> |
MixingMap(j,i)%isSoftCore = MixingMap(i,j)%isSoftCore |
264 |
|
endif |
303 |
– |
|
304 |
– |
tp6 = MixingMap(i,j)%sigma6/rcut6 |
305 |
– |
tp12 = tp6**2 |
265 |
|
|
307 |
– |
MixingMap(i,j)%delta =-4.0_DP*MixingMap(i,j)%epsilon*(tp12 - tp6) |
266 |
|
enddo |
267 |
|
enddo |
268 |
|
|
270 |
|
|
271 |
|
end subroutine createMixingMap |
272 |
|
|
273 |
< |
subroutine do_lj_pair(atom1, atom2, d, rij, r2, sw, vpair, fpair, & |
273 |
> |
subroutine do_lj_pair(atom1, atom2, d, rij, r2, rcut, sw, vpair, fpair, & |
274 |
|
pot, f, do_pot) |
275 |
< |
|
275 |
> |
|
276 |
|
integer, intent(in) :: atom1, atom2 |
277 |
|
integer :: atid1, atid2, ljt1, ljt2 |
278 |
< |
real( kind = dp ), intent(in) :: rij, r2 |
278 |
> |
real( kind = dp ), intent(in) :: rij, r2, rcut |
279 |
|
real( kind = dp ) :: pot, sw, vpair |
280 |
|
real( kind = dp ), dimension(3,nLocal) :: f |
281 |
|
real( kind = dp ), intent(in), dimension(3) :: d |
288 |
|
real( kind = dp ) :: pot_temp, dudr |
289 |
|
real( kind = dp ) :: sigma6 |
290 |
|
real( kind = dp ) :: epsilon |
291 |
< |
real( kind = dp ) :: r6 |
292 |
< |
real( kind = dp ) :: t6 |
293 |
< |
real( kind = dp ) :: t12 |
291 |
> |
real( kind = dp ) :: r6, rc6 |
292 |
> |
real( kind = dp ) :: t6, tp6 |
293 |
> |
real( kind = dp ) :: t12, tp12 |
294 |
|
real( kind = dp ) :: delta |
295 |
|
logical :: isSoftCore, shiftedPot |
296 |
|
integer :: id1, id2, localError |
326 |
|
|
327 |
|
pot_temp = 4.0E0_DP * epsilon * t6 |
328 |
|
if (shiftedPot) then |
329 |
+ |
rc6 = rcut**6 |
330 |
+ |
tp6 = sigma6 / rc6 |
331 |
+ |
delta =-4.0_DP*epsilon*(tp6) |
332 |
|
pot_temp = pot_temp + delta |
333 |
|
endif |
334 |
|
|
339 |
|
else |
340 |
|
pot_temp = 4.0E0_DP * epsilon * (t12 - t6) |
341 |
|
if (shiftedPot) then |
342 |
+ |
rc6 = rcut**6 |
343 |
+ |
tp6 = sigma6 / rc6 |
344 |
+ |
tp12 = tp6*tp6 |
345 |
+ |
delta =-4.0_DP*epsilon*(tp12 - tp6) |
346 |
|
pot_temp = pot_temp + delta |
347 |
|
endif |
348 |
|
|
359 |
|
fy = dudr * drdy |
360 |
|
fz = dudr * drdz |
361 |
|
|
397 |
– |
|
362 |
|
#ifdef IS_MPI |
363 |
|
if (do_pot) then |
364 |
< |
pot_Row(atom1) = pot_Row(atom1) + sw*pot_temp*0.5 |
365 |
< |
pot_Col(atom2) = pot_Col(atom2) + sw*pot_temp*0.5 |
364 |
> |
pot_Row(VDW_POT,atom1) = pot_Row(VDW_POT,atom1) + sw*pot_temp*0.5 |
365 |
> |
pot_Col(VDW_POT,atom2) = pot_Col(VDW_POT,atom2) + sw*pot_temp*0.5 |
366 |
|
endif |
367 |
|
|
368 |
|
f_Row(1,atom1) = f_Row(1,atom1) + fx |