--- trunk/OOPSE/libmdtools/do_Forces.F90 2004/05/12 15:58:35 1166 +++ trunk/OOPSE/libmdtools/do_Forces.F90 2004/05/26 16:41:23 1197 @@ -4,7 +4,7 @@ !! @author Charles F. Vardeman II !! @author Matthew Meineke -!! @version $Id: do_Forces.F90,v 1.57 2004-05-12 15:58:35 gezelter Exp $, $Date: 2004-05-12 15:58:35 $, $Name: not supported by cvs2svn $, $Revision: 1.57 $ +!! @version $Id: do_Forces.F90,v 1.62 2004-05-26 16:41:23 gezelter Exp $, $Date: 2004-05-26 16:41:23 $, $Name: not supported by cvs2svn $, $Revision: 1.62 $ module do_Forces use force_globals @@ -33,6 +33,9 @@ module do_Forces #include "fForceField.h" #include "fSwitchingFunction.h" + INTEGER, PARAMETER:: PREPAIR_LOOP = 1 + INTEGER, PARAMETER:: PAIR_LOOP = 2 + logical, save :: haveRlist = .false. logical, save :: haveNeighborList = .false. logical, save :: havePolicies = .false. @@ -399,19 +402,21 @@ contains #endif integer :: natoms logical :: update_nlist - integer :: i, j, jbeg, jend, jnab + integer :: i, j, jstart, jend, jnab + integer :: istart, iend integer :: ia, jb, atom1, atom2 integer :: nlist - real( kind = DP ) :: ratmsq, rgrpsq, rgrp, vpair, vab + real( kind = DP ) :: ratmsq, rgrpsq, rgrp, vpair, vij real( kind = DP ) :: sw, dswdr, swderiv, mf - real(kind=dp),dimension(3) :: d_atm, d_grp + real(kind=dp),dimension(3) :: d_atm, d_grp, fpair, fij real(kind=dp) :: rfpot, mu_i, virial - integer :: me_i, me_j + integer :: me_i, me_j, n_in_i, n_in_j logical :: is_dp_i integer :: neighborListSize integer :: listerror, error integer :: localError integer :: propPack_i, propPack_j + integer :: loopStart, loopEnd, loop real(kind=dp) :: listSkin = 1.0 @@ -464,127 +469,70 @@ contains nloops = nloops + 1 #endif + loopEnd = PAIR_LOOP if (FF_RequiresPrepairCalc() .and. SIM_requires_prepair_calc) then - !! See if we need to update neighbor lists + loopStart = PREPAIR_LOOP + else + loopStart = PAIR_LOOP + endif - call checkNeighborList(nGroup, q_group, listSkin, update_nlist) + do loop = loopStart, loopEnd - !! if_mpi_gather_stuff_for_prepair - !! do_prepair_loop_if_needed - !! if_mpi_scatter_stuff_from_prepair - !! if_mpi_gather_stuff_from_prepair_to_main_loop + ! See if we need to update neighbor lists + ! (but only on the first time through): + if (loop .eq. loopStart) then + call checkNeighborList(nGroup, q_group, listSkin, update_nlist) + endif - !--------------------PREFORCE LOOP----------->>>>>>>>>>>>>>>>>>>>>>>>>>> -#ifdef IS_MPI - if (update_nlist) then - - !! save current configuration, construct neighbor list, - !! and calculate forces - - call saveNeighborList(nGroup, q_group) - + !! save current configuration and construct neighbor list + call saveNeighborList(nGroup, q_group) neighborListSize = size(list) - nlist = 0 - - do i = 1, nrow_group - point(i) = nlist + 1 - - do j = 1, ncol_group - - call get_interatomic_vector(q_group_Row(:,i), & - q_group_Col(:,j), d_grp, rgrpsq) - - if (rgrpsq < rlistsq) then - nlist = nlist + 1 - - if (nlist > neighborListSize) then - call expandNeighborList(nGroup, listerror) - if (listerror /= 0) then - error = -1 - write(DEFAULT_ERROR,*) "ERROR: nlist > list size and max allocations exceeded." - return - end if - neighborListSize = size(list) - endif - - list(nlist) = j - - do ia = groupStart(i), groupStart(i+1)-1 - atom1 = groupList(ia) - - prepair_inner: do jb = groupStart(j), groupStart(j+1)-1 - atom2 = groupList(jb) - - if (skipThisPair(atom1, atom2)) cycle prepair_inner - - call get_interatomic_vector(q_Row(:,atom1), & - q_Col(:,atom2), d_atm, ratmsq) - - call do_prepair(atom1, atom2, ratmsq, d_atm, & - rgrpsq, d_grp, do_pot, do_stress, & - u_l, A, f, t, pot_local) - - enddo prepair_inner - enddo - end if - enddo - enddo - point(nrow_group + 1) = nlist + 1 - - else !! (of update_check) - - ! use the list to find the neighbors - do i = 1, nrow_group - JBEG = POINT(i) - JEND = POINT(i+1) - 1 - ! check that group i has neighbors - if (jbeg .le. jend) then - - do jnab = jbeg, jend - j = list(jnab) - - do ia = groupStart(i), groupStart(i+1)-1 - atom1 = groupList(ia) - - do jb = groupStart(j), groupStart(j+1)-1 - atom2 = groupList(jb) - - call get_interatomic_vector(q_Row(:,atom1), & - q_Col(:,atom2), d_atm, ratmsq) - - call do_prepair(atom1, atom2, ratmsq, d_atm, & - rgrpsq, d_grp, do_pot, do_stress, & - u_l, A, f, t, pot_local) - - enddo - enddo - enddo - endif - enddo + nlist = 0 endif + istart = 1 +#ifdef IS_MPI + iend = nrow_group #else - - if (update_nlist) then + iend = nGroup - 1 +#endif + outer: do i = istart, iend - !! save current configuration, construct neighbor list, - !! and calculate forces + if (update_nlist) point(i) = nlist + 1 - call saveNeighborList(nGroup, q_group) + n_in_i = groupStart(i+1) - groupStart(i) - neighborListSize = size(list) - nlist = 0 + if (update_nlist) then +#ifdef IS_MPI + jstart = 1 + jend = ncol_group +#else + jstart = i+1 + jend = nGroup +#endif + else + jstart = point(i) + jend = point(i+1) - 1 + ! make sure group i has neighbors + if (jstart .gt. jend) cycle outer + endif - do i = 1, nGroup-1 - point(i) = nlist + 1 - - do j = i+1, nGroup - - call get_interatomic_vector(q_group(:,i), & - q_group(:,j), d_grp, rgrpsq) - - if (rgrpsq < rlistsq) then + do jnab = jstart, jend + if (update_nlist) then + j = jnab + else + j = list(jnab) + endif +#ifdef IS_MPI + call get_interatomic_vector(q_group_Row(:,i), & + q_group_Col(:,j), d_grp, rgrpsq) +#else + call get_interatomic_vector(q_group(:,i), & + q_group(:,j), d_grp, rgrpsq) +#endif + if (rgrpsq < rlistsq) then + if (update_nlist) then nlist = nlist + 1 if (nlist > neighborListSize) then @@ -598,370 +546,128 @@ contains endif list(nlist) = j - - do ia = groupStart(i), groupStart(i+1)-1 - atom1 = groupList(ia) - - prepair_inner: do jb = groupStart(j), groupStart(j+1)-1 - atom2 = groupList(jb) - - if (skipThisPair(atom1, atom2)) cycle prepair_inner - - call get_interatomic_vector(q(:,atom1), & - q(:,atom2), d_atm, ratmsq) - - call do_prepair(atom1, atom2, ratmsq, d_atm, & - rgrpsq, d_grp, do_pot, do_stress, & - u_l, A, f, t, pot) - - enddo prepair_inner - enddo - end if - enddo - enddo - point(nGroup) = nlist + 1 - - else !! (of update_check) - - ! use the list to find the neighbors - do i = 1, nGroup-1 - JBEG = POINT(i) - JEND = POINT(i+1) - 1 - ! check that group i has neighbors - if (jbeg .le. jend) then - - do jnab = jbeg, jend - j = list(jnab) - - do ia = groupStart(i), groupStart(i+1)-1 - atom1 = groupList(ia) - - do jb = groupStart(j), groupStart(j+1)-1 - atom2 = groupList(jb) - - call get_interatomic_vector(q(:,atom1), & - q(:,atom2), d_atm, ratmsq) - - call do_prepair(atom1, atom2, ratmsq, d_atm, & - rgrpsq, d_grp, do_pot, do_stress, & - u_l, A, f, t, pot) - - enddo - enddo - enddo - endif - enddo - endif - -#endif - - !! Do rest of preforce calculations - !! do necessary preforce calculations - call do_preforce(nlocal,pot) - ! we have already updated the neighbor list set it to false... - update_nlist = .false. - else - !! See if we need to update neighbor lists for non pre-pair - call checkNeighborList(nGroup, q_group, listSkin, update_nlist) - endif - - !---------------------------------MAIN Pair LOOP->>>>>>>>>>>>> - -#ifdef IS_MPI - - if (update_nlist) then - - !! save current configuration, construct neighbor list, - !! and calculate forces - - call saveNeighborList(nGroup, q_group) - - neighborListSize = size(list) - nlist = 0 - - do i = 1, nrow_group - point(i) = nlist + 1 - - do j = 1, ncol_group - - call get_interatomic_vector(q_group_Row(:,i), & - q_group_Col(:,j), d_grp, rgrpsq) - - if (rgrpsq < rlistsq) then - nlist = nlist + 1 - - if (nlist > neighborListSize) then - call expandNeighborList(nGroup, listerror) - if (listerror /= 0) then - error = -1 - write(DEFAULT_ERROR,*) "ERROR: nlist > list size and max allocations exceeded." - return - end if - neighborListSize = size(list) endif - list(nlist) = j - - vab = 0.0d0 - call get_switch(rgrpsq, sw, dswdr, rgrp, group_switch, & - in_switching_region) - - do ia = groupStart(i), groupStart(i+1)-1 - atom1 = groupList(ia) - - inner: do jb = groupStart(j), groupStart(j+1)-1 - atom2 = groupList(jb) - - if (skipThisPair(atom1, atom2)) cycle inner - - call get_interatomic_vector(q_Row(:,atom1), & - q_Col(:,atom2), d_atm, ratmsq) - - call do_pair(atom1, atom2, ratmsq, d_atm, sw, & - do_pot, do_stress, & - u_l, A, f, t, pot_local, vpair) - - vab = vab + vpair - enddo inner - enddo - - if (in_switching_region) then - swderiv = vab*dswdr/rgrp - - do ia=groupStart(i), groupStart(i+1)-1 - atom1=groupList(ia) - mf = mfact(atom1) - f_Row(1,atom1) = f_Row(1,atom1) - swderiv*d_grp(1)*mf - f_Row(2,atom1) = f_Row(2,atom1) - swderiv*d_grp(2)*mf - f_Row(3,atom1) = f_Row(3,atom1) - swderiv*d_grp(3)*mf - enddo - - do jb=groupStart(j), groupStart(j+1)-1 - atom2=groupList(jb) - mf = mfact(atom2) - f_Col(1,atom2) = f_Col(1,atom2) + swderiv*d_grp(1)*mf - f_Col(2,atom2) = f_Col(2,atom2) + swderiv*d_grp(2)*mf - f_Col(3,atom2) = f_Col(3,atom2) + swderiv*d_grp(3)*mf - enddo + if (loop .eq. PAIR_LOOP) then + vij = 0.0d0 + fij(1:3) = 0.0d0 endif - - end if - enddo - enddo - point(nrow_group + 1) = nlist + 1 - - else !! (of update_check) - - ! use the list to find the neighbors - do i = 1, nrow_group - JBEG = POINT(i) - JEND = POINT(i+1) - 1 - ! check that group i has neighbors - if (jbeg .le. jend) then - - do jnab = jbeg, jend - j = list(jnab) - - call get_interatomic_vector(q_group_Row(:,i), & - q_group_Col(:,j), d_grp, rgrpsq) - vab = 0.0d0 call get_switch(rgrpsq, sw, dswdr, rgrp, group_switch, & in_switching_region) - do ia = groupStart(i), groupStart(i+1)-1 - atom1 = groupList(ia) - - do jb = groupStart(j), groupStart(j+1)-1 - atom2 = groupList(jb) - write(*,*) 'doing ', atom1, atom2 - - call get_interatomic_vector(q_Row(:,atom1), & - q_Col(:,atom2), d_atm, ratmsq) - - call do_pair(atom1, atom2, ratmsq, d_atm, sw, & - do_pot, do_stress, & - u_l, A, f, t, pot_local, vpair) - - vab = vab + vpair - - enddo - enddo + n_in_j = groupStart(j+1) - groupStart(j) - if (in_switching_region) then - swderiv = vab*dswdr/rgrp - - do ia=groupStart(i), groupStart(i+1)-1 - atom1=groupList(ia) - mf = mfact(atom1) - f_Row(1,atom1) = f_Row(1,atom1) - swderiv*d_grp(1)*mf - f_Row(2,atom1) = f_Row(2,atom1) - swderiv*d_grp(2)*mf - f_Row(3,atom1) = f_Row(3,atom1) - swderiv*d_grp(3)*mf - enddo - - do jb=groupStart(j), groupStart(j+1)-1 - atom2=groupList(jb) - mf = mfact(atom2) - f_Col(1,atom2) = f_Col(1,atom2) + swderiv*d_grp(1)*mf - f_Col(2,atom2) = f_Col(2,atom2) + swderiv*d_grp(2)*mf - f_Col(3,atom2) = f_Col(3,atom2) + swderiv*d_grp(3)*mf - enddo - endif - - enddo - endif - enddo - endif - -#else - - if (update_nlist) then - - !! save current configuration, construct neighbor list, - !! and calculate forces - - call saveNeighborList(nGroup, q_group) - - neighborListSize = size(list) - nlist = 0 - - do i = 1, nGroup-1 - point(i) = nlist + 1 - - do j = i+1, nGroup - - call get_interatomic_vector(q_group(:,i), & - q_group(:,j), d_grp, rgrpsq) - - if (rgrpsq < rlistsq) then - nlist = nlist + 1 - - if (nlist > neighborListSize) then - call expandNeighborList(nGroup, listerror) - if (listerror /= 0) then - error = -1 - write(DEFAULT_ERROR,*) "ERROR: nlist > list size and max allocations exceeded." - return - end if - neighborListSize = size(list) - endif - - list(nlist) = j - - vab = 0.0d0 - call get_switch(rgrpsq, sw, dswdr, rgrp, group_switch, & - in_switching_region) - do ia = groupStart(i), groupStart(i+1)-1 + atom1 = groupList(ia) inner: do jb = groupStart(j), groupStart(j+1)-1 + atom2 = groupList(jb) if (skipThisPair(atom1, atom2)) cycle inner - call get_interatomic_vector(q(:,atom1), & - q(:,atom2), d_atm, ratmsq) - - call do_pair(atom1, atom2, ratmsq, d_atm, sw, & - do_pot, do_stress, & - u_l, A, f, t, pot, vpair) - - vab = vab + vpair - + if ((n_in_i .eq. 1).and.(n_in_j .eq. 1)) then + d_atm(1:3) = d_grp(1:3) + ratmsq = rgrpsq + else +#ifdef IS_MPI + call get_interatomic_vector(q_Row(:,atom1), & + q_Col(:,atom2), d_atm, ratmsq) +#else + call get_interatomic_vector(q(:,atom1), & + q(:,atom2), d_atm, ratmsq) +#endif + endif + if (loop .eq. PREPAIR_LOOP) then +#ifdef IS_MPI + call do_prepair(atom1, atom2, ratmsq, d_atm, sw, & + rgrpsq, d_grp, do_pot, do_stress, & + u_l, A, f, t, pot_local) +#else + call do_prepair(atom1, atom2, ratmsq, d_atm, sw, & + rgrpsq, d_grp, do_pot, do_stress, & + u_l, A, f, t, pot) +#endif + else +#ifdef IS_MPI + call do_pair(atom1, atom2, ratmsq, d_atm, sw, & + do_pot, & + u_l, A, f, t, pot_local, vpair, fpair) +#else + call do_pair(atom1, atom2, ratmsq, d_atm, sw, & + do_pot, & + u_l, A, f, t, pot, vpair, fpair) +#endif + vij = vij + vpair + fij(1:3) = fij(1:3) + fpair(1:3) + endif enddo inner enddo - - if (in_switching_region) then - swderiv = vab*dswdr/rgrp - do ia=groupStart(i), groupStart(i+1)-1 - atom1=groupList(ia) - mf = mfact(atom1) - f(1,atom1) = f(1,atom1) - swderiv*d_grp(1)*mf - f(2,atom1) = f(2,atom1) - swderiv*d_grp(2)*mf - f(3,atom1) = f(3,atom1) - swderiv*d_grp(3)*mf - enddo + + if (loop .eq. PAIR_LOOP) then + if (in_switching_region) then + swderiv = vij*dswdr/rgrp + fij(1) = fij(1) + swderiv*d_grp(1) + fij(2) = fij(2) + swderiv*d_grp(2) + fij(3) = fij(3) + swderiv*d_grp(3) + + do ia=groupStart(i), groupStart(i+1)-1 + atom1=groupList(ia) + mf = mfact(atom1) +#ifdef IS_MPI + f_Row(1,atom1) = f_Row(1,atom1) + swderiv*d_grp(1)*mf + f_Row(2,atom1) = f_Row(2,atom1) + swderiv*d_grp(2)*mf + f_Row(3,atom1) = f_Row(3,atom1) + swderiv*d_grp(3)*mf +#else + f(1,atom1) = f(1,atom1) + swderiv*d_grp(1)*mf + f(2,atom1) = f(2,atom1) + swderiv*d_grp(2)*mf + f(3,atom1) = f(3,atom1) + swderiv*d_grp(3)*mf +#endif + enddo + + do jb=groupStart(j), groupStart(j+1)-1 + atom2=groupList(jb) + mf = mfact(atom2) +#ifdef IS_MPI + f_Col(1,atom2) = f_Col(1,atom2) - swderiv*d_grp(1)*mf + f_Col(2,atom2) = f_Col(2,atom2) - swderiv*d_grp(2)*mf + f_Col(3,atom2) = f_Col(3,atom2) - swderiv*d_grp(3)*mf +#else + f(1,atom2) = f(1,atom2) - swderiv*d_grp(1)*mf + f(2,atom2) = f(2,atom2) - swderiv*d_grp(2)*mf + f(3,atom2) = f(3,atom2) - swderiv*d_grp(3)*mf +#endif + enddo + endif - do jb=groupStart(j), groupStart(j+1)-1 - atom2=groupList(jb) - mf = mfact(atom2) - f(1,atom2) = f(1,atom2) + swderiv*d_grp(1)*mf - f(2,atom2) = f(2,atom2) + swderiv*d_grp(2)*mf - f(3,atom2) = f(3,atom2) + swderiv*d_grp(3)*mf - enddo + if (do_stress) call add_stress_tensor(d_grp, fij) endif - end if enddo - enddo - point(nGroup) = nlist + 1 + enddo outer - else !! (of update_check) - - ! use the list to find the neighbors - do i = 1, nGroup-1 - JBEG = POINT(i) - JEND = POINT(i+1) - 1 - ! check that group i has neighbors - if (jbeg .le. jend) then - - do jnab = jbeg, jend - j = list(jnab) - - call get_interatomic_vector(q_group(:,i), & - q_group(:,j), d_grp, rgrpsq) - - vab = 0.0d0 - - call get_switch(rgrpsq, sw, dswdr, rgrp, group_switch, & - in_switching_region) - - do ia = groupStart(i), groupStart(i+1)-1 - atom1 = groupList(ia) - - do jb = groupStart(j), groupStart(j+1)-1 - atom2 = groupList(jb) - - call get_interatomic_vector(q(:,atom1), & - q(:,atom2), d_atm, ratmsq) - - call do_pair(atom1, atom2, ratmsq, d_atm, sw, & - do_pot, do_stress, & - u_l, A, f, t, pot, vpair) - - vab = vab + vpair - - enddo - enddo - - if (in_switching_region) then - swderiv = vab*dswdr/rgrp - - do ia=groupStart(i), groupStart(i+1)-1 - atom1=groupList(ia) - mf = mfact(atom1) - f(1,atom1) = f(1,atom1) - swderiv*d_grp(1)*mf - f(2,atom1) = f(2,atom1) - swderiv*d_grp(2)*mf - f(3,atom1) = f(3,atom1) - swderiv*d_grp(3)*mf - enddo - - do jb=groupStart(j), groupStart(j+1)-1 - atom2=groupList(jb) - mf = mfact(atom2) - f(1,atom2) = f(1,atom2) + swderiv*d_grp(1)*mf - f(2,atom2) = f(2,atom2) + swderiv*d_grp(2)*mf - f(3,atom2) = f(3,atom2) + swderiv*d_grp(3)*mf - enddo - endif - enddo + if (update_nlist) then +#ifdef IS_MPI + point(nrow_group + 1) = nlist + 1 +#else + point(nGroup) = nlist + 1 +#endif + if (loop .eq. PREPAIR_LOOP) then + ! we just did the neighbor list update on the first + ! pass, so we don't need to do it + ! again on the second pass + update_nlist = .false. endif - enddo - endif - -#endif + endif + + if (loop .eq. PREPAIR_LOOP) then + call do_preforce(nlocal, pot) + endif + + enddo - ! phew, done with main loop. - !! Do timing #ifdef PROFILE call cpu_time(forceTimeFinal) @@ -1083,22 +789,21 @@ contains endif #endif - - + end subroutine do_force_loop - - subroutine do_pair(i, j, rijsq, d, sw, do_pot, do_stress, & - u_l, A, f, t, pot, vpair) + subroutine do_pair(i, j, rijsq, d, sw, do_pot, & + u_l, A, f, t, pot, vpair, fpair) real( kind = dp ) :: pot, vpair, sw + real( kind = dp ), dimension(3) :: fpair real( kind = dp ), dimension(nLocal) :: mfact real( kind = dp ), dimension(3,nLocal) :: u_l real( kind = dp ), dimension(9,nLocal) :: A real( kind = dp ), dimension(3,nLocal) :: f real( kind = dp ), dimension(3,nLocal) :: t - logical, intent(inout) :: do_pot, do_stress + logical, intent(inout) :: do_pot integer, intent(in) :: i, j real ( kind = dp ), intent(inout) :: rijsq real ( kind = dp ) :: r @@ -1107,6 +812,7 @@ contains r = sqrt(rijsq) vpair = 0.0d0 + fpair(1:3) = 0.0d0 #ifdef IS_MPI if (tagRow(i) .eq. tagColumn(j)) then @@ -1128,8 +834,7 @@ contains !write(*,'(3es12.3)') sw, vpair, pot !write(*,*) - call do_lj_pair(i, j, d, r, rijsq, sw, vpair, pot, f, do_pot, & - do_stress) + call do_lj_pair(i, j, d, r, rijsq, sw, vpair, fpair, pot, f, do_pot) endif endif @@ -1137,8 +842,7 @@ contains if (FF_uses_charges .and. SIM_uses_charges) then if (PropertyMap(me_i)%is_Charge .and. PropertyMap(me_j)%is_Charge) then - call do_charge_pair(i, j, d, r, rijsq, sw, vpair, pot, f, do_pot, & - do_stress) + call do_charge_pair(i, j, d, r, rijsq, sw, vpair, fpair, pot, f, do_pot) endif endif @@ -1146,11 +850,11 @@ contains if (FF_uses_dipoles .and. SIM_uses_dipoles) then if ( PropertyMap(me_i)%is_DP .and. PropertyMap(me_j)%is_DP) then - call do_dipole_pair(i, j, d, r, rijsq, sw, vpair, pot, u_l, f, t, & - do_pot, do_stress) + call do_dipole_pair(i, j, d, r, rijsq, sw, vpair, fpair, pot, u_l, f, t, & + do_pot) if (FF_uses_RF .and. SIM_uses_RF) then call accumulate_rf(i, j, r, u_l, sw) - call rf_correct_forces(i, j, d, r, u_l, sw, f, do_stress) + call rf_correct_forces(i, j, d, r, u_l, sw, f, fpair) endif endif @@ -1159,8 +863,8 @@ contains if (FF_uses_Sticky .and. SIM_uses_sticky) then if ( PropertyMap(me_i)%is_Sticky .and. PropertyMap(me_j)%is_Sticky) then - call do_sticky_pair(i, j, d, r, rijsq, sw, vpair, pot, A, f, t, & - do_pot, do_stress) + call do_sticky_pair(i, j, d, r, rijsq, sw, vpair, fpair, pot, A, f, t, & + do_pot) endif endif @@ -1169,8 +873,8 @@ contains if (FF_uses_GB .and. SIM_uses_GB) then if ( PropertyMap(me_i)%is_GB .and. PropertyMap(me_j)%is_GB) then - call do_gb_pair(i, j, d, r, rijsq, sw, vpair, pot, u_l, f, t, & - do_pot, do_stress) + call do_gb_pair(i, j, d, r, rijsq, sw, vpair, fpair, pot, u_l, f, t, & + do_pot) endif endif @@ -1178,17 +882,18 @@ contains if (FF_uses_EAM .and. SIM_uses_EAM) then if ( PropertyMap(me_i)%is_EAM .and. PropertyMap(me_j)%is_EAM) then - call do_eam_pair(i, j, d, r, rijsq, sw, vpair, pot, f, & - do_pot, do_stress) + call do_eam_pair(i, j, d, r, rijsq, sw, vpair, fpair, pot, f, & + do_pot) endif endif end subroutine do_pair - subroutine do_prepair(i, j, rijsq, d, rcijsq, dc, & + subroutine do_prepair(i, j, rijsq, d, sw, rcijsq, dc, & do_pot, do_stress, u_l, A, f, t, pot) - real( kind = dp ) :: pot + + real( kind = dp ) :: pot, sw real( kind = dp ), dimension(3,nLocal) :: u_l real (kind=dp), dimension(9,nLocal) :: A real (kind=dp), dimension(3,nLocal) :: f @@ -1215,7 +920,7 @@ contains #ifdef IS_MPI if (tagRow(i) .eq. tagColumn(j)) then - write(0,*) 'do_pair is doing', i , j, tagRow(i), tagColumn(j) + write(0,*) 'do_prepair is doing', i , j, tagRow(i), tagColumn(j) endif me_i = atid_row(i) @@ -1227,19 +932,17 @@ contains me_j = atid(j) #endif - + if (FF_uses_EAM .and. SIM_uses_EAM) then - + if (PropertyMap(me_i)%is_EAM .and. PropertyMap(me_j)%is_EAM) & call calc_EAM_prepair_rho(i, j, d, r, rijsq ) - + endif end subroutine do_prepair - - - - + + subroutine do_preforce(nlocal,pot) integer :: nlocal real( kind = dp ) :: pot @@ -1418,19 +1121,10 @@ contains endif enddo - do i = 1, nExcludes_local - if (excludesLocal(1,i) == unique_id_1) then - if (excludesLocal(2,i) == unique_id_2) then - skip_it = .true. - return - endif - else - if (excludesLocal(1,i) == unique_id_2) then - if (excludesLocal(2,i) == unique_id_1) then - skip_it = .true. - return - endif - endif + do i = 1, nSkipsForAtom(unique_id_1) + if (skipsForAtom(unique_id_1, i) .eq. unique_id_2) then + skip_it = .true. + return endif end do @@ -1461,5 +1155,30 @@ contains #endif !! This cleans componets of force arrays belonging only to fortran + + subroutine add_stress_tensor(dpair, fpair) + + real( kind = dp ), dimension(3), intent(in) :: dpair, fpair + + ! because the d vector is the rj - ri vector, and + ! because fx, fy, fz are the force on atom i, we need a + ! negative sign here: + + tau_Temp(1) = tau_Temp(1) - dpair(1) * fpair(1) + tau_Temp(2) = tau_Temp(2) - dpair(1) * fpair(2) + tau_Temp(3) = tau_Temp(3) - dpair(1) * fpair(3) + tau_Temp(4) = tau_Temp(4) - dpair(2) * fpair(1) + tau_Temp(5) = tau_Temp(5) - dpair(2) * fpair(2) + tau_Temp(6) = tau_Temp(6) - dpair(2) * fpair(3) + tau_Temp(7) = tau_Temp(7) - dpair(3) * fpair(1) + tau_Temp(8) = tau_Temp(8) - dpair(3) * fpair(2) + tau_Temp(9) = tau_Temp(9) - dpair(3) * fpair(3) + + !write(*,'(6es12.3)') fpair(1:3), tau_Temp(1), tau_Temp(5), tau_temp(9) + virial_Temp = virial_Temp + & + (tau_Temp(1) + tau_Temp(5) + tau_Temp(9)) + + end subroutine add_stress_tensor end module do_Forces +