2 |
|
!! Corresponds to the force field defined in lj_FF.cpp |
3 |
|
!! @author Charles F. Vardeman II |
4 |
|
!! @author Matthew Meineke |
5 |
< |
!! @version $Id: calc_LJ_FF.F90,v 1.2 2003-04-04 22:22:30 chuckv Exp $, $Date: 2003-04-04 22:22:30 $, $Name: not supported by cvs2svn $, $Revision: 1.2 $ |
5 |
> |
!! @version $Id: calc_LJ_FF.F90,v 1.14 2004-01-05 22:49:14 chuckv Exp $, $Date: 2004-01-05 22:49:14 $, $Name: not supported by cvs2svn $, $Revision: 1.14 $ |
6 |
|
|
7 |
|
module lj |
8 |
|
use definitions |
21 |
|
#include "fForceField.h" |
22 |
|
|
23 |
|
integer, save :: LJ_Mixing_Policy |
24 |
< |
integer, save :: LJ_rcut |
24 |
> |
real(kind=DP), save :: LJ_rcut |
25 |
> |
logical, save :: havePolicy = .false., haveCut = .false. |
26 |
> |
|
27 |
|
|
28 |
|
!! Logical has lj force field module been initialized? |
29 |
|
|
31 |
|
|
32 |
|
!! Public methods and data |
33 |
|
public :: init_LJ_FF |
34 |
< |
public :: LJ_new_rcut |
34 |
> |
public :: setCutoffLJ |
35 |
|
public :: do_lj_pair |
36 |
|
|
37 |
|
type :: lj_mixed_params |
47 |
|
|
48 |
|
real ( kind = dp ) :: delta = 0.0_dp |
49 |
|
|
50 |
+ |
|
51 |
|
end type lj_mixed_params |
52 |
|
|
53 |
|
type (lj_mixed_params), dimension(:,:), pointer :: ljMixed |
54 |
|
|
55 |
|
contains |
56 |
|
|
57 |
< |
subroutine init_LJ_FF(mix_Policy, rcut, status) |
57 |
> |
subroutine init_LJ_FF(mix_Policy, status) |
58 |
|
integer, intent(in) :: mix_Policy |
59 |
|
integer, intent(out) :: status |
60 |
|
integer :: myStatus |
58 |
– |
real(kind=dp) :: rcut |
61 |
|
|
62 |
|
if (mix_Policy == LB_MIXING_RULE) then |
63 |
|
LJ_Mixing_Policy = LB_MIXING_RULE |
70 |
|
return |
71 |
|
endif |
72 |
|
endif |
71 |
– |
|
72 |
– |
LJ_rcut = rcut |
73 |
|
|
74 |
< |
status = 0 |
75 |
< |
call createMixingList(myStatus) |
76 |
< |
if (myStatus /= 0) then |
77 |
< |
status = -1 |
78 |
< |
return |
74 |
> |
havePolicy = .true. |
75 |
> |
|
76 |
> |
if (haveCut) then |
77 |
> |
status = 0 |
78 |
> |
call createMixingList(myStatus) |
79 |
> |
if (myStatus /= 0) then |
80 |
> |
status = -1 |
81 |
> |
return |
82 |
> |
end if |
83 |
> |
|
84 |
> |
LJ_FF_initialized = .true. |
85 |
|
end if |
86 |
< |
|
81 |
< |
LJ_FF_initialized = .true. |
82 |
< |
|
86 |
> |
|
87 |
|
end subroutine init_LJ_FF |
88 |
|
|
89 |
< |
subroutine LJ_new_rcut(rcut, status) |
89 |
> |
subroutine setCutoffLJ(rcut, status) |
90 |
|
integer :: status, myStatus |
91 |
|
real(kind=dp) :: rcut |
92 |
+ |
|
93 |
+ |
status = 0 |
94 |
|
|
95 |
|
LJ_rcut = rcut |
96 |
< |
status = 0 |
91 |
< |
call createMixingList(myStatus) |
92 |
< |
if (myStatus /= 0) then |
93 |
< |
status = -1 |
94 |
< |
return |
95 |
< |
end if |
96 |
> |
haveCut = .true. |
97 |
|
|
98 |
+ |
if (havePolicy) then |
99 |
+ |
status = 0 |
100 |
+ |
call createMixingList(myStatus) |
101 |
+ |
if (myStatus /= 0) then |
102 |
+ |
status = -1 |
103 |
+ |
return |
104 |
+ |
end if |
105 |
+ |
|
106 |
+ |
LJ_FF_initialized = .true. |
107 |
+ |
end if |
108 |
+ |
|
109 |
|
return |
110 |
< |
end subroutine LJ_new_rcut |
110 |
> |
end subroutine setCutoffLJ |
111 |
|
|
112 |
|
subroutine createMixingList(status) |
113 |
|
integer :: nAtypes |
127 |
|
|
128 |
|
if (.not. associated(ljMixed)) then |
129 |
|
allocate(ljMixed(nAtypes, nAtypes)) |
130 |
< |
else |
119 |
< |
status = -1 |
120 |
< |
return |
121 |
< |
end if |
130 |
> |
endif |
131 |
|
|
132 |
|
rcut6 = LJ_rcut**6 |
133 |
|
|
138 |
|
! do self mixing rule |
139 |
|
ljMixed(i,i)%sigma = mySigma_i |
140 |
|
|
141 |
< |
ljMixed(i,i)%sigma6 = (ljMixed(i,i)%sigma) ** 6 |
133 |
< |
ljMixed(i,i)%tp6 = ljMixed(i,i)%sigma6/rcut6 |
141 |
> |
ljMixed(i,i)%sigma6 = (ljMixed(i,i)%sigma) ** 6 |
142 |
|
|
143 |
+ |
ljMixed(i,i)%tp6 = (ljMixed(i,i)%sigma6)/rcut6 |
144 |
+ |
|
145 |
|
ljMixed(i,i)%tp12 = (ljMixed(i,i)%tp6) ** 2 |
146 |
|
|
147 |
+ |
|
148 |
|
ljMixed(i,i)%epsilon = myEpsilon_i |
149 |
|
|
150 |
|
ljMixed(i,i)%delta = -4.0_DP * ljMixed(i,i)%epsilon * & |
192 |
|
integer, intent(in) :: atom1, atom2 |
193 |
|
real( kind = dp ), intent(in) :: rij, r2 |
194 |
|
real( kind = dp ) :: pot |
195 |
< |
real( kind = dp ), dimension(3,getNlocal()) :: f |
195 |
> |
real( kind = dp ), dimension(3,nLocal) :: f |
196 |
|
real( kind = dp ), intent(in), dimension(3) :: d |
197 |
|
logical, intent(in) :: do_pot, do_stress |
198 |
|
|
206 |
|
real( kind = dp ) :: t6 |
207 |
|
real( kind = dp ) :: t12 |
208 |
|
real( kind = dp ) :: delta |
209 |
+ |
integer :: id1, id2 |
210 |
|
|
211 |
|
|
212 |
|
if (rij.lt.LJ_rcut) then |
231 |
|
|
232 |
|
dudr = 24.0E0_DP * epsilon * (t6 - 2.0E0_DP*t12) / rij |
233 |
|
|
234 |
< |
drdx = -d(1) / rij |
235 |
< |
drdy = -d(2) / rij |
236 |
< |
drdz = -d(3) / rij |
234 |
> |
drdx = d(1) / rij |
235 |
> |
drdy = d(2) / rij |
236 |
> |
drdz = d(3) / rij |
237 |
|
|
238 |
|
fx = dudr * drdx |
239 |
|
fy = dudr * drdy |
266 |
|
#endif |
267 |
|
|
268 |
|
if (do_stress) then |
269 |
< |
tau_Temp(1) = tau_Temp(1) + fx * d(1) |
270 |
< |
tau_Temp(2) = tau_Temp(2) + fx * d(2) |
271 |
< |
tau_Temp(3) = tau_Temp(3) + fx * d(3) |
272 |
< |
tau_Temp(4) = tau_Temp(4) + fy * d(1) |
273 |
< |
tau_Temp(5) = tau_Temp(5) + fy * d(2) |
274 |
< |
tau_Temp(6) = tau_Temp(6) + fy * d(3) |
275 |
< |
tau_Temp(7) = tau_Temp(7) + fz * d(1) |
276 |
< |
tau_Temp(8) = tau_Temp(8) + fz * d(2) |
277 |
< |
tau_Temp(9) = tau_Temp(9) + fz * d(3) |
278 |
< |
virial_Temp = virial_Temp + (tau_Temp(1) + tau_Temp(5) + tau_Temp(9)) |
269 |
> |
|
270 |
> |
#ifdef IS_MPI |
271 |
> |
id1 = tagRow(atom1) |
272 |
> |
id2 = tagColumn(atom2) |
273 |
> |
#else |
274 |
> |
id1 = atom1 |
275 |
> |
id2 = atom2 |
276 |
> |
#endif |
277 |
> |
|
278 |
> |
if (molMembershipList(id1) .ne. molMembershipList(id2)) then |
279 |
> |
|
280 |
> |
! because the d vector is the rj - ri vector, and |
281 |
> |
! because fx, fy, fz are the force on atom i, we need a |
282 |
> |
! negative sign here: |
283 |
> |
|
284 |
> |
tau_Temp(1) = tau_Temp(1) - d(1) * fx |
285 |
> |
tau_Temp(2) = tau_Temp(2) - d(1) * fy |
286 |
> |
tau_Temp(3) = tau_Temp(3) - d(1) * fz |
287 |
> |
tau_Temp(4) = tau_Temp(4) - d(2) * fx |
288 |
> |
tau_Temp(5) = tau_Temp(5) - d(2) * fy |
289 |
> |
tau_Temp(6) = tau_Temp(6) - d(2) * fz |
290 |
> |
tau_Temp(7) = tau_Temp(7) - d(3) * fx |
291 |
> |
tau_Temp(8) = tau_Temp(8) - d(3) * fy |
292 |
> |
tau_Temp(9) = tau_Temp(9) - d(3) * fz |
293 |
> |
|
294 |
> |
virial_Temp = virial_Temp + & |
295 |
> |
(tau_Temp(1) + tau_Temp(5) + tau_Temp(9)) |
296 |
> |
|
297 |
> |
endif |
298 |
|
endif |
299 |
|
|
300 |
|
endif |
317 |
|
|
318 |
|
if (present(status)) status = 0 |
319 |
|
select case (LJ_Mixing_Policy) |
320 |
< |
case (LB_MIXING_RULE) |
320 |
> |
case (1) |
321 |
|
select case (thisParam) |
322 |
|
case ("sigma") |
323 |
|
myMixParam = 0.5_dp * (param1 + param2) |