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 2461 by gezelter, Mon Nov 21 22:59:02 2005 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.69 2005-11-21 22:58:35 gezelter Exp $, $Date: 2005-11-21 22:58:35 $, $Name: not supported by cvs2svn $, $Revision: 1.69 $
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
169
170    status = 0  
179  
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 274 | Line 288 | contains
288      integer :: nGroupsInRow
289      integer :: nGroupsInCol
290      integer :: nGroupTypesRow,nGroupTypesCol
291 <    real(kind=dp):: thisSigma, bigSigma, thisRcut, tradRcut, tol, skin
291 >    real(kind=dp):: thisSigma, bigSigma, thisRcut, tradRcut, tol
292      real(kind=dp) :: biggestAtypeCutoff
293  
280    stat = 0
294      if (.not. haveInteractionHash) then
295 <       call createInteractionHash(myStatus)      
283 <       if (myStatus .ne. 0) then
284 <          write(default_error, *) 'createInteractionHash failed in doForces!'
285 <          stat = -1
286 <          return
287 <       endif
295 >       call createInteractionHash()      
296      endif
297   #ifdef IS_MPI
298      nGroupsInRow = getNgroupsInRow(plan_group_row)
# Line 336 | Line 344 | contains
344                  if (thisRCut .gt. atypeMaxCutoff(i)) atypeMaxCutoff(i) = thisRCut
345               endif
346            endif
347 <          
340 <          
347 >                    
348            if (atypeMaxCutoff(i).gt.biggestAtypeCutoff) then
349               biggestAtypeCutoff = atypeMaxCutoff(i)
350            endif
351  
352         endif
353      enddo
347  
348
354      
355      istart = 1
356      jstart = 1
# Line 494 | Line 499 | contains
499      groupMaxCutoffCol => groupMaxCutoffRow
500   #endif
501  
497
498
499
500
502      !! allocate the gtypeCutoffMap here.
503      allocate(gtypeCutoffMap(nGroupTypesRow,nGroupTypesCol))
504      !! then we do a double loop over all the group TYPES to find the cutoff
505      !! map between groups of two types
506      tradRcut = max(maxval(gtypeMaxCutoffRow),maxval(gtypeMaxCutoffCol))
507  
508 <    do i = 1, nGroupTypesRow
508 >    do i = 1, nGroupTypesRow      
509         do j = 1, nGroupTypesCol
510        
511            select case(cutoffPolicy)
# Line 519 | Line 520 | contains
520               return
521            end select
522            gtypeCutoffMap(i,j)%rcut = thisRcut
523 +          
524 +          if (thisRcut.gt.largestRcut) largestRcut = thisRcut
525 +
526            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
527  
528 +          if (.not.haveSkinThickness) then
529 +             skinThickness = 1.0_dp
530 +          endif
531 +
532 +          gtypeCutoffMap(i,j)%rlistsq = (thisRcut + skinThickness)**2
533 +
534            ! sanity check
535  
536            if (haveDefaultCutoffs) then
# Line 533 | Line 540 | contains
540            endif
541         enddo
542      enddo
543 +
544      if(allocated(gtypeMaxCutoffRow)) deallocate(gtypeMaxCutoffRow)
545      if(allocated(groupMaxCutoffRow)) deallocate(groupMaxCutoffRow)
546      if(allocated(atypeMaxCutoff)) deallocate(atypeMaxCutoff)
# Line 546 | Line 554 | contains
554      haveGtypeCutoffMap = .true.
555     end subroutine createGtypeCutoffMap
556  
557 <   subroutine setDefaultCutoffs(defRcut, defRsw, defRlist, cutPolicy)
550 <     real(kind=dp),intent(in) :: defRcut, defRsw, defRlist
551 <     integer, intent(in) :: cutPolicy
557 >   subroutine setCutoffs(defRcut, defRsw)
558  
559 +     real(kind=dp),intent(in) :: defRcut, defRsw
560 +     character(len = statusMsgSize) :: errMsg
561 +     integer :: localError
562 +
563       defaultRcut = defRcut
564       defaultRsw = defRsw
565 <     defaultRlist = defRlist
566 <     cutoffPolicy = cutPolicy
565 >    
566 >     defaultDoShift = .false.
567 >     if (abs(defaultRcut-defaultRsw) .lt. 0.0001) then
568 >        
569 >        write(errMsg, *) &
570 >             'cutoffRadius and switchingRadius are set to the same', newline &
571 >             // tab, 'value.  OOPSE will use shifted ', newline &
572 >             // tab, 'potentials instead of switching functions.'
573 >        
574 >        call handleInfo("setCutoffs", errMsg)
575 >        
576 >        defaultDoShift = .true.
577 >        
578 >     endif
579  
580 +     localError = 0
581 +     call setLJDefaultCutoff( defaultRcut, defaultDoShift )
582 +     call setCutoffEAM( defaultRcut, localError)
583 +     if (localError /= 0) then
584 +       write(errMsg, *) 'An error has occured in setting the EAM cutoff'
585 +       call handleError("setCutoffs", errMsg)
586 +     end if
587 +     call set_switch(GROUP_SWITCH, defaultRsw, defaultRcut)
588 +    
589       haveDefaultCutoffs = .true.
590 <   end subroutine setDefaultCutoffs
590 >   end subroutine setCutoffs
591  
592 +   subroutine cWasLame()
593 +    
594 +     VisitCutoffsAfterComputing = .true.
595 +     return
596 +    
597 +   end subroutine cWasLame
598 +  
599     subroutine setCutoffPolicy(cutPolicy)
600 <
600 >    
601       integer, intent(in) :: cutPolicy
602 +    
603       cutoffPolicy = cutPolicy
604 +     haveCutoffPolicy = .true.
605 +
606       call createGtypeCutoffMap()
566   end subroutine setCutoffPolicy
567    
607      
608 <  subroutine setSimVariables()
609 <    SIM_uses_DirectionalAtoms = SimUsesDirectionalAtoms()
610 <    SIM_uses_EAM = SimUsesEAM()
572 <    SIM_requires_postpair_calc = SimRequiresPostpairCalc()
573 <    SIM_requires_prepair_calc = SimRequiresPrepairCalc()
574 <    SIM_uses_PBC = SimUsesPBC()
608 >   end subroutine setCutoffPolicy
609 >  
610 >   subroutine setElectrostaticMethod( thisESM )
611  
612 <    haveSIMvariables = .true.
612 >     integer, intent(in) :: thisESM
613  
614 <    return
615 <  end subroutine setSimVariables
614 >     electrostaticSummationMethod = thisESM
615 >     haveElectrostaticSummationMethod = .true.
616 >    
617 >   end subroutine setElectrostaticMethod
618  
619 +   subroutine setSkinThickness( thisSkin )
620 +    
621 +     real(kind=dp), intent(in) :: thisSkin
622 +    
623 +     skinThickness = thisSkin
624 +     haveSkinThickness = .true.
625 +    
626 +     call createGtypeCutoffMap()
627 +    
628 +   end subroutine setSkinThickness
629 +      
630 +   subroutine setSimVariables()
631 +     SIM_uses_DirectionalAtoms = SimUsesDirectionalAtoms()
632 +     SIM_uses_EAM = SimUsesEAM()
633 +     SIM_requires_postpair_calc = SimRequiresPostpairCalc()
634 +     SIM_requires_prepair_calc = SimRequiresPrepairCalc()
635 +     SIM_uses_PBC = SimUsesPBC()
636 +    
637 +     haveSIMvariables = .true.
638 +    
639 +     return
640 +   end subroutine setSimVariables
641 +
642    subroutine doReadyCheck(error)
643      integer, intent(out) :: error
644  
# Line 586 | Line 647 | contains
647      error = 0
648  
649      if (.not. haveInteractionHash) then      
650 <       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
650 >       call createInteractionHash()      
651      endif
652  
653      if (.not. haveGtypeCutoffMap) then        
654 <       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
654 >       call createGtypeCutoffMap()      
655      endif
656  
657 +
658 +    if (VisitCutoffsAfterComputing) then
659 +       call set_switch(GROUP_SWITCH, largestRcut, largestRcut)      
660 +    endif
661 +
662 +
663      if (.not. haveSIMvariables) then
664         call setSimVariables()
665      endif
# Line 638 | Line 693 | contains
693    end subroutine doReadyCheck
694  
695  
696 <  subroutine init_FF(thisESM, thisStat)
696 >  subroutine init_FF(thisStat)
697  
643    integer, intent(in) :: thisESM
698      integer, intent(out) :: thisStat  
699      integer :: my_status, nMatches
700      integer, pointer :: MatchList(:) => null()
647    real(kind=dp) :: rcut, rrf, rt, dielect
701  
702      !! assume things are copacetic, unless they aren't
703      thisStat = 0
704  
652    electrostaticSummationMethod = thisESM
653
705      !! init_FF is called *after* all of the atom types have been
706      !! defined in atype_module using the new_atype subroutine.
707      !!
# Line 747 | Line 798 | contains
798      real( kind = DP ) :: rVal
799      real(kind=dp),dimension(3) :: d_atm, d_grp, fpair, fij
800      real(kind=dp) :: rfpot, mu_i, virial
801 +    real(kind=dp):: rCut
802      integer :: me_i, me_j, n_in_i, n_in_j
803      logical :: is_dp_i
804      integer :: neighborListSize
# Line 756 | Line 808 | contains
808      integer :: loopStart, loopEnd, loop
809      integer :: iHash
810      integer :: i1
759    logical :: indirect_only
811    
812  
813      !! initialize local variables  
# Line 821 | Line 872 | contains
872         ! (but only on the first time through):
873         if (loop .eq. loopStart) then
874   #ifdef IS_MPI
875 <          call checkNeighborList(nGroupsInRow, q_group_row, listSkin, &
875 >          call checkNeighborList(nGroupsInRow, q_group_row, skinThickness, &
876                 update_nlist)
877   #else
878 <          call checkNeighborList(nGroups, q_group, listSkin, &
878 >          call checkNeighborList(nGroups, q_group, skinThickness, &
879                 update_nlist)
880   #endif
881         endif
# Line 904 | Line 955 | contains
955  
956                     list(nlist) = j
957                  endif
958 +
959  
960 <                if (loop .eq. PAIR_LOOP) then
961 <                   vij = 0.0d0
910 <                   fij(1:3) = 0.0d0
911 <                endif
912 <
913 <                call get_switch(rgrpsq, sw, dswdr, rgrp, group_switch, &
914 <                     in_switching_region)
915 <
916 <                n_in_j = groupStartCol(j+1) - groupStartCol(j)
917 <
918 <                do ia = groupStartRow(i), groupStartRow(i+1)-1
919 <
920 <                   atom1 = groupListRow(ia)
960 >                
961 >                if (rgrpsq < gtypeCutoffMap(groupToGtypeRow(i),groupToGtypeCol(j))%rCutsq) then
962  
963 <                   inner: do jb = groupStartCol(j), groupStartCol(j+1)-1
964 <
965 <                      atom2 = groupListCol(jb)
966 <
967 <                      indirect_only = .false.
968 <    
969 <                      if (skipThisPair(atom1, atom2)) then
970 <                         if (electrostaticSummationMethod.ne.REACTION_FIELD) then
971 <                            cycle inner
963 >                   rCut = gtypeCutoffMap(groupToGtypeRow(i),groupToGtypeCol(j))%rCut
964 >                   if (loop .eq. PAIR_LOOP) then
965 >                      vij = 0.0d0
966 >                      fij(1:3) = 0.0d0
967 >                   endif
968 >                  
969 >                   call get_switch(rgrpsq, sw, dswdr, rgrp, &
970 >                        group_switch, in_switching_region)
971 >                  
972 >                   n_in_j = groupStartCol(j+1) - groupStartCol(j)
973 >                  
974 >                   do ia = groupStartRow(i), groupStartRow(i+1)-1
975 >                      
976 >                      atom1 = groupListRow(ia)
977 >                      
978 >                      inner: do jb = groupStartCol(j), groupStartCol(j+1)-1
979 >                        
980 >                         atom2 = groupListCol(jb)
981 >                        
982 >                         if (skipThisPair(atom1, atom2))  cycle inner
983 >                        
984 >                         if ((n_in_i .eq. 1).and.(n_in_j .eq. 1)) then
985 >                            d_atm(1:3) = d_grp(1:3)
986 >                            ratmsq = rgrpsq
987                           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
988   #ifdef IS_MPI
989 <                         call get_interatomic_vector(q_Row(:,atom1), &
990 <                              q_Col(:,atom2), d_atm, ratmsq)
989 >                            call get_interatomic_vector(q_Row(:,atom1), &
990 >                                 q_Col(:,atom2), d_atm, ratmsq)
991   #else
992 <                         call get_interatomic_vector(q(:,atom1), &
993 <                              q(:,atom2), d_atm, ratmsq)
992 >                            call get_interatomic_vector(q(:,atom1), &
993 >                                 q(:,atom2), d_atm, ratmsq)
994   #endif
995 <                      endif
996 <
997 <                      if (loop .eq. PREPAIR_LOOP) then
995 >                         endif
996 >                        
997 >                         if (loop .eq. PREPAIR_LOOP) then
998   #ifdef IS_MPI                      
999 <                         call do_prepair(atom1, atom2, ratmsq, d_atm, sw, &
1000 <                              rgrpsq, d_grp, do_pot, do_stress, &
1001 <                              eFrame, A, f, t, pot_local)
1002 < #else
1003 <                         call do_prepair(atom1, atom2, ratmsq, d_atm, sw, &
1004 <                              rgrpsq, d_grp, do_pot, do_stress, &
1005 <                              eFrame, A, f, t, pot)
999 >                            call do_prepair(atom1, atom2, ratmsq, d_atm, sw, &
1000 >                                 rgrpsq, d_grp, rCut, do_pot, do_stress, &
1001 >                                 eFrame, A, f, t, pot_local)
1002 > #else
1003 >                            call do_prepair(atom1, atom2, ratmsq, d_atm, sw, &
1004 >                                 rgrpsq, d_grp, rCut, do_pot, do_stress, &
1005 >                                 eFrame, A, f, t, pot)
1006   #endif                                              
1007 <                      else
1007 >                         else
1008   #ifdef IS_MPI                      
1009 <                         call do_pair(atom1, atom2, ratmsq, d_atm, sw, &
1010 <                              do_pot, eFrame, A, f, t, pot_local, vpair, &
1011 <                              fpair, d_grp, rgrp, indirect_only)
1009 >                            call do_pair(atom1, atom2, ratmsq, d_atm, sw, &
1010 >                                 do_pot, eFrame, A, f, t, pot_local, vpair, &
1011 >                                 fpair, d_grp, rgrp, rCut)
1012   #else
1013 <                         call do_pair(atom1, atom2, ratmsq, d_atm, sw, &
1014 <                              do_pot, eFrame, A, f, t, pot, vpair, fpair, &
1015 <                              d_grp, rgrp, indirect_only)
1013 >                            call do_pair(atom1, atom2, ratmsq, d_atm, sw, &
1014 >                                 do_pot, eFrame, A, f, t, pot, vpair, fpair, &
1015 >                                 d_grp, rgrp, rCut)
1016   #endif
1017 +                            vij = vij + vpair
1018 +                            fij(1:3) = fij(1:3) + fpair(1:3)
1019 +                         endif
1020 +                      enddo inner
1021 +                   enddo
1022  
1023 <                         vij = vij + vpair
1024 <                         fij(1:3) = fij(1:3) + fpair(1:3)
1025 <                      endif
1026 <                   enddo inner
1027 <                enddo
1028 <
1029 <                if (loop .eq. PAIR_LOOP) then
1030 <                   if (in_switching_region) then
1031 <                      swderiv = vij*dswdr/rgrp
1032 <                      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)
1023 >                   if (loop .eq. PAIR_LOOP) then
1024 >                      if (in_switching_region) then
1025 >                         swderiv = vij*dswdr/rgrp
1026 >                         fij(1) = fij(1) + swderiv*d_grp(1)
1027 >                         fij(2) = fij(2) + swderiv*d_grp(2)
1028 >                         fij(3) = fij(3) + swderiv*d_grp(3)
1029 >                        
1030 >                         do ia=groupStartRow(i), groupStartRow(i+1)-1
1031 >                            atom1=groupListRow(ia)
1032 >                            mf = mfactRow(atom1)
1033   #ifdef IS_MPI
1034 <                         f_Row(1,atom1) = f_Row(1,atom1) + swderiv*d_grp(1)*mf
1035 <                         f_Row(2,atom1) = f_Row(2,atom1) + swderiv*d_grp(2)*mf
1036 <                         f_Row(3,atom1) = f_Row(3,atom1) + swderiv*d_grp(3)*mf
1034 >                            f_Row(1,atom1) = f_Row(1,atom1) + swderiv*d_grp(1)*mf
1035 >                            f_Row(2,atom1) = f_Row(2,atom1) + swderiv*d_grp(2)*mf
1036 >                            f_Row(3,atom1) = f_Row(3,atom1) + swderiv*d_grp(3)*mf
1037   #else
1038 <                         f(1,atom1) = f(1,atom1) + swderiv*d_grp(1)*mf
1039 <                         f(2,atom1) = f(2,atom1) + swderiv*d_grp(2)*mf
1040 <                         f(3,atom1) = f(3,atom1) + swderiv*d_grp(3)*mf
1038 >                            f(1,atom1) = f(1,atom1) + swderiv*d_grp(1)*mf
1039 >                            f(2,atom1) = f(2,atom1) + swderiv*d_grp(2)*mf
1040 >                            f(3,atom1) = f(3,atom1) + swderiv*d_grp(3)*mf
1041   #endif
1042 <                      enddo
1043 <
1044 <                      do jb=groupStartCol(j), groupStartCol(j+1)-1
1045 <                         atom2=groupListCol(jb)
1046 <                         mf = mfactCol(atom2)
1042 >                         enddo
1043 >                        
1044 >                         do jb=groupStartCol(j), groupStartCol(j+1)-1
1045 >                            atom2=groupListCol(jb)
1046 >                            mf = mfactCol(atom2)
1047   #ifdef IS_MPI
1048 <                         f_Col(1,atom2) = f_Col(1,atom2) - swderiv*d_grp(1)*mf
1049 <                         f_Col(2,atom2) = f_Col(2,atom2) - swderiv*d_grp(2)*mf
1050 <                         f_Col(3,atom2) = f_Col(3,atom2) - swderiv*d_grp(3)*mf
1048 >                            f_Col(1,atom2) = f_Col(1,atom2) - swderiv*d_grp(1)*mf
1049 >                            f_Col(2,atom2) = f_Col(2,atom2) - swderiv*d_grp(2)*mf
1050 >                            f_Col(3,atom2) = f_Col(3,atom2) - swderiv*d_grp(3)*mf
1051   #else
1052 <                         f(1,atom2) = f(1,atom2) - swderiv*d_grp(1)*mf
1053 <                         f(2,atom2) = f(2,atom2) - swderiv*d_grp(2)*mf
1054 <                         f(3,atom2) = f(3,atom2) - swderiv*d_grp(3)*mf
1052 >                            f(1,atom2) = f(1,atom2) - swderiv*d_grp(1)*mf
1053 >                            f(2,atom2) = f(2,atom2) - swderiv*d_grp(2)*mf
1054 >                            f(3,atom2) = f(3,atom2) - swderiv*d_grp(3)*mf
1055   #endif
1056 <                      enddo
1057 <                   endif
1056 >                         enddo
1057 >                      endif
1058  
1059 <                   if (do_stress) call add_stress_tensor(d_grp, fij)
1059 >                      if (do_stress) call add_stress_tensor(d_grp, fij)
1060 >                   endif
1061                  endif
1062 <             end if
1062 >             endif
1063            enddo
1064 <
1064 >          
1065         enddo outer
1066  
1067         if (update_nlist) then
# Line 1110 | Line 1157 | contains
1157  
1158            if ( iand(iHash, ELECTROSTATIC_PAIR).ne.0 ) then
1159   #ifdef IS_MPI
1160 <             call rf_self_self(i, eFrame, pot_local(ELECTROSTATIC_POT), &
1160 >             call self_self(i, eFrame, pot_local(ELECTROSTATIC_POT), &
1161                    t, do_pot)
1162   #else
1163 <             call rf_self_self(i, eFrame, pot(ELECTROSTATIC_POT), &
1163 >             call self_self(i, eFrame, pot(ELECTROSTATIC_POT), &
1164                    t, do_pot)
1165   #endif
1166            endif
1167    
1168 <          ! loop over the excludes to accumulate any additional RF components
1169 <
1123 <          do i1 = 1, nSkipsForAtom(i)
1124 <             j = skipsForAtom(i, i1)
1168 >          
1169 >          if (electrostaticSummationMethod.eq.REACTION_FIELD) then
1170              
1171 <             ! prevent overcounting of the skips
1172 <             if (i.lt.j) then
1173 <                call get_interatomic_vector(q(:,i), &
1174 <                     q(:,j), d_atm, ratmsq)
1175 <                rVal = dsqrt(ratmsq)
1176 <                call get_switch(ratmsq, sw, dswdr, rVal, group_switch, &
1177 <                     in_switching_region)
1171 >             ! loop over the excludes to accumulate RF stuff we've
1172 >             ! left out of the normal pair loop
1173 >            
1174 >             do i1 = 1, nSkipsForAtom(i)
1175 >                j = skipsForAtom(i, i1)
1176 >                
1177 >                ! prevent overcounting of the skips
1178 >                if (i.lt.j) then
1179 >                   call get_interatomic_vector(q(:,i), &
1180 >                        q(:,j), d_atm, ratmsq)
1181 >                   rVal = dsqrt(ratmsq)
1182 >                   call get_switch(ratmsq, sw, dswdr, rVal, group_switch, &
1183 >                        in_switching_region)
1184   #ifdef IS_MPI
1185 <                call rf_self_excludes(i, j, sw, eFrame, d_atm, rVal, vpair, &
1186 <                     pot_local(ELECTROSTATIC_POT), f, t, do_pot)
1185 >                   call rf_self_excludes(i, j, sw, eFrame, d_atm, rVal, &
1186 >                        vpair, pot_local(ELECTROSTATIC_POT), f, t, do_pot)
1187   #else
1188 <                call rf_self_excludes(i, j, sw, eFrame, d_atm, rVal, vpair, &
1189 <                     pot(ELECTROSTATIC_POT), f, t, do_pot)
1188 >                   call rf_self_excludes(i, j, sw, eFrame, d_atm, rVal, &
1189 >                        vpair, pot(ELECTROSTATIC_POT), f, t, do_pot)
1190   #endif
1191 <             endif
1192 <          enddo
1193 <       enddo      
1191 >                endif
1192 >             enddo
1193 >          endif
1194 >       enddo
1195      endif
1196      
1197   #ifdef IS_MPI
# Line 1168 | Line 1220 | contains
1220    end subroutine do_force_loop
1221  
1222    subroutine do_pair(i, j, rijsq, d, sw, do_pot, &
1223 <       eFrame, A, f, t, pot, vpair, fpair, d_grp, r_grp, indirect_only)
1223 >       eFrame, A, f, t, pot, vpair, fpair, d_grp, r_grp, rCut)
1224  
1225      real( kind = dp ) :: vpair, sw
1226      real( kind = dp ), dimension(LR_POT_TYPES) :: pot
# Line 1180 | Line 1232 | contains
1232      real( kind = dp ), dimension(3,nLocal) :: t
1233  
1234      logical, intent(inout) :: do_pot
1183    logical, intent(inout) :: indirect_only
1235      integer, intent(in) :: i, j
1236      real ( kind = dp ), intent(inout) :: rijsq
1237      real ( kind = dp ), intent(inout) :: r_grp
1238      real ( kind = dp ), intent(inout) :: d(3)
1239      real ( kind = dp ), intent(inout) :: d_grp(3)
1240 +    real ( kind = dp ), intent(inout) :: rCut
1241      real ( kind = dp ) :: r
1242      integer :: me_i, me_j
1243  
# Line 1204 | Line 1256 | contains
1256   #endif
1257  
1258      iHash = InteractionHash(me_i, me_j)
1259 <
1260 <    if (indirect_only) then
1261 <       if ( iand(iHash, ELECTROSTATIC_PAIR).ne.0 ) then
1262 <          call doElectrostaticPair(i, j, d, r, rijsq, sw, vpair, fpair, &
1263 <               pot(ELECTROSTATIC_POT), eFrame, f, t, do_pot, indirect_only)
1264 <       endif
1265 <    else
1266 <          
1267 <       if ( iand(iHash, LJ_PAIR).ne.0 ) then
1268 <          call do_lj_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
1269 <               pot(VDW_POT), f, do_pot)
1270 <       endif
1259 >    
1260 >    if ( iand(iHash, LJ_PAIR).ne.0 ) then
1261 >       call do_lj_pair(i, j, d, r, rijsq, rcut, sw, vpair, fpair, &
1262 >            pot(VDW_POT), f, do_pot)
1263 >    endif
1264 >    
1265 >    if ( iand(iHash, ELECTROSTATIC_PAIR).ne.0 ) then
1266 >       call doElectrostaticPair(i, j, d, r, rijsq, rcut, sw, vpair, fpair, &
1267 >            pot(ELECTROSTATIC_POT), eFrame, f, t, do_pot)
1268 >    endif
1269 >    
1270 >    if ( iand(iHash, STICKY_PAIR).ne.0 ) then
1271 >       call do_sticky_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
1272 >            pot(HB_POT), A, f, t, do_pot)
1273 >    endif
1274 >    
1275 >    if ( iand(iHash, STICKYPOWER_PAIR).ne.0 ) then
1276 >       call do_sticky_power_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
1277 >            pot(HB_POT), A, f, t, do_pot)
1278 >    endif
1279 >    
1280 >    if ( iand(iHash, GAYBERNE_PAIR).ne.0 ) then
1281 >       call do_gb_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
1282 >            pot(VDW_POT), A, f, t, do_pot)
1283 >    endif
1284 >    
1285 >    if ( iand(iHash, GAYBERNE_LJ).ne.0 ) then
1286 >       call do_gb_lj_pair(i, j, d, r, rijsq, rcut, sw, vpair, fpair, &
1287 >            pot(VDW_POT), A, f, t, do_pot)
1288 >    endif
1289 >    
1290 >    if ( iand(iHash, EAM_PAIR).ne.0 ) then      
1291 >       call do_eam_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
1292 >            pot(METALLIC_POT), f, do_pot)
1293 >    endif
1294 >    
1295 >    if ( iand(iHash, SHAPE_PAIR).ne.0 ) then      
1296 >       call do_shape_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
1297 >            pot(VDW_POT), A, f, t, do_pot)
1298 >    endif
1299 >    
1300 >    if ( iand(iHash, SHAPE_LJ).ne.0 ) then      
1301 >       call do_shape_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
1302 >            pot(VDW_POT), A, f, t, do_pot)
1303 >    endif
1304  
1305 <       if ( iand(iHash, ELECTROSTATIC_PAIR).ne.0 ) then
1306 <          call doElectrostaticPair(i, j, d, r, rijsq, sw, vpair, fpair, &
1307 <               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
1305 >    if ( iand(iHash, SC_PAIR).ne.0 ) then      
1306 >       call do_SC_pair(i, j, d, r, rijsq, rcut, sw, vpair, fpair, &
1307 >            pot(METALLIC_POT), f, do_pot)
1308      endif
1309 +
1310      
1311 +    
1312    end subroutine do_pair
1313  
1314 <  subroutine do_prepair(i, j, rijsq, d, sw, rcijsq, dc, &
1314 >  subroutine do_prepair(i, j, rijsq, d, sw, rcijsq, dc, rCut, &
1315         do_pot, do_stress, eFrame, A, f, t, pot)
1316  
1317      real( kind = dp ) :: sw
# Line 1272 | Line 1323 | contains
1323  
1324      logical, intent(inout) :: do_pot, do_stress
1325      integer, intent(in) :: i, j
1326 <    real ( kind = dp ), intent(inout)    :: rijsq, rcijsq
1326 >    real ( kind = dp ), intent(inout)    :: rijsq, rcijsq, rCut
1327      real ( kind = dp )                :: r, rc
1328      real ( kind = dp ), intent(inout) :: d(3), dc(3)
1329  
# Line 1291 | Line 1342 | contains
1342      iHash = InteractionHash(me_i, me_j)
1343  
1344      if ( iand(iHash, EAM_PAIR).ne.0 ) then      
1345 <            call calc_EAM_prepair_rho(i, j, d, r, rijsq )
1345 >            call calc_EAM_prepair_rho(i, j, d, r, rijsq)
1346      endif
1347 +
1348 +    if ( iand(iHash, SC_PAIR).ne.0 ) then      
1349 +            call calc_SC_prepair_rho(i, j, d, r, rijsq, rcut )
1350 +    endif
1351      
1352    end subroutine do_prepair
1353  
# Line 1304 | Line 1359 | contains
1359      if (FF_uses_EAM .and. SIM_uses_EAM) then
1360         call calc_EAM_preforce_Frho(nlocal,pot(METALLIC_POT))
1361      endif
1362 +    if (FF_uses_SC .and. SIM_uses_SC) then
1363 +       call calc_SC_preforce_Frho(nlocal,pot(METALLIC_POT))
1364 +    endif
1365  
1366  
1367    end subroutine do_preforce
# Line 1388 | Line 1446 | contains
1446      pot_Col = 0.0_dp
1447      pot_Temp = 0.0_dp
1448  
1391    rf_Row = 0.0_dp
1392    rf_Col = 0.0_dp
1393    rf_Temp = 0.0_dp
1394
1449   #endif
1450  
1451      if (FF_uses_EAM .and. SIM_uses_EAM) then
1452         call clean_EAM()
1453      endif
1454  
1401    rf = 0.0_dp
1455      tau_Temp = 0.0_dp
1456      virial_Temp = 0.0_dp
1457    end subroutine zero_work_arrays
# Line 1492 | Line 1545 | contains
1545  
1546    function FF_RequiresPrepairCalc() result(doesit)
1547      logical :: doesit
1548 <    doesit = FF_uses_EAM
1548 >    doesit = FF_uses_EAM .or. FF_uses_SC &
1549 >         .or. FF_uses_MEAM
1550    end function FF_RequiresPrepairCalc
1551  
1552   #ifdef PROFILE

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines