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 2350 by chuckv, Mon Oct 10 21:20:46 2005 UTC vs.
Revision 2390 by chrisfen, Wed Oct 19 19:24:40 2005 UTC

# Line 45 | Line 45
45  
46   !! @author Charles F. Vardeman II
47   !! @author Matthew Meineke
48 < !! @version $Id: doForces.F90,v 1.51 2005-10-10 21:20:46 chuckv Exp $, $Date: 2005-10-10 21:20:46 $, $Name: not supported by cvs2svn $, $Revision: 1.51 $
48 > !! @version $Id: doForces.F90,v 1.61 2005-10-19 19:24:29 chrisfen Exp $, $Date: 2005-10-19 19:24:29 $, $Name: not supported by cvs2svn $, $Revision: 1.61 $
49  
50  
51   module doForces
# Line 58 | Line 58 | module doForces
58    use lj
59    use sticky
60    use electrostatic_module
61 <  use reaction_field_module
62 <  use gb_pair
61 >  use gayberne
62    use shapes
63    use vector_class
64    use eam
# Line 185 | Line 184 | contains
184  
185      if (.not. allocated(InteractionHash)) then
186         allocate(InteractionHash(nAtypes,nAtypes))
187 +    else
188 +       deallocate(InteractionHash)
189 +       allocate(InteractionHash(nAtypes,nAtypes))
190      endif
191  
192      if (.not. allocated(atypeMaxCutoff)) then
193         allocate(atypeMaxCutoff(nAtypes))
194 +    else
195 +       deallocate(atypeMaxCutoff)
196 +       allocate(atypeMaxCutoff(nAtypes))
197      endif
198          
199      do i = 1, nAtypes
# Line 265 | Line 270 | contains
270      logical :: GtypeFound
271  
272      integer :: myStatus, nAtypes,  i, j, istart, iend, jstart, jend
273 <    integer :: n_in_i, me_i, ia, g, atom1
273 >    integer :: n_in_i, me_i, ia, g, atom1, ja, n_in_j,me_j
274      integer :: nGroupsInRow
275      integer :: nGroupsInCol
276      integer :: nGroupTypesRow,nGroupTypesCol
# Line 377 | Line 382 | contains
382  
383   #ifdef IS_MPI
384         ! We only allocate new storage if we are in MPI because Ncol /= Nrow
385 <    if(.not.allocated(groupToGtypeCol)) then
385 >    if(.not.associated(groupToGtypeCol)) then
386         allocate(groupToGtypeCol(jend))
387      else
388         deallocate(groupToGtypeCol)
389         allocate(groupToGtypeCol(jend))
390      end if
391  
392 <    if(.not.allocated(groupToGtypeCol)) then
392 >    if(.not.associated(groupToGtypeCol)) then
393         allocate(groupToGtypeCol(jend))
394      else
395         deallocate(groupToGtypeCol)
396         allocate(groupToGtypeCol(jend))
397      end if
398 <    if(.not.allocated(gtypeMaxCutoffCol)) then
398 >    if(.not.associated(gtypeMaxCutoffCol)) then
399         allocate(gtypeMaxCutoffCol(jend))
400      else
401         deallocate(gtypeMaxCutoffCol)      
# Line 674 | Line 679 | contains
679  
680  
681      haveSaneForceField = .true.
677
678    !! check to make sure the reaction field setting makes sense
679
680    if (FF_uses_Dipoles) then
681       if (electrostaticSummationMethod == REACTION_FIELD) then
682          dielect = getDielect()
683          call initialize_rf(dielect)
684       endif
685    else
686       if (electrostaticSummationMethod == REACTION_FIELD) then
687          write(default_error,*) 'Using Reaction Field with no dipoles?  Huh?'
688          thisStat = -1
689          haveSaneForceField = .false.
690          return
691       endif
692    endif
682  
683      if (FF_uses_EAM) then
684         call init_EAM_FF(my_status)
# Line 701 | Line 690 | contains
690         end if
691      endif
692  
704    if (FF_uses_GayBerne) then
705       call check_gb_pair_FF(my_status)
706       if (my_status .ne. 0) then
707          thisStat = -1
708          haveSaneForceField = .false.
709          return
710       endif
711    endif
712
693      if (.not. haveNeighborList) then
694         !! Create neighbor lists
695         call expandNeighborList(nLocal, my_status)
# Line 743 | Line 723 | contains
723  
724      !! Stress Tensor
725      real( kind = dp), dimension(9) :: tau  
726 <    real ( kind = dp ) :: pot
726 >    real ( kind = dp ),dimension(LR_POT_TYPES) :: pot
727      logical ( kind = 2) :: do_pot_c, do_stress_c
728      logical :: do_pot
729      logical :: do_stress
730      logical :: in_switching_region
731   #ifdef IS_MPI
732 <    real( kind = DP ) :: pot_local
732 >    real( kind = DP ), dimension(LR_POT_TYPES) :: pot_local
733      integer :: nAtomsInRow
734      integer :: nAtomsInCol
735      integer :: nprocs
# Line 1082 | Line 1062 | contains
1062  
1063      if (do_pot) then
1064         ! scatter/gather pot_row into the members of my column
1065 <       call scatter(pot_Row, pot_Temp, plan_atom_row)
1066 <
1065 >       do i = 1,LR_POT_TYPES
1066 >          call scatter(pot_Row(i,:), pot_Temp(i,:), plan_atom_row)
1067 >       end do
1068         ! scatter/gather pot_local into all other procs
1069         ! add resultant to get total pot
1070         do i = 1, nlocal
1071 <          pot_local = pot_local + pot_Temp(i)
1071 >          pot_local(1:LR_POT_TYPES) = pot_local(1:LR_POT_TYPES) &
1072 >               + pot_Temp(1:LR_POT_TYPES,i)
1073         enddo
1074  
1075         pot_Temp = 0.0_DP
1076 <
1077 <       call scatter(pot_Col, pot_Temp, plan_atom_col)
1076 >       do i = 1,LR_POT_TYPES
1077 >          call scatter(pot_Col(i,:), pot_Temp(i,:), plan_atom_col)
1078 >       end do
1079         do i = 1, nlocal
1080 <          pot_local = pot_local + pot_Temp(i)
1080 >          pot_local(1:LR_POT_TYPES) = pot_local(1:LR_POT_TYPES)&
1081 >               + pot_Temp(1:LR_POT_TYPES,i)
1082         enddo
1083  
1084      endif
1085   #endif
1102
1103    if (FF_RequiresPostpairCalc() .and. SIM_requires_postpair_calc) then
1104
1105       if (electrostaticSummationMethod == REACTION_FIELD) then
1086  
1087 +    if (SIM_requires_postpair_calc) then
1088 +      
1089   #ifdef IS_MPI
1090 <          call scatter(rf_Row,rf,plan_atom_row_3d)
1091 <          call scatter(rf_Col,rf_Temp,plan_atom_col_3d)
1092 <          do i = 1,nlocal
1093 <             rf(1:3,i) = rf(1:3,i) + rf_Temp(1:3,i)
1094 <          end do
1090 >       call scatter(rf_Row,rf,plan_atom_row_3d)
1091 >       call scatter(rf_Col,rf_Temp,plan_atom_col_3d)
1092 >       do i = 1,nlocal
1093 >          rf(1:3,i) = rf(1:3,i) + rf_Temp(1:3,i)
1094 >       end do
1095   #endif
1096  
1097 <          do i = 1, nLocal
1098 <
1099 <             rfpot = 0.0_DP
1097 >       do i = 1, nLocal
1098 >          
1099 >          rfpot = 0.0_DP
1100   #ifdef IS_MPI
1101 <             me_i = atid_row(i)
1101 >          me_i = atid_row(i)
1102   #else
1103 <             me_i = atid(i)
1103 >          me_i = atid(i)
1104   #endif
1105 <             iHash = InteractionHash(me_i,me_j)
1105 >          iHash = InteractionHash(me_i,me_j)
1106 >          
1107 >          if ( iand(iHash, ELECTROSTATIC_PAIR).ne.0 ) then
1108              
1109 <             if ( iand(iHash, ELECTROSTATIC_PAIR).ne.0 ) then
1110 <
1111 <                mu_i = getDipoleMoment(me_i)
1112 <
1113 <                !! The reaction field needs to include a self contribution
1114 <                !! to the field:
1115 <                call accumulate_self_rf(i, mu_i, eFrame)
1116 <                !! Get the reaction field contribution to the
1133 <                !! potential and torques:
1134 <                call reaction_field_final(i, mu_i, eFrame, rfpot, t, do_pot)
1109 >             mu_i = getDipoleMoment(me_i)
1110 >            
1111 >             !! The reaction field needs to include a self contribution
1112 >             !! to the field:
1113 >             call accumulate_self_rf(i, mu_i, eFrame)
1114 >             !! Get the reaction field contribution to the
1115 >             !! potential and torques:
1116 >             call reaction_field_final(i, mu_i, eFrame, rfpot, t, do_pot)
1117   #ifdef IS_MPI
1118 <                pot_local = pot_local + rfpot
1118 >             pot_local(ELECTROSTATIC_POT) = pot_local(ELECTROSTATIC_POT) + rfpot
1119   #else
1120 <                pot = pot + rfpot
1121 <
1120 >             pot(ELECTROSTATIC_POT) = pot(ELECTROSTATIC_POT) + rfpot
1121 >            
1122   #endif
1123 <             endif
1124 <          enddo
1143 <       endif
1123 >          endif
1124 >       enddo
1125      endif
1126 <
1146 <
1126 >    
1127   #ifdef IS_MPI
1128  
1129      if (do_pot) then
1130 <       pot = pot + pot_local
1130 >       pot(1:LR_POT_TYPES) = pot(1:LR_POT_TYPES) &
1131 >            + pot_local(1:LR_POT_TYPES)
1132         !! we assume the c code will do the allreduce to get the total potential
1133         !! we could do it right here if we needed to...
1134      endif
# Line 1173 | Line 1154 | contains
1154    subroutine do_pair(i, j, rijsq, d, sw, do_pot, &
1155         eFrame, A, f, t, pot, vpair, fpair)
1156  
1157 <    real( kind = dp ) :: pot, vpair, sw
1157 >    real( kind = dp ) :: vpair, sw
1158 >    real( kind = dp ), dimension(LR_POT_TYPES) :: pot
1159      real( kind = dp ), dimension(3) :: fpair
1160      real( kind = dp ), dimension(nLocal)   :: mfact
1161      real( kind = dp ), dimension(9,nLocal) :: eFrame
# Line 1205 | Line 1187 | contains
1187      iHash = InteractionHash(me_i, me_j)
1188  
1189      if ( iand(iHash, LJ_PAIR).ne.0 ) then
1190 <       call do_lj_pair(i, j, d, r, rijsq, sw, vpair, fpair, pot, f, do_pot)
1190 >       call do_lj_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
1191 >            pot(VDW_POT), f, do_pot)
1192      endif
1193  
1194      if ( iand(iHash, ELECTROSTATIC_PAIR).ne.0 ) then
1195         call doElectrostaticPair(i, j, d, r, rijsq, sw, vpair, fpair, &
1196 <            pot, eFrame, f, t, do_pot)
1196 >            pot(ELECTROSTATIC_POT), eFrame, f, t, do_pot)
1197  
1198         if (electrostaticSummationMethod == REACTION_FIELD) then
1199  
# Line 1223 | Line 1206 | contains
1206  
1207      if ( iand(iHash, STICKY_PAIR).ne.0 ) then
1208         call do_sticky_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
1209 <            pot, A, f, t, do_pot)
1209 >            pot(HB_POT), A, f, t, do_pot)
1210      endif
1211  
1212      if ( iand(iHash, STICKYPOWER_PAIR).ne.0 ) then
1213         call do_sticky_power_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
1214 <            pot, A, f, t, do_pot)
1214 >            pot(HB_POT), A, f, t, do_pot)
1215      endif
1216  
1217      if ( iand(iHash, GAYBERNE_PAIR).ne.0 ) then
1218         call do_gb_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
1219 <            pot, A, f, t, do_pot)
1219 >            pot(VDW_POT), A, f, t, do_pot)
1220      endif
1221      
1222      if ( iand(iHash, GAYBERNE_LJ).ne.0 ) then
1223 < !      call do_gblj_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
1224 < !           pot, A, f, t, do_pot)
1223 >       call do_gb_lj_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
1224 >            pot(VDW_POT), A, f, t, do_pot)
1225      endif
1226  
1227      if ( iand(iHash, EAM_PAIR).ne.0 ) then      
1228 <       call do_eam_pair(i, j, d, r, rijsq, sw, vpair, fpair, pot, f, &
1229 <            do_pot)
1228 >       call do_eam_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
1229 >            pot(METALLIC_POT), f, do_pot)
1230      endif
1231  
1232      if ( iand(iHash, SHAPE_PAIR).ne.0 ) then      
1233         call do_shape_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
1234 <            pot, A, f, t, do_pot)
1234 >            pot(VDW_POT), A, f, t, do_pot)
1235      endif
1236  
1237      if ( iand(iHash, SHAPE_LJ).ne.0 ) then      
1238         call do_shape_pair(i, j, d, r, rijsq, sw, vpair, fpair, &
1239 <            pot, A, f, t, do_pot)
1239 >            pot(VDW_POT), A, f, t, do_pot)
1240      endif
1241      
1242    end subroutine do_pair
# Line 1261 | Line 1244 | contains
1244    subroutine do_prepair(i, j, rijsq, d, sw, rcijsq, dc, &
1245         do_pot, do_stress, eFrame, A, f, t, pot)
1246  
1247 <    real( kind = dp ) :: pot, sw
1247 >    real( kind = dp ) :: sw
1248 >    real( kind = dp ), dimension(LR_POT_TYPES) :: pot
1249      real( kind = dp ), dimension(9,nLocal) :: eFrame
1250      real (kind=dp), dimension(9,nLocal) :: A
1251      real (kind=dp), dimension(3,nLocal) :: f
# Line 1296 | Line 1280 | contains
1280  
1281    subroutine do_preforce(nlocal,pot)
1282      integer :: nlocal
1283 <    real( kind = dp ) :: pot
1283 >    real( kind = dp ),dimension(LR_POT_TYPES) :: pot
1284  
1285      if (FF_uses_EAM .and. SIM_uses_EAM) then
1286 <       call calc_EAM_preforce_Frho(nlocal,pot)
1286 >       call calc_EAM_preforce_Frho(nlocal,pot(METALLIC_POT))
1287      endif
1288  
1289  
# Line 1492 | Line 1476 | contains
1476      doesit = FF_uses_EAM
1477    end function FF_RequiresPrepairCalc
1478  
1495  function FF_RequiresPostpairCalc() result(doesit)
1496    logical :: doesit
1497    if (electrostaticSummationMethod == REACTION_FIELD) doesit = .true.
1498  end function FF_RequiresPostpairCalc
1499
1479   #ifdef PROFILE
1480    function getforcetime() result(totalforcetime)
1481      real(kind=dp) :: totalforcetime

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines