63 |
|
|
64 |
|
character(len = 200) :: errMsg |
65 |
|
character(len=*), parameter :: RoutineName = "EAM MODULE" |
66 |
< |
!! Logical that determines if eam arrays should be zeroed |
66 |
> |
!! Logical that determines if eam arrays should be zeroed |
67 |
|
logical :: cleanme = .true. |
68 |
|
logical :: nmflag = .false. |
69 |
|
|
70 |
< |
|
70 |
> |
|
71 |
|
type, private :: EAMtype |
72 |
|
integer :: eam_atype |
73 |
|
real( kind = DP ) :: eam_dr |
77 |
|
real( kind = DP ) :: eam_drho |
78 |
|
real( kind = DP ) :: eam_rcut |
79 |
|
integer :: eam_atype_map |
80 |
< |
|
80 |
> |
|
81 |
|
real( kind = DP ), pointer, dimension(:) :: eam_rvals => null() |
82 |
|
real( kind = DP ), pointer, dimension(:) :: eam_rhovals => null() |
83 |
|
real( kind = DP ), pointer, dimension(:) :: eam_F_rho => null() |
99 |
|
real( kind = dp), dimension(:), allocatable :: d2frhodrhodrho |
100 |
|
|
101 |
|
|
102 |
< |
!! Arrays for MPI storage |
102 |
> |
!! Arrays for MPI storage |
103 |
|
#ifdef IS_MPI |
104 |
|
real( kind = dp),save, dimension(:), allocatable :: dfrhodrho_col |
105 |
|
real( kind = dp),save, dimension(:), allocatable :: dfrhodrho_row |
115 |
|
type, private :: EAMTypeList |
116 |
|
integer :: n_eam_types = 0 |
117 |
|
integer :: currentAddition = 0 |
118 |
< |
|
118 |
> |
|
119 |
|
type (EAMtype), pointer :: EAMParams(:) => null() |
120 |
|
end type EAMTypeList |
121 |
|
|
163 |
|
|
164 |
|
!! Assume that atypes has already been set and get the total number of types in atypes |
165 |
|
!! Also assume that every member of atypes is a EAM model. |
166 |
– |
|
166 |
|
|
167 |
+ |
|
168 |
|
! check to see if this is the first time into |
169 |
|
if (.not.associated(EAMList%EAMParams)) then |
170 |
|
call getMatchingElementList(atypes, "is_EAM", .true., nAtypes, MatchList) |
174 |
|
|
175 |
|
EAMList%currentAddition = EAMList%currentAddition + 1 |
176 |
|
current = EAMList%currentAddition |
177 |
– |
|
177 |
|
|
178 |
+ |
|
179 |
|
call allocate_EAMType(eam_nrho,eam_nr,EAMList%EAMParams(current),stat=alloc_stat) |
180 |
|
if (alloc_stat /= 0) then |
181 |
|
status = -1 |
184 |
|
|
185 |
|
! this is a possible bug, we assume a correspondence between the vector atypes and |
186 |
|
! EAMAtypes |
187 |
< |
|
187 |
> |
|
188 |
|
EAMList%EAMParams(current)%eam_atype = eam_ident |
189 |
|
EAMList%EAMParams(current)%eam_lattice = lattice_constant |
190 |
|
EAMList%EAMParams(current)%eam_nrho = eam_nrho |
210 |
|
end do |
211 |
|
if(associated( eamList%EAMParams)) deallocate( eamList%EAMParams) |
212 |
|
eamList%EAMParams => null() |
213 |
< |
|
213 |
> |
|
214 |
|
eamList%n_eam_types = 0 |
215 |
|
eamList%currentAddition = 0 |
216 |
< |
|
216 |
> |
|
217 |
|
end subroutine destroyEAMtypes |
218 |
|
|
219 |
|
subroutine init_EAM_FF(status) |
231 |
|
return |
232 |
|
end if |
233 |
|
|
234 |
– |
|
235 |
– |
do i = 1, EAMList%currentAddition |
234 |
|
|
235 |
< |
! Build array of r values |
235 |
> |
do i = 1, EAMList%currentAddition |
236 |
|
|
237 |
< |
do j = 1,EAMList%EAMParams(i)%eam_nr |
240 |
< |
EAMList%EAMParams(i)%eam_rvals(j) = & |
241 |
< |
real(j-1,kind=dp)* & |
242 |
< |
EAMList%EAMParams(i)%eam_dr |
243 |
< |
end do |
244 |
< |
! Build array of rho values |
245 |
< |
do j = 1,EAMList%EAMParams(i)%eam_nrho |
246 |
< |
EAMList%EAMParams(i)%eam_rhovals(j) = & |
247 |
< |
real(j-1,kind=dp)* & |
248 |
< |
EAMList%EAMParams(i)%eam_drho |
249 |
< |
end do |
250 |
< |
! convert from eV to kcal / mol: |
251 |
< |
EAMList%EAMParams(i)%eam_F_rho = EAMList%EAMParams(i)%eam_F_rho * 23.06054E0_DP |
237 |
> |
! Build array of r values |
238 |
|
|
239 |
< |
! precompute the pair potential and get it into kcal / mol: |
240 |
< |
EAMList%EAMParams(i)%eam_phi_r(1) = 0.0E0_DP |
241 |
< |
do j = 2, EAMList%EAMParams(i)%eam_nr |
242 |
< |
EAMList%EAMParams(i)%eam_phi_r(j) = (EAMList%EAMParams(i)%eam_Z_r(j)**2)/EAMList%EAMParams(i)%eam_rvals(j) |
257 |
< |
EAMList%EAMParams(i)%eam_phi_r(j) = EAMList%EAMParams(i)%eam_phi_r(j)*331.999296E0_DP |
258 |
< |
enddo |
239 |
> |
do j = 1,EAMList%EAMParams(i)%eam_nr |
240 |
> |
EAMList%EAMParams(i)%eam_rvals(j) = & |
241 |
> |
real(j-1,kind=dp)* & |
242 |
> |
EAMList%EAMParams(i)%eam_dr |
243 |
|
end do |
244 |
< |
|
244 |
> |
! Build array of rho values |
245 |
> |
do j = 1,EAMList%EAMParams(i)%eam_nrho |
246 |
> |
EAMList%EAMParams(i)%eam_rhovals(j) = & |
247 |
> |
real(j-1,kind=dp)* & |
248 |
> |
EAMList%EAMParams(i)%eam_drho |
249 |
> |
end do |
250 |
> |
! convert from eV to kcal / mol: |
251 |
> |
EAMList%EAMParams(i)%eam_F_rho = EAMList%EAMParams(i)%eam_F_rho * 23.06054E0_DP |
252 |
|
|
253 |
< |
do i = 1, EAMList%currentAddition |
254 |
< |
number_r = EAMList%EAMParams(i)%eam_nr |
255 |
< |
number_rho = EAMList%EAMParams(i)%eam_nrho |
256 |
< |
|
257 |
< |
call eam_spline(number_r, EAMList%EAMParams(i)%eam_rvals, & |
267 |
< |
EAMList%EAMParams(i)%eam_rho_r, & |
268 |
< |
EAMList%EAMParams(i)%eam_rho_r_pp, & |
269 |
< |
0.0E0_DP, 0.0E0_DP, 'N') |
270 |
< |
call eam_spline(number_r, EAMList%EAMParams(i)%eam_rvals, & |
271 |
< |
EAMList%EAMParams(i)%eam_Z_r, & |
272 |
< |
EAMList%EAMParams(i)%eam_Z_r_pp, & |
273 |
< |
0.0E0_DP, 0.0E0_DP, 'N') |
274 |
< |
call eam_spline(number_rho, EAMList%EAMParams(i)%eam_rhovals, & |
275 |
< |
EAMList%EAMParams(i)%eam_F_rho, & |
276 |
< |
EAMList%EAMParams(i)%eam_F_rho_pp, & |
277 |
< |
0.0E0_DP, 0.0E0_DP, 'N') |
278 |
< |
call eam_spline(number_r, EAMList%EAMParams(i)%eam_rvals, & |
279 |
< |
EAMList%EAMParams(i)%eam_phi_r, & |
280 |
< |
EAMList%EAMParams(i)%eam_phi_r_pp, & |
281 |
< |
0.0E0_DP, 0.0E0_DP, 'N') |
253 |
> |
! precompute the pair potential and get it into kcal / mol: |
254 |
> |
EAMList%EAMParams(i)%eam_phi_r(1) = 0.0E0_DP |
255 |
> |
do j = 2, EAMList%EAMParams(i)%eam_nr |
256 |
> |
EAMList%EAMParams(i)%eam_phi_r(j) = (EAMList%EAMParams(i)%eam_Z_r(j)**2)/EAMList%EAMParams(i)%eam_rvals(j) |
257 |
> |
EAMList%EAMParams(i)%eam_phi_r(j) = EAMList%EAMParams(i)%eam_phi_r(j)*331.999296E0_DP |
258 |
|
enddo |
259 |
+ |
end do |
260 |
|
|
284 |
– |
! current_rcut_max = EAMList%EAMParams(1)%eam_rcut |
285 |
– |
!! find the smallest rcut for any eam atype |
286 |
– |
! do i = 2, EAMList%currentAddition |
287 |
– |
! current_rcut_max =max(current_rcut_max,EAMList%EAMParams(i)%eam_rcut) |
288 |
– |
! end do |
261 |
|
|
262 |
< |
! EAM_rcut = current_rcut_max |
263 |
< |
! EAM_rcut_orig = current_rcut_max |
264 |
< |
! do i = 1, EAMList%currentAddition |
265 |
< |
! EAMList%EAMParam(i)s%eam_atype_map(eam_atype(i)) = i |
266 |
< |
! end do |
267 |
< |
!! Allocate arrays for force calculation |
268 |
< |
|
269 |
< |
call allocateEAM(alloc_stat) |
270 |
< |
if (alloc_stat /= 0 ) then |
271 |
< |
write(*,*) "allocateEAM failed" |
272 |
< |
status = -1 |
273 |
< |
return |
274 |
< |
endif |
275 |
< |
|
262 |
> |
do i = 1, EAMList%currentAddition |
263 |
> |
number_r = EAMList%EAMParams(i)%eam_nr |
264 |
> |
number_rho = EAMList%EAMParams(i)%eam_nrho |
265 |
> |
|
266 |
> |
call eam_spline(number_r, EAMList%EAMParams(i)%eam_rvals, & |
267 |
> |
EAMList%EAMParams(i)%eam_rho_r, & |
268 |
> |
EAMList%EAMParams(i)%eam_rho_r_pp, & |
269 |
> |
0.0E0_DP, 0.0E0_DP, 'N') |
270 |
> |
call eam_spline(number_r, EAMList%EAMParams(i)%eam_rvals, & |
271 |
> |
EAMList%EAMParams(i)%eam_Z_r, & |
272 |
> |
EAMList%EAMParams(i)%eam_Z_r_pp, & |
273 |
> |
0.0E0_DP, 0.0E0_DP, 'N') |
274 |
> |
call eam_spline(number_rho, EAMList%EAMParams(i)%eam_rhovals, & |
275 |
> |
EAMList%EAMParams(i)%eam_F_rho, & |
276 |
> |
EAMList%EAMParams(i)%eam_F_rho_pp, & |
277 |
> |
0.0E0_DP, 0.0E0_DP, 'N') |
278 |
> |
call eam_spline(number_r, EAMList%EAMParams(i)%eam_rvals, & |
279 |
> |
EAMList%EAMParams(i)%eam_phi_r, & |
280 |
> |
EAMList%EAMParams(i)%eam_phi_r_pp, & |
281 |
> |
0.0E0_DP, 0.0E0_DP, 'N') |
282 |
> |
enddo |
283 |
> |
|
284 |
> |
! current_rcut_max = EAMList%EAMParams(1)%eam_rcut |
285 |
> |
!! find the smallest rcut for any eam atype |
286 |
> |
! do i = 2, EAMList%currentAddition |
287 |
> |
! current_rcut_max =max(current_rcut_max,EAMList%EAMParams(i)%eam_rcut) |
288 |
> |
! end do |
289 |
> |
|
290 |
> |
! EAM_rcut = current_rcut_max |
291 |
> |
! EAM_rcut_orig = current_rcut_max |
292 |
> |
! do i = 1, EAMList%currentAddition |
293 |
> |
! EAMList%EAMParam(i)s%eam_atype_map(eam_atype(i)) = i |
294 |
> |
! end do |
295 |
> |
!! Allocate arrays for force calculation |
296 |
> |
|
297 |
> |
call allocateEAM(alloc_stat) |
298 |
> |
if (alloc_stat /= 0 ) then |
299 |
> |
write(*,*) "allocateEAM failed" |
300 |
> |
status = -1 |
301 |
> |
return |
302 |
> |
endif |
303 |
> |
|
304 |
|
end subroutine init_EAM_FF |
305 |
|
|
306 |
< |
!! routine checks to see if array is allocated, deallocates array if allocated |
307 |
< |
!! and then creates the array to the required size |
306 |
> |
!! routine checks to see if array is allocated, deallocates array if allocated |
307 |
> |
!! and then creates the array to the required size |
308 |
|
subroutine allocateEAM(status) |
309 |
|
integer, intent(out) :: status |
310 |
|
|
347 |
|
status = -1 |
348 |
|
return |
349 |
|
end if |
350 |
< |
|
350 |
> |
|
351 |
|
#ifdef IS_MPI |
352 |
|
|
353 |
|
if (allocated(rho_tmp)) deallocate(rho_tmp) |
384 |
|
end if |
385 |
|
|
386 |
|
|
387 |
< |
! Now do column arrays |
387 |
> |
! Now do column arrays |
388 |
|
|
389 |
|
if (allocated(frho_col)) deallocate(frho_col) |
390 |
|
allocate(frho_col(nAtomsInCol),stat=alloc_stat) |
410 |
|
status = -1 |
411 |
|
return |
412 |
|
end if |
413 |
< |
|
413 |
> |
|
414 |
|
#endif |
415 |
|
|
416 |
|
end subroutine allocateEAM |
417 |
|
|
418 |
< |
!! C sets rcut to be the largest cutoff of any atype |
419 |
< |
!! present in this simulation. Doesn't include all atypes |
420 |
< |
!! sim knows about, just those in the simulation. |
418 |
> |
!! C sets rcut to be the largest cutoff of any atype |
419 |
> |
!! present in this simulation. Doesn't include all atypes |
420 |
> |
!! sim knows about, just those in the simulation. |
421 |
|
subroutine setCutoffEAM(rcut, status) |
422 |
|
real(kind=dp) :: rcut |
423 |
|
integer :: status |
430 |
|
|
431 |
|
|
432 |
|
subroutine clean_EAM() |
433 |
< |
|
434 |
< |
! clean non-IS_MPI first |
433 |
> |
|
434 |
> |
! clean non-IS_MPI first |
435 |
|
frho = 0.0_dp |
436 |
|
rho = 0.0_dp |
437 |
|
dfrhodrho = 0.0_dp |
438 |
< |
! clean MPI if needed |
438 |
> |
! clean MPI if needed |
439 |
|
#ifdef IS_MPI |
440 |
|
frho_row = 0.0_dp |
441 |
|
frho_col = 0.0_dp |
459 |
|
|
460 |
|
|
461 |
|
if (present(stat)) stat = 0 |
462 |
< |
|
462 |
> |
|
463 |
|
allocate(thisEAMType%eam_rvals(eam_n_r),stat=alloc_stat) |
464 |
|
if (alloc_stat /= 0 ) then |
465 |
|
if (present(stat)) stat = -1 |
510 |
|
if (present(stat)) stat = -1 |
511 |
|
return |
512 |
|
end if |
513 |
– |
|
513 |
|
|
514 |
+ |
|
515 |
|
end subroutine allocate_EAMType |
516 |
|
|
517 |
|
|
529 |
|
if(associated(thisEAMType%eam_F_rho)) deallocate(thisEAMType%eam_F_rho) |
530 |
|
if(associated(thisEAMType%eam_rhovals)) deallocate(thisEAMType%eam_rhovals) |
531 |
|
if(associated(thisEAMType%eam_rvals)) deallocate(thisEAMType%eam_rvals) |
532 |
< |
|
532 |
> |
|
533 |
|
end subroutine deallocate_EAMType |
534 |
|
|
535 |
< |
!! Calculates rho_r |
535 |
> |
!! Calculates rho_r |
536 |
|
subroutine calc_eam_prepair_rho(atom1,atom2,d,r,rijsq) |
537 |
|
integer :: atom1,atom2 |
538 |
|
real(kind = dp), dimension(3) :: d |
546 |
|
! we don't use the derivatives, dummy variables |
547 |
|
real( kind = dp) :: drho,d2rho |
548 |
|
integer :: eam_err |
549 |
< |
|
549 |
> |
|
550 |
|
integer :: myid_atom1 |
551 |
|
integer :: myid_atom2 |
552 |
|
|
553 |
< |
! check to see if we need to be cleaned at the start of a force loop |
554 |
< |
|
553 |
> |
! check to see if we need to be cleaned at the start of a force loop |
554 |
|
|
555 |
|
|
556 |
|
|
557 |
+ |
|
558 |
|
#ifdef IS_MPI |
559 |
|
myid_atom1 = atid_Row(atom1) |
560 |
|
myid_atom2 = atid_Col(atom2) |
574 |
|
r, rho_i_at_j,drho,d2rho) |
575 |
|
|
576 |
|
|
577 |
< |
|
577 |
> |
|
578 |
|
#ifdef IS_MPI |
579 |
|
rho_col(atom2) = rho_col(atom2) + rho_i_at_j |
580 |
|
#else |
581 |
|
rho(atom2) = rho(atom2) + rho_i_at_j |
582 |
|
#endif |
583 |
< |
! write(*,*) atom1,atom2,r,rho_i_at_j |
584 |
< |
endif |
583 |
> |
! write(*,*) atom1,atom2,r,rho_i_at_j |
584 |
> |
endif |
585 |
|
|
586 |
< |
if (r.lt.EAMList%EAMParams(myid_atom2)%eam_rcut) then |
587 |
< |
call eam_splint(EAMList%EAMParams(myid_atom2)%eam_nr, & |
588 |
< |
EAMList%EAMParams(myid_atom2)%eam_rvals, & |
589 |
< |
EAMList%EAMParams(myid_atom2)%eam_rho_r, & |
590 |
< |
EAMList%EAMParams(myid_atom2)%eam_rho_r_pp, & |
591 |
< |
r, rho_j_at_i,drho,d2rho) |
586 |
> |
if (r.lt.EAMList%EAMParams(myid_atom2)%eam_rcut) then |
587 |
> |
call eam_splint(EAMList%EAMParams(myid_atom2)%eam_nr, & |
588 |
> |
EAMList%EAMParams(myid_atom2)%eam_rvals, & |
589 |
> |
EAMList%EAMParams(myid_atom2)%eam_rho_r, & |
590 |
> |
EAMList%EAMParams(myid_atom2)%eam_rho_r_pp, & |
591 |
> |
r, rho_j_at_i,drho,d2rho) |
592 |
|
|
593 |
< |
|
594 |
< |
|
595 |
< |
|
593 |
> |
|
594 |
> |
|
595 |
> |
|
596 |
|
#ifdef IS_MPI |
597 |
< |
rho_row(atom1) = rho_row(atom1) + rho_j_at_i |
597 |
> |
rho_row(atom1) = rho_row(atom1) + rho_j_at_i |
598 |
|
#else |
599 |
< |
rho(atom1) = rho(atom1) + rho_j_at_i |
599 |
> |
rho(atom1) = rho(atom1) + rho_j_at_i |
600 |
|
#endif |
601 |
< |
endif |
601 |
> |
endif |
602 |
|
|
603 |
|
|
604 |
|
|
621 |
|
integer :: me |
622 |
|
integer :: n_rho_points |
623 |
|
|
624 |
< |
|
624 |
> |
|
625 |
|
cleanme = .true. |
626 |
|
!! Scatter the electron density from pre-pair calculation back to local atoms |
627 |
|
#ifdef IS_MPI |
628 |
|
call scatter(rho_row,rho,plan_atom_row,eam_err) |
629 |
|
if (eam_err /= 0 ) then |
630 |
< |
write(errMsg,*) " Error scattering rho_row into rho" |
631 |
< |
call handleError(RoutineName,errMesg) |
632 |
< |
endif |
630 |
> |
write(errMsg,*) " Error scattering rho_row into rho" |
631 |
> |
call handleError(RoutineName,errMesg) |
632 |
> |
endif |
633 |
|
call scatter(rho_col,rho_tmp,plan_atom_col,eam_err) |
634 |
|
if (eam_err /= 0 ) then |
635 |
< |
write(errMsg,*) " Error scattering rho_col into rho" |
636 |
< |
call handleError(RoutineName,errMesg) |
637 |
< |
endif |
635 |
> |
write(errMsg,*) " Error scattering rho_col into rho" |
636 |
> |
call handleError(RoutineName,errMesg) |
637 |
> |
endif |
638 |
|
|
639 |
< |
rho(1:nlocal) = rho(1:nlocal) + rho_tmp(1:nlocal) |
639 |
> |
rho(1:nlocal) = rho(1:nlocal) + rho_tmp(1:nlocal) |
640 |
|
#endif |
641 |
|
|
642 |
|
|
643 |
|
|
644 |
< |
!! Calculate F(rho) and derivative |
644 |
> |
!! Calculate F(rho) and derivative |
645 |
|
do atom = 1, nlocal |
646 |
|
me = atid(atom) |
647 |
|
n_rho_points = EAMList%EAMParams(me)%eam_nrho |
671 |
|
|
672 |
|
enddo |
673 |
|
|
674 |
– |
|
674 |
|
|
675 |
+ |
|
676 |
|
#ifdef IS_MPI |
677 |
|
!! communicate f(rho) and derivatives back into row and column arrays |
678 |
|
call gather(frho,frho_row,plan_atom_row, eam_err) |
702 |
|
endif |
703 |
|
#endif |
704 |
|
|
705 |
< |
|
705 |
> |
|
706 |
|
end subroutine calc_eam_preforce_Frho |
707 |
|
|
708 |
|
|
720 |
|
real( kind = dp ), intent(inout), dimension(3) :: fpair |
721 |
|
|
722 |
|
logical, intent(in) :: do_pot |
723 |
< |
|
723 |
> |
|
724 |
|
real( kind = dp ) :: drdx,drdy,drdz |
725 |
|
real( kind = dp ) :: d2 |
726 |
|
real( kind = dp ) :: phab,pha,dvpdr,d2vpdrdr |
738 |
|
integer :: mytype_atom1 |
739 |
|
integer :: mytype_atom2 |
740 |
|
|
741 |
< |
!Local Variables |
742 |
< |
|
743 |
< |
! write(*,*) "Frho: ", Frho(atom1) |
741 |
> |
!Local Variables |
742 |
|
|
743 |
+ |
! write(*,*) "Frho: ", Frho(atom1) |
744 |
+ |
|
745 |
|
phab = 0.0E0_DP |
746 |
|
dvpdr = 0.0E0_DP |
747 |
|
d2vpdrdr = 0.0E0_DP |
759 |
|
rci = EAMList%EAMParams(mytype_atom1)%eam_rcut |
760 |
|
! get type specific cutoff for atom 2 |
761 |
|
rcj = EAMList%EAMParams(mytype_atom2)%eam_rcut |
762 |
< |
|
762 |
> |
|
763 |
|
drdx = d(1)/rij |
764 |
|
drdy = d(2)/rij |
765 |
|
drdz = d(3)/rij |
766 |
< |
|
766 |
> |
|
767 |
|
if (rij.lt.rci) then |
768 |
|
call eam_splint(EAMList%EAMParams(mytype_atom1)%eam_nr, & |
769 |
|
EAMList%EAMParams(mytype_atom1)%eam_rvals, & |
785 |
|
EAMList%EAMParams(mytype_atom2)%eam_rho_r, & |
786 |
|
EAMList%EAMParams(mytype_atom2)%eam_rho_r_pp, & |
787 |
|
rij, rhb,drhb,d2rhb) |
788 |
< |
|
788 |
> |
|
789 |
|
!! Calculate Phi(r) for atom2. |
790 |
|
call eam_splint(EAMList%EAMParams(mytype_atom2)%eam_nr, & |
791 |
|
EAMList%EAMParams(mytype_atom2)%eam_rvals, & |
803 |
|
pha*((d2rhb/rha) - 2.0E0_DP*(drhb*drha/rha/rha) + & |
804 |
|
(2.0E0_DP*rhb*drha*drha/rha/rha/rha) - (rhb*d2rha/rha/rha))) |
805 |
|
endif |
806 |
< |
|
806 |
> |
|
807 |
|
if (rij.lt.rcj) then |
808 |
|
phab = phab + 0.5E0_DP*(rha/rhb)*phb |
809 |
|
dvpdr = dvpdr + 0.5E0_DP*((rha/rhb)*dphb + & |
813 |
|
phb*((d2rha/rhb) - 2.0E0_DP*(drha*drhb/rhb/rhb) + & |
814 |
|
(2.0E0_DP*rha*drhb*drhb/rhb/rhb/rhb) - (rha*d2rhb/rhb/rhb))) |
815 |
|
endif |
816 |
< |
|
816 |
> |
|
817 |
|
drhoidr = drha |
818 |
|
drhojdr = drhb |
819 |
|
|
828 |
|
#else |
829 |
|
dudr = drhojdr*dfrhodrho(atom1)+drhoidr*dfrhodrho(atom2) & |
830 |
|
+ dvpdr |
831 |
< |
! write(*,*) "Atom1,Atom2, dfrhodrho(atom1) dfrhodrho(atom2): ", atom1,atom2,dfrhodrho(atom1),dfrhodrho(atom2) |
831 |
> |
! write(*,*) "Atom1,Atom2, dfrhodrho(atom1) dfrhodrho(atom2): ", atom1,atom2,dfrhodrho(atom1),dfrhodrho(atom2) |
832 |
|
#endif |
833 |
|
|
834 |
|
fx = dudr * drdx |
845 |
|
f_Row(1,atom1) = f_Row(1,atom1) + fx |
846 |
|
f_Row(2,atom1) = f_Row(2,atom1) + fy |
847 |
|
f_Row(3,atom1) = f_Row(3,atom1) + fz |
848 |
< |
|
848 |
> |
|
849 |
|
f_Col(1,atom2) = f_Col(1,atom2) - fx |
850 |
|
f_Col(2,atom2) = f_Col(2,atom2) - fy |
851 |
|
f_Col(3,atom2) = f_Col(3,atom2) - fz |
858 |
|
f(1,atom1) = f(1,atom1) + fx |
859 |
|
f(2,atom1) = f(2,atom1) + fy |
860 |
|
f(3,atom1) = f(3,atom1) + fz |
861 |
< |
|
861 |
> |
|
862 |
|
f(1,atom2) = f(1,atom2) - fx |
863 |
|
f(2,atom2) = f(2,atom2) - fy |
864 |
|
f(3,atom2) = f(3,atom2) - fz |
865 |
|
#endif |
866 |
< |
|
866 |
> |
|
867 |
|
vpair = vpair + phab |
868 |
|
#ifdef IS_MPI |
869 |
|
id1 = AtomRowToGlobal(atom1) |
872 |
|
id1 = atom1 |
873 |
|
id2 = atom2 |
874 |
|
#endif |
875 |
< |
|
875 |
> |
|
876 |
|
if (molMembershipList(id1) .ne. molMembershipList(id2)) then |
877 |
< |
|
877 |
> |
|
878 |
|
fpair(1) = fpair(1) + fx |
879 |
|
fpair(2) = fpair(2) + fy |
880 |
|
fpair(3) = fpair(3) + fz |
881 |
< |
|
881 |
> |
|
882 |
|
endif |
883 |
< |
|
883 |
> |
|
884 |
|
if (nmflag) then |
885 |
|
|
886 |
|
drhoidr = drha |
894 |
|
d2rhojdrdr*dfrhodrho_row(atom1) + & |
895 |
|
drhoidr*drhoidr*d2frhodrhodrho_col(atom2) + & |
896 |
|
drhojdr*drhojdr*d2frhodrhodrho_row(atom1) |
897 |
< |
|
897 |
> |
|
898 |
|
#else |
899 |
|
|
900 |
|
d2 = d2vpdrdr + & |
904 |
|
drhojdr*drhojdr*d2frhodrhodrho(atom1) |
905 |
|
#endif |
906 |
|
end if |
907 |
< |
|
908 |
< |
endif |
907 |
> |
|
908 |
> |
endif |
909 |
|
end subroutine do_eam_pair |
910 |
|
|
911 |
|
|
920 |
|
real( kind = DP ) :: del, h, a, b, c, d |
921 |
|
integer :: pp_arraySize |
922 |
|
|
923 |
< |
|
923 |
> |
|
924 |
|
! this spline code assumes that the x points are equally spaced |
925 |
|
! do not attempt to use this code if they are not. |
926 |
< |
|
927 |
< |
|
926 |
> |
|
927 |
> |
|
928 |
|
! find the closest point with a value below our own: |
929 |
|
j = FLOOR(real((nx-1),kind=dp) * (x - xa(1)) / (xa(nx) - xa(1))) + 1 |
930 |
|
|
936 |
|
! check to make sure we haven't screwed up the calculation of j: |
937 |
|
if ((x.lt.xa(j)).or.(x.gt.xa(j+1))) then |
938 |
|
if (j.ne.nx) then |
939 |
< |
write(errMSG,*) "EAM_splint:",x," x is outside bounding range" |
940 |
< |
call handleError(routineName,errMSG) |
939 |
> |
write(errMSG,*) "EAM_splint:",x," x is outside bounding range" |
940 |
> |
call handleError(routineName,errMSG) |
941 |
|
endif |
942 |
|
endif |
943 |
|
|
944 |
|
del = xa(j+1) - x |
945 |
|
h = xa(j+1) - xa(j) |
946 |
< |
|
946 |
> |
|
947 |
|
a = del / h |
948 |
|
b = 1.0E0_DP - a |
949 |
|
c = a*(a*a - 1.0E0_DP)*h*h/6.0E0_DP |
950 |
|
d = b*(b*b - 1.0E0_DP)*h*h/6.0E0_DP |
951 |
< |
|
951 |
> |
|
952 |
|
y = a*ya(j) + b*ya(j+1) + c*yppa(j) + d*yppa(j+1) |
953 |
– |
|
954 |
– |
dy = (ya(j+1)-ya(j))/h & |
955 |
– |
- (3.0E0_DP*a*a - 1.0E0_DP)*h*yppa(j)/6.0E0_DP & |
956 |
– |
+ (3.0E0_DP*b*b - 1.0E0_DP)*h*yppa(j+1)/6.0E0_DP |
957 |
– |
|
958 |
– |
|
959 |
– |
d2y = a*yppa(j) + b*yppa(j+1) |
960 |
– |
|
953 |
|
|
954 |
+ |
dy = (ya(j+1)-ya(j))/h & |
955 |
+ |
- (3.0E0_DP*a*a - 1.0E0_DP)*h*yppa(j)/6.0E0_DP & |
956 |
+ |
+ (3.0E0_DP*b*b - 1.0E0_DP)*h*yppa(j+1)/6.0E0_DP |
957 |
+ |
|
958 |
+ |
|
959 |
+ |
d2y = a*yppa(j) + b*yppa(j+1) |
960 |
+ |
|
961 |
+ |
|
962 |
|
end subroutine eam_splint |
963 |
|
|
964 |
|
|
970 |
|
! if boundary is 'U' the upper derivative is used |
971 |
|
! if boundary is 'B' then both derivatives are used |
972 |
|
! if boundary is anything else, then both derivatives are assumed to be 0 |
973 |
< |
|
973 |
> |
|
974 |
|
integer :: nx, i, k, max_array_size |
975 |
< |
|
975 |
> |
|
976 |
|
real( kind = DP ), dimension(:) :: xa |
977 |
|
real( kind = DP ), dimension(:) :: ya |
978 |
|
real( kind = DP ), dimension(:) :: yppa |
979 |
|
real( kind = DP ), dimension(size(xa)) :: u |
980 |
|
real( kind = DP ) :: yp1,ypn,un,qn,sig,p |
981 |
|
character(len=*) :: boundary |
982 |
< |
|
982 |
> |
|
983 |
|
! make sure the sizes match |
984 |
|
if ((nx /= size(xa)) .or. (nx /= size(ya))) then |
985 |
|
call handleWarning("EAM_SPLINE","Array size mismatch") |
994 |
|
yppa(1) = 0.0E0_DP |
995 |
|
u(1) = 0.0E0_DP |
996 |
|
endif |
997 |
< |
|
997 |
> |
|
998 |
|
do i = 2, nx - 1 |
999 |
|
sig = (xa(i) - xa(i-1)) / (xa(i+1) - xa(i-1)) |
1000 |
|
p = sig * yppa(i-1) + 2.0E0_DP |
1003 |
|
(ya(i)-ya(i-1))/(xa(i)-xa(i-1)))/ & |
1004 |
|
(xa(i+1)-xa(i-1)) - sig * u(i-1))/p |
1005 |
|
enddo |
1006 |
< |
|
1006 |
> |
|
1007 |
|
if ((boundary.eq.'u').or.(boundary.eq.'U').or. & |
1008 |
|
(boundary.eq.'b').or.(boundary.eq.'B')) then |
1009 |
|
qn = 0.5E0_DP |
1015 |
|
endif |
1016 |
|
|
1017 |
|
yppa(nx)=(un-qn*u(nx-1))/(qn*yppa(nx-1)+1.0E0_DP) |
1018 |
< |
|
1018 |
> |
|
1019 |
|
do k = nx-1, 1, -1 |
1020 |
|
yppa(k)=yppa(k)*yppa(k+1)+u(k) |
1021 |
|
enddo |