ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/UseTheForce/doForces.F90
(Generate patch)

Comparing trunk/OOPSE-4/src/UseTheForce/doForces.F90 (file contents):
Revision 2261 by gezelter, Tue Jun 28 13:58:45 2005 UTC vs.
Revision 2270 by gezelter, Tue Aug 9 22:33:37 2005 UTC

# Line 45 | Line 45
45  
46   !! @author Charles F. Vardeman II
47   !! @author Matthew Meineke
48 < !! @version $Id: doForces.F90,v 1.22 2005-06-28 13:58:45 gezelter Exp $, $Date: 2005-06-28 13:58:45 $, $Name: not supported by cvs2svn $, $Revision: 1.22 $
48 > !! @version $Id: doForces.F90,v 1.28 2005-08-09 22:33:37 gezelter Exp $, $Date: 2005-08-09 22:33:37 $, $Name: not supported by cvs2svn $, $Revision: 1.28 $
49  
50  
51   module doForces
# Line 78 | Line 78 | module doForces
78    INTEGER, PARAMETER:: PREPAIR_LOOP = 1
79    INTEGER, PARAMETER:: PAIR_LOOP    = 2
80  
81  logical, save :: haveRlist = .false.
81    logical, save :: haveNeighborList = .false.
82    logical, save :: haveSIMvariables = .false.
83    logical, save :: haveSaneForceField = .false.
84 +  logical, save :: haveInteractionHash = .false.
85 +  logical, save :: haveGtypeCutoffMap = .false.
86  
87    logical, save :: FF_uses_DirectionalAtoms
87  logical, save :: FF_uses_LennardJones
88  logical, save :: FF_uses_Electrostatics
89  logical, save :: FF_uses_Charges
88    logical, save :: FF_uses_Dipoles
91  logical, save :: FF_uses_Quadrupoles
92  logical, save :: FF_uses_Sticky
93  logical, save :: FF_uses_StickyPower
89    logical, save :: FF_uses_GayBerne
90    logical, save :: FF_uses_EAM
96  logical, save :: FF_uses_Shapes
97  logical, save :: FF_uses_FLARB
91    logical, save :: FF_uses_RF
92  
93    logical, save :: SIM_uses_DirectionalAtoms
101  logical, save :: SIM_uses_LennardJones
102  logical, save :: SIM_uses_Electrostatics
103  logical, save :: SIM_uses_Charges
104  logical, save :: SIM_uses_Dipoles
105  logical, save :: SIM_uses_Quadrupoles
106  logical, save :: SIM_uses_Sticky
107  logical, save :: SIM_uses_StickyPower
108  logical, save :: SIM_uses_GayBerne
94    logical, save :: SIM_uses_EAM
110  logical, save :: SIM_uses_Shapes
111  logical, save :: SIM_uses_FLARB
95    logical, save :: SIM_uses_RF
96    logical, save :: SIM_requires_postpair_calc
97    logical, save :: SIM_requires_prepair_calc
98    logical, save :: SIM_uses_PBC
116  logical, save :: SIM_uses_molecular_cutoffs
99  
118  !!!GO AWAY---------
119  !!!!!real(kind=dp), save :: rlist, rlistsq
120
100    public :: init_FF
101    public :: do_force_loop
102 < !  public :: setRlistDF
102 >  public :: createInteractionHash
103 >  public :: createGtypeCutoffMap
104  
105   #ifdef PROFILE
106    public :: getforcetime
# Line 128 | Line 108 | module doForces
108    real :: forceTimeInitial, forceTimeFinal
109    integer :: nLoops
110   #endif
131
132  type, public :: Interaction
133     integer :: InteractionHash
134     real(kind=dp) :: rCut
135  end type Interaction
111    
112 <  type(Interaction), dimension(:,:),allocatable :: InteractionMap
112 >  !! Variables for cutoff mapping and interaction mapping
113 >  ! Bit hash to determine pair-pair interactions.
114 >  integer, dimension(:,:), allocatable :: InteractionHash
115 >  real(kind=dp), dimension(:), allocatable :: atypeMaxCutoff
116 >  real(kind=dp), dimension(:), allocatable :: groupMaxCutoff
117 >  integer, dimension(:), allocatable :: groupToGtype
118 >  real(kind=dp), dimension(:), allocatable :: gtypeMaxCutoff
119 >  type ::gtypeCutoffs
120 >     real(kind=dp) :: rcut
121 >     real(kind=dp) :: rcutsq
122 >     real(kind=dp) :: rlistsq
123 >  end type gtypeCutoffs
124 >  type(gtypeCutoffs), dimension(:,:), allocatable :: gtypeCutoffMap
125    
139  !public :: addInteraction
140  !public :: setInteractionHash
141  !public :: getInteractionHash
142  public :: createInteractionMap
143  
126   contains
127  
128 <
147 <  subroutine createInteractionMap(status)
128 >  subroutine createInteractionHash(status)
129      integer :: nAtypes
130 <    integer :: status
130 >    integer, intent(out) :: status
131      integer :: i
132      integer :: j
133 <    integer :: ihash
134 <    real(kind=dp) :: myRcut
154 < ! Test Types
133 >    integer :: iHash
134 >    !! Test Types
135      logical :: i_is_LJ
136      logical :: i_is_Elect
137      logical :: i_is_Sticky
# Line 167 | Line 147 | contains
147      logical :: j_is_EAM
148      logical :: j_is_Shape
149      
150 <    
150 >    status = 0  
151 >
152      if (.not. associated(atypes)) then
153 <       call handleError("atype", "atypes was not present before call of createDefaultInteractionMap!")
153 >       call handleError("atype", "atypes was not present before call of createInteractionHash!")
154         status = -1
155         return
156      endif
# Line 181 | Line 162 | contains
162         return
163      end if
164  
165 <    if (.not. allocated(InteractionMap)) then
166 <       allocate(InteractionMap(nAtypes,nAtypes))
165 >    if (.not. allocated(InteractionHash)) then
166 >       allocate(InteractionHash(nAtypes,nAtypes))
167      endif
168 +
169 +    if (.not. allocated(atypeMaxCutoff)) then
170 +       allocate(atypeMaxCutoff(nAtypes))
171 +    endif
172          
173      do i = 1, nAtypes
174         call getElementProperty(atypes, i, "is_LennardJones", i_is_LJ)
# Line 194 | Line 179 | contains
179         call getElementProperty(atypes, i, "is_EAM", i_is_EAM)
180         call getElementProperty(atypes, i, "is_Shape", i_is_Shape)
181  
182 +       if (i_is_LJ) then
183 +          thisCut = getDefaultLJCutoff(i)
184 +          if (thisCut .gt. atypeMaxCutoff(i)) atypeMaxCutoff(i) = thisCut
185 +       endif
186 +
187 +
188 +
189         do j = i, nAtypes
190  
191            iHash = 0
# Line 236 | Line 228 | contains
228            if (i_is_LJ .and. j_is_Shape) iHash = ior(iHash, SHAPE_LJ)
229  
230  
231 <          InteractionMap(i,j)%InteractionHash = iHash
232 <          InteractionMap(j,i)%InteractionHash = iHash
231 >          InteractionHash(i,j) = iHash
232 >          InteractionHash(j,i) = iHash
233  
234         end do
235  
236      end do
245  end subroutine createInteractionMap
237  
238 +    haveInteractionHash = .true.
239 +  end subroutine createInteractionHash
240  
241 +  subroutine createGtypeCutoffMap(defaultRcut, defaultSkinThickness, stat)
242  
243 < !!! THIS GOES AWAY FOR SIZE DEPENDENT CUTOFF
244 < !!$  subroutine setRlistDF( this_rlist )
251 < !!$
252 < !!$   real(kind=dp) :: this_rlist
253 < !!$
254 < !!$    rlist = this_rlist
255 < !!$    rlistsq = rlist * rlist
256 < !!$
257 < !!$    haveRlist = .true.
258 < !!$
259 < !!$  end subroutine setRlistDF
243 >    real(kind=dp), intent(in), optional :: defaultRCut, defaultSkinThickness
244 >    integer, intent(out) :: stat
245  
246 +    integer :: myStatus, nAtypes
247  
248 +    stat = 0
249 +    if (.not. haveInteractionHash) then
250 +       call createInteractionHash(myStatus)      
251 +       if (myStatus .ne. 0) then
252 +          write(default_error, *) 'createInteractionHash failed in doForces!'
253 +          stat = -1
254 +          return
255 +       endif
256 +    endif
257 +
258 +    nAtypes = getSize(atypes)
259 +
260 +    do i = 1, nAtypes
261 +      
262 +       atypeMaxCutoff(i) =
263 +
264 +    
265 +
266 +
267 +
268 +     haveGtypeCutoffMap = .true.
269 +   end subroutine createGtypeCutoffMap
270 +
271    subroutine setSimVariables()
272      SIM_uses_DirectionalAtoms = SimUsesDirectionalAtoms()
264    SIM_uses_LennardJones = SimUsesLennardJones()
265    SIM_uses_Electrostatics = SimUsesElectrostatics()
266    SIM_uses_Charges = SimUsesCharges()
267    SIM_uses_Dipoles = SimUsesDipoles()
268    SIM_uses_Sticky = SimUsesSticky()
269    SIM_uses_StickyPower = SimUsesStickyPower()
270    SIM_uses_GayBerne = SimUsesGayBerne()
273      SIM_uses_EAM = SimUsesEAM()
272    SIM_uses_Shapes = SimUsesShapes()
273    SIM_uses_FLARB = SimUsesFLARB()
274      SIM_uses_RF = SimUsesRF()
275      SIM_requires_postpair_calc = SimRequiresPostpairCalc()
276      SIM_requires_prepair_calc = SimRequiresPrepairCalc()
# Line 288 | Line 288 | contains
288  
289      error = 0
290  
291 <    if (.not. haveInteractionMap) then
292 <
293 <       myStatus = 0
294 <
295 <       call createInteractionMap(myStatus)
291 >    if (.not. haveInteractionHash) then      
292 >       myStatus = 0      
293 >       call createInteractionHash(myStatus)      
294 >       if (myStatus .ne. 0) then
295 >          write(default_error, *) 'createInteractionHash failed in doForces!'
296 >          error = -1
297 >          return
298 >       endif
299 >    endif
300  
301 +    if (.not. haveGtypeCutoffMap) then        
302 +       myStatus = 0      
303 +       call createGtypeCutoffMap(myStatus)      
304         if (myStatus .ne. 0) then
305 <          write(default_error, *) 'createInteractionMap failed in doForces!'
305 >          write(default_error, *) 'createGtypeCutoffMap failed in doForces!'
306            error = -1
307            return
308         endif
# Line 356 | Line 363 | contains
363      !! interactions are used by the force field.    
364  
365      FF_uses_DirectionalAtoms = .false.
359    FF_uses_LennardJones = .false.
360    FF_uses_Electrostatics = .false.
361    FF_uses_Charges = .false.    
366      FF_uses_Dipoles = .false.
363    FF_uses_Sticky = .false.
364    FF_uses_StickyPower = .false.
367      FF_uses_GayBerne = .false.
368      FF_uses_EAM = .false.
367    FF_uses_Shapes = .false.
368    FF_uses_FLARB = .false.
369  
370      call getMatchingElementList(atypes, "is_Directional", .true., &
371           nMatches, MatchList)
372      if (nMatches .gt. 0) FF_uses_DirectionalAtoms = .true.
373  
374    call getMatchingElementList(atypes, "is_LennardJones", .true., &
375         nMatches, MatchList)
376    if (nMatches .gt. 0) FF_uses_LennardJones = .true.
377
378    call getMatchingElementList(atypes, "is_Electrostatic", .true., &
379         nMatches, MatchList)
380    if (nMatches .gt. 0) then
381       FF_uses_Electrostatics = .true.
382    endif
383
384    call getMatchingElementList(atypes, "is_Charge", .true., &
385         nMatches, MatchList)
386    if (nMatches .gt. 0) then
387       FF_uses_Charges = .true.  
388       FF_uses_Electrostatics = .true.
389    endif
390
374      call getMatchingElementList(atypes, "is_Dipole", .true., &
375           nMatches, MatchList)
376 <    if (nMatches .gt. 0) then
394 <       FF_uses_Dipoles = .true.
395 <       FF_uses_Electrostatics = .true.
396 <       FF_uses_DirectionalAtoms = .true.
397 <    endif
398 <
399 <    call getMatchingElementList(atypes, "is_Quadrupole", .true., &
400 <         nMatches, MatchList)
401 <    if (nMatches .gt. 0) then
402 <       FF_uses_Quadrupoles = .true.
403 <       FF_uses_Electrostatics = .true.
404 <       FF_uses_DirectionalAtoms = .true.
405 <    endif
406 <
407 <    call getMatchingElementList(atypes, "is_Sticky", .true., nMatches, &
408 <         MatchList)
409 <    if (nMatches .gt. 0) then
410 <       FF_uses_Sticky = .true.
411 <       FF_uses_DirectionalAtoms = .true.
412 <    endif
413 <
414 <    call getMatchingElementList(atypes, "is_StickyPower", .true., nMatches, &
415 <         MatchList)
416 <    if (nMatches .gt. 0) then
417 <       FF_uses_StickyPower = .true.
418 <       FF_uses_DirectionalAtoms = .true.
419 <    endif
376 >    if (nMatches .gt. 0) FF_uses_Dipoles = .true.
377      
378      call getMatchingElementList(atypes, "is_GayBerne", .true., &
379           nMatches, MatchList)
380 <    if (nMatches .gt. 0) then
424 <       FF_uses_GayBerne = .true.
425 <       FF_uses_DirectionalAtoms = .true.
426 <    endif
380 >    if (nMatches .gt. 0) FF_uses_GayBerne = .true.
381  
382      call getMatchingElementList(atypes, "is_EAM", .true., nMatches, MatchList)
383      if (nMatches .gt. 0) FF_uses_EAM = .true.
384  
431    call getMatchingElementList(atypes, "is_Shape", .true., &
432         nMatches, MatchList)
433    if (nMatches .gt. 0) then
434       FF_uses_Shapes = .true.
435       FF_uses_DirectionalAtoms = .true.
436    endif
437
438    call getMatchingElementList(atypes, "is_FLARB", .true., &
439         nMatches, MatchList)
440    if (nMatches .gt. 0) FF_uses_FLARB = .true.
385  
442    !! Assume sanity (for the sake of argument)
386      haveSaneForceField = .true.
387  
388      !! check to make sure the FF_uses_RF setting makes sense
389  
390 <    if (FF_uses_dipoles) then
390 >    if (FF_uses_Dipoles) then
391         if (FF_uses_RF) then
392            dielect = getDielect()
393            call initialize_rf(dielect)
# Line 458 | Line 401 | contains
401         endif
402      endif
403  
461    !sticky module does not contain check_sticky_FF anymore
462    !if (FF_uses_sticky) then
463    !   call check_sticky_FF(my_status)
464    !   if (my_status /= 0) then
465    !      thisStat = -1
466    !      haveSaneForceField = .false.
467    !      return
468    !   end if
469    !endif
470
404      if (FF_uses_EAM) then
405         call init_EAM_FF(my_status)
406         if (my_status /= 0) then
# Line 487 | Line 420 | contains
420         endif
421      endif
422  
490    if (FF_uses_GayBerne .and. FF_uses_LennardJones) then
491    endif
492
423      if (.not. haveNeighborList) then
424         !! Create neighbor lists
425         call expandNeighborList(nLocal, my_status)
# Line 553 | Line 483 | contains
483      integer :: localError
484      integer :: propPack_i, propPack_j
485      integer :: loopStart, loopEnd, loop
486 <
486 >    integer :: iHash
487      real(kind=dp) :: listSkin = 1.0  
488  
489      !! initialize local variables  
# Line 645 | Line 575 | contains
575   #endif
576         outer: do i = istart, iend
577  
578 + #ifdef IS_MPI
579 +             me_i = atid_row(i)
580 + #else
581 +             me_i = atid(i)
582 + #endif
583 +
584            if (update_nlist) point(i) = nlist + 1
585  
586            n_in_i = groupStartRow(i+1) - groupStartRow(i)
# Line 672 | Line 608 | contains
608               endif
609  
610   #ifdef IS_MPI
611 +             me_j = atid_col(j)
612               call get_interatomic_vector(q_group_Row(:,i), &
613                    q_group_Col(:,j), d_grp, rgrpsq)
614   #else
615 +             me_j = atid(j)
616               call get_interatomic_vector(q_group(:,i), &
617                    q_group(:,j), d_grp, rgrpsq)
618   #endif
619  
620 <             if (rgrpsq < rlistsq) then
620 >             if (rgrpsq < InteractionHash(me_i,me_j)%rListsq) then
621                  if (update_nlist) then
622                     nlist = nlist + 1
623  
# Line 897 | Line 835 | contains
835   #else
836               me_i = atid(i)
837   #endif
838 <             iMap = InteractionMap(me_i, me_j)%InteractionHash
838 >             iHash = InteractionHash(me_i,me_j)
839              
840 <             if ( iand(iMap, ELECTROSTATIC_PAIR).ne.0 ) then
840 >             if ( iand(iHash, ELECTROSTATIC_PAIR).ne.0 ) then
841  
842                  mu_i = getDipoleMoment(me_i)
843  
# Line 966 | Line 904 | contains
904      real ( kind = dp ) :: ebalance
905      integer :: me_i, me_j
906  
907 <    integer :: iMap
907 >    integer :: iHash
908  
909      r = sqrt(rijsq)
910      vpair = 0.0d0
# Line 980 | Line 918 | contains
918      me_j = atid(j)
919   #endif
920  
921 <    iMap = InteractionMap(me_i, me_j)%InteractionHash
921 >    iHash = InteractionHash(me_i, me_j)
922  
923 <    if ( iand(iMap, LJ_PAIR).ne.0 ) then
923 >    if ( iand(iHash, LJ_PAIR).ne.0 ) then
924         call do_lj_pair(i, j, d, r, rijsq, sw, vpair, fpair, pot, f, do_pot)
925      endif
926  
927 <    if ( iand(iMap, ELECTROSTATIC_PAIR).ne.0 ) then
927 >    if ( iand(iHash, ELECTROSTATIC_PAIR).ne.0 ) then
928         call doElectrostaticPair(i, j, d, r, rijsq, sw, vpair, fpair, &
929              pot, eFrame, f, t, do_pot)
930  
# Line 999 | Line 937 | contains
937  
938      endif
939  
940 <    if ( iand(iMap, STICKY_PAIR).ne.0 ) then
940 >    if ( iand(iHash, STICKY_PAIR).ne.0 ) then
941         call do_sticky_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
942              pot, A, f, t, do_pot)
943      endif
944  
945 <    if ( iand(iMap, STICKYPOWER_PAIR).ne.0 ) then
945 >    if ( iand(iHash, STICKYPOWER_PAIR).ne.0 ) then
946         call do_sticky_power_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
947              pot, A, f, t, do_pot)
948      endif
949  
950 <    if ( iand(iMap, GAYBERNE_PAIR).ne.0 ) then
950 >    if ( iand(iHash, GAYBERNE_PAIR).ne.0 ) then
951         call do_gb_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
952              pot, A, f, t, do_pot)
953      endif
954      
955 <    if ( iand(iMap, GAYBERNE_LJ).ne.0 ) then
956 <       call do_gblj_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
957 <            pot, A, f, t, do_pot)
955 >    if ( iand(iHash, GAYBERNE_LJ).ne.0 ) then
956 > !      call do_gblj_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
957 > !           pot, A, f, t, do_pot)
958      endif
959  
960 <    if ( iand(iMap, EAM_PAIR).ne.0 ) then      
960 >    if ( iand(iHash, EAM_PAIR).ne.0 ) then      
961         call do_eam_pair(i, j, d, r, rijsq, sw, vpair, fpair, pot, f, &
962              do_pot)
963      endif
964  
965 <    if ( iand(iMap, SHAPE_PAIR).ne.0 ) then      
965 >    if ( iand(iHash, SHAPE_PAIR).ne.0 ) then      
966         call do_shape_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
967              pot, A, f, t, do_pot)
968      endif
969  
970 <    if ( iand(iMap, SHAPE_LJ).ne.0 ) then      
970 >    if ( iand(iHash, SHAPE_LJ).ne.0 ) then      
971         call do_shape_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
972              pot, A, f, t, do_pot)
973      endif
# Line 1051 | Line 989 | contains
989      real ( kind = dp )                :: r, rc
990      real ( kind = dp ), intent(inout) :: d(3), dc(3)
991  
992 <    integer :: me_i, me_j, iMap
992 >    integer :: me_i, me_j, iHash
993  
994   #ifdef IS_MPI  
995      me_i = atid_row(i)
# Line 1061 | Line 999 | contains
999      me_j = atid(j)  
1000   #endif
1001  
1002 <    iMap = InteractionMap(me_i, me_j)%InteractionHash
1002 >    iHash = InteractionHash(me_i, me_j)
1003  
1004 <    if ( iand(iMap, EAM_PAIR).ne.0 ) then      
1004 >    if ( iand(iHash, EAM_PAIR).ne.0 ) then      
1005              call calc_EAM_prepair_rho(i, j, d, r, rijsq )
1006      endif
1007      
# Line 1260 | Line 1198 | contains
1198  
1199    function FF_UsesDirectionalAtoms() result(doesit)
1200      logical :: doesit
1201 <    doesit = FF_uses_DirectionalAtoms .or. FF_uses_Dipoles .or. &
1264 <         FF_uses_Quadrupoles .or. FF_uses_Sticky .or. &
1265 <         FF_uses_StickyPower .or. FF_uses_GayBerne .or. FF_uses_Shapes
1201 >    doesit = FF_uses_DirectionalAtoms
1202    end function FF_UsesDirectionalAtoms
1203  
1204    function FF_RequiresPrepairCalc() result(doesit)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines