--- trunk/OOPSE/libmdtools/calc_LJ_FF.F90 2003/07/15 17:10:50 611 +++ trunk/OOPSE/libmdtools/calc_LJ_FF.F90 2004/01/30 15:01:09 999 @@ -2,7 +2,7 @@ !! Corresponds to the force field defined in lj_FF.cpp !! @author Charles F. Vardeman II !! @author Matthew Meineke -!! @version $Id: calc_LJ_FF.F90,v 1.7 2003-07-15 17:10:50 gezelter Exp $, $Date: 2003-07-15 17:10:50 $, $Name: not supported by cvs2svn $, $Revision: 1.7 $ +!! @version $Id: calc_LJ_FF.F90,v 1.16 2004-01-30 15:01:09 chrisfen Exp $, $Date: 2004-01-30 15:01:09 $, $Name: not supported by cvs2svn $, $Revision: 1.16 $ module lj use definitions @@ -21,7 +21,9 @@ module lj #include "fForceField.h" integer, save :: LJ_Mixing_Policy - integer, save :: LJ_rcut + real(kind=DP), save :: LJ_rcut + logical, save :: havePolicy = .false., haveCut = .false. + !! Logical has lj force field module been initialized? @@ -29,7 +31,7 @@ module lj !! Public methods and data public :: init_LJ_FF - public :: LJ_new_rcut + public :: setCutoffLJ public :: do_lj_pair type :: lj_mixed_params @@ -45,17 +47,17 @@ module lj real ( kind = dp ) :: delta = 0.0_dp + end type lj_mixed_params type (lj_mixed_params), dimension(:,:), pointer :: ljMixed contains - subroutine init_LJ_FF(mix_Policy, rcut, status) + subroutine init_LJ_FF(mix_Policy, status) integer, intent(in) :: mix_Policy integer, intent(out) :: status integer :: myStatus - real(kind=dp) :: rcut if (mix_Policy == LB_MIXING_RULE) then LJ_Mixing_Policy = LB_MIXING_RULE @@ -68,34 +70,46 @@ contains return endif endif - - LJ_rcut = rcut - status = 0 - call createMixingList(myStatus) - if (myStatus /= 0) then - status = -1 - return + havePolicy = .true. + + if (haveCut) then + status = 0 + call createMixingList(myStatus) + if (myStatus /= 0) then + status = -1 + return + end if + + LJ_FF_initialized = .true. end if - - LJ_FF_initialized = .true. - + end subroutine init_LJ_FF - subroutine LJ_new_rcut(rcut, status) + subroutine setCutoffLJ(rcut, status) integer :: status, myStatus real(kind=dp) :: rcut - - LJ_rcut = rcut + status = 0 - call createMixingList(myStatus) - if (myStatus /= 0) then - status = -1 - return - end if +! LJ_rcut = rcut + ! ATTENTION! This is a hardwiring of rcut! + LJ_rcut = 9.0d0 + haveCut = .true. + + if (havePolicy) then + status = 0 + call createMixingList(myStatus) + if (myStatus /= 0) then + status = -1 + return + end if + + LJ_FF_initialized = .true. + end if + return - end subroutine LJ_new_rcut + end subroutine setCutoffLJ subroutine createMixingList(status) integer :: nAtypes @@ -115,13 +129,11 @@ contains if (.not. associated(ljMixed)) then allocate(ljMixed(nAtypes, nAtypes)) - else - status = -1 - return - end if + endif rcut6 = LJ_rcut**6 +! This loops through all atypes, even those that don't support LJ forces. do i = 1, nAtypes call getElementProperty(atypes, i, "lj_epsilon", myEpsilon_i) @@ -129,11 +141,13 @@ contains ! do self mixing rule ljMixed(i,i)%sigma = mySigma_i - ljMixed(i,i)%sigma6 = (ljMixed(i,i)%sigma) ** 6 - ljMixed(i,i)%tp6 = ljMixed(i,i)%sigma6/rcut6 + ljMixed(i,i)%sigma6 = (ljMixed(i,i)%sigma) ** 6 + ljMixed(i,i)%tp6 = (ljMixed(i,i)%sigma6)/rcut6 + ljMixed(i,i)%tp12 = (ljMixed(i,i)%tp6) ** 2 + ljMixed(i,i)%epsilon = myEpsilon_i ljMixed(i,i)%delta = -4.0_DP * ljMixed(i,i)%epsilon * & @@ -181,7 +195,7 @@ contains integer, intent(in) :: atom1, atom2 real( kind = dp ), intent(in) :: rij, r2 real( kind = dp ) :: pot - real( kind = dp ), dimension(3,getNlocal()) :: f + real( kind = dp ), dimension(3,nLocal) :: f real( kind = dp ), intent(in), dimension(3) :: d logical, intent(in) :: do_pot, do_stress @@ -197,7 +211,6 @@ contains real( kind = dp ) :: delta integer :: id1, id2 - if (rij.lt.LJ_rcut) then ! Look up the correct parameters in the mixing matrix @@ -306,7 +319,7 @@ contains if (present(status)) status = 0 select case (LJ_Mixing_Policy) - case (LB_MIXING_RULE) + case (1) select case (thisParam) case ("sigma") myMixParam = 0.5_dp * (param1 + param2)