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.15 2003-01-30 22:29:37 chuckv Exp $, $Date: 2003-01-30 22:29:37 $, $Name: not supported by cvs2svn $, $Revision: 1.15 $ |
5 |
> |
!! @version $Id: lj_FF.F90,v 1.19 2003-02-24 21:25:15 chuckv Exp $, $Date: 2003-02-24 21:25:15 $, $Name: not supported by cvs2svn $, $Revision: 1.19 $ |
6 |
|
|
7 |
|
|
8 |
|
|
124 |
|
|
125 |
|
integer :: thisStat |
126 |
|
integer :: i |
127 |
+ |
|
128 |
+ |
integer :: myNode |
129 |
|
#ifdef IS_MPI |
130 |
|
integer, allocatable, dimension(:) :: identRow |
131 |
|
integer, allocatable, dimension(:) :: identCol |
169 |
|
endif |
170 |
|
nrow = getNrow(plan_row) |
171 |
|
ncol = getNcol(plan_col) |
172 |
< |
|
172 |
> |
mynode = getMyNode() |
173 |
|
!! Allocate temperary arrays to hold gather information |
174 |
|
allocate(identRow(nrow),stat=alloc_stat) |
175 |
|
if (alloc_stat /= 0 ) then |
188 |
|
call gather(ident,identRow,plan_row) |
189 |
|
call gather(ident,identCol,plan_col) |
190 |
|
|
191 |
< |
|
191 |
> |
|
192 |
|
!! Create row and col pointer lists |
193 |
< |
|
193 |
> |
|
194 |
|
call create_IdentPtrlst(identRow,ljListHead,identPtrListRow,thisStat) |
195 |
|
if (thisStat /= 0 ) then |
196 |
|
status = -1 |
197 |
|
return |
198 |
|
endif |
199 |
< |
|
199 |
> |
|
200 |
|
call create_IdentPtrlst(identCol,ljListHead,identPtrListColumn,thisStat) |
201 |
|
if (thisStat /= 0 ) then |
202 |
|
status = -1 |
203 |
|
return |
204 |
|
endif |
205 |
< |
write(*,*) "After createIdent row-col lists" |
205 |
> |
|
206 |
|
!! free temporary ident arrays |
207 |
|
if (allocated(identCol)) then |
208 |
|
deallocate(identCol) |
249 |
|
endif |
250 |
|
isljFFinit = .true. |
251 |
|
|
252 |
+ |
|
253 |
|
end subroutine init_ljFF |
254 |
|
|
255 |
|
|
348 |
|
|
349 |
|
!! FORCE routine Calculates Lennard Jones forces. |
350 |
|
!-------------------------------------------------------------> |
351 |
< |
subroutine do_lj_ff(q,f,potE,do_pot) |
351 |
> |
subroutine do_lj_ff(q,f,potE,tau,do_pot) |
352 |
|
!! Position array provided by C, dimensioned by getNlocal |
353 |
|
real ( kind = dp ), dimension(3,getNlocal()) :: q |
354 |
|
!! Force array provided by C, dimensioned by getNlocal |
355 |
|
real ( kind = dp ), dimension(3,getNlocal()) :: f |
356 |
+ |
!! Stress Tensor |
357 |
+ |
real( kind = dp), dimension(9) :: tau |
358 |
+ |
real( kind = dp), dimension(9) :: tauTemp |
359 |
|
real ( kind = dp ) :: potE |
360 |
|
logical ( kind = 2) :: do_pot |
361 |
|
|
362 |
|
type(lj_atype), pointer :: ljAtype_i |
363 |
|
type(lj_atype), pointer :: ljAtype_j |
364 |
|
|
365 |
+ |
|
366 |
+ |
|
367 |
+ |
|
368 |
+ |
|
369 |
+ |
|
370 |
|
#ifdef IS_MPI |
360 |
– |
real( kind = DP ), dimension(3,getNcol(plan_col)) :: efr |
371 |
|
real( kind = DP ) :: pot_local |
372 |
< |
#else |
363 |
< |
real( kind = DP ), dimension(3,getNlocal()) :: efr |
364 |
< |
#endif |
365 |
< |
|
372 |
> |
|
373 |
|
!! Local arrays needed for MPI |
374 |
< |
#ifdef IS_MPI |
375 |
< |
real(kind = dp), dimension(3,getNrow(plan_row)) :: qRow |
369 |
< |
real(kind = dp), dimension(3,getNcol(plan_col)) :: qCol |
374 |
> |
real(kind = dp), dimension(3,getNrow(plan_row)) :: qRow = 0.0_dp |
375 |
> |
real(kind = dp), dimension(3,getNcol(plan_col)) :: qCol = 0.0_dp |
376 |
|
|
377 |
< |
real(kind = dp), dimension(3,getNrow(plan_row)) :: fRow |
378 |
< |
real(kind = dp), dimension(3,getNcol(plan_col)) :: fCol |
379 |
< |
real(kind = dp), dimension(3,getNlocal()) :: fMPITemp |
377 |
> |
real(kind = dp), dimension(3,getNrow(plan_row)) :: fRow = 0.0_dp |
378 |
> |
real(kind = dp), dimension(3,getNcol(plan_col)) :: fCol = 0.0_dp |
379 |
> |
real(kind = dp), dimension(3,getNlocal()) :: fMPITemp = 0.0_dp |
380 |
|
|
381 |
< |
real(kind = dp), dimension(getNrow(plan_row)) :: eRow |
382 |
< |
real(kind = dp), dimension(getNcol(plan_col)) :: eCol |
381 |
> |
real(kind = dp), dimension(getNrow(plan_row)) :: eRow = 0.0_dp |
382 |
> |
real(kind = dp), dimension(getNcol(plan_col)) :: eCol = 0.0_dp |
383 |
|
|
384 |
< |
real(kind = dp), dimension(getNlocal()) :: eTemp |
379 |
< |
#endif |
384 |
> |
real(kind = dp), dimension(getNlocal()) :: eTemp = 0.0_dp |
385 |
|
|
386 |
+ |
#endif |
387 |
|
|
388 |
|
|
389 |
+ |
|
390 |
|
real( kind = DP ) :: pe |
391 |
|
logical :: update_nlist |
392 |
|
|
396 |
|
integer :: j_start |
397 |
|
integer :: tag_i,tag_j |
398 |
|
real( kind = DP ) :: r, pot, ftmp, dudr, d2, drdx1, kt1, kt2, kt3, ktmp |
399 |
+ |
real( kind = dp ) :: fx,fy,fz |
400 |
+ |
real( kind = DP ) :: drdx, drdy, drdz |
401 |
|
real( kind = DP ) :: rxi, ryi, rzi, rxij, ryij, rzij, rijsq |
402 |
|
real( kind = DP ) :: rlistsq, rcutsq,rlist,rcut |
403 |
|
|
410 |
|
integer :: nrow |
411 |
|
integer :: ncol |
412 |
|
integer :: natoms |
413 |
+ |
!! should we calculate the stress tensor |
414 |
+ |
logical :: do_stress = .false. |
415 |
|
|
416 |
|
|
417 |
|
|
407 |
– |
|
418 |
|
! Make sure we are properly initialized. |
419 |
|
if (.not. isljFFInit) then |
420 |
|
write(default_error,*) "ERROR: lj_FF has not been properly initialized" |
431 |
|
natoms = getNlocal() |
432 |
|
call getRcut(rcut,rcut2=rcutsq) |
433 |
|
call getRlist(rlist,rlistsq) |
434 |
+ |
!! Find ensemble |
435 |
+ |
if (isEnsemble("NPT")) do_stress = .true. |
436 |
|
|
437 |
|
#ifndef IS_MPI |
438 |
|
nrow = natoms - 1 |
471 |
|
eCol = 0.0E0_DP |
472 |
|
eTemp = 0.0E0_DP |
473 |
|
#endif |
462 |
– |
efr = 0.0E0_DP |
474 |
|
|
475 |
|
! communicate MPI positions |
476 |
|
#ifdef IS_MPI |
559 |
|
pe = pe + pot |
560 |
|
#endif |
561 |
|
|
562 |
< |
efr(1,j) = -rxij |
563 |
< |
efr(2,j) = -ryij |
564 |
< |
efr(3,j) = -rzij |
565 |
< |
|
566 |
< |
do dim = 1, 3 |
567 |
< |
|
568 |
< |
|
569 |
< |
drdx1 = efr(dim,j) / r |
559 |
< |
ftmp = dudr * drdx1 |
560 |
< |
|
561 |
< |
|
562 |
> |
drdx = -rxij / r |
563 |
> |
drdy = -ryij / r |
564 |
> |
drdz = -rzij / r |
565 |
> |
|
566 |
> |
fx = dudr * drdx |
567 |
> |
fy = dudr * drdy |
568 |
> |
fz = dudr * drdz |
569 |
> |
|
570 |
|
#ifdef IS_MPI |
571 |
< |
fCol(dim,j) = fCol(dim,j) - ftmp |
572 |
< |
fRow(dim,i) = fRow(dim,i) + ftmp |
573 |
< |
#else |
574 |
< |
|
575 |
< |
f(dim,j) = f(dim,j) - ftmp |
576 |
< |
f(dim,i) = f(dim,i) + ftmp |
577 |
< |
|
578 |
< |
#endif |
579 |
< |
enddo |
580 |
< |
endif |
581 |
< |
endif |
582 |
< |
enddo inner |
571 |
> |
fCol(1,j) = fCol(1,j) - fx |
572 |
> |
fCol(2,j) = fCol(2,j) - fy |
573 |
> |
fCol(3,j) = fCol(3,j) - fz |
574 |
> |
|
575 |
> |
fRow(1,j) = fRow(1,j) + fx |
576 |
> |
fRow(2,j) = fRow(2,j) + fy |
577 |
> |
fRow(3,j) = fRow(3,j) + fz |
578 |
> |
#else |
579 |
> |
f(1,j) = f(1,j) - fx |
580 |
> |
f(2,j) = f(2,j) - fy |
581 |
> |
f(3,j) = f(3,j) - fz |
582 |
> |
f(1,i) = f(1,i) + fx |
583 |
> |
f(2,i) = f(2,i) + fy |
584 |
> |
f(3,i) = f(3,i) + fz |
585 |
> |
#endif |
586 |
> |
|
587 |
> |
if (do_stress) then |
588 |
> |
tauTemp(1) = tauTemp(1) + fx * rxij |
589 |
> |
tauTemp(2) = tauTemp(2) + fx * ryij |
590 |
> |
tauTemp(3) = tauTemp(3) + fx * rzij |
591 |
> |
tauTemp(4) = tauTemp(4) + fy * rxij |
592 |
> |
tauTemp(5) = tauTemp(5) + fy * ryij |
593 |
> |
tauTemp(6) = tauTemp(6) + fy * rzij |
594 |
> |
tauTemp(7) = tauTemp(7) + fz * rxij |
595 |
> |
tauTemp(8) = tauTemp(8) + fz * ryij |
596 |
> |
tauTemp(9) = tauTemp(9) + fz * rzij |
597 |
> |
endif |
598 |
> |
endif |
599 |
> |
enddo inner |
600 |
|
enddo |
601 |
|
|
602 |
|
#ifdef IS_MPI |
650 |
|
#else |
651 |
|
pe = pe + pot |
652 |
|
#endif |
653 |
< |
|
654 |
< |
|
655 |
< |
efr(1,j) = -rxij |
656 |
< |
efr(2,j) = -ryij |
657 |
< |
efr(3,j) = -rzij |
658 |
< |
|
659 |
< |
do dim = 1, 3 |
660 |
< |
|
661 |
< |
drdx1 = efr(dim,j) / r |
637 |
< |
ftmp = dudr * drdx1 |
653 |
> |
|
654 |
> |
drdx = -rxij / r |
655 |
> |
drdy = -ryij / r |
656 |
> |
drdz = -rzij / r |
657 |
> |
|
658 |
> |
fx = dudr * drdx |
659 |
> |
fy = dudr * drdy |
660 |
> |
fz = dudr * drdz |
661 |
> |
|
662 |
|
#ifdef IS_MPI |
663 |
< |
fCol(dim,j) = fCol(dim,j) - ftmp |
664 |
< |
fRow(dim,i) = fRow(dim,i) + ftmp |
665 |
< |
#else |
666 |
< |
f(dim,j) = f(dim,j) - ftmp |
667 |
< |
f(dim,i) = f(dim,i) + ftmp |
668 |
< |
#endif |
669 |
< |
enddo |
670 |
< |
endif |
671 |
< |
enddo |
672 |
< |
endif |
673 |
< |
enddo |
674 |
< |
endif |
663 |
> |
fCol(1,j) = fCol(1,j) - fx |
664 |
> |
fCol(2,j) = fCol(2,j) - fy |
665 |
> |
fCol(3,j) = fCol(3,j) - fz |
666 |
> |
|
667 |
> |
fRow(1,j) = fRow(1,j) + fx |
668 |
> |
fRow(2,j) = fRow(2,j) + fy |
669 |
> |
fRow(3,j) = fRow(3,j) + fz |
670 |
> |
#else |
671 |
> |
f(1,j) = f(1,j) - fx |
672 |
> |
f(2,j) = f(2,j) - fy |
673 |
> |
f(3,j) = f(3,j) - fz |
674 |
> |
f(1,i) = f(1,i) + fx |
675 |
> |
f(2,i) = f(2,i) + fy |
676 |
> |
f(3,i) = f(3,i) + fz |
677 |
> |
#endif |
678 |
> |
|
679 |
> |
if (do_stress) then |
680 |
> |
tauTemp(1) = tauTemp(1) + fx * rxij |
681 |
> |
tauTemp(2) = tauTemp(2) + fx * ryij |
682 |
> |
tauTemp(3) = tauTemp(3) + fx * rzij |
683 |
> |
tauTemp(4) = tauTemp(4) + fy * rxij |
684 |
> |
tauTemp(5) = tauTemp(5) + fy * ryij |
685 |
> |
tauTemp(6) = tauTemp(6) + fy * rzij |
686 |
> |
tauTemp(7) = tauTemp(7) + fz * rxij |
687 |
> |
tauTemp(8) = tauTemp(8) + fz * ryij |
688 |
> |
tauTemp(9) = tauTemp(9) + fz * rzij |
689 |
> |
endif |
690 |
> |
|
691 |
> |
|
692 |
> |
endif |
693 |
> |
enddo |
694 |
> |
endif |
695 |
> |
enddo |
696 |
> |
endif |
697 |
> |
|
698 |
|
|
699 |
|
|
653 |
– |
|
700 |
|
#ifdef IS_MPI |
701 |
|
!!distribute forces |
702 |
+ |
|
703 |
|
call scatter(fRow,f,plan_row3d) |
704 |
|
|
705 |
|
call scatter(fCol,fMPITemp,plan_col3d) |
711 |
|
|
712 |
|
|
713 |
|
if (do_pot) then |
714 |
< |
! scatter/gather pot_row into the members of my column |
714 |
> |
! scatter/gather pot_row into the members of my column |
715 |
|
call scatter(eRow,eTemp,plan_row) |
716 |
|
|
717 |
|
! scatter/gather pot_local into all other procs |
726 |
|
pe_local = pe_local + eTemp(i) |
727 |
|
enddo |
728 |
|
endif |
729 |
+ |
pe = pe_local |
730 |
|
endif |
731 |
< |
potE = pe_local |
731 |
> |
|
732 |
|
#endif |
733 |
|
|
734 |
|
potE = pe |
735 |
|
|
688 |
– |
|
736 |
|
|
737 |
+ |
if (do_stress) then |
738 |
+ |
#ifdef IS_MPI |
739 |
+ |
mpi_allreduce = (tau,tauTemp,9,mpi_double_precision,mpi_sum, & |
740 |
+ |
mpi_comm_world,mpi_err) |
741 |
+ |
#else |
742 |
+ |
tau = tauTemp |
743 |
+ |
#endif |
744 |
+ |
endif |
745 |
|
|
746 |
+ |
|
747 |
|
end subroutine do_lj_ff |
748 |
|
|
749 |
|
!! Calculates the potential between two lj particles based on two lj_atype pointers, optionally returns second |
839 |
|
real(kind = dp) :: param1 |
840 |
|
real(kind = dp) :: param2 |
841 |
|
real(kind = dp ) :: myMixParam |
842 |
+ |
character(len = getStringLen()) :: thisMixingRule |
843 |
|
integer, optional :: status |
844 |
|
|
845 |
< |
|
845 |
> |
!! get the mixing rules from the simulation |
846 |
> |
thisMixingRule = returnMixingRules() |
847 |
|
myMixParam = 0.0_dp |
848 |
|
|
849 |
|
if (present(status)) status = 0 |
850 |
< |
|
851 |
< |
select case (thisParam) |
852 |
< |
|
853 |
< |
case ("sigma") |
854 |
< |
myMixParam = 0.5_dp * (param1 + param2) |
855 |
< |
case ("epsilon") |
856 |
< |
myMixParam = sqrt(param1 * param2) |
850 |
> |
select case (thisMixingRule) |
851 |
> |
case ("standard") |
852 |
> |
select case (thisParam) |
853 |
> |
case ("sigma") |
854 |
> |
myMixParam = 0.5_dp * (param1 + param2) |
855 |
> |
case ("epsilon") |
856 |
> |
myMixParam = sqrt(param1 * param2) |
857 |
> |
case default |
858 |
> |
status = -1 |
859 |
> |
end select |
860 |
> |
case("LJglass") |
861 |
|
case default |
862 |
|
status = -1 |
863 |
|
end select |
802 |
– |
|
864 |
|
end function calcLJMix |
865 |
|
|
866 |
|
|