2 |
|
!! Corresponds to the force field defined in lj_FF.cpp |
3 |
|
!! @author Charles F. Vardeman II |
4 |
|
!! @author Matthew Meineke |
5 |
< |
!! @version $Id: lj_FF.F90,v 1.8 2003-01-20 22:36:12 chuckv Exp $, $Date: 2003-01-20 22:36:12 $, $Name: not supported by cvs2svn $, $Revision: 1.8 $ |
5 |
> |
!! @version $Id: lj_FF.F90,v 1.10 2003-01-24 21:36:52 chuckv Exp $, $Date: 2003-01-24 21:36:52 $, $Name: not supported by cvs2svn $, $Revision: 1.10 $ |
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
module lj_ff |
10 |
|
use simulation |
11 |
< |
use definitions, ONLY : dp, ndim |
11 |
> |
use definitions |
12 |
|
#ifdef IS_MPI |
13 |
|
use mpiSimulation |
14 |
|
#endif |
32 |
|
!! Mass of Particle |
33 |
|
real ( kind = dp ) :: mass = 0.0_dp |
34 |
|
!! Lennard-Jones epslon |
35 |
< |
real ( kind = dp ) :: epslon = 0.0_dp |
35 |
> |
real ( kind = dp ) :: epsilon = 0.0_dp |
36 |
|
!! Lennard-Jones Sigma |
37 |
|
real ( kind = dp ) :: sigma = 0.0_dp |
38 |
|
!! Lennard-Jones Sigma Squared |
51 |
|
!! Global list of lj atypes in simulation |
52 |
|
type (lj_atype), pointer :: lj_atype_list => null() |
53 |
|
!! LJ mixing array |
54 |
< |
type (lj_atype), dimension(:,:), allocatable, pointer :: ljMixed =>null() |
54 |
> |
type (lj_atype), dimension(:,:), pointer :: ljMixed => null() |
55 |
|
!! identity pointer list for force loop. |
56 |
< |
type (lj_atypePtr), dimension(:), allocatable :: identPtrList |
56 |
> |
type (lj_atypePtr), dimension(:), pointer :: identPtrList => null() |
57 |
|
|
58 |
|
|
59 |
|
!! Neighbor list and commom arrays |
67 |
|
#ifdef IS_MPI |
68 |
|
! Universal routines: All types of force calculations will need these arrays |
69 |
|
! Arrays specific to a type of force calculation should be declared in that module. |
70 |
+ |
!! Row position array. |
71 |
|
real( kind = dp ), allocatable, dimension(:,:) :: qRow |
72 |
+ |
!! Column position array. |
73 |
|
real( kind = dp ), allocatable, dimension(:,:) :: qColumn |
74 |
|
|
75 |
+ |
!! Row Force array. |
76 |
|
real( kind = dp ), allocatable, dimension(:,:) :: fRow |
77 |
+ |
!! Column Force Array. |
78 |
|
real( kind = dp ), allocatable, dimension(:,:) :: fColumn |
79 |
|
|
80 |
< |
type (lj_atypePtr), dimension(:), allocatable :: identPtrListRow |
81 |
< |
type (lj_atypePtr), dimension(:), allocatable :: identPtrListColumn |
82 |
< |
#endif |
80 |
> |
!! Row potential energy array |
81 |
> |
real( kind = dp ), allocatable, dimension(:) :: eRow |
82 |
> |
!! Column potential energy array |
83 |
> |
real( kind = dp ), allocatable, dimension(:) :: eColumn |
84 |
|
|
85 |
|
|
86 |
+ |
!! Row lj_atype pointer list |
87 |
+ |
type (lj_atypePtr), dimension(:), pointer :: identPtrListRow => null() |
88 |
+ |
!! Column lj_atype pointer list |
89 |
+ |
type (lj_atypePtr), dimension(:), pointer :: identPtrListColumn => null() |
90 |
+ |
#endif |
91 |
|
|
82 |
– |
logical :: isljFFinit = .false. |
92 |
|
|
93 |
+ |
!! Logical has lj force field module been initialized? |
94 |
+ |
logical, save :: isljFFinit = .false. |
95 |
|
|
96 |
+ |
|
97 |
|
!! Public methods and data |
98 |
|
public :: new_lj_atype |
99 |
|
public :: do_lj_ff |
100 |
|
public :: getLjPot |
101 |
< |
|
101 |
> |
public :: init_ljFF |
102 |
|
|
103 |
|
|
104 |
|
|
105 |
|
|
106 |
|
contains |
107 |
|
|
108 |
< |
subroutine new_lj_atype(ident,mass,epslon,sigma,status) |
108 |
> |
subroutine new_lj_atype(ident,mass,epsilon,sigma,status) |
109 |
|
real( kind = dp ), intent(in) :: mass |
110 |
< |
real( kind = dp ), intent(in) :: epslon |
110 |
> |
real( kind = dp ), intent(in) :: epsilon |
111 |
|
real( kind = dp ), intent(in) :: sigma |
112 |
|
integer, intent(in) :: ident |
113 |
|
integer, intent(out) :: status |
115 |
|
type (lj_atype), pointer :: this_lj_atype |
116 |
|
type (lj_atype), pointer :: lj_atype_ptr |
117 |
|
|
118 |
< |
type (lj_atype), allocatable, dimension(:,:), pointer :: thisMix |
119 |
< |
type (lj_atype), allocatable, dimension(:,:), pointer :: oldMix |
118 |
> |
type (lj_atype), dimension(:,:), pointer :: thisMix |
119 |
> |
type (lj_atype), dimension(:,:), pointer :: oldMix |
120 |
|
integer :: alloc_error |
121 |
|
integer :: atype_counter = 0 |
122 |
|
integer :: alloc_size |
133 |
|
end if |
134 |
|
|
135 |
|
! assign our new lj_atype information |
136 |
< |
this_lj_atype%mass = mass |
137 |
< |
this_lj_atype%epslon = epslon |
138 |
< |
this_lj_atype%sigma = sigma |
139 |
< |
this_lj_atype%sigma2 = sigma * sigma |
140 |
< |
this_lj_atype%sigma6 = this_lj_atype%sigma2 * this_lj_atype%sigma2 & |
136 |
> |
this_lj_atype%mass = mass |
137 |
> |
this_lj_atype%epsilon = epsilon |
138 |
> |
this_lj_atype%sigma = sigma |
139 |
> |
this_lj_atype%sigma2 = sigma * sigma |
140 |
> |
this_lj_atype%sigma6 = this_lj_atype%sigma2 * this_lj_atype%sigma2 & |
141 |
|
* this_lj_atype%sigma2 |
142 |
|
! assume that this atype will be successfully added |
143 |
|
this_lj_atype%atype_ident = ident |
144 |
< |
this_lj_atype%number = n_lj_atypes + 1 |
144 |
> |
this_lj_atype%atype_number = n_lj_atypes + 1 |
145 |
|
|
146 |
|
|
147 |
|
! First time through allocate a array of size ljMixed_blocksize |
155 |
|
! If we have outgrown ljMixed_blocksize, allocate a new matrix twice the size and |
156 |
|
! point ljMix at the new matrix. |
157 |
|
else if( (n_lj_atypes + 1) > size(ljMixed)) then |
158 |
< |
alloc_size = 2*size(ljMix) |
158 |
> |
alloc_size = 2*size(ljMixed) |
159 |
|
allocate(thisMix(alloc_size,alloc_size)) |
160 |
|
if (alloc_error /= 0 ) then |
161 |
|
status = -1 |
178 |
|
! Find bottom of atype master list |
179 |
|
! if lj_atype_list is null then we are at the top of the list. |
180 |
|
if (.not. associated(lj_atype_list)) then |
169 |
– |
lj_atype_ptr => this_lj_atype |
170 |
– |
atype_counter = 1 |
181 |
|
|
182 |
+ |
write(*,*) "Associating lists for first time" |
183 |
+ |
|
184 |
+ |
|
185 |
+ |
this_lj_atype%atype_number = 1 |
186 |
+ |
|
187 |
+ |
ljMixed(n_lj_atypes,n_lj_atypes)%sigma = this_lj_atype%sigma |
188 |
+ |
|
189 |
+ |
ljMixed(n_lj_atypes,n_lj_atypes)%sigma2 = ljMixed(n_lj_atypes,n_lj_atypes)%sigma & |
190 |
+ |
* ljMixed(n_lj_atypes,n_lj_atypes)%sigma |
191 |
+ |
|
192 |
+ |
ljMixed(n_lj_atypes,n_lj_atypes)%sigma6 = ljMixed(n_lj_atypes,n_lj_atypes)%sigma2 & |
193 |
+ |
* ljMixed(n_lj_atypes,n_lj_atypes)%sigma2 & |
194 |
+ |
* ljMixed(n_lj_atypes,n_lj_atypes)%sigma2 |
195 |
+ |
|
196 |
+ |
ljMixed(n_lj_atypes,n_lj_atypes)%epsilon = this_lj_atype%epsilon |
197 |
+ |
|
198 |
+ |
lj_atype_list => this_lj_atype |
199 |
+ |
|
200 |
+ |
write(*,*) "lj_atype_list first time through -- ident", lj_atype_list%atype_ident |
201 |
|
else ! we need to find the bottom of the list to insert new atype |
202 |
< |
lj_atype_ptr => lj_atype_list%next |
202 |
> |
write(*,*) "Second time through" |
203 |
> |
lj_atype_ptr => lj_atype_list |
204 |
> |
write(*,*) "lj_atype_ptr to next" |
205 |
|
atype_counter = 1 |
206 |
|
find_end: do |
207 |
< |
if (.not. associated(lj_atype_ptr%next)) then |
208 |
< |
exit find_end |
209 |
< |
end if |
207 |
> |
if (.not. associated(lj_atype_ptr)) exit find_end |
208 |
> |
|
209 |
> |
write(*,*) "Inside find_end-this ident", lj_atype_ptr%atype_ident |
210 |
|
! Set up mixing for new atype and current atype in list |
211 |
< |
ljMix(this_lj_atype%atype_number,lj_atype_ptr%atype_number)%sigma = & |
211 |
> |
ljMixed(this_lj_atype%atype_number,lj_atype_ptr%atype_number)%sigma = & |
212 |
|
calcLJMix("sigma",this_lj_atype%sigma, & |
213 |
< |
lj_atype_prt%sigma) |
213 |
> |
lj_atype_ptr%sigma) |
214 |
|
|
215 |
< |
ljMix(this_lj_atype%atype_number,lj_atype_ptr%atype_number)%sigma2 = & |
216 |
< |
ljMix(this_lj_atype%atype_number,lj_atype_ptr%atype_number)%sigma & |
217 |
< |
* ljMix(this_lj_atype%atype_number,lj_atype_ptr%atype_number)%sigma |
215 |
> |
ljMixed(this_lj_atype%atype_number,lj_atype_ptr%atype_number)%sigma2 = & |
216 |
> |
ljMixed(this_lj_atype%atype_number,lj_atype_ptr%atype_number)%sigma & |
217 |
> |
* ljMixed(this_lj_atype%atype_number,lj_atype_ptr%atype_number)%sigma |
218 |
|
|
219 |
< |
ljMix(this_lj_atype%atype_number,lj_atype_ptr%atype_number)%sigma6 = & |
220 |
< |
ljMix(this_lj_atype%atype_number,lj_atype_ptr%atype_number)%sigma2 & |
221 |
< |
* ljMix(this_lj_atype%atype_number,lj_atype_ptr%atype_number)%sigma2 & |
222 |
< |
* ljMix(this_lj_atype%atype_number,lj_atype_ptr%atype_number)%sigma2 |
219 |
> |
ljMixed(this_lj_atype%atype_number,lj_atype_ptr%atype_number)%sigma6 = & |
220 |
> |
ljMixed(this_lj_atype%atype_number,lj_atype_ptr%atype_number)%sigma2 & |
221 |
> |
* ljMixed(this_lj_atype%atype_number,lj_atype_ptr%atype_number)%sigma2 & |
222 |
> |
* ljMixed(this_lj_atype%atype_number,lj_atype_ptr%atype_number)%sigma2 |
223 |
|
|
224 |
< |
ljMix(this_lj_atype%atype_number,lj_atype_ptr%atype_number)%epslon = & |
225 |
< |
calcLJMix("epslon",this_lj_atype%epslon, & |
226 |
< |
lj_atype_prt%epslon) |
224 |
> |
ljMixed(this_lj_atype%atype_number,lj_atype_ptr%atype_number)%epsilon = & |
225 |
> |
calcLJMix("epsilon",this_lj_atype%epsilon, & |
226 |
> |
lj_atype_ptr%epsilon) |
227 |
|
|
228 |
|
! Advance to next pointer |
229 |
< |
lj_atype_ptr => lj_atype_ptr%next |
230 |
< |
atype_counter = atype_counter + 1 |
200 |
< |
|
229 |
> |
lj_atype_ptr => lj_atype_ptr%next |
230 |
> |
atype_counter = atype_counter + 1 |
231 |
|
end do find_end |
232 |
+ |
|
233 |
+ |
lj_atype_ptr => this_lj_atype |
234 |
+ |
write(*,*) "just added: ", lj_atype_ptr%atype_ident |
235 |
|
end if |
236 |
|
|
237 |
< |
|
205 |
< |
|
237 |
> |
write(*,*) "lj_atype_list now contains.." |
238 |
|
|
239 |
+ |
lj_atype_ptr => lj_atype_list |
240 |
+ |
do while (associated(lj_atype_ptr)) |
241 |
+ |
write(*,*) "lj_atype_list contains ident", lj_atype_ptr%atype_ident |
242 |
+ |
lj_atype_ptr => lj_atype_ptr%next |
243 |
+ |
end do |
244 |
+ |
|
245 |
|
! Insert new atype at end of list |
246 |
< |
lj_atype_ptr => this_lj_atype |
246 |
> |
|
247 |
|
! Increment number of atypes |
248 |
|
|
249 |
|
n_lj_atypes = n_lj_atypes + 1 |
250 |
|
|
251 |
|
! Set up self mixing |
252 |
|
|
215 |
– |
ljMix(n_lj_atypes,n_lj_atypes)%sigma = this_lj_atype%sigma |
216 |
– |
|
217 |
– |
ljMix(n_lj_atypes,n_lj_atypes)%sigma2 = ljMix(n_lj_atypes,n_lj_atypes)%sigma & |
218 |
– |
* ljMix(n_lj_atypes,n_lj_atypes)%sigma |
219 |
– |
|
220 |
– |
ljMix(n_lj_atypes,n_lj_atypes)%sigma6 = ljMix(n_lj_atypes,n_lj_atypes)%sigma2 & |
221 |
– |
* ljMix(n_lj_atypes,n_lj_atypes)%sigma2 & |
222 |
– |
* ljMix(n_lj_atypes,n_lj_atypes)%sigma2 |
223 |
– |
|
224 |
– |
ljMix(n_lj_atypes,n_lj_atypes)%epslon = this_lj_atype%epslon |
225 |
– |
|
226 |
– |
|
253 |
|
end subroutine new_lj_atype |
254 |
|
|
255 |
|
|
262 |
|
!! Result status, success = 0, error = -1 |
263 |
|
integer, intent(out) :: Status |
264 |
|
|
265 |
+ |
integer :: alloc_stat |
266 |
+ |
|
267 |
|
integer :: thisStat |
268 |
+ |
integer :: i |
269 |
|
#ifdef IS_MPI |
270 |
|
integer, allocatable, dimension(:) :: identRow |
271 |
|
integer, allocatable, dimension(:) :: identCol |
275 |
|
#endif |
276 |
|
status = 0 |
277 |
|
|
278 |
+ |
write(*,*) "Initializing ljFF" |
279 |
|
!! if were're not in MPI, we just update ljatypePtrList |
280 |
|
#ifndef IS_MPI |
281 |
|
call new_ljatypePtrList(nComponents,ident,identPtrList,thisStat) |
283 |
|
status = -1 |
284 |
|
return |
285 |
|
endif |
286 |
+ |
write(*,*) "component pointer list initialized" |
287 |
|
!! Allocate pointer lists |
288 |
|
allocate(point(nComponents),stat=alloc_stat) |
289 |
|
if (alloc_stat /=0) then |
397 |
|
else |
398 |
|
deallocate(fCol) |
399 |
|
allocate(fCol(3,ncol),stat=alloc_stat) |
400 |
+ |
if (alloc_stat /= 0 ) then |
401 |
+ |
status = -1 |
402 |
+ |
return |
403 |
+ |
endif |
404 |
+ |
endif |
405 |
+ |
|
406 |
+ |
if (.not.allocated(eRow)) then |
407 |
+ |
allocate(eRow(nrow),stat=alloc_stat) |
408 |
+ |
if (alloc_stat /= 0 ) then |
409 |
+ |
status = -1 |
410 |
+ |
return |
411 |
+ |
endif |
412 |
+ |
else |
413 |
+ |
deallocate(eRow) |
414 |
+ |
allocate(eRow(nrow),stat=alloc_stat) |
415 |
+ |
if (alloc_stat /= 0 ) then |
416 |
+ |
status = -1 |
417 |
+ |
return |
418 |
+ |
endif |
419 |
+ |
endif |
420 |
+ |
|
421 |
+ |
if (.not.allocated(eCol)) then |
422 |
+ |
allocate(eCol(ncol),stat=alloc_stat) |
423 |
|
if (alloc_stat /= 0 ) then |
424 |
|
status = -1 |
425 |
|
return |
426 |
|
endif |
427 |
+ |
else |
428 |
+ |
deallocate(eCol) |
429 |
+ |
allocate(eCol(ncol),stat=alloc_stat) |
430 |
+ |
if (alloc_stat /= 0 ) then |
431 |
+ |
status = -1 |
432 |
+ |
return |
433 |
+ |
endif |
434 |
|
endif |
435 |
+ |
|
436 |
+ |
if (.not.allocated(eTemp)) then |
437 |
+ |
allocate(eTemp(nComponents),stat=alloc_stat) |
438 |
+ |
if (alloc_stat /= 0 ) then |
439 |
+ |
status = -1 |
440 |
+ |
return |
441 |
+ |
endif |
442 |
+ |
else |
443 |
+ |
deallocate(eTemp) |
444 |
+ |
allocate(eTemp(nComponets),stat=alloc_stat) |
445 |
+ |
if (alloc_stat /= 0 ) then |
446 |
+ |
status = -1 |
447 |
+ |
return |
448 |
+ |
endif |
449 |
+ |
endif |
450 |
+ |
|
451 |
+ |
|
452 |
|
!! Allocate neighbor lists for mpi simulations. |
453 |
|
if (.not. allocated(point)) then |
454 |
|
allocate(point(nrow),stat=alloc_stat) |
480 |
|
|
481 |
|
#endif |
482 |
|
|
483 |
+ |
|
484 |
+ |
do i = 1, nComponents |
485 |
+ |
write(*,*) "Ident pointer list ident: ", identPtrList(i)%this%atype_ident |
486 |
+ |
end do |
487 |
|
|
488 |
|
isljFFinit = .true. |
489 |
|
|
408 |
– |
|
490 |
|
end subroutine init_ljFF |
491 |
|
|
492 |
|
|
497 |
|
!! based on those identities |
498 |
|
subroutine new_ljatypePtrList(mysize,ident,PtrList,status) |
499 |
|
integer, intent(in) :: mysize |
500 |
< |
integer, intent(in) :: ident |
500 |
> |
integer,dimension(:), intent(in) :: ident |
501 |
|
integer, optional :: status |
502 |
< |
type(lj_atypePtr), dimension(:) :: PtrList |
502 |
> |
type(lj_atypePtr), dimension(:), pointer :: PtrList |
503 |
|
|
504 |
|
integer :: thisIdent |
505 |
|
integer :: i |
508 |
|
|
509 |
|
if (present(status)) status = 0 |
510 |
|
|
511 |
+ |
write(*,*) "Creating new ljatypePtrList...." |
512 |
|
! First time through, allocate list |
513 |
< |
if (.not.(allocated)) then |
513 |
> |
if (.not.associated(PtrList)) then |
514 |
> |
write(*,*) "allocating pointer list...." |
515 |
|
allocate(PtrList(mysize)) |
516 |
|
else |
517 |
|
! We want to creat a new ident list so free old list |
518 |
< |
deallocate(PrtList) |
518 |
> |
deallocate(PtrList) |
519 |
|
allocate(PtrList(mysize)) |
520 |
|
endif |
521 |
|
|
522 |
|
! Match pointer list |
523 |
+ |
write(*,*) "Doing ident search" |
524 |
|
do i = 1, mysize |
525 |
|
thisIdent = ident(i) |
526 |
+ |
write(*,*) "Calling getLJatype for ident ", thisIdent |
527 |
|
call getLJatype(thisIdent,tmpPtr) |
528 |
|
|
529 |
|
if (.not. associated(tmpPtr)) then |
530 |
+ |
write(*,*) "tmpptr was not associated" |
531 |
|
status = -1 |
532 |
|
return |
533 |
|
endif |
541 |
|
!! returns a null pointer if error |
542 |
|
subroutine getLJatype(ident,ljAtypePtr) |
543 |
|
integer, intent(in) :: ident |
544 |
< |
type (lj_atype), intent(out),pointer :: ljAtypePtr => null() |
459 |
< |
|
544 |
> |
type (lj_atype), pointer :: ljAtypePtr |
545 |
|
type (lj_atype), pointer :: tmplj_atype_ptr => null() |
546 |
|
|
547 |
+ |
write(*,*) "Finding ljAtype for ident ", ident |
548 |
+ |
ljAtypePtr => null() |
549 |
+ |
|
550 |
|
if(.not. associated(lj_atype_list)) return |
551 |
|
|
552 |
|
! Point at head of list. |
553 |
+ |
write(*,*) "Searching at head of list" |
554 |
|
tmplj_atype_ptr => lj_atype_list |
555 |
|
find_ident: do |
556 |
|
if (.not.associated(tmplj_atype_ptr)) then |
557 |
+ |
write(*,*) "Find_ident, pointer not associated" |
558 |
|
exit find_ident |
559 |
< |
else if( lj_atype_ptr%atype_ident == ident) |
559 |
> |
else if( tmplj_atype_ptr%atype_ident == ident) then |
560 |
|
ljAtypePtr => tmplj_atype_ptr |
561 |
|
exit find_ident |
562 |
|
endif |
563 |
|
tmplj_atype_ptr => tmplj_atype_ptr%next |
564 |
|
end do find_ident |
565 |
|
|
566 |
+ |
|
567 |
+ |
|
568 |
+ |
|
569 |
|
end subroutine getLJatype |
570 |
|
|
571 |
|
|
572 |
|
!! FORCE routine Calculates Lennard Jones forces. |
573 |
|
!-------------------------------------------------------------> |
574 |
|
subroutine do_lj_ff(q,f,potE,do_pot) |
575 |
< |
real ( kind = dp ), dimension(ndim,) :: q |
576 |
< |
real ( kind = dp ), dimension(ndim,nLRparticles) :: f |
575 |
> |
!! Position array provided by C, dimensioned by getNlocal |
576 |
> |
real ( kind = dp ), dimension(3,getNlocal()) :: q |
577 |
> |
!! Force array provided by C, dimensioned by getNlocal |
578 |
> |
real ( kind = dp ), dimension(3,getNlocal()) :: f |
579 |
|
real ( kind = dp ) :: potE |
580 |
|
logical ( kind = 2) :: do_pot |
581 |
|
|
583 |
|
type(lj_atype), pointer :: ljAtype_j |
584 |
|
|
585 |
|
#ifdef MPI |
586 |
< |
real( kind = DP ), dimension(3,ncol) :: efr |
586 |
> |
real( kind = DP ), dimension(3,getNcol()) :: efr |
587 |
|
real( kind = DP ) :: pot_local |
588 |
|
#else |
589 |
< |
! real( kind = DP ), dimension(3,natoms) :: efr |
589 |
> |
real( kind = DP ), dimension(3,getNlocal()) :: efr |
590 |
|
#endif |
591 |
|
|
592 |
|
real( kind = DP ) :: pe |
593 |
< |
logical, :: update_nlist |
593 |
> |
logical :: update_nlist |
594 |
|
|
595 |
|
|
596 |
|
integer :: i, j, jbeg, jend, jnab, idim, jdim, idim2, jdim2, dim, dim2 |
599 |
|
integer :: tag_i,tag_j |
600 |
|
real( kind = DP ) :: r, pot, ftmp, dudr, d2, drdx1, kt1, kt2, kt3, ktmp |
601 |
|
real( kind = DP ) :: rxi, ryi, rzi, rxij, ryij, rzij, rijsq |
602 |
+ |
real( kind = DP ) :: rlistsq, rcutsq,rlist,rcut |
603 |
|
|
604 |
+ |
! a rig that need to be fixed. |
605 |
+ |
#ifdef IS_MPI |
606 |
+ |
logical :: newtons_thrd = .true. |
607 |
+ |
real( kind = dp ) :: pe_local |
608 |
+ |
integer :: nlocal |
609 |
+ |
#endif |
610 |
|
integer :: nrow |
611 |
|
integer :: ncol |
612 |
+ |
integer :: natoms |
613 |
|
|
614 |
+ |
! Make sure we are properly initialized. |
615 |
|
if (.not. isljFFInit) then |
616 |
|
write(default_error,*) "ERROR: lj_FF has not been properly initialized" |
617 |
+ |
return |
618 |
+ |
endif |
619 |
+ |
#ifdef IS_MPI |
620 |
+ |
if (.not. isMPISimSet()) then |
621 |
+ |
write(default_error,*) "ERROR: mpiSimulation has not been properly initialized" |
622 |
|
return |
623 |
|
endif |
624 |
+ |
#endif |
625 |
|
|
626 |
+ |
!! initialize local variables |
627 |
+ |
natoms = getNlocal() |
628 |
+ |
call getRcut(rcut,rcut2=rcutsq) |
629 |
+ |
call getRlist(rlist,rlistsq) |
630 |
|
#ifndef IS_MPI |
631 |
|
nrow = natoms - 1 |
632 |
|
ncol = natoms |
633 |
|
#else |
634 |
|
nrow = getNrow(plan_row) |
635 |
|
ncol = getNcol(plan_col) |
636 |
+ |
nlocal = natoms |
637 |
|
j_start = 1 |
638 |
|
#endif |
639 |
|
|
640 |
|
|
641 |
+ |
!! See if we need to update neighbor lists |
642 |
+ |
call check(q,update_nlist) |
643 |
|
|
527 |
– |
call check(update_nlist) |
528 |
– |
|
644 |
|
!--------------WARNING........................... |
645 |
|
! Zero variables, NOTE:::: Forces are zeroed in C |
646 |
|
! Zeroing them here could delete previously computed |
647 |
|
! Forces. |
648 |
|
!------------------------------------------------ |
649 |
|
#ifndef IS_MPI |
650 |
< |
nloops = nloops + 1 |
651 |
< |
pot = 0.0E0_DP |
652 |
< |
e = 0.0E0_DP |
650 |
> |
! nloops = nloops + 1 |
651 |
> |
pe = 0.0E0_DP |
652 |
> |
|
653 |
|
#else |
654 |
|
f_row = 0.0E0_DP |
655 |
|
f_col = 0.0E0_DP |
656 |
|
|
657 |
< |
pot_local = 0.0E0_DP |
657 |
> |
pe_local = 0.0E0_DP |
658 |
|
|
659 |
< |
e_row = 0.0E0_DP |
660 |
< |
e_col = 0.0E0_DP |
661 |
< |
e_tmp = 0.0E0_DP |
659 |
> |
eRow = 0.0E0_DP |
660 |
> |
eCol = 0.0E0_DP |
661 |
> |
eTemp = 0.0E0_DP |
662 |
|
#endif |
663 |
|
efr = 0.0E0_DP |
664 |
|
|
668 |
|
call gather(q,qCol,plan_col3) |
669 |
|
#endif |
670 |
|
|
556 |
– |
#ifndef MPI |
671 |
|
|
558 |
– |
#endif |
559 |
– |
|
672 |
|
if (update_nlist) then |
673 |
|
|
674 |
|
! save current configuration, contruct neighbor list, |
675 |
|
! and calculate forces |
676 |
< |
call save_nlist() |
676 |
> |
call save_nlist(q) |
677 |
|
|
678 |
|
nlist = 0 |
679 |
|
|
721 |
|
rijsq = rxij*rxij + ryij*ryij + rzij*rzij |
722 |
|
|
723 |
|
#ifdef MPI |
724 |
< |
if (rijsq <= rlstsq .AND. & |
724 |
> |
if (rijsq <= rlistsq .AND. & |
725 |
|
tag_j /= tag_i) then |
726 |
|
#else |
727 |
< |
if (rijsq < rlstsq) then |
727 |
> |
if (rijsq < rlistsq) then |
728 |
|
#endif |
729 |
|
|
730 |
|
nlist = nlist + 1 |
731 |
|
if (nlist > size(list)) then |
732 |
< |
#warning "Change how nlist size is done" |
732 |
> |
!! "Change how nlist size is done" |
733 |
|
write(DEFAULT_ERROR,*) "ERROR: nlist > list size" |
734 |
|
endif |
735 |
|
list(nlist) = j |
742 |
|
call getLJPot(r,pot,dudr,ljAtype_i,ljAtype_j) |
743 |
|
|
744 |
|
#ifdef MPI |
745 |
< |
e_row(i) = e_row(i) + pot*0.5 |
746 |
< |
e_col(i) = e_col(i) + pot*0.5 |
745 |
> |
eRow(i) = eRow(i) + pot*0.5 |
746 |
> |
eCol(i) = eCol(i) + pot*0.5 |
747 |
|
#else |
748 |
|
pe = pe + pot |
749 |
|
#endif |
820 |
|
|
821 |
|
call getLJPot(r,pot,dudr,ljAtype_i,ljAtype_j) |
822 |
|
#ifdef MPI |
823 |
< |
e_row(i) = e_row(i) + pot*0.5 |
824 |
< |
e_col(i) = e_col(i) + pot*0.5 |
823 |
> |
eRow(i) = eRow(i) + pot*0.5 |
824 |
> |
eCol(i) = eCol(i) + pot*0.5 |
825 |
|
#else |
826 |
< |
if (do_pot) pe = pe + pot |
826 |
> |
pe = pe + pot |
827 |
|
#endif |
828 |
|
|
829 |
|
|
856 |
|
call scatter(fRow,f,plan_row3) |
857 |
|
|
858 |
|
call scatter(fCol,f_tmp,plan_col3) |
859 |
+ |
|
860 |
|
do i = 1,nlocal |
861 |
< |
do dim = 1,3 |
749 |
< |
f(dim,i) = f(dim,i) + f_tmp(dim,i) |
750 |
< |
end do |
861 |
> |
f(1:3,i) = f(1:3,i) + f_tmp(1:3,i) |
862 |
|
end do |
863 |
|
|
864 |
|
|
870 |
|
! scatter/gather pot_local into all other procs |
871 |
|
! add resultant to get total pot |
872 |
|
do i = 1, nlocal |
873 |
< |
pot_local = pot_local + e_tmp(i) |
873 |
> |
pe_local = pe_local + e_tmp(i) |
874 |
|
enddo |
875 |
|
if (newtons_thrd) then |
876 |
|
e_tmp = 0.0E0_DP |
877 |
|
call scatter(e_col,e_tmp,plan_col) |
878 |
|
do i = 1, nlocal |
879 |
< |
pot_local = pot_local + e_tmp(i) |
879 |
> |
pe_local = pe_local + e_tmp(i) |
880 |
|
enddo |
881 |
|
endif |
882 |
|
endif |
883 |
+ |
potE = pe_local |
884 |
|
#endif |
885 |
|
|
886 |
+ |
potE = pe |
887 |
|
|
888 |
|
|
776 |
– |
|
889 |
|
end subroutine do_lj_ff |
890 |
|
|
891 |
|
!! Calculates the potential between two lj particles based on two lj_atype pointers, optionally returns second |
901 |
|
!! Second Derivative, optional, used mainly for normal mode calculations. |
902 |
|
real( kind = dp ), intent(out), optional :: d2 |
903 |
|
|
904 |
< |
type (lj_atype), intent(in), pointer :: atype1 |
905 |
< |
type (lj_atype), intent(in), pointer :: atype2 |
904 |
> |
type (lj_atype), pointer :: atype1 |
905 |
> |
type (lj_atype), pointer :: atype2 |
906 |
|
|
907 |
|
integer, intent(out), optional :: status |
908 |
|
|
910 |
|
real( kind = dp ) :: sigma |
911 |
|
real( kind = dp ) :: sigma2 |
912 |
|
real( kind = dp ) :: sigma6 |
913 |
< |
real( kind = dp ) :: epslon |
913 |
> |
real( kind = dp ) :: epsilon |
914 |
|
|
915 |
|
real( kind = dp ) :: rcut |
916 |
|
real( kind = dp ) :: rcut2 |
935 |
|
if (present(status)) status = 0 |
936 |
|
|
937 |
|
! Look up the correct parameters in the mixing matrix |
938 |
< |
sigma = ljMixed(atype1%atype_ident,atype2_atype_ident)%sigma |
939 |
< |
sigma2 = ljMixed(atype1%atype_ident,atype2_atype_ident)%sigma2 |
940 |
< |
sigma6 = ljMixed(atype1%atype_ident,atype2_atype_ident)%sigma6 |
941 |
< |
epslon = ljMixed(atype1%atype_ident,atype2_atype_ident)%epslon |
938 |
> |
sigma = ljMixed(atype1%atype_ident,atype2%atype_ident)%sigma |
939 |
> |
sigma2 = ljMixed(atype1%atype_ident,atype2%atype_ident)%sigma2 |
940 |
> |
sigma6 = ljMixed(atype1%atype_ident,atype2%atype_ident)%sigma6 |
941 |
> |
epsilon = ljMixed(atype1%atype_ident,atype2%atype_ident)%epsilon |
942 |
|
|
943 |
|
|
944 |
|
|
958 |
|
delta = -4.0E0_DP*epsilon * (tp12 - tp6) |
959 |
|
|
960 |
|
if (r.le.rcut) then |
961 |
< |
u = 4.0E0_DP * epsilon * (t12 - t6) + delta |
961 |
> |
pot = 4.0E0_DP * epsilon * (t12 - t6) + delta |
962 |
|
dudr = 24.0E0_DP * epsilon * (t6 - 2.0E0_DP*t12) / r |
963 |
|
if(doSec) d2 = 24.0E0_DP * epsilon * (26.0E0_DP*t12 - 7.0E0_DP*t6)/r/r |
964 |
|
else |
965 |
< |
u = 0.0E0_DP |
965 |
> |
pot = 0.0E0_DP |
966 |
|
dudr = 0.0E0_DP |
967 |
|
if(doSec) d2 = 0.0E0_DP |
968 |
|
endif |
991 |
|
|
992 |
|
case ("sigma") |
993 |
|
myMixParam = 0.5_dp * (param1 + param2) |
994 |
< |
case ("epslon") |
994 |
> |
case ("epsilon") |
995 |
|
myMixParam = sqrt(param1 * param2) |
996 |
|
case default |
997 |
|
status = -1 |