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 2398 by chrisfen, Wed Oct 26 23:31:18 2005 UTC vs.
Revision 2592 by gezelter, Thu Feb 16 21:40:20 2006 UTC

# Line 45 | Line 45
45  
46   !! @author Charles F. Vardeman II
47   !! @author Matthew Meineke
48 < !! @version $Id: doForces.F90,v 1.63 2005-10-26 23:31:18 chrisfen Exp $, $Date: 2005-10-26 23:31:18 $, $Name: not supported by cvs2svn $, $Revision: 1.63 $
48 > !! @version $Id: doForces.F90,v 1.76 2006-02-16 21:40:20 gezelter Exp $, $Date: 2006-02-16 21:40:20 $, $Name: not supported by cvs2svn $, $Revision: 1.76 $
49  
50  
51   module doForces
# Line 62 | Line 62 | module doForces
62    use shapes
63    use vector_class
64    use eam
65 +  use suttonchen
66    use status
67   #ifdef IS_MPI
68    use mpiSimulation
# Line 86 | Line 87 | module doForces
87    logical, save :: haveInteractionHash = .false.
88    logical, save :: haveGtypeCutoffMap = .false.
89    logical, save :: haveDefaultCutoffs = .false.
90 <  logical, save :: haveRlist = .false.
90 >  logical, save :: haveSkinThickness = .false.
91 >  logical, save :: haveElectrostaticSummationMethod = .false.
92 >  logical, save :: haveCutoffPolicy = .false.
93 >  logical, save :: VisitCutoffsAfterComputing = .false.
94  
95    logical, save :: FF_uses_DirectionalAtoms
96    logical, save :: FF_uses_Dipoles
97    logical, save :: FF_uses_GayBerne
98    logical, save :: FF_uses_EAM
99 +  logical, save :: FF_uses_SC
100 +  logical, save :: FF_uses_MEAM
101 +
102  
103    logical, save :: SIM_uses_DirectionalAtoms
104    logical, save :: SIM_uses_EAM
105 +  logical, save :: SIM_uses_SC
106 +  logical, save :: SIM_uses_MEAM
107    logical, save :: SIM_requires_postpair_calc
108    logical, save :: SIM_requires_prepair_calc
109    logical, save :: SIM_uses_PBC
110  
111    integer, save :: electrostaticSummationMethod
112 +  integer, save :: cutoffPolicy = TRADITIONAL_CUTOFF_POLICY
113  
114 +  real(kind=dp), save :: defaultRcut, defaultRsw, largestRcut
115 +  real(kind=dp), save :: skinThickness
116 +  logical, save :: defaultDoShift
117 +
118    public :: init_FF
119 <  public :: setDefaultCutoffs
119 >  public :: setCutoffs
120 >  public :: cWasLame
121 >  public :: setElectrostaticMethod
122 >  public :: setCutoffPolicy
123 >  public :: setSkinThickness
124    public :: do_force_loop
107  public :: createInteractionHash
108  public :: createGtypeCutoffMap
109  public :: getStickyCut
110  public :: getStickyPowerCut
111  public :: getGayBerneCut
112  public :: getEAMCut
113  public :: getShapeCut
125  
126   #ifdef PROFILE
127    public :: getforcetime
# Line 138 | Line 149 | module doForces
149    end type gtypeCutoffs
150    type(gtypeCutoffs), dimension(:,:), allocatable :: gtypeCutoffMap
151  
141  integer, save :: cutoffPolicy = TRADITIONAL_CUTOFF_POLICY
142  real(kind=dp),save :: defaultRcut, defaultRsw, defaultRlist
143  real(kind=dp),save :: listSkin
144  
152   contains
153  
154 <  subroutine createInteractionHash(status)
154 >  subroutine createInteractionHash()
155      integer :: nAtypes
149    integer, intent(out) :: status
156      integer :: i
157      integer :: j
158      integer :: iHash
# Line 158 | Line 164 | contains
164      logical :: i_is_GB
165      logical :: i_is_EAM
166      logical :: i_is_Shape
167 +    logical :: i_is_SC
168 +    logical :: i_is_MEAM
169      logical :: j_is_LJ
170      logical :: j_is_Elect
171      logical :: j_is_Sticky
# Line 165 | Line 173 | contains
173      logical :: j_is_GB
174      logical :: j_is_EAM
175      logical :: j_is_Shape
176 +    logical :: j_is_SC
177 +    logical :: j_is_MEAM
178      real(kind=dp) :: myRcut
179  
170    status = 0  
171
180      if (.not. associated(atypes)) then
181 <       call handleError("atype", "atypes was not present before call of createInteractionHash!")
174 <       status = -1
181 >       call handleError("doForces", "atypes was not present before call of createInteractionHash!")
182         return
183      endif
184      
185      nAtypes = getSize(atypes)
186      
187      if (nAtypes == 0) then
188 <       status = -1
188 >       call handleError("doForces", "nAtypes was zero during call of createInteractionHash!")
189         return
190      end if
191  
# Line 204 | Line 211 | contains
211         call getElementProperty(atypes, i, "is_GayBerne", i_is_GB)
212         call getElementProperty(atypes, i, "is_EAM", i_is_EAM)
213         call getElementProperty(atypes, i, "is_Shape", i_is_Shape)
214 +       call getElementProperty(atypes, i, "is_SC", i_is_SC)
215 +       call getElementProperty(atypes, i, "is_MEAM", i_is_MEAM)
216  
217         do j = i, nAtypes
218  
# Line 217 | Line 226 | contains
226            call getElementProperty(atypes, j, "is_GayBerne", j_is_GB)
227            call getElementProperty(atypes, j, "is_EAM", j_is_EAM)
228            call getElementProperty(atypes, j, "is_Shape", j_is_Shape)
229 +          call getElementProperty(atypes, j, "is_SC", j_is_SC)
230 +          call getElementProperty(atypes, j, "is_MEAM", j_is_MEAM)
231  
232            if (i_is_LJ .and. j_is_LJ) then
233               iHash = ior(iHash, LJ_PAIR)            
# Line 238 | Line 249 | contains
249               iHash = ior(iHash, EAM_PAIR)
250            endif
251  
252 +          if (i_is_SC .and. j_is_SC) then
253 +             iHash = ior(iHash, SC_PAIR)
254 +          endif
255 +
256            if (i_is_GB .and. j_is_GB) iHash = ior(iHash, GAYBERNE_PAIR)
257            if (i_is_GB .and. j_is_LJ) iHash = ior(iHash, GAYBERNE_LJ)
258            if (i_is_LJ .and. j_is_GB) iHash = ior(iHash, GAYBERNE_LJ)
# Line 257 | Line 272 | contains
272      haveInteractionHash = .true.
273    end subroutine createInteractionHash
274  
275 <  subroutine createGtypeCutoffMap(stat)
275 >  subroutine createGtypeCutoffMap()
276  
262    integer, intent(out), optional :: stat
277      logical :: i_is_LJ
278      logical :: i_is_Elect
279      logical :: i_is_Sticky
# Line 267 | Line 281 | contains
281      logical :: i_is_GB
282      logical :: i_is_EAM
283      logical :: i_is_Shape
284 +    logical :: i_is_SC
285      logical :: GtypeFound
286  
287      integer :: myStatus, nAtypes,  i, j, istart, iend, jstart, jend
# Line 274 | Line 289 | contains
289      integer :: nGroupsInRow
290      integer :: nGroupsInCol
291      integer :: nGroupTypesRow,nGroupTypesCol
292 <    real(kind=dp):: thisSigma, bigSigma, thisRcut, tradRcut, tol, skin
292 >    real(kind=dp):: thisSigma, bigSigma, thisRcut, tradRcut, tol
293      real(kind=dp) :: biggestAtypeCutoff
294  
280    stat = 0
295      if (.not. haveInteractionHash) then
296 <       call createInteractionHash(myStatus)      
283 <       if (myStatus .ne. 0) then
284 <          write(default_error, *) 'createInteractionHash failed in doForces!'
285 <          stat = -1
286 <          return
287 <       endif
296 >       call createInteractionHash()      
297      endif
298   #ifdef IS_MPI
299      nGroupsInRow = getNgroupsInRow(plan_group_row)
# Line 302 | Line 311 | contains
311            call getElementProperty(atypes, i, "is_GayBerne", i_is_GB)
312            call getElementProperty(atypes, i, "is_EAM", i_is_EAM)
313            call getElementProperty(atypes, i, "is_Shape", i_is_Shape)
314 <          
314 >          call getElementProperty(atypes, i, "is_SC", i_is_SC)
315  
316            if (haveDefaultCutoffs) then
317               atypeMaxCutoff(i) = defaultRcut
# Line 335 | Line 344 | contains
344                  thisRcut = getShapeCut(i)
345                  if (thisRCut .gt. atypeMaxCutoff(i)) atypeMaxCutoff(i) = thisRCut
346               endif
347 +             if (i_is_SC) then
348 +                thisRcut = getSCCut(i)
349 +                if (thisRCut .gt. atypeMaxCutoff(i)) atypeMaxCutoff(i) = thisRCut
350 +             endif
351            endif
352 <          
340 <          
352 >                    
353            if (atypeMaxCutoff(i).gt.biggestAtypeCutoff) then
354               biggestAtypeCutoff = atypeMaxCutoff(i)
355            endif
356  
357         endif
358      enddo
347  
348
359      
360      istart = 1
361      jstart = 1
# Line 389 | Line 399 | contains
399         allocate(groupToGtypeCol(jend))
400      end if
401  
402 <    if(.not.associated(groupToGtypeCol)) then
403 <       allocate(groupToGtypeCol(jend))
402 >    if(.not.associated(groupMaxCutoffCol)) then
403 >       allocate(groupMaxCutoffCol(jend))
404      else
405 <       deallocate(groupToGtypeCol)
406 <       allocate(groupToGtypeCol(jend))
405 >       deallocate(groupMaxCutoffCol)
406 >       allocate(groupMaxCutoffCol(jend))
407      end if
408      if(.not.associated(gtypeMaxCutoffCol)) then
409         allocate(gtypeMaxCutoffCol(jend))
# Line 416 | Line 426 | contains
426      
427      tol = 1.0d-6
428      nGroupTypesRow = 0
429 <
429 >    nGroupTypesCol = 0
430      do i = istart, iend      
431         n_in_i = groupStartRow(i+1) - groupStartRow(i)
432         groupMaxCutoffRow(i) = 0.0_dp
# Line 431 | Line 441 | contains
441               groupMaxCutoffRow(i)=atypeMaxCutoff(me_i)
442            endif          
443         enddo
434
444         if (nGroupTypesRow.eq.0) then
445            nGroupTypesRow = nGroupTypesRow + 1
446            gtypeMaxCutoffRow(nGroupTypesRow) = groupMaxCutoffRow(i)
# Line 494 | Line 503 | contains
503      groupMaxCutoffCol => groupMaxCutoffRow
504   #endif
505  
497
498
499
500
506      !! allocate the gtypeCutoffMap here.
507      allocate(gtypeCutoffMap(nGroupTypesRow,nGroupTypesCol))
508      !! then we do a double loop over all the group TYPES to find the cutoff
509      !! map between groups of two types
510      tradRcut = max(maxval(gtypeMaxCutoffRow),maxval(gtypeMaxCutoffCol))
511  
512 <    do i = 1, nGroupTypesRow
512 >    do i = 1, nGroupTypesRow      
513         do j = 1, nGroupTypesCol
514        
515            select case(cutoffPolicy)
# Line 519 | Line 524 | contains
524               return
525            end select
526            gtypeCutoffMap(i,j)%rcut = thisRcut
527 +          
528 +          if (thisRcut.gt.largestRcut) largestRcut = thisRcut
529 +
530            gtypeCutoffMap(i,j)%rcutsq = thisRcut*thisRcut
523          skin = defaultRlist - defaultRcut
524          listSkin = skin ! set neighbor list skin thickness
525          gtypeCutoffMap(i,j)%rlistsq = (thisRcut + skin)**2
531  
532 +          if (.not.haveSkinThickness) then
533 +             skinThickness = 1.0_dp
534 +          endif
535 +
536 +          gtypeCutoffMap(i,j)%rlistsq = (thisRcut + skinThickness)**2
537 +
538            ! sanity check
539  
540            if (haveDefaultCutoffs) then
# Line 533 | Line 544 | contains
544            endif
545         enddo
546      enddo
547 +
548      if(allocated(gtypeMaxCutoffRow)) deallocate(gtypeMaxCutoffRow)
549      if(allocated(groupMaxCutoffRow)) deallocate(groupMaxCutoffRow)
550      if(allocated(atypeMaxCutoff)) deallocate(atypeMaxCutoff)
# Line 546 | Line 558 | contains
558      haveGtypeCutoffMap = .true.
559     end subroutine createGtypeCutoffMap
560  
561 <   subroutine setDefaultCutoffs(defRcut, defRsw, defRlist, cutPolicy)
550 <     real(kind=dp),intent(in) :: defRcut, defRsw, defRlist
551 <     integer, intent(in) :: cutPolicy
561 >   subroutine setCutoffs(defRcut, defRsw)
562  
563 +     real(kind=dp),intent(in) :: defRcut, defRsw
564 +     character(len = statusMsgSize) :: errMsg
565 +     integer :: localError
566 +
567       defaultRcut = defRcut
568       defaultRsw = defRsw
569 <     defaultRlist = defRlist
570 <     cutoffPolicy = cutPolicy
569 >    
570 >     defaultDoShift = .false.
571 >     if (abs(defaultRcut-defaultRsw) .lt. 0.0001) then
572 >        
573 >        write(errMsg, *) &
574 >             'cutoffRadius and switchingRadius are set to the same', newline &
575 >             // tab, 'value.  OOPSE will use shifted ', newline &
576 >             // tab, 'potentials instead of switching functions.'
577 >        
578 >        call handleInfo("setCutoffs", errMsg)
579 >        
580 >        defaultDoShift = .true.
581 >        
582 >     endif
583  
584 +     localError = 0
585 +     call setLJDefaultCutoff( defaultRcut, defaultDoShift )
586 +     call setElectrostaticCutoffRadius( defaultRcut, defaultRsw )
587 +     call setCutoffEAM( defaultRcut, localError)
588 +     if (localError /= 0) then
589 +       write(errMsg, *) 'An error has occured in setting the EAM cutoff'
590 +       call handleError("setCutoffs", errMsg)
591 +     end if
592 +     call set_switch(GROUP_SWITCH, defaultRsw, defaultRcut)
593 +     call setHmatDangerousRcutValue(defaultRcut)
594 +
595       haveDefaultCutoffs = .true.
596 <   end subroutine setDefaultCutoffs
596 >     haveGtypeCutoffMap = .false.
597 >   end subroutine setCutoffs
598  
599 +   subroutine cWasLame()
600 +    
601 +     VisitCutoffsAfterComputing = .true.
602 +     return
603 +    
604 +   end subroutine cWasLame
605 +  
606     subroutine setCutoffPolicy(cutPolicy)
607 <
607 >    
608       integer, intent(in) :: cutPolicy
609 +    
610       cutoffPolicy = cutPolicy
611 <     call createGtypeCutoffMap()
612 <   end subroutine setCutoffPolicy
567 <    
611 >     haveCutoffPolicy = .true.
612 >     haveGtypeCutoffMap = .false.
613      
614 <  subroutine setSimVariables()
615 <    SIM_uses_DirectionalAtoms = SimUsesDirectionalAtoms()
616 <    SIM_uses_EAM = SimUsesEAM()
572 <    SIM_requires_postpair_calc = SimRequiresPostpairCalc()
573 <    SIM_requires_prepair_calc = SimRequiresPrepairCalc()
574 <    SIM_uses_PBC = SimUsesPBC()
614 >   end subroutine setCutoffPolicy
615 >  
616 >   subroutine setElectrostaticMethod( thisESM )
617  
618 <    haveSIMvariables = .true.
618 >     integer, intent(in) :: thisESM
619  
620 <    return
621 <  end subroutine setSimVariables
620 >     electrostaticSummationMethod = thisESM
621 >     haveElectrostaticSummationMethod = .true.
622 >    
623 >   end subroutine setElectrostaticMethod
624 >
625 >   subroutine setSkinThickness( thisSkin )
626 >    
627 >     real(kind=dp), intent(in) :: thisSkin
628 >    
629 >     skinThickness = thisSkin
630 >     haveSkinThickness = .true.    
631 >     haveGtypeCutoffMap = .false.
632 >    
633 >   end subroutine setSkinThickness
634 >      
635 >   subroutine setSimVariables()
636 >     SIM_uses_DirectionalAtoms = SimUsesDirectionalAtoms()
637 >     SIM_uses_EAM = SimUsesEAM()
638 >     SIM_requires_postpair_calc = SimRequiresPostpairCalc()
639 >     SIM_requires_prepair_calc = SimRequiresPrepairCalc()
640 >     SIM_uses_PBC = SimUsesPBC()
641 >     SIM_uses_SC = SimUsesSC()
642 >    
643 >     haveSIMvariables = .true.
644 >    
645 >     return
646 >   end subroutine setSimVariables
647  
648    subroutine doReadyCheck(error)
649      integer, intent(out) :: error
# Line 586 | Line 653 | contains
653      error = 0
654  
655      if (.not. haveInteractionHash) then      
656 <       myStatus = 0      
590 <       call createInteractionHash(myStatus)      
591 <       if (myStatus .ne. 0) then
592 <          write(default_error, *) 'createInteractionHash failed in doForces!'
593 <          error = -1
594 <          return
595 <       endif
656 >       call createInteractionHash()      
657      endif
658  
659      if (.not. haveGtypeCutoffMap) then        
660 <       myStatus = 0      
600 <       call createGtypeCutoffMap(myStatus)      
601 <       if (myStatus .ne. 0) then
602 <          write(default_error, *) 'createGtypeCutoffMap failed in doForces!'
603 <          error = -1
604 <          return
605 <       endif
660 >       call createGtypeCutoffMap()      
661      endif
662  
663 +
664 +    if (VisitCutoffsAfterComputing) then
665 +       call set_switch(GROUP_SWITCH, largestRcut, largestRcut)      
666 +       call setHmatDangerousRcutValue(largestRcut)
667 +    endif
668 +
669 +
670      if (.not. haveSIMvariables) then
671         call setSimVariables()
672      endif
# Line 638 | Line 700 | contains
700    end subroutine doReadyCheck
701  
702  
703 <  subroutine init_FF(thisESM, thisStat)
703 >  subroutine init_FF(thisStat)
704  
643    integer, intent(in) :: thisESM
705      integer, intent(out) :: thisStat  
706      integer :: my_status, nMatches
707      integer, pointer :: MatchList(:) => null()
647    real(kind=dp) :: rcut, rrf, rt, dielect
708  
709      !! assume things are copacetic, unless they aren't
710      thisStat = 0
711  
652    electrostaticSummationMethod = thisESM
653
712      !! init_FF is called *after* all of the atom types have been
713      !! defined in atype_module using the new_atype subroutine.
714      !!
# Line 661 | Line 719 | contains
719      FF_uses_Dipoles = .false.
720      FF_uses_GayBerne = .false.
721      FF_uses_EAM = .false.
722 +    FF_uses_SC = .false.
723  
724      call getMatchingElementList(atypes, "is_Directional", .true., &
725           nMatches, MatchList)
# Line 677 | Line 736 | contains
736      call getMatchingElementList(atypes, "is_EAM", .true., nMatches, MatchList)
737      if (nMatches .gt. 0) FF_uses_EAM = .true.
738  
739 +    call getMatchingElementList(atypes, "is_SC", .true., nMatches, MatchList)
740 +    if (nMatches .gt. 0) FF_uses_SC = .true.
741  
742 +
743      haveSaneForceField = .true.
744  
745      if (FF_uses_EAM) then
# Line 747 | Line 809 | contains
809      real( kind = DP ) :: rVal
810      real(kind=dp),dimension(3) :: d_atm, d_grp, fpair, fij
811      real(kind=dp) :: rfpot, mu_i, virial
812 +    real(kind=dp):: rCut
813      integer :: me_i, me_j, n_in_i, n_in_j
814      logical :: is_dp_i
815      integer :: neighborListSize
# Line 756 | Line 819 | contains
819      integer :: loopStart, loopEnd, loop
820      integer :: iHash
821      integer :: i1
759    logical :: indirect_only
822    
823  
824      !! initialize local variables  
# Line 821 | Line 883 | contains
883         ! (but only on the first time through):
884         if (loop .eq. loopStart) then
885   #ifdef IS_MPI
886 <          call checkNeighborList(nGroupsInRow, q_group_row, listSkin, &
886 >          call checkNeighborList(nGroupsInRow, q_group_row, skinThickness, &
887                 update_nlist)
888   #else
889 <          call checkNeighborList(nGroups, q_group, listSkin, &
889 >          call checkNeighborList(nGroups, q_group, skinThickness, &
890                 update_nlist)
891   #endif
892         endif
# Line 904 | Line 966 | contains
966  
967                     list(nlist) = j
968                  endif
969 +
970  
971 <                if (loop .eq. PAIR_LOOP) then
972 <                   vij = 0.0d0
910 <                   fij(1:3) = 0.0d0
911 <                endif
971 >                
972 >                if (rgrpsq < gtypeCutoffMap(groupToGtypeRow(i),groupToGtypeCol(j))%rCutsq) then
973  
974 <                call get_switch(rgrpsq, sw, dswdr, rgrp, group_switch, &
975 <                     in_switching_region)
976 <
977 <                n_in_j = groupStartCol(j+1) - groupStartCol(j)
978 <
979 <                do ia = groupStartRow(i), groupStartRow(i+1)-1
980 <
981 <                   atom1 = groupListRow(ia)
982 <
983 <                   inner: do jb = groupStartCol(j), groupStartCol(j+1)-1
984 <
985 <                      atom2 = groupListCol(jb)
986 <
987 <                      indirect_only = .false.
988 <    
989 <                      if (skipThisPair(atom1, atom2)) then
990 <                         if (electrostaticSummationMethod.ne.REACTION_FIELD) then
991 <                            cycle inner
974 >                   rCut = gtypeCutoffMap(groupToGtypeRow(i),groupToGtypeCol(j))%rCut
975 >                   if (loop .eq. PAIR_LOOP) then
976 >                      vij = 0.0d0
977 >                      fij(1:3) = 0.0d0
978 >                   endif
979 >                  
980 >                   call get_switch(rgrpsq, sw, dswdr, rgrp, &
981 >                        group_switch, in_switching_region)
982 >                  
983 >                   n_in_j = groupStartCol(j+1) - groupStartCol(j)
984 >                  
985 >                   do ia = groupStartRow(i), groupStartRow(i+1)-1
986 >                      
987 >                      atom1 = groupListRow(ia)
988 >                      
989 >                      inner: do jb = groupStartCol(j), groupStartCol(j+1)-1
990 >                        
991 >                         atom2 = groupListCol(jb)
992 >                        
993 >                         if (skipThisPair(atom1, atom2))  cycle inner
994 >                        
995 >                         if ((n_in_i .eq. 1).and.(n_in_j .eq. 1)) then
996 >                            d_atm(1:3) = d_grp(1:3)
997 >                            ratmsq = rgrpsq
998                           else
932                            indirect_only = .true.
933                         endif
934                      endif
935    
936
937                      if ((n_in_i .eq. 1).and.(n_in_j .eq. 1)) then
938                         d_atm(1:3) = d_grp(1:3)
939                         ratmsq = rgrpsq
940                      else
999   #ifdef IS_MPI
1000 <                         call get_interatomic_vector(q_Row(:,atom1), &
1001 <                              q_Col(:,atom2), d_atm, ratmsq)
1000 >                            call get_interatomic_vector(q_Row(:,atom1), &
1001 >                                 q_Col(:,atom2), d_atm, ratmsq)
1002   #else
1003 <                         call get_interatomic_vector(q(:,atom1), &
1004 <                              q(:,atom2), d_atm, ratmsq)
1003 >                            call get_interatomic_vector(q(:,atom1), &
1004 >                                 q(:,atom2), d_atm, ratmsq)
1005   #endif
1006 <                      endif
1007 <
1008 <                      if (loop .eq. PREPAIR_LOOP) then
1006 >                         endif
1007 >                        
1008 >                         if (loop .eq. PREPAIR_LOOP) then
1009   #ifdef IS_MPI                      
1010 <                         call do_prepair(atom1, atom2, ratmsq, d_atm, sw, &
1011 <                              rgrpsq, d_grp, do_pot, do_stress, &
1012 <                              eFrame, A, f, t, pot_local)
1010 >                            call do_prepair(atom1, atom2, ratmsq, d_atm, sw, &
1011 >                                 rgrpsq, d_grp, rCut, do_pot, do_stress, &
1012 >                                 eFrame, A, f, t, pot_local)
1013   #else
1014 <                         call do_prepair(atom1, atom2, ratmsq, d_atm, sw, &
1015 <                              rgrpsq, d_grp, do_pot, do_stress, &
1016 <                              eFrame, A, f, t, pot)
1014 >                            call do_prepair(atom1, atom2, ratmsq, d_atm, sw, &
1015 >                                 rgrpsq, d_grp, rCut, do_pot, do_stress, &
1016 >                                 eFrame, A, f, t, pot)
1017   #endif                                              
1018 <                      else
1018 >                         else
1019   #ifdef IS_MPI                      
1020 <                         call do_pair(atom1, atom2, ratmsq, d_atm, sw, &
1021 <                              do_pot, eFrame, A, f, t, pot_local, vpair, &
1022 <                              fpair, d_grp, rgrp, indirect_only)
1020 >                            call do_pair(atom1, atom2, ratmsq, d_atm, sw, &
1021 >                                 do_pot, eFrame, A, f, t, pot_local, vpair, &
1022 >                                 fpair, d_grp, rgrp, rCut)
1023   #else
1024 <                         call do_pair(atom1, atom2, ratmsq, d_atm, sw, &
1025 <                              do_pot, eFrame, A, f, t, pot, vpair, fpair, &
1026 <                              d_grp, rgrp, indirect_only)
1024 >                            call do_pair(atom1, atom2, ratmsq, d_atm, sw, &
1025 >                                 do_pot, eFrame, A, f, t, pot, vpair, fpair, &
1026 >                                 d_grp, rgrp, rCut)
1027   #endif
1028 +                            vij = vij + vpair
1029 +                            fij(1:3) = fij(1:3) + fpair(1:3)
1030 +                         endif
1031 +                      enddo inner
1032 +                   enddo
1033  
1034 <                         vij = vij + vpair
1035 <                         fij(1:3) = fij(1:3) + fpair(1:3)
1036 <                      endif
1037 <                   enddo inner
1038 <                enddo
1039 <
1040 <                if (loop .eq. PAIR_LOOP) then
1041 <                   if (in_switching_region) then
1042 <                      swderiv = vij*dswdr/rgrp
1043 <                      fij(1) = fij(1) + swderiv*d_grp(1)
981 <                      fij(2) = fij(2) + swderiv*d_grp(2)
982 <                      fij(3) = fij(3) + swderiv*d_grp(3)
983 <
984 <                      do ia=groupStartRow(i), groupStartRow(i+1)-1
985 <                         atom1=groupListRow(ia)
986 <                         mf = mfactRow(atom1)
1034 >                   if (loop .eq. PAIR_LOOP) then
1035 >                      if (in_switching_region) then
1036 >                         swderiv = vij*dswdr/rgrp
1037 >                         fij(1) = fij(1) + swderiv*d_grp(1)
1038 >                         fij(2) = fij(2) + swderiv*d_grp(2)
1039 >                         fij(3) = fij(3) + swderiv*d_grp(3)
1040 >                        
1041 >                         do ia=groupStartRow(i), groupStartRow(i+1)-1
1042 >                            atom1=groupListRow(ia)
1043 >                            mf = mfactRow(atom1)
1044   #ifdef IS_MPI
1045 <                         f_Row(1,atom1) = f_Row(1,atom1) + swderiv*d_grp(1)*mf
1046 <                         f_Row(2,atom1) = f_Row(2,atom1) + swderiv*d_grp(2)*mf
1047 <                         f_Row(3,atom1) = f_Row(3,atom1) + swderiv*d_grp(3)*mf
1045 >                            f_Row(1,atom1) = f_Row(1,atom1) + swderiv*d_grp(1)*mf
1046 >                            f_Row(2,atom1) = f_Row(2,atom1) + swderiv*d_grp(2)*mf
1047 >                            f_Row(3,atom1) = f_Row(3,atom1) + swderiv*d_grp(3)*mf
1048   #else
1049 <                         f(1,atom1) = f(1,atom1) + swderiv*d_grp(1)*mf
1050 <                         f(2,atom1) = f(2,atom1) + swderiv*d_grp(2)*mf
1051 <                         f(3,atom1) = f(3,atom1) + swderiv*d_grp(3)*mf
1049 >                            f(1,atom1) = f(1,atom1) + swderiv*d_grp(1)*mf
1050 >                            f(2,atom1) = f(2,atom1) + swderiv*d_grp(2)*mf
1051 >                            f(3,atom1) = f(3,atom1) + swderiv*d_grp(3)*mf
1052   #endif
1053 <                      enddo
1054 <
1055 <                      do jb=groupStartCol(j), groupStartCol(j+1)-1
1056 <                         atom2=groupListCol(jb)
1057 <                         mf = mfactCol(atom2)
1053 >                         enddo
1054 >                        
1055 >                         do jb=groupStartCol(j), groupStartCol(j+1)-1
1056 >                            atom2=groupListCol(jb)
1057 >                            mf = mfactCol(atom2)
1058   #ifdef IS_MPI
1059 <                         f_Col(1,atom2) = f_Col(1,atom2) - swderiv*d_grp(1)*mf
1060 <                         f_Col(2,atom2) = f_Col(2,atom2) - swderiv*d_grp(2)*mf
1061 <                         f_Col(3,atom2) = f_Col(3,atom2) - swderiv*d_grp(3)*mf
1059 >                            f_Col(1,atom2) = f_Col(1,atom2) - swderiv*d_grp(1)*mf
1060 >                            f_Col(2,atom2) = f_Col(2,atom2) - swderiv*d_grp(2)*mf
1061 >                            f_Col(3,atom2) = f_Col(3,atom2) - swderiv*d_grp(3)*mf
1062   #else
1063 <                         f(1,atom2) = f(1,atom2) - swderiv*d_grp(1)*mf
1064 <                         f(2,atom2) = f(2,atom2) - swderiv*d_grp(2)*mf
1065 <                         f(3,atom2) = f(3,atom2) - swderiv*d_grp(3)*mf
1063 >                            f(1,atom2) = f(1,atom2) - swderiv*d_grp(1)*mf
1064 >                            f(2,atom2) = f(2,atom2) - swderiv*d_grp(2)*mf
1065 >                            f(3,atom2) = f(3,atom2) - swderiv*d_grp(3)*mf
1066   #endif
1067 <                      enddo
1068 <                   endif
1067 >                         enddo
1068 >                      endif
1069  
1070 <                   if (do_stress) call add_stress_tensor(d_grp, fij)
1070 >                      if (do_stress) call add_stress_tensor(d_grp, fij)
1071 >                   endif
1072                  endif
1073 <             end if
1073 >             endif
1074            enddo
1075 <
1075 >          
1076         enddo outer
1077  
1078         if (update_nlist) then
# Line 1110 | Line 1168 | contains
1168  
1169            if ( iand(iHash, ELECTROSTATIC_PAIR).ne.0 ) then
1170   #ifdef IS_MPI
1171 <             call rf_self_self(i, eFrame, pot_local(ELECTROSTATIC_POT), &
1171 >             call self_self(i, eFrame, pot_local(ELECTROSTATIC_POT), &
1172                    t, do_pot)
1173   #else
1174 <             call rf_self_self(i, eFrame, pot(ELECTROSTATIC_POT), &
1174 >             call self_self(i, eFrame, pot(ELECTROSTATIC_POT), &
1175                    t, do_pot)
1176   #endif
1177            endif
1178    
1179 <          ! loop over the excludes to accumulate any additional RF components
1180 <
1123 <          do i1 = 1, nSkipsForAtom(i)
1124 <             j = skipsForAtom(i, i1)
1179 >          
1180 >          if (electrostaticSummationMethod.eq.REACTION_FIELD) then
1181              
1182 <             ! prevent overcounting of the skips
1183 <             if (i.lt.j) then
1184 <                call get_interatomic_vector(q(:,i), &
1185 <                     q(:,j), d_atm, ratmsq)
1186 <                rVal = dsqrt(ratmsq)
1187 <                call get_switch(ratmsq, sw, dswdr, rVal, group_switch, &
1188 <                     in_switching_region)
1182 >             ! loop over the excludes to accumulate RF stuff we've
1183 >             ! left out of the normal pair loop
1184 >            
1185 >             do i1 = 1, nSkipsForAtom(i)
1186 >                j = skipsForAtom(i, i1)
1187 >                
1188 >                ! prevent overcounting of the skips
1189 >                if (i.lt.j) then
1190 >                   call get_interatomic_vector(q(:,i), &
1191 >                        q(:,j), d_atm, ratmsq)
1192 >                   rVal = dsqrt(ratmsq)
1193 >                   call get_switch(ratmsq, sw, dswdr, rVal, group_switch, &
1194 >                        in_switching_region)
1195   #ifdef IS_MPI
1196 <                call rf_self_excludes(i, j, sw, eFrame, d_atm, rVal, vpair, &
1197 <                     pot_local(ELECTROSTATIC_POT), f, t, do_pot)
1196 >                   call rf_self_excludes(i, j, sw, eFrame, d_atm, rVal, &
1197 >                        vpair, pot_local(ELECTROSTATIC_POT), f, t, do_pot)
1198   #else
1199 <                call rf_self_excludes(i, j, sw, eFrame, d_atm, rVal, vpair, &
1200 <                     pot(ELECTROSTATIC_POT), f, t, do_pot)
1199 >                   call rf_self_excludes(i, j, sw, eFrame, d_atm, rVal, &
1200 >                        vpair, pot(ELECTROSTATIC_POT), f, t, do_pot)
1201   #endif
1202 <             endif
1203 <          enddo
1204 <       enddo      
1202 >                endif
1203 >             enddo
1204 >          endif
1205 >       enddo
1206      endif
1207      
1208   #ifdef IS_MPI
# Line 1168 | Line 1231 | contains
1231    end subroutine do_force_loop
1232  
1233    subroutine do_pair(i, j, rijsq, d, sw, do_pot, &
1234 <       eFrame, A, f, t, pot, vpair, fpair, d_grp, r_grp, indirect_only)
1234 >       eFrame, A, f, t, pot, vpair, fpair, d_grp, r_grp, rCut)
1235  
1236      real( kind = dp ) :: vpair, sw
1237      real( kind = dp ), dimension(LR_POT_TYPES) :: pot
# Line 1180 | Line 1243 | contains
1243      real( kind = dp ), dimension(3,nLocal) :: t
1244  
1245      logical, intent(inout) :: do_pot
1183    logical, intent(inout) :: indirect_only
1246      integer, intent(in) :: i, j
1247      real ( kind = dp ), intent(inout) :: rijsq
1248      real ( kind = dp ), intent(inout) :: r_grp
1249      real ( kind = dp ), intent(inout) :: d(3)
1250      real ( kind = dp ), intent(inout) :: d_grp(3)
1251 +    real ( kind = dp ), intent(inout) :: rCut
1252      real ( kind = dp ) :: r
1253      integer :: me_i, me_j
1254  
# Line 1204 | Line 1267 | contains
1267   #endif
1268  
1269      iHash = InteractionHash(me_i, me_j)
1270 <
1271 <    if (indirect_only) then
1272 <       if ( iand(iHash, ELECTROSTATIC_PAIR).ne.0 ) then
1273 <          call doElectrostaticPair(i, j, d, r, rijsq, sw, vpair, fpair, &
1274 <               pot(ELECTROSTATIC_POT), eFrame, f, t, do_pot, indirect_only)
1275 <       endif
1276 <    else
1277 <          
1278 <       if ( iand(iHash, LJ_PAIR).ne.0 ) then
1279 <          call do_lj_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
1280 <               pot(VDW_POT), f, do_pot)
1281 <       endif
1270 >    
1271 >    if ( iand(iHash, LJ_PAIR).ne.0 ) then
1272 >       call do_lj_pair(i, j, d, r, rijsq, rcut, sw, vpair, fpair, &
1273 >            pot(VDW_POT), f, do_pot)
1274 >    endif
1275 >    
1276 >    if ( iand(iHash, ELECTROSTATIC_PAIR).ne.0 ) then
1277 >       call doElectrostaticPair(i, j, d, r, rijsq, rcut, sw, vpair, fpair, &
1278 >            pot(ELECTROSTATIC_POT), eFrame, f, t, do_pot)
1279 >    endif
1280 >    
1281 >    if ( iand(iHash, STICKY_PAIR).ne.0 ) then
1282 >       call do_sticky_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
1283 >            pot(HB_POT), A, f, t, do_pot)
1284 >    endif
1285 >    
1286 >    if ( iand(iHash, STICKYPOWER_PAIR).ne.0 ) then
1287 >       call do_sticky_power_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
1288 >            pot(HB_POT), A, f, t, do_pot)
1289 >    endif
1290 >    
1291 >    if ( iand(iHash, GAYBERNE_PAIR).ne.0 ) then
1292 >       call do_gb_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
1293 >            pot(VDW_POT), A, f, t, do_pot)
1294 >    endif
1295 >    
1296 >    if ( iand(iHash, GAYBERNE_LJ).ne.0 ) then
1297 >       call do_gb_lj_pair(i, j, d, r, rijsq, rcut, sw, vpair, fpair, &
1298 >            pot(VDW_POT), A, f, t, do_pot)
1299 >    endif
1300 >    
1301 >    if ( iand(iHash, EAM_PAIR).ne.0 ) then      
1302 >       call do_eam_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
1303 >            pot(METALLIC_POT), f, do_pot)
1304 >    endif
1305 >    
1306 >    if ( iand(iHash, SHAPE_PAIR).ne.0 ) then      
1307 >       call do_shape_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
1308 >            pot(VDW_POT), A, f, t, do_pot)
1309 >    endif
1310 >    
1311 >    if ( iand(iHash, SHAPE_LJ).ne.0 ) then      
1312 >       call do_shape_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
1313 >            pot(VDW_POT), A, f, t, do_pot)
1314 >    endif
1315  
1316 <       if ( iand(iHash, ELECTROSTATIC_PAIR).ne.0 ) then
1317 <          call doElectrostaticPair(i, j, d, r, rijsq, sw, vpair, fpair, &
1318 <               pot(ELECTROSTATIC_POT), eFrame, f, t, do_pot, indirect_only)
1223 <       endif
1224 <      
1225 <       if ( iand(iHash, STICKY_PAIR).ne.0 ) then
1226 <          call do_sticky_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
1227 <               pot(HB_POT), A, f, t, do_pot)
1228 <       endif
1229 <      
1230 <       if ( iand(iHash, STICKYPOWER_PAIR).ne.0 ) then
1231 <          call do_sticky_power_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
1232 <               pot(HB_POT), A, f, t, do_pot)
1233 <       endif
1234 <      
1235 <       if ( iand(iHash, GAYBERNE_PAIR).ne.0 ) then
1236 <          call do_gb_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
1237 <               pot(VDW_POT), A, f, t, do_pot)
1238 <       endif
1239 <      
1240 <       if ( iand(iHash, GAYBERNE_LJ).ne.0 ) then
1241 <          call do_gb_lj_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
1242 <               pot(VDW_POT), A, f, t, do_pot)
1243 <       endif
1244 <      
1245 <       if ( iand(iHash, EAM_PAIR).ne.0 ) then      
1246 <          call do_eam_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
1247 <               pot(METALLIC_POT), f, do_pot)
1248 <       endif
1249 <      
1250 <       if ( iand(iHash, SHAPE_PAIR).ne.0 ) then      
1251 <          call do_shape_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
1252 <               pot(VDW_POT), A, f, t, do_pot)
1253 <       endif
1254 <      
1255 <       if ( iand(iHash, SHAPE_LJ).ne.0 ) then      
1256 <          call do_shape_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
1257 <               pot(VDW_POT), A, f, t, do_pot)
1258 <       endif
1316 >    if ( iand(iHash, SC_PAIR).ne.0 ) then      
1317 >       call do_SC_pair(i, j, d, r, rijsq, rcut, sw, vpair, fpair, &
1318 >            pot(METALLIC_POT), f, do_pot)
1319      endif
1320 +
1321      
1322 +    
1323    end subroutine do_pair
1324  
1325 <  subroutine do_prepair(i, j, rijsq, d, sw, rcijsq, dc, &
1325 >  subroutine do_prepair(i, j, rijsq, d, sw, rcijsq, dc, rCut, &
1326         do_pot, do_stress, eFrame, A, f, t, pot)
1327  
1328      real( kind = dp ) :: sw
# Line 1272 | Line 1334 | contains
1334  
1335      logical, intent(inout) :: do_pot, do_stress
1336      integer, intent(in) :: i, j
1337 <    real ( kind = dp ), intent(inout)    :: rijsq, rcijsq
1337 >    real ( kind = dp ), intent(inout)    :: rijsq, rcijsq, rCut
1338      real ( kind = dp )                :: r, rc
1339      real ( kind = dp ), intent(inout) :: d(3), dc(3)
1340  
# Line 1291 | Line 1353 | contains
1353      iHash = InteractionHash(me_i, me_j)
1354  
1355      if ( iand(iHash, EAM_PAIR).ne.0 ) then      
1356 <            call calc_EAM_prepair_rho(i, j, d, r, rijsq )
1356 >            call calc_EAM_prepair_rho(i, j, d, r, rijsq)
1357      endif
1358 +
1359 +    if ( iand(iHash, SC_PAIR).ne.0 ) then      
1360 +            call calc_SC_prepair_rho(i, j, d, r, rijsq, rcut )
1361 +    endif
1362      
1363    end subroutine do_prepair
1364  
# Line 1304 | Line 1370 | contains
1370      if (FF_uses_EAM .and. SIM_uses_EAM) then
1371         call calc_EAM_preforce_Frho(nlocal,pot(METALLIC_POT))
1372      endif
1373 +    if (FF_uses_SC .and. SIM_uses_SC) then
1374 +       call calc_SC_preforce_Frho(nlocal,pot(METALLIC_POT))
1375 +    endif
1376  
1377  
1378    end subroutine do_preforce
# Line 1388 | Line 1457 | contains
1457      pot_Col = 0.0_dp
1458      pot_Temp = 0.0_dp
1459  
1391    rf_Row = 0.0_dp
1392    rf_Col = 0.0_dp
1393    rf_Temp = 0.0_dp
1394
1460   #endif
1461  
1462      if (FF_uses_EAM .and. SIM_uses_EAM) then
1463         call clean_EAM()
1464      endif
1465  
1401    rf = 0.0_dp
1466      tau_Temp = 0.0_dp
1467      virial_Temp = 0.0_dp
1468    end subroutine zero_work_arrays
# Line 1492 | Line 1556 | contains
1556  
1557    function FF_RequiresPrepairCalc() result(doesit)
1558      logical :: doesit
1559 <    doesit = FF_uses_EAM
1559 >    doesit = FF_uses_EAM .or. FF_uses_SC &
1560 >         .or. FF_uses_MEAM
1561    end function FF_RequiresPrepairCalc
1562  
1563   #ifdef PROFILE

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines