--- trunk/OOPSE/libmdtools/calc_eam.F90 2003/07/25 20:00:17 653 +++ trunk/OOPSE/libmdtools/calc_eam.F90 2003/07/30 21:17:01 657 @@ -114,9 +114,10 @@ contains integer :: alloc_stat integer :: current integer,pointer :: Matchlist(:) => null() - type (EAMtype), pointer :: makeEamtype => null() + 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. @@ -132,12 +133,11 @@ contains current = EAMList%currentAddition - call allocate_EAMType(eam_nrho,eam_nr,makeEamtype,stat=alloc_stat) + call allocate_EAMType(eam_nrho,eam_nr,EAMList%EAMParams(current),stat=alloc_stat) if (alloc_stat /= 0) then status = -1 return end if - makeEamtype => EAMList%EAMParams(current) ! this is a possible bug, we assume a correspondence between the vector atypes and ! EAMAtypes @@ -147,6 +147,7 @@ contains EAMList%EAMParams(current)%eam_nrho = eam_nrho EAMList%EAMParams(current)%eam_drho = eam_drho EAMList%EAMParams(current)%eam_nr = eam_nr + EAMList%EAMParams(current)%eam_dr = eam_dr EAMList%EAMParams(current)%eam_rcut = rcut EAMList%EAMParams(current)%eam_Z_r = eam_Z_r EAMList%EAMParams(current)%eam_rho_r = eam_rho_r @@ -163,28 +164,40 @@ contains integer :: alloc_stat integer :: number_r, number_rho + if (EAMList%currentAddition == 0) then + call handleError("init_EAM_FF","No members in EAMList") + status = -1 + return + end if + do i = 1, EAMList%currentAddition - - EAMList%EAMParams(i)%eam_rvals(1:EAMList%EAMParams(i)%eam_nr) = & - real(EAMList%EAMParams(i)%eam_nr,kind=dp)* & - EAMList%EAMParams(i)%eam_dr - EAMList%EAMParams(i)%eam_rhovals(1:EAMList%EAMParams(i)%eam_nrho) = & - real(EAMList%EAMParams(i)%eam_nrho,kind=dp)* & - EAMList%EAMParams(i)%eam_drho +! Build array of r values + do j = 1,EAMList%EAMParams(i)%eam_nr + EAMList%EAMParams(i)%eam_rvals(j) = & + real(j-1,kind=dp)* & + EAMList%EAMParams(i)%eam_dr + end do +! Build array of rho values + do j = 1,EAMList%EAMParams(i)%eam_nrho + EAMList%EAMParams(i)%eam_rhovals(j) = & + real(j-1,kind=dp)* & + EAMList%EAMParams(i)%eam_drho + end do ! convert from eV to kcal / mol: EAMList%EAMParams(i)%eam_F_rho = EAMList%EAMParams(i)%eam_F_rho * 23.06054E0_DP ! precompute the pair potential and get it into kcal / mol: - EAMList%EAMParams(i)%eam_phi_r = 0.0E0_DP + EAMList%EAMParams(i)%eam_phi_r(1) = 0.0E0_DP do j = 2, EAMList%EAMParams(i)%eam_nr EAMList%EAMParams(i)%eam_phi_r(j) = (EAMList%EAMParams(i)%eam_Z_r(j)**2)/EAMList%EAMParams(i)%eam_rvals(j) EAMList%EAMParams(i)%eam_phi_r(j) = EAMList%EAMParams(i)%eam_phi_r(j)*331.999296E0_DP enddo end do + do i = 1, EAMList%currentAddition number_r = EAMList%EAMParams(i)%eam_nr @@ -207,7 +220,8 @@ contains EAMList%EAMParams(i)%eam_phi_r_pp, & 0.0E0_DP, 0.0E0_DP, 'N') enddo - + + current_rcut_max = EAMList%EAMParams(1)%eam_rcut !! find the smallest rcut for any eam atype do i = 2, EAMList%currentAddition @@ -371,7 +385,7 @@ contains subroutine allocate_EAMType(eam_n_rho,eam_n_r,thisEAMType,stat) integer, intent(in) :: eam_n_rho integer, intent(in) :: eam_n_r - type (EAMType), pointer :: thisEAMType + type (EAMType) :: thisEAMType integer, optional :: stat integer :: alloc_stat