--- trunk/OOPSE/libmdtools/do_Forces.F90 2003/04/11 15:16:59 490 +++ trunk/OOPSE/libmdtools/do_Forces.F90 2003/07/01 22:39:53 571 @@ -4,7 +4,7 @@ !! @author Charles F. Vardeman II !! @author Matthew Meineke -!! @version $Id: do_Forces.F90,v 1.15 2003-04-11 15:16:59 gezelter Exp $, $Date: 2003-04-11 15:16:59 $, $Name: not supported by cvs2svn $, $Revision: 1.15 $ +!! @version $Id: do_Forces.F90,v 1.16 2003-07-01 22:39:53 gezelter Exp $, $Date: 2003-07-01 22:39:53 $, $Name: not supported by cvs2svn $, $Revision: 1.16 $ module do_Forces use force_globals @@ -597,21 +597,53 @@ contains real (kind = dp), dimension(3) :: q_i real (kind = dp), dimension(3) :: q_j real ( kind = dp ), intent(out) :: r_sq - real( kind = dp ) :: d(3) - real( kind = dp ) :: d_old(3) + real( kind = dp ) :: d(3), scaled(3) + integer i + d(1:3) = q_j(1:3) - q_i(1:3) - d_old = d + ! Wrap back into periodic box if necessary if ( SimUsesPBC() ) then - d(1:3) = d(1:3) - box(1:3) * sign(1.0_dp,d(1:3)) * & - int(abs(d(1:3)/box(1:3)) + 0.5_dp) + if( .not.boxIsOrthorhombic ) then + ! calc the scaled coordinates. + + scaled = matmul(d, HmatInv) + + ! wrap the scaled coordinates + + do i = 1, 3 + scaled(i) = scaled(i) - anint(scaled(i)) + enddo + + ! calc the wrapped real coordinates from the wrapped scaled + ! coordinates + + d = matmul(scaled,Hmat) + + else + ! calc the scaled coordinates. + + do i = 1, 3 + scaled(i) = d(i) * HmatInv(i,i) + + ! wrap the scaled coordinates + + scaled(i) = scaled(i) - anint(scaled(i)) + + ! calc the wrapped real coordinates from the wrapped scaled + ! coordinates + + d(i) = scaled(i)*Hmat(i,i) + enddo + endif endif + r_sq = dot_product(d,d) - + end subroutine get_interatomic_vector - + subroutine check_initialization(error) integer, intent(out) :: error