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 2413 by chuckv, Thu Nov 3 23:06:00 2005 UTC vs.
Revision 2756 by gezelter, Wed May 17 15:37:15 2006 UTC

# Line 44 | Line 44 | module suttonchen
44  
45  
46   module suttonchen
47 +  use definitions
48    use simulation
49    use force_globals
50    use status
51    use atype_module
52    use vector_class
53 +  use fForceOptions
54 +  use interpolation
55   #ifdef IS_MPI
56    use mpiSimulation
57   #endif
# Line 57 | Line 60 | module suttonchen
60   #define __FORTRAN90
61   #include "UseTheForce/DarkSide/fInteractionMap.h"
62  
63 <  INTEGER, PARAMETER :: DP = selected_real_kind(15)
63 >  !! number of points for the spline approximations
64 >  INTEGER, PARAMETER :: np = 3000
65  
66    logical, save :: SC_FF_initialized = .false.
67    integer, save :: SC_Mixing_Policy
68    real(kind = dp), save :: SC_rcut
69    logical, save :: haveRcut = .false.
70 <  logical, save,:: haveMixingMap = .false.
70 >  logical, save :: haveMixingMap = .false.
71 >  logical, save :: useGeometricDistanceMixing = .false.
72 >  logical, save :: cleanArrays = .true.
73 >  logical, save :: arraysAllocated = .false.
74  
75 +
76    character(len = statusMsgSize) :: errMesg
77    integer :: sc_err
78  
79    character(len = 200) :: errMsg
80    character(len=*), parameter :: RoutineName =  "Sutton-Chen MODULE"
81 <  !! Logical that determines if eam arrays should be zeroed
74 <  logical :: cleanme = .true.
75 <  logical :: nmflag  = .false.
76 <
77 <
81 >  
82    type, private :: SCtype
83 <     integer           :: atid      
84 <     real(kind=dp)     :: c
85 <     real(kind=dp)     :: m
86 <     real(kind=dp)     :: n
87 <     real(kind=dp)     :: alpha
88 <     real(kind=dp)     :: epsilon
83 >     integer       :: atid      
84 >     real(kind=dp) :: c
85 >     real(kind=dp) :: m
86 >     real(kind=dp) :: n
87 >     real(kind=dp) :: alpha
88 >     real(kind=dp) :: epsilon
89 >     real(kind=dp) :: sc_rcut
90    end type SCtype
91 +  
92  
87
93    !! Arrays for derivatives used in force calculation
94    real( kind = dp), dimension(:), allocatable :: rho
95    real( kind = dp), dimension(:), allocatable :: frho
96    real( kind = dp), dimension(:), allocatable :: dfrhodrho
97 <  real( kind = dp), dimension(:), allocatable :: d2frhodrhodrho
93 <
94 <
97 >  
98    !! Arrays for MPI storage
99   #ifdef IS_MPI
100    real( kind = dp),save, dimension(:), allocatable :: dfrhodrho_col
# Line 101 | Line 104 | module suttonchen
104    real( kind = dp),save, dimension(:), allocatable :: rho_row
105    real( kind = dp),save, dimension(:), allocatable :: rho_col
106    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
107   #endif
108  
109    type, private :: SCTypeList
110       integer           :: nSCTypes = 0
111 <     integer           :: currentSCtype = 0
112 <
113 <     type (SCtype), pointer  :: SCtypes(:) => null()
113 <     integer, pointer         :: atidToSCtype(:) => null()
111 >     integer           :: currentSCtype = 0    
112 >     type (SCtype), pointer :: SCtypes(:) => null()
113 >     integer, pointer       :: atidToSCtype(:) => null()
114    end type SCTypeList
115  
116    type (SCTypeList), save :: SCList
117  
118 <
119 <
120 <
121 < type :: MixParameters
118 >  type:: MixParameters
119       real(kind=DP) :: alpha
120       real(kind=DP) :: epsilon
121 <     real(kind=dp) :: sigma6
121 >     real(kind=DP) :: m
122 >     real(Kind=DP) :: n
123       real(kind=dp) :: rCut
124 <     real(kind=dp) :: vpair_pot
124 >     real(kind=dp) :: vCut
125       logical       :: rCutWasSet = .false.
126 <     logical       :: shiftedPot
127 <     logical       :: isSoftCore = .false.
126 >     type(cubicSpline) :: V
127 >     type(cubicSpline) :: phi
128    end type MixParameters
129  
130    type(MixParameters), dimension(:,:), allocatable :: MixingMap
131  
134
135
136  public :: init_SC_FF
132    public :: setCutoffSC
133    public :: do_SC_pair
134    public :: newSCtype
135    public :: calc_SC_prepair_rho
136 +  public :: calc_SC_preforce_Frho
137    public :: clean_SC
138    public :: destroySCtypes
139    public :: getSCCut
140 <  public :: setSCDefaultCutoff
141 <  public :: setSCUniformCutoff
140 > ! public :: setSCDefaultCutoff
141 > ! public :: setSCUniformCutoff
142 >
143  
144   contains
145  
146  
147 <  subroutine newSCtype(c,m,n,alpha,epsilon,c_ident,status)
148 <    real (kind = dp )                      :: lattice_constant
149 <    integer                                :: eam_nrho
150 <    real (kind = dp )                      :: eam_drho
151 <    integer                                :: eam_nr
152 <    real (kind = dp )                      :: eam_dr
156 <    real (kind = dp )                      :: rcut
157 <    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
147 >  subroutine newSCtype(c_ident,c,m,n,alpha,epsilon,status)
148 >    real (kind = dp )                      :: c ! Density Scaling
149 >    real (kind = dp )                      :: m ! Density Exponent
150 >    real (kind = dp )                      :: n ! Pair Potential Exponent
151 >    real (kind = dp )                      :: alpha ! Length Scaling
152 >    real (kind = dp )                      :: epsilon ! Energy Scaling
153      integer                                :: c_ident
154      integer                                :: status
162
155      integer                                :: nAtypes,nSCTypes,myATID
156      integer                                :: maxVals
157      integer                                :: alloc_stat
# Line 170 | Line 162 | contains
162  
163  
164      !! 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.
165  
166  
167      ! check to see if this is the first time into
168 <    if (.not.associated(SCTypeList%EAMParams)) then
169 <       call getMatchingElementList(atypes, "is_SuttonChen", .true., nSCtypes, MatchList)
170 <       SCTypeList%nSCtypes = nSCtypes
171 <       allocate(SCTypeList%SCTypes(nSCTypes))
168 >    if (.not.associated(SCList%SCTypes)) then
169 >       call getMatchingElementList(atypes, "is_SC", .true., nSCtypes, MatchList)
170 >       SCList%nSCtypes = nSCtypes
171 >       allocate(SCList%SCTypes(nSCTypes))
172         nAtypes = getSize(atypes)
173 <       allocate(SCTypeList%atidToSCType(nAtypes))
173 >       allocate(SCList%atidToSCType(nAtypes))
174      end if
175  
176 <    SCTypeList%currentSCType = SCTypeList%currentSCType + 1
177 <    current = SCTypeList%currentSCType
176 >    SCList%currentSCType = SCList%currentSCType + 1
177 >    current = SCList%currentSCType
178  
179      myATID =  getFirstMatchingElement(atypes, "c_ident", c_ident)
180 <    SCTypeList%atidToSCType(myATID) = current
190 <
191 <
180 >    SCList%atidToSCType(myATID) = current
181    
182 <    SCTypeList%SCTypes(current)%atid         = c_ident
183 <    SCTypeList%SCTypes(current)%alpha        = alpha
184 <    SCTypeList%SCTypes(current)%c            = c
185 <    SCTypeList%SCTypes(current)%m            = m
186 <    SCTypeList%SCTypes(current)%n            = n
187 <    SCTypeList%SCTypes(current)%epsilon      = epsilon
182 >    SCList%SCTypes(current)%atid         = c_ident
183 >    SCList%SCTypes(current)%alpha        = alpha
184 >    SCList%SCTypes(current)%c            = c
185 >    SCList%SCTypes(current)%m            = m
186 >    SCList%SCTypes(current)%n            = n
187 >    SCList%SCTypes(current)%epsilon      = epsilon
188    end subroutine newSCtype
189  
190    
191    subroutine destroySCTypes()
192 <
193 <    
194 <    if(allocated(SCTypeList)) deallocate(SCTypeList)
195 <
196 <
192 >    if (associated(SCList%SCtypes)) then
193 >       deallocate(SCList%SCTypes)
194 >       SCList%SCTypes=>null()
195 >    end if
196 >    if (associated(SCList%atidToSCtype)) then
197 >       deallocate(SCList%atidToSCtype)
198 >       SCList%atidToSCtype=>null()
199 >    end if
200 > ! Reset Capacity
201 >    SCList%nSCTypes = 0
202 >    SCList%currentSCtype=0
203  
204    end subroutine destroySCTypes
205  
211
212
206    function getSCCut(atomID) result(cutValue)
207      integer, intent(in) :: atomID
208 <    integer :: eamID
208 >    integer :: scID
209      real(kind=dp) :: cutValue
210      
211 <    eamID = SCTypeList%atidToEAMType(atomID)
212 <    cutValue = SCTypeList%EAMParams(eamID)%eam_rcut
211 >    scID = SCList%atidToSCType(atomID)
212 >    cutValue = 2.0_dp * SCList%SCTypes(scID)%alpha
213    end function getSCCut
214  
222
223
224
215    subroutine createMixingMap()
216 <    integer :: nSCtypes, i, j
217 <    real ( kind = dp ) :: e1, e2,m1,m2,alpha1,alpha2,n1,n2
218 <    real ( kind = dp ) :: rcut6, tp6, tp12
219 <    logical :: isSoftCore1, isSoftCore2, doShift
216 >    integer :: nSCtypes, i, j, k
217 >    real ( kind = dp ) :: e1, e2, m1, m2, alpha1, alpha2, n1, n2
218 >    real ( kind = dp ) :: epsilon, m, n, alpha, rCut, vCut, dr, r
219 >    real ( kind = dp ), dimension(np) :: rvals, vvals, phivals
220  
221      if (SCList%currentSCtype == 0) then
222         call handleError("SuttonChen", "No members in SCMap")
# Line 238 | Line 228 | contains
228      if (.not. allocated(MixingMap)) then
229         allocate(MixingMap(nSCtypes, nSCtypes))
230      endif
231 <
231 >    useGeometricDistanceMixing = usesGeometricDistanceMixing()
232      do i = 1, nSCtypes
233  
234         e1 = SCList%SCtypes(i)%epsilon
# Line 246 | Line 236 | contains
236         n1 = SCList%SCtypes(i)%n
237         alpha1 = SCList%SCtypes(i)%alpha
238  
239 <       do j = i, nSCtypes
239 >       do j = 1, nSCtypes
240            
251
241            e2 = SCList%SCtypes(j)%epsilon
242            m2 = SCList%SCtypes(j)%m
243            n2 = SCList%SCtypes(j)%n
244            alpha2 = SCList%SCtypes(j)%alpha
245  
246 <          MixingMap(i,j)%epsilon = dsqrt(e1 * e2)
247 <          MixingMap(i,j)%m = 0.5_dp*(m1+m2)
248 <          MixingMap(i,j)%n = 0.5_dp*(n1+n2)
249 <          MixingMap(i,j)%alpha = 0.5_dp*(alpha1+alpha2)
250 <          MixingMap(i,j)%rcut = 2.0_dp *MixingMap(i,j)%alpha
251 <          MixingMap(i,j)%vpair_rcut = MixingMap%epsilon(i,j)* &
252 <               (MixingMap%alpha(i,j)/MixingMap(i,j)%rcut)**MixingMap(i,j)%n
246 >          if (useGeometricDistanceMixing) then
247 >             alpha = sqrt(alpha1 * alpha2) !SC formulation
248 >          else
249 >             alpha = 0.5_dp * (alpha1 + alpha2) ! Goddard formulation
250 >          endif
251 >          rcut = 2.0_dp * alpha
252 >          epsilon = sqrt(e1 * e2)
253 >          m = 0.5_dp*(m1+m2)
254 >          n = 0.5_dp*(n1+n2)
255  
256 +          dr = (rCut) / dble(np-1)
257 +          rvals(1) = 0.0_dp
258 +          vvals(1) = 0.0_dp
259 +          phivals(1) = 0.0_dp
260 +
261 +          do k = 2, np
262 +             r = dble(k-1)*dr
263 +             rvals(k) = r
264 +             vvals(k) = epsilon*((alpha/r)**n)
265 +             phivals(k) = (alpha/r)**m
266 +          enddo
267 +
268 +          vCut = epsilon*((alpha/rCut)**n)
269 +
270 +          call newSpline(MixingMap(i,j)%V, rvals, vvals, .true.)
271 +          call newSpline(MixingMap(i,j)%phi, rvals, phivals, .true.)
272 +
273 +          MixingMap(i,j)%epsilon = epsilon
274 +          MixingMap(i,j)%m = m
275 +          MixingMap(i,j)%n = n
276 +          MixingMap(i,j)%alpha = alpha
277 +          MixingMap(i,j)%rCut = rcut
278 +          MixingMap(i,j)%vCut = vCut
279         enddo
280      enddo
281      
# Line 272 | Line 286 | contains
286  
287    !! routine checks to see if array is allocated, deallocates array if allocated
288    !! and then creates the array to the required size
289 <  subroutine allocateSC(status)
290 <    integer, intent(out) :: status
289 >  subroutine allocateSC()
290 >    integer :: status
291  
292   #ifdef IS_MPI
293      integer :: nAtomsInRow
# Line 281 | Line 295 | contains
295   #endif
296      integer :: alloc_stat
297  
298 <
298 >    
299      status = 0
300   #ifdef IS_MPI
301      nAtomsInRow = getNatomsInRow(plan_atom_row)
302      nAtomsInCol = getNatomsInCol(plan_atom_col)
303   #endif
304  
291
292
305      if (allocated(frho)) deallocate(frho)
306      allocate(frho(nlocal),stat=alloc_stat)
307      if (alloc_stat /= 0) then
308         status = -1
297       return
309      end if
310  
311      if (allocated(rho)) deallocate(rho)
312      allocate(rho(nlocal),stat=alloc_stat)
313      if (alloc_stat /= 0) then
314         status = -1
304       return
315      end if
316  
317      if (allocated(dfrhodrho)) deallocate(dfrhodrho)
318      allocate(dfrhodrho(nlocal),stat=alloc_stat)
319      if (alloc_stat /= 0) then
320         status = -1
311       return
321      end if
322  
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
323   #ifdef IS_MPI
324  
325      if (allocated(rho_tmp)) deallocate(rho_tmp)
326      allocate(rho_tmp(nlocal),stat=alloc_stat)
327      if (alloc_stat /= 0) then
328         status = -1
327       return
329      end if
330  
331  
# Line 332 | Line 333 | contains
333      allocate(frho_row(nAtomsInRow),stat=alloc_stat)
334      if (alloc_stat /= 0) then
335         status = -1
335       return
336      end if
337      if (allocated(rho_row)) deallocate(rho_row)
338      allocate(rho_row(nAtomsInRow),stat=alloc_stat)
339      if (alloc_stat /= 0) then
340         status = -1
341       return
341      end if
342      if (allocated(dfrhodrho_row)) deallocate(dfrhodrho_row)
343      allocate(dfrhodrho_row(nAtomsInRow),stat=alloc_stat)
344      if (alloc_stat /= 0) then
345         status = -1
347       return
346      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
347  
348  
349      ! Now do column arrays
# Line 360 | Line 352 | contains
352      allocate(frho_col(nAtomsInCol),stat=alloc_stat)
353      if (alloc_stat /= 0) then
354         status = -1
363       return
355      end if
356      if (allocated(rho_col)) deallocate(rho_col)
357      allocate(rho_col(nAtomsInCol),stat=alloc_stat)
358      if (alloc_stat /= 0) then
359         status = -1
369       return
360      end if
361      if (allocated(dfrhodrho_col)) deallocate(dfrhodrho_col)
362      allocate(dfrhodrho_col(nAtomsInCol),stat=alloc_stat)
363      if (alloc_stat /= 0) then
364         status = -1
375       return
365      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
366  
367   #endif
368 <
369 <  end subroutine allocateSC
370 <
371 <  !! C sets rcut to be the largest cutoff of any atype
372 <  !! present in this simulation. Doesn't include all atypes
390 <  !! sim knows about, just those in the simulation.
391 <  subroutine setCutoffSC(rcut, status)
392 <    real(kind=dp) :: rcut
393 <    integer :: status
394 <    status = 0
368 >    if (status == -1) then
369 >       call handleError("SuttonChen:allocateSC","Error in allocating SC arrays")
370 >    end if
371 >    arraysAllocated = .true.
372 >  end subroutine allocateSC
373  
374 +  subroutine setCutoffSC(rcut)
375 +    real(kind=dp) :: rcut
376      SC_rcut = rcut
397
377    end subroutine setCutoffSC
378 <
379 <
380 <
381 <  subroutine clean_EAM()
382 <
378 >  
379 >  !! This array allocates module arrays if needed and builds mixing map.
380 >  subroutine clean_SC()
381 >    if (.not.arraysAllocated) call allocateSC()
382 >    if (.not.haveMixingMap) call createMixingMap()
383      ! clean non-IS_MPI first
384      frho = 0.0_dp
385      rho  = 0.0_dp
# Line 415 | Line 394 | contains
394      dfrhodrho_row = 0.0_dp
395      dfrhodrho_col = 0.0_dp
396   #endif
397 <  end subroutine clean_EAM
397 >  end subroutine clean_SC
398  
420
421
399    !! Calculates rho_r
400 <  subroutine calc_sc_prepair_rho(atom1,atom2,d,r,rijsq)
400 >  subroutine calc_sc_prepair_rho(atom1, atom2, d, r, rijsq, rcut)
401      integer :: atom1,atom2
402      real(kind = dp), dimension(3) :: d
403      real(kind = dp), intent(inout)               :: r
404 <    real(kind = dp), intent(inout)               :: rijsq
404 >    real(kind = dp), intent(inout)               :: rijsq, rcut
405      ! value of electron density rho do to atom i at atom j
406      real(kind = dp) :: rho_i_at_j
407      ! value of electron density rho do to atom j at atom i
408      real(kind = dp) :: rho_j_at_i
409  
410      ! we don't use the derivatives, dummy variables
411 <    real( kind = dp) :: drho,d2rho
411 >    real( kind = dp) :: drho
412      integer :: sc_err
413      
414      integer :: atid1,atid2 ! Global atid    
# Line 441 | Line 418 | contains
418  
419      ! check to see if we need to be cleaned at the start of a force loop
420  
421 +    if (cleanArrays) call clean_SC()
422 +    cleanArrays = .false.
423  
445
446
424   #ifdef IS_MPI
425      Atid1 = Atid_row(Atom1)
426      Atid2 = Atid_col(Atom2)
# Line 452 | Line 429 | contains
429      Atid2 = Atid(Atom2)
430   #endif
431  
432 <    Myid_atom1 = SCTypeList%atidtoSCtype(Atid1)
433 <    Myid_atom2 = SCTypeList%atidtoSCtype(Atid2)
432 >    Myid_atom1 = SCList%atidtoSCtype(Atid1)
433 >    Myid_atom2 = SCList%atidtoSCtype(Atid2)
434 >    
435 >    call lookupUniformSpline(MixingMap(myid_atom1,myid_atom2)%phi, r, &
436 >         rho_i_at_j)
437 >    rho_j_at_i = rho_i_at_j
438  
458
459
460       rho_i_at_j = (MixingMap(Myid_atom1,Myid_atom2)%alpha/r)&
461            **MixingMap(Myid_atom1,Myid_atom2)%m
462       rho_j_at_i = rho_i_at_j
463
439   #ifdef  IS_MPI
440 <       rho_col(atom2) = rho_col(atom2) + rho_i_at_j
441 <       rho_row(atom1) = rho_row(atom1) + rho_j_at_i
440 >    rho_col(atom2) = rho_col(atom2) + rho_i_at_j
441 >    rho_row(atom1) = rho_row(atom1) + rho_j_at_i
442   #else
443 <       rho(atom2) = rho(atom2) + rho_i_at_j
444 <       rho(atom1) = rho(atom1) + rho_j_at_i
443 >    rho(atom2) = rho(atom2) + rho_i_at_j
444 >    rho(atom1) = rho(atom1) + rho_j_at_i
445   #endif
446 <
446 >    
447    end subroutine calc_sc_prepair_rho
448  
449  
450 < !! Calculate the rho_a for all local atoms
451 <  subroutine calc_eam_preforce_Frho(nlocal,pot)
450 >  !! Calculate the rho_a for all local atoms
451 >  subroutine calc_sc_preforce_Frho(nlocal,pot)
452      integer :: nlocal
453      real(kind=dp) :: pot
454      integer :: i,j
455      integer :: atom
481    real(kind=dp) :: U,U1,U2
456      integer :: atype1
457 <    integer :: me,atid1
458 <    integer :: n_rho_points
457 >    integer :: atid1
458 >    integer :: myid
459  
460 <
461 <    cleanme = .true.
488 <    !! Scatter the electron density from  pre-pair calculation back to local atoms
460 >    !! Scatter the electron density from  pre-pair calculation back to
461 >    !! local atoms
462   #ifdef IS_MPI
463      call scatter(rho_row,rho,plan_atom_row,sc_err)
464      if (sc_err /= 0 ) then
# Line 501 | Line 474 | contains
474  
475      rho(1:nlocal) = rho(1:nlocal) + rho_tmp(1:nlocal)
476   #endif
477 <
505 <
506 <
477 >    
478      !! Calculate F(rho) and derivative
479      do atom = 1, nlocal
480 <       Myid = ScTypeList%atidtoSctype(Atid(atom))
481 <       frho(atom) = -MixingMap(Myid,Myid)%c * MixingMap(Myid,Myid)%epsilon &
482 <            * sqrt(rho(i))
480 >       Myid = SCList%atidtoSctype(Atid(atom))
481 >       frho(atom) = - SCList%SCTypes(Myid)%c * &
482 >            SCList%SCTypes(Myid)%epsilon * sqrt(rho(atom))
483 >
484         dfrhodrho(atom) = 0.5_dp*frho(atom)/rho(atom)
485 <       d2frhodrhodrho(atom) = -0.5_dp*dfrhodrho(atom)/rho(atom)
486 <       pot = pot + u
485 >
486 >       pot = pot + frho(atom)
487      enddo
488  
489 <    #ifdef IS_MPI
489 > #ifdef IS_MPI
490      !! communicate f(rho) and derivatives back into row and column arrays
491      call gather(frho,frho_row,plan_atom_row, sc_err)
492      if (sc_err /=  0) then
# Line 532 | Line 504 | contains
504      if (sc_err /=  0) then
505         call handleError("cal_eam_forces()","MPI gather dfrhodrho_col failure")
506      endif
535
536    if (nmflag) then
537       call gather(d2frhodrhodrho,d2frhodrhodrho_row,plan_atom_row)
538       call gather(d2frhodrhodrho,d2frhodrhodrho_col,plan_atom_col)
539    endif
507   #endif
508      
509      
510 <  end subroutine calc_eam_preforce_Frho
511 <
545 <
510 >  end subroutine calc_sc_preforce_Frho  
511 >  
512    !! Does Sutton-Chen  pairwise Force calculation.  
513 <  subroutine do_eam_pair(atom1, atom2, d, rij, r2, sw, vpair, fpair, &
513 >  subroutine do_sc_pair(atom1, atom2, d, rij, r2, rcut, sw, vpair, fpair, &
514         pot, f, do_pot)
515      !Arguments    
516      integer, intent(in) ::  atom1, atom2
517 <    real( kind = dp ), intent(in) :: rij, r2
517 >    real( kind = dp ), intent(in) :: rij, r2, rcut
518      real( kind = dp ) :: pot, sw, vpair
519      real( kind = dp ), dimension(3,nLocal) :: f
520      real( kind = dp ), intent(in), dimension(3) :: d
# Line 556 | Line 522 | contains
522  
523      logical, intent(in) :: do_pot
524  
525 <    real( kind = dp ) :: drdx,drdy,drdz
526 <    real( kind = dp ) :: d2
527 <    real( kind = dp ) :: phab,pha,dvpdr,d2vpdrdr
528 <    real( kind = dp ) :: rha,drha,d2rha, dpha
563 <    real( kind = dp ) :: rhb,drhb,d2rhb, dphb
564 <    real( kind = dp ) :: dudr
565 <    real( kind = dp ) :: rcij
566 <    real( kind = dp ) :: drhoidr,drhojdr
567 <    real( kind = dp ) :: d2rhoidrdr
568 <    real( kind = dp ) :: d2rhojdrdr
525 >    real( kind = dp ) :: drdx, drdy, drdz
526 >    real( kind = dp ) :: dvpdr
527 >    real( kind = dp ) :: rhtmp, drhodr
528 >    real( kind = dp ) :: dudr
529      real( kind = dp ) :: Fx,Fy,Fz
530 <    real( kind = dp ) :: r,d2pha,phb,d2phb
531 <
532 <    integer :: id1,id2
530 >    real( kind = dp ) :: pot_temp, vptmp
531 >    real( kind = dp ) :: rcij, vcij
532 >    integer :: id1, id2
533      integer  :: mytype_atom1
534      integer  :: mytype_atom2
535 <    integer  :: atid1,atid2
535 >    integer  :: atid1, atid2
536      !Local Variables
537 +    
538 +    cleanArrays = .true.
539  
578    ! write(*,*) "Frho: ", Frho(atom1)
579
580    phab = 0.0E0_DP
581    dvpdr = 0.0E0_DP
582    d2vpdrdr = 0.0E0_DP
583
584
540   #ifdef IS_MPI
541         atid1 = atid_row(atom1)
542         atid2 = atid_col(atom2)
# Line 590 | Line 545 | contains
545         atid2 = atid(atom2)
546   #endif
547  
548 <       mytype_atom1 = SCTypeList%atidToSCType(atid1)
549 <       mytype_atom2 = SCTypeList%atidTOSCType(atid2)
548 >       mytype_atom1 = SCList%atidToSCType(atid1)
549 >       mytype_atom2 = SCList%atidTOSCType(atid2)
550  
551         drdx = d(1)/rij
552         drdy = d(2)/rij
553         drdz = d(3)/rij
599
554                  
555 <       epsilonij = MixingMap(mytype_atom1,mytype_atom2)%epsilon
556 <       aij       = MixingMap(mytype_atom1,mytype_atom2)%alpha
603 <       nij       = MixingMap(mytype_atom1,mytype_atom2)%n
604 <       mij       = MixingMap(mytype_atom1,mytype_atom2)%m
605 <       vcij      = MixingMap(mytype_atom1,mytype_atom2)%vpair_pot              
606 <
607 <       vptmp = dij*((aij/r)**nij)
608 <
609 <
610 <       dvpdr = -nij*vptmp/r
611 <       d2vpdrdr = -dvpdr*(nij+1.0d0)/r
555 >       rcij = MixingMap(mytype_atom1,mytype_atom2)%rCut
556 >       vcij = MixingMap(mytype_atom1,mytype_atom2)%vCut
557        
558 <       drhodr = -mij*((aij/r)**mij)/r
559 <       d2rhodrdr = -drhodr*(mij+1.0d0)/r
615 <      
616 <       dudr = drhodr*(dfrhodrho(i)+dfrhodrho(j)) &
617 <            + dvpdr
618 <
619 <
558 >       call lookupUniformSpline1d(MixingMap(mytype_atom1, mytype_atom2)%phi, &
559 >            rij, rhtmp, drhodr)
560  
561 +       call lookupUniformSpline1d(MixingMap(mytype_atom1, mytype_atom2)%V, &
562 +            rij, vptmp, dvpdr)
563 +      
564   #ifdef IS_MPI
565 <       dudr = drhodr*(dfrhodrho_row(atom1)+dfrhodrho_col(atom2)) &
623 <            + dvpdr
624 <
565 >       dudr = drhodr*(dfrhodrho_row(atom1) + dfrhodrho_col(atom2)) + dvpdr
566   #else
567 <       dudr = drhodr*(dfrhodrho(atom1)+dfrhodrho(atom2)) &
627 <            + dvpdr
567 >       dudr = drhodr*(dfrhodrho(atom1)+ dfrhodrho(atom2)) + dvpdr
568   #endif
569 <
570 <
569 >              
570 >       pot_temp = vptmp - vcij
571 >
572         fx = dudr * drdx
573         fy = dudr * drdy
574         fz = dudr * drdz
575  
635
576   #ifdef IS_MPI
577         if (do_pot) then
578 <          pot_Row(METALLIC_POT,atom1) = pot_Row(METALLIC_POT,atom1) + phab*0.5
579 <          pot_Col(METALLIC_POT,atom2) = pot_Col(METALLIC_POT,atom2) + phab*0.5
578 >          pot_Row(METALLIC_POT,atom1) = pot_Row(METALLIC_POT,atom1) + (pot_temp)*0.5
579 >          pot_Col(METALLIC_POT,atom2) = pot_Col(METALLIC_POT,atom2) + (pot_temp)*0.5
580         end if
581  
582         f_Row(1,atom1) = f_Row(1,atom1) + fx
# Line 649 | Line 589 | contains
589   #else
590  
591         if(do_pot) then
592 <          pot = pot + phab
592 >          pot = pot + pot_temp
593         end if
594  
595         f(1,atom1) = f(1,atom1) + fx
# Line 661 | Line 601 | contains
601         f(3,atom2) = f(3,atom2) - fz
602   #endif
603  
604 <       vpair = vpair + phab
604 >      
605   #ifdef IS_MPI
606         id1 = AtomRowToGlobal(atom1)
607         id2 = AtomColToGlobal(atom2)
# Line 677 | Line 617 | contains
617            fpair(3) = fpair(3) + fz
618  
619         endif
620 <
681 <       if (nmflag) then
682 <
683 <          drhoidr = drha
684 <          drhojdr = drhb
685 <          d2rhoidrdr = d2rha
686 <          d2rhojdrdr = d2rhb
687 <
688 < #ifdef IS_MPI
689 <          d2 = d2vpdrdr + &
690 <               d2rhoidrdr*dfrhodrho_col(atom2) + &
691 <               d2rhojdrdr*dfrhodrho_row(atom1) + &
692 <               drhoidr*drhoidr*d2frhodrhodrho_col(atom2) + &
693 <               drhojdr*drhojdr*d2frhodrhodrho_row(atom1)
694 <
695 < #else
696 <
697 <          d2 = d2vpdrdr + &
698 <               d2rhoidrdr*dfrhodrho(atom2) + &
699 <               d2rhojdrdr*dfrhodrho(atom1) + &
700 <               drhoidr*drhoidr*d2frhodrhodrho(atom2) + &
701 <               drhojdr*drhojdr*d2frhodrhodrho(atom1)
702 < #endif
703 <       end if
704 <
705 <    endif
706 <  end subroutine do_eam_pair
707 <
708 <
709 <
620 >  end subroutine do_sc_pair
621   end module suttonchen

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines