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.15 2005-09-21 17:20:14 chrisfen Exp $, $Date: 2005-09-21 17:20:14 $, $Name: not supported by cvs2svn $, $Revision: 1.15 $ |
46 |
> |
!! @version $Id: LJ.F90,v 1.20 2005-12-07 19:58:18 chuckv Exp $, $Date: 2005-12-07 19:58:18 $, $Name: not supported by cvs2svn $, $Revision: 1.20 $ |
47 |
|
|
48 |
|
|
49 |
|
module lj |
51 |
|
use vector_class |
52 |
|
use simulation |
53 |
|
use status |
54 |
+ |
use fForceOptions |
55 |
|
#ifdef IS_MPI |
56 |
|
use mpiSimulation |
57 |
|
#endif |
59 |
|
|
60 |
|
implicit none |
61 |
|
PRIVATE |
62 |
+ |
#define __FORTRAN90 |
63 |
+ |
#include "UseTheForce/DarkSide/fInteractionMap.h" |
64 |
|
|
65 |
|
integer, parameter :: DP = selected_real_kind(15) |
66 |
|
|
80 |
|
end type LJtype |
81 |
|
|
82 |
|
type, private :: LJList |
83 |
< |
integer :: nLJtypes = 0 |
83 |
> |
integer :: Nljtypes = 0 |
84 |
|
integer :: currentLJtype = 0 |
85 |
|
type(LJtype), pointer :: LJtypes(:) => null() |
86 |
|
integer, pointer :: atidToLJtype(:) => null() |
103 |
|
|
104 |
|
public :: newLJtype |
105 |
|
public :: setLJDefaultCutoff |
103 |
– |
public :: setLJUniformCutoff |
104 |
– |
public :: setLJCutoffByTypes |
106 |
|
public :: getSigma |
107 |
|
public :: getEpsilon |
107 |
– |
public :: useGeometricMixing |
108 |
|
public :: do_lj_pair |
109 |
|
public :: destroyLJtypes |
110 |
|
|
157 |
|
defaultCutoff = thisRcut |
158 |
|
defaultShift = shiftedPot |
159 |
|
haveDefaultCutoff = .true. |
160 |
< |
call createMixingMap() |
161 |
< |
end subroutine setLJDefaultCutoff |
162 |
< |
|
163 |
< |
subroutine setLJUniformCutoff(thisRcut, shiftedPot) |
164 |
< |
real(kind=dp), intent(in) :: thisRcut |
165 |
< |
logical, intent(in) :: shiftedPot |
166 |
< |
integer :: nLJtypes, i, j |
167 |
< |
|
168 |
< |
if (LJMap%currentLJtype == 0) then |
169 |
< |
call handleError("LJ", "No members in LJMap") |
170 |
< |
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 |
< |
|
173 |
< |
nLJtypes = LJMap%nLJtypes |
174 |
< |
if (.not. allocated(MixingMap)) then |
175 |
< |
allocate(MixingMap(nLJtypes, nLJtypes)) |
176 |
< |
endif |
177 |
< |
|
178 |
< |
do i = 1, nLJtypes |
179 |
< |
do j = 1, nLJtypes |
180 |
< |
MixingMap(i,j)%rCut = thisRcut |
181 |
< |
MixingMap(i,j)%shiftedPot = shiftedPot |
182 |
< |
MixingMap(i,j)%rCutWasSet = .true. |
183 |
< |
enddo |
184 |
< |
enddo |
185 |
< |
call createMixingMap() |
186 |
< |
end subroutine setLJUniformCutoff |
187 |
< |
|
188 |
< |
subroutine setLJCutoffByTypes(atid1, atid2, thisRcut, shiftedPot) |
189 |
< |
integer, intent(in) :: atid1, atid2 |
190 |
< |
real(kind=dp), intent(in) :: thisRcut |
191 |
< |
logical, intent(in) :: shiftedPot |
192 |
< |
integer :: nLJtypes, ljt1, ljt2 |
193 |
< |
|
194 |
< |
if (LJMap%currentLJtype == 0) then |
195 |
< |
call handleError("LJ", "No members in LJMap") |
196 |
< |
return |
197 |
< |
end if |
198 |
< |
|
199 |
< |
nLJtypes = LJMap%nLJtypes |
200 |
< |
if (.not. allocated(MixingMap)) then |
201 |
< |
allocate(MixingMap(nLJtypes, nLJtypes)) |
202 |
< |
endif |
203 |
< |
|
204 |
< |
ljt1 = LJMap%atidToLJtype(atid1) |
205 |
< |
ljt2 = LJMap%atidToLJtype(atid2) |
206 |
< |
|
207 |
< |
MixingMap(ljt1,ljt2)%rCut = thisRcut |
208 |
< |
MixingMap(ljt1,ljt2)%shiftedPot = shiftedPot |
209 |
< |
MixingMap(ljt1,ljt2)%rCutWasSet = .true. |
210 |
< |
MixingMap(ljt2,ljt1)%rCut = thisRcut |
211 |
< |
MixingMap(ljt2,ljt1)%shiftedPot = shiftedPot |
212 |
< |
MixingMap(ljt2,ljt1)%rCutWasSet = .true. |
164 |
> |
end subroutine setLJDefaultCutoff |
165 |
|
|
214 |
– |
call createMixingMap() |
215 |
– |
end subroutine setLJCutoffByTypes |
216 |
– |
|
166 |
|
function getSigma(atid) result (s) |
167 |
|
integer, intent(in) :: atid |
168 |
|
integer :: ljt1 |
193 |
|
|
194 |
|
end function getEpsilon |
195 |
|
|
247 |
– |
subroutine useGeometricMixing() |
248 |
– |
useGeometricDistanceMixing = .true. |
249 |
– |
haveMixingMap = .false. |
250 |
– |
return |
251 |
– |
end subroutine useGeometricMixing |
252 |
– |
|
196 |
|
subroutine createMixingMap() |
197 |
|
integer :: nLJtypes, i, j |
198 |
|
real ( kind = dp ) :: s1, s2, e1, e2 |
210 |
|
allocate(MixingMap(nLJtypes, nLJtypes)) |
211 |
|
endif |
212 |
|
|
213 |
+ |
useGeometricDistanceMixing = usesGeometricDistanceMixing() |
214 |
|
do i = 1, nLJtypes |
215 |
|
|
216 |
|
s1 = LJMap%LJtypes(i)%sigma |
236 |
|
|
237 |
|
MixingMap(i,j)%sigma6 = (MixingMap(i,j)%sigma)**6 |
238 |
|
|
239 |
< |
if (MixingMap(i,j)%rCutWasSet) then |
240 |
< |
rcut6 = (MixingMap(i,j)%rcut)**6 |
239 |
> |
if (haveDefaultCutoff) then |
240 |
> |
rcut6 = defaultCutoff**6 |
241 |
> |
tp6 = MixingMap(i,j)%sigma6/rcut6 |
242 |
> |
tp12 = tp6**2 |
243 |
> |
MixingMap(i,j)%delta =-4.0_DP*MixingMap(i,j)%epsilon*(tp12 - tp6) |
244 |
> |
MixingMap(i,j)%shiftedPot = defaultShift |
245 |
|
else |
246 |
< |
if (haveDefaultCutoff) then |
247 |
< |
rcut6 = defaultCutoff**6 |
248 |
< |
doShift = defaultShift |
301 |
< |
else |
302 |
< |
call handleError("LJ", "No specified or default cutoff value!") |
303 |
< |
endif |
304 |
< |
endif |
305 |
< |
|
306 |
< |
tp6 = MixingMap(i,j)%sigma6/rcut6 |
307 |
< |
tp12 = tp6**2 |
308 |
< |
MixingMap(i,j)%delta =-4.0_DP*MixingMap(i,j)%epsilon*(tp12 - tp6) |
309 |
< |
MixingMap(i,j)%shiftedPot = doShift |
246 |
> |
MixingMap(i,j)%delta = 0.0_DP |
247 |
> |
MixingMap(i,j)%shiftedPot = defaultShift |
248 |
> |
endif |
249 |
|
|
250 |
|
if (i.ne.j) then |
251 |
|
MixingMap(j,i)%sigma = MixingMap(i,j)%sigma |
265 |
|
|
266 |
|
end subroutine createMixingMap |
267 |
|
|
268 |
< |
subroutine do_lj_pair(atom1, atom2, d, rij, r2, sw, vpair, fpair, & |
268 |
> |
subroutine do_lj_pair(atom1, atom2, d, rij, r2, rcut, sw, vpair, fpair, & |
269 |
|
pot, f, do_pot) |
270 |
< |
|
270 |
> |
|
271 |
|
integer, intent(in) :: atom1, atom2 |
272 |
|
integer :: atid1, atid2, ljt1, ljt2 |
273 |
< |
real( kind = dp ), intent(in) :: rij, r2 |
273 |
> |
real( kind = dp ), intent(in) :: rij, r2, rcut |
274 |
|
real( kind = dp ) :: pot, sw, vpair |
275 |
|
real( kind = dp ), dimension(3,nLocal) :: f |
276 |
|
real( kind = dp ), intent(in), dimension(3) :: d |
283 |
|
real( kind = dp ) :: pot_temp, dudr |
284 |
|
real( kind = dp ) :: sigma6 |
285 |
|
real( kind = dp ) :: epsilon |
286 |
< |
real( kind = dp ) :: r6 |
287 |
< |
real( kind = dp ) :: t6 |
288 |
< |
real( kind = dp ) :: t12 |
286 |
> |
real( kind = dp ) :: r6, rc6 |
287 |
> |
real( kind = dp ) :: t6, tp6 |
288 |
> |
real( kind = dp ) :: t12, tp12 |
289 |
|
real( kind = dp ) :: delta |
290 |
|
logical :: isSoftCore, shiftedPot |
291 |
|
integer :: id1, id2, localError |
321 |
|
|
322 |
|
pot_temp = 4.0E0_DP * epsilon * t6 |
323 |
|
if (shiftedPot) then |
324 |
+ |
rc6 = rcut**6 |
325 |
+ |
tp6 = sigma6 / rc6 |
326 |
+ |
delta =-4.0_DP*epsilon*(tp6) |
327 |
|
pot_temp = pot_temp + delta |
328 |
|
endif |
329 |
|
|
334 |
|
else |
335 |
|
pot_temp = 4.0E0_DP * epsilon * (t12 - t6) |
336 |
|
if (shiftedPot) then |
337 |
+ |
rc6 = rcut**6 |
338 |
+ |
tp6 = sigma6 / rc6 |
339 |
+ |
tp12 = tp6*tp6 |
340 |
+ |
delta =-4.0_DP*epsilon*(tp12 - tp6) |
341 |
|
pot_temp = pot_temp + delta |
342 |
|
endif |
343 |
|
|
356 |
|
|
357 |
|
#ifdef IS_MPI |
358 |
|
if (do_pot) then |
359 |
< |
pot_Row(atom1) = pot_Row(atom1) + sw*pot_temp*0.5 |
360 |
< |
pot_Col(atom2) = pot_Col(atom2) + sw*pot_temp*0.5 |
359 |
> |
pot_Row(VDW_POT,atom1) = pot_Row(VDW_POT,atom1) + sw*pot_temp*0.5 |
360 |
> |
pot_Col(VDW_POT,atom2) = pot_Col(VDW_POT,atom2) + sw*pot_temp*0.5 |
361 |
|
endif |
362 |
|
|
363 |
|
f_Row(1,atom1) = f_Row(1,atom1) + fx |