ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/UseTheForce/DarkSide/suttonchen.F90
(Generate patch)

Comparing trunk/OOPSE-4/src/UseTheForce/DarkSide/suttonchen.F90 (file contents):
Revision 2412 by chuckv, Wed Nov 2 23:50:56 2005 UTC vs.
Revision 2530 by chuckv, Fri Dec 30 00:18:28 2005 UTC

# Line 49 | Line 49 | module suttonchen
49    use status
50    use atype_module
51    use vector_class
52 +  use fForceOptions
53   #ifdef IS_MPI
54    use mpiSimulation
55   #endif
# Line 63 | Line 64 | module suttonchen
64    integer, save :: SC_Mixing_Policy
65    real(kind = dp), save :: SC_rcut
66    logical, save :: haveRcut = .false.
67 <  logical, save,:: haveMixingMap = .false.
67 >  logical, save :: haveMixingMap = .false.
68 >  logical, save :: useGeometricDistanceMixing = .false.
69  
70 +
71 +
72 +
73    character(len = statusMsgSize) :: errMesg
74 <  integer :: eam_err
74 >  integer :: sc_err
75  
76    character(len = 200) :: errMsg
77    character(len=*), parameter :: RoutineName =  "Sutton-Chen MODULE"
# Line 82 | Line 87 | module suttonchen
87       real(kind=dp)     :: n
88       real(kind=dp)     :: alpha
89       real(kind=dp)     :: epsilon
90 +     real(kind=dp)     :: sc_rcut
91    end type SCtype
92  
93  
# Line 89 | Line 95 | module suttonchen
95    real( kind = dp), dimension(:), allocatable :: rho
96    real( kind = dp), dimension(:), allocatable :: frho
97    real( kind = dp), dimension(:), allocatable :: dfrhodrho
92  real( kind = dp), dimension(:), allocatable :: d2frhodrhodrho
98  
99  
100 +
101    !! Arrays for MPI storage
102   #ifdef IS_MPI
103    real( kind = dp),save, dimension(:), allocatable :: dfrhodrho_col
# Line 101 | Line 107 | module suttonchen
107    real( kind = dp),save, dimension(:), allocatable :: rho_row
108    real( kind = dp),save, dimension(:), allocatable :: rho_col
109    real( kind = dp),save, dimension(:), allocatable :: rho_tmp
104  real( kind = dp),save, dimension(:), allocatable :: d2frhodrhodrho_col
105  real( kind = dp),save, dimension(:), allocatable :: d2frhodrhodrho_row
110   #endif
111  
112    type, private :: SCTypeList
# Line 121 | Line 125 | module suttonchen
125   type :: MixParameters
126       real(kind=DP) :: alpha
127       real(kind=DP) :: epsilon
128 <     real(kind=dp) :: sigma6
128 >     real(kind=DP) :: m
129 >     real(Kind=DP) :: n
130 >     real(kind=DP) :: vpair_pot
131       real(kind=dp) :: rCut
126     real(kind=dp) :: vpair_pot
132       logical       :: rCutWasSet = .false.
133 <     logical       :: shiftedPot
129 <     logical       :: isSoftCore = .false.
133 >
134    end type MixParameters
135  
136    type(MixParameters), dimension(:,:), allocatable :: MixingMap
137  
138  
139  
136  public :: init_SC_FF
140    public :: setCutoffSC
141    public :: do_SC_pair
142    public :: newSCtype
143    public :: calc_SC_prepair_rho
144 +  public :: calc_SC_preforce_Frho
145    public :: clean_SC
146    public :: destroySCtypes
147    public :: getSCCut
148 <  public :: setSCDefaultCutoff
149 <  public :: setSCUniformCutoff
148 > ! public :: setSCDefaultCutoff
149 > ! public :: setSCUniformCutoff
150 >
151  
152   contains
153  
154  
155 <  subroutine newSCtype(c,m,n,alpha,epsilon,c_ident,status)
156 <    real (kind = dp )                      :: lattice_constant
157 <    integer                                :: eam_nrho
158 <    real (kind = dp )                      :: eam_drho
159 <    integer                                :: eam_nr
160 <    real (kind = dp )                      :: eam_dr
161 <    real (kind = dp )                      :: rcut
162 <    real (kind = dp ), dimension(eam_nr)   :: eam_Z_r
158 <    real (kind = dp ), dimension(eam_nr)   :: eam_rho_r
159 <    real (kind = dp ), dimension(eam_nrho) :: eam_F_rho
155 >  subroutine newSCtype(c_ident,c,m,n,alpha,epsilon,status)
156 >    real (kind = dp )                      :: c ! Density Scaling
157 >    real (kind = dp )                      :: m ! Density Exponent
158 >    real (kind = dp )                      :: n ! Pair Potential Exponent
159 >    real (kind = dp )                      :: alpha ! Length Scaling
160 >    real (kind = dp )                      :: epsilon ! Energy Scaling
161 >
162 >
163      integer                                :: c_ident
164      integer                                :: status
165  
# Line 170 | Line 173 | contains
173  
174  
175      !! Assume that atypes has already been set and get the total number of types in atypes
173    !! Also assume that every member of atypes is a EAM model.
176  
177  
178      ! check to see if this is the first time into
179 <    if (.not.associated(EAMList%EAMParams)) then
180 <       call getMatchingElementList(atypes, "is_SuttonChen", .true., nSCtypes, MatchList)
181 <       SCTypeList%nSCtypes = nSCtypes
182 <       allocate(SCTypeList%SCTypes(nSCTypes))
179 >    if (.not.associated(SCList%SCTypes)) then
180 >       call getMatchingElementList(atypes, "is_SC", .true., nSCtypes, MatchList)
181 >       SCList%nSCtypes = nSCtypes
182 >       allocate(SCList%SCTypes(nSCTypes))
183         nAtypes = getSize(atypes)
184 <       allocate(SCTypeList%atidToSCType(nAtypes))
184 >       allocate(SCList%atidToSCType(nAtypes))
185      end if
186  
187 <    SCTypeList%currentSCType = SCTypeList%currentSCType + 1
188 <    current = SCTypeList%currentSCType
187 >    SCList%currentSCType = SCList%currentSCType + 1
188 >    current = SCList%currentSCType
189  
190      myATID =  getFirstMatchingElement(atypes, "c_ident", c_ident)
191 <    SCTypeList%atidToSCType(myATID) = current
191 >    SCList%atidToSCType(myATID) = current
192  
193  
194    
195 <    SCTypeList%SCTypes(current)%atid         = c_ident
196 <    SCTypeList%SCTypes(current)%alpha        = alpha
197 <    SCTypeList%SCTypes(current)%c            = c
198 <    SCTypeList%SCTypes(current)%m            = m
199 <    SCTypeList%SCTypes(current)%n            = n
200 <    SCTypeList%SCTypes(current)%epsilon      = epsilon
195 >    SCList%SCTypes(current)%atid         = c_ident
196 >    SCList%SCTypes(current)%alpha        = alpha
197 >    SCList%SCTypes(current)%c            = c
198 >    SCList%SCTypes(current)%m            = m
199 >    SCList%SCTypes(current)%n            = n
200 >    SCList%SCTypes(current)%epsilon      = epsilon
201    end subroutine newSCtype
202  
203    
204    subroutine destroySCTypes()
205 +    if (associated(SCList%SCtypes)) then
206 +       deallocate(SCList%SCTypes)
207 +       SCList%SCTypes=>null()
208 +    end if
209 +    if (associated(SCList%atidToSCtype)) then
210 +       deallocate(SCList%atidToSCtype)
211 +       SCList%atidToSCtype=>null()
212 +    end if
213  
204    
205    if(allocated(SCTypeList)) deallocate(SCTypeList)
214  
207
208
215    end subroutine destroySCTypes
216  
217  
218  
219    function getSCCut(atomID) result(cutValue)
220      integer, intent(in) :: atomID
221 <    integer :: eamID
221 >    integer :: scID
222      real(kind=dp) :: cutValue
223      
224 <    eamID = EAMList%atidToEAMType(atomID)
225 <    cutValue = EAMList%EAMParams(eamID)%eam_rcut
224 >    scID = SCList%atidToSCType(atomID)
225 >    cutValue = 2.0_dp * SCList%SCTypes(scID)%alpha
226    end function getSCCut
227  
228  
# Line 238 | Line 244 | contains
244      if (.not. allocated(MixingMap)) then
245         allocate(MixingMap(nSCtypes, nSCtypes))
246      endif
247 <
247 >    useGeometricDistanceMixing = usesGeometricDistanceMixing()
248      do i = 1, nSCtypes
249  
250         e1 = SCList%SCtypes(i)%epsilon
# Line 254 | Line 260 | contains
260            n2 = SCList%SCtypes(j)%n
261            alpha2 = SCList%SCtypes(j)%alpha
262  
263 <          MixingMap(i,j)%epsilon = dsqrt(e1 * e2)
263 >          if (useGeometricDistanceMixing) then
264 >             MixingMap(i,j)%alpha = sqrt(alpha1 * alpha2) !SC formulation
265 >          else
266 >             MixingMap(i,j)%alpha = 0.5_dp * (alpha1 + alpha2) ! Goddard formulation
267 >          endif
268 >
269 >          MixingMap(i,j)%epsilon = sqrt(e1 * e2)
270            MixingMap(i,j)%m = 0.5_dp*(m1+m2)
271            MixingMap(i,j)%n = 0.5_dp*(n1+n2)
272            MixingMap(i,j)%alpha = 0.5_dp*(alpha1+alpha2)
273            MixingMap(i,j)%rcut = 2.0_dp *MixingMap(i,j)%alpha
274 <          MixingMap(i,j)%vpair_rcut = MixingMap%epsilon(i,j)* &
275 <               (MixingMap%alpha(i,j)/MixingMap(i,j)%rcut)**MixingMap(i,j)%n
276 <
274 >          MixingMap(i,j)%vpair_pot = MixingMap(i,j)%epsilon* &
275 >               (MixingMap(i,j)%alpha/MixingMap(i,j)%rcut)**MixingMap(i,j)%n
276 >          if (i.ne.j) then
277 >             MixingMap(j,i)%epsilon    = MixingMap(i,j)%epsilon
278 >             MixingMap(j,i)%m          = MixingMap(i,j)%m
279 >             MixingMap(j,i)%n          = MixingMap(i,j)%n
280 >             MixingMap(j,i)%alpha      = MixingMap(i,j)%alpha
281 >             MixingMap(j,i)%rcut = MixingMap(i,j)%rcut
282 >             MixingMap(j,i)%vpair_pot = MixingMap(i,j)%vpair_pot
283 >          endif
284         enddo
285      enddo
286      
# Line 311 | Line 330 | contains
330         return
331      end if
332  
314    if (allocated(d2frhodrhodrho)) deallocate(d2frhodrhodrho)
315    allocate(d2frhodrhodrho(nlocal),stat=alloc_stat)
316    if (alloc_stat /= 0) then
317       status = -1
318       return
319    end if
320
333   #ifdef IS_MPI
334  
335      if (allocated(rho_tmp)) deallocate(rho_tmp)
# Line 346 | Line 358 | contains
358         status = -1
359         return
360      end if
349    if (allocated(d2frhodrhodrho_row)) deallocate(d2frhodrhodrho_row)
350    allocate(d2frhodrhodrho_row(nAtomsInRow),stat=alloc_stat)
351    if (alloc_stat /= 0) then
352       status = -1
353       return
354    end if
361  
362  
363      ! Now do column arrays
# Line 374 | Line 380 | contains
380         status = -1
381         return
382      end if
377    if (allocated(d2frhodrhodrho_col)) deallocate(d2frhodrhodrho_col)
378    allocate(d2frhodrhodrho_col(nAtomsInCol),stat=alloc_stat)
379    if (alloc_stat /= 0) then
380       status = -1
381       return
382    end if
383  
384   #endif
385  
# Line 397 | Line 397 | contains
397  
398    end subroutine setCutoffSC
399  
400 <
401 <
402 <  subroutine clean_EAM()
400 >  subroutine clean_SC()
401  
402      ! clean non-IS_MPI first
403      frho = 0.0_dp
# Line 415 | Line 413 | contains
413      dfrhodrho_row = 0.0_dp
414      dfrhodrho_col = 0.0_dp
415   #endif
416 <  end subroutine clean_EAM
416 >  end subroutine clean_SC
417  
418  
419  
420    !! Calculates rho_r
421 <  subroutine calc_sc_prepair_rho(atom1,atom2,d,r,rijsq)
421 >  subroutine calc_sc_prepair_rho(atom1,atom2,d,r,rijsq, rcut)
422      integer :: atom1,atom2
423      real(kind = dp), dimension(3) :: d
424      real(kind = dp), intent(inout)               :: r
425 <    real(kind = dp), intent(inout)               :: rijsq
425 >    real(kind = dp), intent(inout)               :: rijsq, rcut
426      ! value of electron density rho do to atom i at atom j
427      real(kind = dp) :: rho_i_at_j
428      ! value of electron density rho do to atom j at atom i
429      real(kind = dp) :: rho_j_at_i
430  
431      ! we don't use the derivatives, dummy variables
432 <    real( kind = dp) :: drho,d2rho
433 <    integer :: eam_err
432 >    real( kind = dp) :: drho
433 >    integer :: sc_err
434      
435      integer :: atid1,atid2 ! Global atid    
436      integer :: myid_atom1 ! EAM atid
# Line 452 | Line 450 | contains
450      Atid2 = Atid(Atom2)
451   #endif
452  
453 <    Myid_atom1 = SCTypeList%atidtoSCtype(Atid1)
454 <    Myid_atom2 = SCTypeList%atidtoSCtype(Atid2)
453 >    Myid_atom1 = SCList%atidtoSCtype(Atid1)
454 >    Myid_atom2 = SCList%atidtoSCtype(Atid2)
455  
456  
457  
# Line 469 | Line 467 | contains
467         rho(atom1) = rho(atom1) + rho_j_at_i
468   #endif
469  
472
473
470    end subroutine calc_sc_prepair_rho
471  
472  
473 < !! Calculate the functional F(rho) for all local atoms
474 <  subroutine calc_eam_preforce_Frho(nlocal,pot)
473 > !! Calculate the rho_a for all local atoms
474 >  subroutine calc_sc_preforce_Frho(nlocal,pot)
475      integer :: nlocal
476      real(kind=dp) :: pot
477      integer :: i,j
478      integer :: atom
479      real(kind=dp) :: U,U1,U2
480      integer :: atype1
481 <    integer :: me,atid1
482 <    integer :: n_rho_points
481 >    integer :: atid1
482 >    integer :: myid
483  
484  
485      cleanme = .true.
486      !! Scatter the electron density from  pre-pair calculation back to local atoms
487   #ifdef IS_MPI
488 <    call scatter(rho_row,rho,plan_atom_row,eam_err)
489 <    if (eam_err /= 0 ) then
488 >    call scatter(rho_row,rho,plan_atom_row,sc_err)
489 >    if (sc_err /= 0 ) then
490         write(errMsg,*) " Error scattering rho_row into rho"
491         call handleError(RoutineName,errMesg)
492      endif
493 <    call scatter(rho_col,rho_tmp,plan_atom_col,eam_err)
494 <    if (eam_err /= 0 ) then
493 >    call scatter(rho_col,rho_tmp,plan_atom_col,sc_err)
494 >    if (sc_err /= 0 ) then
495         write(errMsg,*) " Error scattering rho_col into rho"
496         call handleError(RoutineName,errMesg)
497  
# Line 508 | Line 504 | contains
504  
505      !! Calculate F(rho) and derivative
506      do atom = 1, nlocal
507 <       Myid = ScTypeList%atidtoSctype(Atid(atom))
508 <       frho(atom) = -MixingMap(Myid,Myid)%c * MixingMap(Myid,Myid)%epsilon &
509 <            * sqrt(rho(i))
507 >       Myid = SCList%atidtoSctype(Atid(atom))
508 >       frho(atom) = -SCList%SCTypes(Myid)%c * &
509 >            SCList%SCTypes(Myid)%epsilon * sqrt(rho(i))
510 >
511         dfrhodrho(atom) = 0.5_dp*frho(atom)/rho(atom)
515       d2frhodrhodrho(atom) = -0.5_dp*dfrhodrho(atom)/rho(atom)
512         pot = pot + u
513      enddo
514  
515 <    #ifdef IS_MPI
515 > #ifdef IS_MPI
516      !! communicate f(rho) and derivatives back into row and column arrays
517 <    call gather(frho,frho_row,plan_atom_row, eam_err)
518 <    if (eam_err /=  0) then
517 >    call gather(frho,frho_row,plan_atom_row, sc_err)
518 >    if (sc_err /=  0) then
519         call handleError("cal_eam_forces()","MPI gather frho_row failure")
520      endif
521 <    call gather(dfrhodrho,dfrhodrho_row,plan_atom_row, eam_err)
522 <    if (eam_err /=  0) then
521 >    call gather(dfrhodrho,dfrhodrho_row,plan_atom_row, sc_err)
522 >    if (sc_err /=  0) then
523         call handleError("cal_eam_forces()","MPI gather dfrhodrho_row failure")
524      endif
525 <    call gather(frho,frho_col,plan_atom_col, eam_err)
526 <    if (eam_err /=  0) then
525 >    call gather(frho,frho_col,plan_atom_col, sc_err)
526 >    if (sc_err /=  0) then
527         call handleError("cal_eam_forces()","MPI gather frho_col failure")
528      endif
529 <    call gather(dfrhodrho,dfrhodrho_col,plan_atom_col, eam_err)
530 <    if (eam_err /=  0) then
529 >    call gather(dfrhodrho,dfrhodrho_col,plan_atom_col, sc_err)
530 >    if (sc_err /=  0) then
531         call handleError("cal_eam_forces()","MPI gather dfrhodrho_col failure")
532      endif
537
538    if (nmflag) then
539       call gather(d2frhodrhodrho,d2frhodrhodrho_row,plan_atom_row)
540       call gather(d2frhodrhodrho,d2frhodrhodrho_col,plan_atom_col)
541    endif
533   #endif
534      
535      
536 <  end subroutine calc_eam_preforce_Frho
536 >  end subroutine calc_sc_preforce_Frho
537  
538  
539    !! Does Sutton-Chen  pairwise Force calculation.  
540 <  subroutine do_eam_pair(atom1, atom2, d, rij, r2, sw, vpair, fpair, &
540 >  subroutine do_sc_pair(atom1, atom2, d, rij, r2, rcut, sw, vpair, fpair, &
541         pot, f, do_pot)
542      !Arguments    
543      integer, intent(in) ::  atom1, atom2
544 <    real( kind = dp ), intent(in) :: rij, r2
544 >    real( kind = dp ), intent(in) :: rij, r2, rcut
545      real( kind = dp ) :: pot, sw, vpair
546      real( kind = dp ), dimension(3,nLocal) :: f
547      real( kind = dp ), intent(in), dimension(3) :: d
# Line 559 | Line 550 | contains
550      logical, intent(in) :: do_pot
551  
552      real( kind = dp ) :: drdx,drdy,drdz
553 <    real( kind = dp ) :: d2
554 <    real( kind = dp ) :: phab,pha,dvpdr,d2vpdrdr
564 <    real( kind = dp ) :: rha,drha,d2rha, dpha
565 <    real( kind = dp ) :: rhb,drhb,d2rhb, dphb
553 >    real( kind = dp ) :: dvpdr
554 >    real( kind = dp ) :: drhodr
555      real( kind = dp ) :: dudr
556 <    real( kind = dp ) :: rci,rcj
556 >    real( kind = dp ) :: rcij
557      real( kind = dp ) :: drhoidr,drhojdr
569    real( kind = dp ) :: d2rhoidrdr
570    real( kind = dp ) :: d2rhojdrdr
558      real( kind = dp ) :: Fx,Fy,Fz
559      real( kind = dp ) :: r,d2pha,phb,d2phb
560 <
560 >    real( kind = dp ) :: pot_temp,vptmp
561 >    real( kind = dp ) :: epsilonij,aij,nij,mij,vcij
562      integer :: id1,id2
563      integer  :: mytype_atom1
564      integer  :: mytype_atom2
# Line 579 | Line 567 | contains
567  
568      ! write(*,*) "Frho: ", Frho(atom1)
569  
570 <    phab = 0.0E0_DP
570 >
571      dvpdr = 0.0E0_DP
584    d2vpdrdr = 0.0E0_DP
572  
586    if (rij .lt. EAM_rcut) then
573  
574   #ifdef IS_MPI
575         atid1 = atid_row(atom1)
# Line 593 | Line 579 | contains
579         atid2 = atid(atom2)
580   #endif
581  
582 <       mytype_atom1 = EAMList%atidToEAMType(atid1)
583 <       mytype_atom2 = EAMList%atidTOEAMType(atid2)
582 >       mytype_atom1 = SCList%atidToSCType(atid1)
583 >       mytype_atom2 = SCList%atidTOSCType(atid2)
584  
599
600       ! get cutoff for atom 1
601       rci = EAMList%EAMParams(mytype_atom1)%eam_rcut
602       ! get type specific cutoff for atom 2
603       rcj = EAMList%EAMParams(mytype_atom2)%eam_rcut
604
585         drdx = d(1)/rij
586         drdy = d(2)/rij
587         drdz = d(3)/rij
588  
589 <       if (rij.lt.rci) then
590 <          call eam_splint(EAMList%EAMParams(mytype_atom1)%eam_nr, &
591 <               EAMList%EAMParams(mytype_atom1)%eam_rvals, &
592 <               EAMList%EAMParams(mytype_atom1)%eam_rho_r, &
593 <               EAMList%EAMParams(mytype_atom1)%eam_rho_r_pp, &
594 <               rij, rha,drha,d2rha)
615 <          !! Calculate Phi(r) for atom1.
616 <          call eam_splint(EAMList%EAMParams(mytype_atom1)%eam_nr, &
617 <               EAMList%EAMParams(mytype_atom1)%eam_rvals, &
618 <               EAMList%EAMParams(mytype_atom1)%eam_phi_r, &
619 <               EAMList%EAMParams(mytype_atom1)%eam_phi_r_pp, &
620 <               rij, pha,dpha,d2pha)
621 <       endif
589 >                
590 >       epsilonij = MixingMap(mytype_atom1,mytype_atom2)%epsilon
591 >       aij       = MixingMap(mytype_atom1,mytype_atom2)%alpha
592 >       nij       = MixingMap(mytype_atom1,mytype_atom2)%n
593 >       mij       = MixingMap(mytype_atom1,mytype_atom2)%m
594 >       vcij      = MixingMap(mytype_atom1,mytype_atom2)%vpair_pot              
595  
596 <       if (rij.lt.rcj) then      
624 <          ! Calculate rho,drho and d2rho for atom1
625 <          call eam_splint(EAMList%EAMParams(mytype_atom2)%eam_nr, &
626 <               EAMList%EAMParams(mytype_atom2)%eam_rvals, &
627 <               EAMList%EAMParams(mytype_atom2)%eam_rho_r, &
628 <               EAMList%EAMParams(mytype_atom2)%eam_rho_r_pp, &
629 <               rij, rhb,drhb,d2rhb)
596 >       vptmp = epsilonij*((aij/r)**nij)
597  
631          !! Calculate Phi(r) for atom2.
632          call eam_splint(EAMList%EAMParams(mytype_atom2)%eam_nr, &
633               EAMList%EAMParams(mytype_atom2)%eam_rvals, &
634               EAMList%EAMParams(mytype_atom2)%eam_phi_r, &
635               EAMList%EAMParams(mytype_atom2)%eam_phi_r_pp, &
636               rij, phb,dphb,d2phb)
637       endif
598  
599 <       if (rij.lt.rci) then
600 <          phab = phab + 0.5E0_DP*(rhb/rha)*pha
641 <          dvpdr = dvpdr + 0.5E0_DP*((rhb/rha)*dpha + &
642 <               pha*((drhb/rha) - (rhb*drha/rha/rha)))
643 <          d2vpdrdr = d2vpdrdr + 0.5E0_DP*((rhb/rha)*d2pha + &
644 <               2.0E0_DP*dpha*((drhb/rha) - (rhb*drha/rha/rha)) + &
645 <               pha*((d2rhb/rha) - 2.0E0_DP*(drhb*drha/rha/rha) + &
646 <               (2.0E0_DP*rhb*drha*drha/rha/rha/rha) - (rhb*d2rha/rha/rha)))
647 <       endif
599 >       dvpdr = -nij*vptmp/r
600 >       drhodr = -mij*((aij/r)**mij)/r
601  
602 <       if (rij.lt.rcj) then
603 <          phab = phab + 0.5E0_DP*(rha/rhb)*phb
604 <          dvpdr = dvpdr + 0.5E0_DP*((rha/rhb)*dphb + &
605 <               phb*((drha/rhb) - (rha*drhb/rhb/rhb)))
606 <          d2vpdrdr = d2vpdrdr + 0.5E0_DP*((rha/rhb)*d2phb + &
607 <               2.0E0_DP*dphb*((drha/rhb) - (rha*drhb/rhb/rhb)) + &
655 <               phb*((d2rha/rhb) - 2.0E0_DP*(drha*drhb/rhb/rhb) + &
656 <               (2.0E0_DP*rha*drhb*drhb/rhb/rhb/rhb) - (rha*d2rhb/rhb/rhb)))
657 <       endif
602 >      
603 >       dudr = drhodr*(dfrhodrho(atom1)+dfrhodrho(atom2)) &
604 >            + dvpdr
605 >      
606 >       pot_temp = vptmp + vcij
607 >
608  
659       drhoidr = drha
660       drhojdr = drhb
661
662       d2rhoidrdr = d2rha
663       d2rhojdrdr = d2rhb
664
665
609   #ifdef IS_MPI
610 <       dudr = drhojdr*dfrhodrho_row(atom1)+drhoidr*dfrhodrho_col(atom2) &
610 >       dudr = drhodr*(dfrhodrho_row(atom1)+dfrhodrho_col(atom2)) &
611              + dvpdr
612  
613   #else
614 <       dudr = drhojdr*dfrhodrho(atom1)+drhoidr*dfrhodrho(atom2) &
614 >       dudr = drhodr*(dfrhodrho(atom1)+dfrhodrho(atom2)) &
615              + dvpdr
673       ! write(*,*) "Atom1,Atom2, dfrhodrho(atom1) dfrhodrho(atom2): ", atom1,atom2,dfrhodrho(atom1),dfrhodrho(atom2)
616   #endif
617  
618 +
619         fx = dudr * drdx
620         fy = dudr * drdy
621         fz = dudr * drdz
# Line 680 | Line 623 | contains
623  
624   #ifdef IS_MPI
625         if (do_pot) then
626 <          pot_Row(METALLIC_POT,atom1) = pot_Row(METALLIC_POT,atom1) + phab*0.5
627 <          pot_Col(METALLIC_POT,atom2) = pot_Col(METALLIC_POT,atom2) + phab*0.5
626 >          pot_Row(METALLIC_POT,atom1) = pot_Row(METALLIC_POT,atom1) + (pot_temp)*0.5
627 >          pot_Col(METALLIC_POT,atom2) = pot_Col(METALLIC_POT,atom2) + (pot_temp)*0.5
628         end if
629  
630         f_Row(1,atom1) = f_Row(1,atom1) + fx
# Line 694 | Line 637 | contains
637   #else
638  
639         if(do_pot) then
640 <          pot = pot + phab
640 >          pot = pot + pot_temp
641         end if
642  
643         f(1,atom1) = f(1,atom1) + fx
# Line 706 | Line 649 | contains
649         f(3,atom2) = f(3,atom2) - fz
650   #endif
651  
652 <       vpair = vpair + phab
652 >      
653   #ifdef IS_MPI
654         id1 = AtomRowToGlobal(atom1)
655         id2 = AtomColToGlobal(atom2)
# Line 723 | Line 666 | contains
666  
667         endif
668  
726       if (nmflag) then
669  
670 <          drhoidr = drha
729 <          drhojdr = drhb
730 <          d2rhoidrdr = d2rha
731 <          d2rhojdrdr = d2rhb
670 >  end subroutine do_sc_pair
671  
733 #ifdef IS_MPI
734          d2 = d2vpdrdr + &
735               d2rhoidrdr*dfrhodrho_col(atom2) + &
736               d2rhojdrdr*dfrhodrho_row(atom1) + &
737               drhoidr*drhoidr*d2frhodrhodrho_col(atom2) + &
738               drhojdr*drhojdr*d2frhodrhodrho_row(atom1)
672  
740 #else
673  
742          d2 = d2vpdrdr + &
743               d2rhoidrdr*dfrhodrho(atom2) + &
744               d2rhojdrdr*dfrhodrho(atom1) + &
745               drhoidr*drhoidr*d2frhodrhodrho(atom2) + &
746               drhojdr*drhojdr*d2frhodrhodrho(atom1)
747 #endif
748       end if
749
750    endif
751  end subroutine do_eam_pair
752
753
754
674   end module suttonchen

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines