--- trunk/OOPSE/libmdtools/calc_eam.F90 2003/07/30 21:17:01 657 +++ trunk/OOPSE/libmdtools/calc_eam.F90 2003/09/05 21:28:52 747 @@ -15,7 +15,7 @@ module eam logical, save :: EAM_FF_initialized = .false. integer, save :: EAM_Mixing_Policy real(kind = dp), save :: EAM_rcut - real(kind = dp), save :: EAM_rcut_orig + logical, save :: haveRcut = .false. character(len = statusMsgSize) :: errMesg integer :: eam_err @@ -60,14 +60,14 @@ module eam !! Arrays for MPI storage #ifdef IS_MPI - real( kind = dp), dimension(:), allocatable :: dfrhodrho_col - real( kind = dp), dimension(:), allocatable :: dfrhodrho_row - real( kind = dp), dimension(:), allocatable :: frho_row - real( kind = dp), dimension(:), allocatable :: frho_col - real( kind = dp), dimension(:), allocatable :: rho_row - real( kind = dp), dimension(:), allocatable :: rho_col - real( kind = dp), dimension(:), allocatable :: d2frhodrhodrho_col - real( kind = dp), dimension(:), allocatable :: d2frhodrhodrho_row + real( kind = dp),save, dimension(:), allocatable :: dfrhodrho_col + real( kind = dp),save, dimension(:), allocatable :: dfrhodrho_row + real( kind = dp),save, dimension(:), allocatable :: frho_row + real( kind = dp),save, dimension(:), allocatable :: frho_col + real( kind = dp),save, dimension(:), allocatable :: rho_row + real( kind = dp),save, dimension(:), allocatable :: rho_col + real( kind = dp),save, dimension(:), allocatable :: d2frhodrhodrho_col + real( kind = dp),save, dimension(:), allocatable :: d2frhodrhodrho_row #endif type, private :: EAMTypeList @@ -78,7 +78,7 @@ module eam end type EAMTypeList - type (eamTypeList) :: EAMList + type (eamTypeList), save :: EAMList !! standard eam stuff @@ -89,7 +89,7 @@ module eam public :: newEAMtype public :: calc_eam_prepair_rho public :: calc_eam_preforce_Frho - + public :: clean_EAM contains @@ -117,7 +117,7 @@ contains status = 0 - write(*,*) "Adding new eamtype: ",eam_ident + !! Assume that atypes has already been set and get the total number of types in atypes !! Also assume that every member of atypes is a EAM model. @@ -222,19 +222,17 @@ contains enddo - current_rcut_max = EAMList%EAMParams(1)%eam_rcut +! current_rcut_max = EAMList%EAMParams(1)%eam_rcut !! find the smallest rcut for any eam atype - do i = 2, EAMList%currentAddition - current_rcut_max = min(current_rcut_max,EAMList%EAMParams(i)%eam_rcut) - end do +! do i = 2, EAMList%currentAddition +! current_rcut_max =max(current_rcut_max,EAMList%EAMParams(i)%eam_rcut) +! end do - EAM_rcut = current_rcut_max - EAM_rcut_orig = current_rcut_max +! EAM_rcut = current_rcut_max +! EAM_rcut_orig = current_rcut_max ! do i = 1, EAMList%currentAddition ! EAMList%EAMParam(i)s%eam_atype_map(eam_atype(i)) = i ! end do - - !! Allocate arrays for force calculation call allocateEAM(alloc_stat) if (alloc_stat /= 0 ) then @@ -350,22 +348,23 @@ contains end subroutine allocateEAM +!! C sets rcut to be the largest cutoff of any atype +!! present in this simulation. Doesn't include all atypes +!! sim knows about, just those in the simulation. subroutine setCutoffEAM(rcut, status) real(kind=dp) :: rcut integer :: status + status = 0 - if (rcut < EAM_rcut) then - EAM_rcut = rcut - endif + EAM_rcut = rcut - end subroutine setCutoffEAM subroutine clean_EAM() - -! clean non-IS_MPI first + + ! clean non-IS_MPI first frho = 0.0_dp rho = 0.0_dp dfrhodrho = 0.0_dp @@ -484,10 +483,10 @@ contains integer :: myid_atom2 ! check to see if we need to be cleaned at the start of a force loop - if (cleanme) call clean_EAM - cleanme = .false. - + + + #ifdef IS_MPI myid_atom1 = atid_Row(atom1) myid_atom2 = atid_Col(atom2) @@ -497,9 +496,9 @@ contains #endif if (r.lt.EAMList%EAMParams(myid_atom1)%eam_rcut) then - + call eam_splint(EAMList%EAMParams(myid_atom1)%eam_nr, & EAMList%EAMParams(myid_atom1)%eam_rvals, & EAMList%EAMParams(myid_atom1)%eam_rho_r, & @@ -513,6 +512,7 @@ contains #else rho(atom2) = rho(atom2) + rho_i_at_j #endif +! write(*,*) atom1,atom2,r,rho_i_at_j endif if (r.lt.EAMList%EAMParams(myid_atom2)%eam_rcut) then @@ -532,6 +532,7 @@ contains #endif endif + end subroutine calc_eam_prepair_rho @@ -547,10 +548,10 @@ contains integer :: atype1 integer :: me integer :: n_rho_points - ! reset clean forces to be true at top of calc rho. - cleanme = .true. -!! Scatter the electron density from pre-pair calculation back to local atoms + + cleanme = .true. + !! Scatter the electron density from pre-pair calculation back to local atoms #ifdef IS_MPI call scatter(rho_row,rho,plan_row,eam_err) if (eam_err /= 0 ) then @@ -588,13 +589,14 @@ contains end if - frho(i) = u - dfrhodrho(i) = u1 - d2frhodrhodrho(i) = u2 + frho(atom) = u + dfrhodrho(atom) = u1 + d2frhodrhodrho(atom) = u2 pot = pot + u - enddo + enddo + #ifdef IS_MPI !! communicate f(rho) and derivatives back into row and column arrays @@ -625,6 +627,7 @@ contains endif #endif + end subroutine calc_eam_preforce_Frho @@ -657,16 +660,14 @@ contains integer :: mytype_atom1 integer :: mytype_atom2 - !Local Variables + ! write(*,*) "Frho: ", Frho(atom1) - phab = 0.0E0_DP dvpdr = 0.0E0_DP d2vpdrdr = 0.0E0_DP - - + if (rij .lt. EAM_rcut) then #ifdef IS_MPI !!!!! FIX ME @@ -753,11 +754,11 @@ contains #ifdef IS_MPI dudr = drhojdr*dfrhodrho_row(atom1)+drhoidr*dfrhodrho_col(atom2) & + dvpdr - + #else dudr = drhojdr*dfrhodrho(atom1)+drhoidr*dfrhodrho(atom2) & + dvpdr - + ! write(*,*) "Atom1,Atom2, dfrhodrho(atom1) dfrhodrho(atom2): ", atom1,atom2,dfrhodrho(atom1),dfrhodrho(atom2) #endif fx = dudr * drdx @@ -779,8 +780,11 @@ contains f_Col(2,atom2) = f_Col(2,atom2) - fy f_Col(3,atom2) = f_Col(3,atom2) - fz #else - if(do_pot) pot = pot + phab - + + if(do_pot) then + pot = pot + phab + end if + f(1,atom1) = f(1,atom1) + fx f(2,atom1) = f(2,atom1) + fy f(3,atom1) = f(3,atom1) + fz @@ -828,10 +832,7 @@ contains #endif if (molMembershipList(id1) .ne. molMembershipList(id2)) then - - - tau_Temp(1) = tau_Temp(1) - d(1) * fx tau_Temp(2) = tau_Temp(2) - d(1) * fy tau_Temp(3) = tau_Temp(3) - d(1) * fz