--- trunk/OOPSE/libmdtools/calc_reaction_field.F90 2003/07/16 02:11:02 621 +++ trunk/OOPSE/libmdtools/calc_reaction_field.F90 2003/08/27 16:25:11 730 @@ -9,34 +9,53 @@ module reaction_field #endif implicit none - real(kind=dp), save :: rrf + PRIVATE + + real(kind=dp), save :: rrf = 1.0_dp real(kind=dp), save :: rt - real(kind=dp), save :: dielect - real(kind=dp), save :: rrfsq + real(kind=dp), save :: dielect = 1.0_dp + real(kind=dp), save :: rrfsq = 1.0_dp real(kind=dp), save :: pre - logical, save :: rf_initialized = .false. + logical, save :: rf_initialized = .false., haveCuts = .false. + logical, save :: haveDie = .false. + PUBLIC::initialize_rf + PUBLIC::setCutoffsRF + PUBLIC::accumulate_rf + PUBLIC::accumulate_self_rf + PUBLIC::reaction_field_final + PUBLIC::rf_correct_forces + contains - subroutine initialize_rf(this_rrf, this_rt, this_dielect) - real(kind=dp), intent(in) :: this_rrf, this_rt, this_dielect - - rrf = this_rrf - rt = this_rt + subroutine initialize_rf(this_dielect) + real(kind=dp), intent(in) :: this_dielect + dielect = this_dielect + + pre = 14.38362d0*2.0d0*(dielect-1.0d0)/((2.0d0*dielect+1.0d0)*rrfsq*rrf) + haveDie = .true. + if (haveCuts) rf_initialized = .true. + + return + end subroutine initialize_rf + + subroutine setCutoffsRF( this_rrf, this_rt ) + + real(kind=dp), intent(in) :: this_rrf, this_rt + + rrf = this_rrf + rt = this_rt + rrfsq = rrf * rrf pre = 14.38362d0*2.0d0*(dielect-1.0d0)/((2.0d0*dielect+1.0d0)*rrfsq*rrf) + haveCuts = .true. + if (haveDie) rf_initialized = .true. - write(*,*) 'rrf = ', rrf - write(*,*) 'rt = ', rt - write(*,*) 'dielect = ', dielect - write(*,*) 'pre = ', pre - rf_initialized = .true. - - return - end subroutine initialize_rf + end subroutine setCutoffsRF + subroutine accumulate_rf(atom1, atom2, rij, u_l) @@ -171,7 +190,7 @@ contains real (kind = dp), dimension(3) :: ul2 real (kind = dp) :: dtdr real (kind = dp) :: dudx, dudy, dudz, u1dotu2 - integer :: me1, me2 + integer :: me1, me2, id1, id2 real (kind = dp) :: mu1, mu2 if (.not.rf_initialized) then @@ -238,8 +257,17 @@ contains #endif if (do_stress) then - if (molMembershipList(atom1) .ne. molMembershipList(atom2)) then +#ifdef IS_MPI + id1 = tagRow(atom1) + id2 = tagColumn(atom2) +#else + id1 = atom1 + id2 = atom2 +#endif + + if (molMembershipList(id1) .ne. molMembershipList(id2)) then + ! because the d vector is the rj - ri vector, and ! because dudx, dudy, and dudz are the ! (positive) force on atom i (negative on atom j) we need