15 |
|
logical, save :: EAM_FF_initialized = .false. |
16 |
|
integer, save :: EAM_Mixing_Policy |
17 |
|
real(kind = dp), save :: EAM_rcut |
18 |
< |
real(kind = dp), save :: EAM_rcut_orig |
18 |
> |
logical, save :: haveRcut = .false. |
19 |
|
|
20 |
|
character(len = statusMsgSize) :: errMesg |
21 |
|
integer :: eam_err |
60 |
|
|
61 |
|
!! Arrays for MPI storage |
62 |
|
#ifdef IS_MPI |
63 |
< |
real( kind = dp), dimension(:), allocatable :: dfrhodrho_col |
64 |
< |
real( kind = dp), dimension(:), allocatable :: dfrhodrho_row |
65 |
< |
real( kind = dp), dimension(:), allocatable :: frho_row |
66 |
< |
real( kind = dp), dimension(:), allocatable :: frho_col |
67 |
< |
real( kind = dp), dimension(:), allocatable :: rho_row |
68 |
< |
real( kind = dp), dimension(:), allocatable :: rho_col |
69 |
< |
real( kind = dp), dimension(:), allocatable :: d2frhodrhodrho_col |
70 |
< |
real( kind = dp), dimension(:), allocatable :: d2frhodrhodrho_row |
63 |
> |
real( kind = dp),save, dimension(:), allocatable :: dfrhodrho_col |
64 |
> |
real( kind = dp),save, dimension(:), allocatable :: dfrhodrho_row |
65 |
> |
real( kind = dp),save, dimension(:), allocatable :: frho_row |
66 |
> |
real( kind = dp),save, dimension(:), allocatable :: frho_col |
67 |
> |
real( kind = dp),save, dimension(:), allocatable :: rho_row |
68 |
> |
real( kind = dp),save, dimension(:), allocatable :: rho_col |
69 |
> |
real( kind = dp),save, dimension(:), allocatable :: rho_tmp |
70 |
> |
real( kind = dp),save, dimension(:), allocatable :: d2frhodrhodrho_col |
71 |
> |
real( kind = dp),save, dimension(:), allocatable :: d2frhodrhodrho_row |
72 |
|
#endif |
73 |
|
|
74 |
|
type, private :: EAMTypeList |
79 |
|
end type EAMTypeList |
80 |
|
|
81 |
|
|
82 |
< |
type (eamTypeList) :: EAMList |
82 |
> |
type (eamTypeList), save :: EAMList |
83 |
|
|
84 |
|
!! standard eam stuff |
85 |
|
|
90 |
|
public :: newEAMtype |
91 |
|
public :: calc_eam_prepair_rho |
92 |
|
public :: calc_eam_preforce_Frho |
93 |
< |
|
93 |
> |
public :: clean_EAM |
94 |
|
|
95 |
|
contains |
96 |
|
|
118 |
|
|
119 |
|
status = 0 |
120 |
|
|
121 |
< |
write(*,*) "Adding new eamtype: ",eam_ident |
121 |
> |
|
122 |
|
!! Assume that atypes has already been set and get the total number of types in atypes |
123 |
|
!! Also assume that every member of atypes is a EAM model. |
124 |
|
|
165 |
|
integer :: alloc_stat |
166 |
|
integer :: number_r, number_rho |
167 |
|
|
168 |
+ |
|
169 |
+ |
status = 0 |
170 |
|
if (EAMList%currentAddition == 0) then |
171 |
|
call handleError("init_EAM_FF","No members in EAMList") |
172 |
|
status = -1 |
173 |
|
return |
174 |
|
end if |
175 |
|
|
176 |
< |
|
174 |
< |
|
176 |
> |
|
177 |
|
do i = 1, EAMList%currentAddition |
178 |
|
|
179 |
|
! Build array of r values |
223 |
|
0.0E0_DP, 0.0E0_DP, 'N') |
224 |
|
enddo |
225 |
|
|
226 |
< |
|
225 |
< |
current_rcut_max = EAMList%EAMParams(1)%eam_rcut |
226 |
> |
! current_rcut_max = EAMList%EAMParams(1)%eam_rcut |
227 |
|
!! find the smallest rcut for any eam atype |
228 |
< |
do i = 2, EAMList%currentAddition |
229 |
< |
current_rcut_max = min(current_rcut_max,EAMList%EAMParams(i)%eam_rcut) |
230 |
< |
end do |
228 |
> |
! do i = 2, EAMList%currentAddition |
229 |
> |
! current_rcut_max =max(current_rcut_max,EAMList%EAMParams(i)%eam_rcut) |
230 |
> |
! end do |
231 |
|
|
232 |
< |
EAM_rcut = current_rcut_max |
233 |
< |
EAM_rcut_orig = current_rcut_max |
232 |
> |
! EAM_rcut = current_rcut_max |
233 |
> |
! EAM_rcut_orig = current_rcut_max |
234 |
|
! do i = 1, EAMList%currentAddition |
235 |
|
! EAMList%EAMParam(i)s%eam_atype_map(eam_atype(i)) = i |
236 |
|
! end do |
236 |
– |
|
237 |
– |
|
237 |
|
!! Allocate arrays for force calculation |
238 |
< |
call allocateEAM(alloc_stat) |
239 |
< |
if (alloc_stat /= 0 ) then |
240 |
< |
status = -1 |
241 |
< |
return |
242 |
< |
endif |
243 |
< |
|
238 |
> |
|
239 |
> |
call allocateEAM(alloc_stat) |
240 |
> |
if (alloc_stat /= 0 ) then |
241 |
> |
write(*,*) "allocateEAM failed" |
242 |
> |
status = -1 |
243 |
> |
return |
244 |
> |
endif |
245 |
> |
|
246 |
|
end subroutine init_EAM_FF |
247 |
|
|
248 |
|
!! routine checks to see if array is allocated, deallocates array if allocated |
250 |
|
subroutine allocateEAM(status) |
251 |
|
integer, intent(out) :: status |
252 |
|
|
252 |
– |
integer :: nlocal |
253 |
|
#ifdef IS_MPI |
254 |
|
integer :: nrow |
255 |
|
integer :: ncol |
257 |
|
integer :: alloc_stat |
258 |
|
|
259 |
|
|
260 |
< |
nlocal = getNlocal() |
261 |
< |
|
260 |
> |
status = 0 |
261 |
|
#ifdef IS_MPI |
262 |
|
nrow = getNrow(plan_row) |
263 |
|
ncol = getNcol(plan_col) |
292 |
|
|
293 |
|
#ifdef IS_MPI |
294 |
|
|
295 |
+ |
if (allocated(rho_tmp)) deallocate(rho_tmp) |
296 |
+ |
allocate(rho_tmp(nlocal),stat=alloc_stat) |
297 |
+ |
if (alloc_stat /= 0) then |
298 |
+ |
status = -1 |
299 |
+ |
return |
300 |
+ |
end if |
301 |
+ |
|
302 |
+ |
|
303 |
|
if (allocated(frho_row)) deallocate(frho_row) |
304 |
|
allocate(frho_row(nrow),stat=alloc_stat) |
305 |
|
if (alloc_stat /= 0) then |
357 |
|
|
358 |
|
end subroutine allocateEAM |
359 |
|
|
360 |
+ |
!! C sets rcut to be the largest cutoff of any atype |
361 |
+ |
!! present in this simulation. Doesn't include all atypes |
362 |
+ |
!! sim knows about, just those in the simulation. |
363 |
|
subroutine setCutoffEAM(rcut, status) |
364 |
|
real(kind=dp) :: rcut |
365 |
|
integer :: status |
366 |
+ |
status = 0 |
367 |
|
|
368 |
< |
if (rcut < EAM_rcut) then |
358 |
< |
EAM_rcut = rcut |
359 |
< |
endif |
368 |
> |
EAM_rcut = rcut |
369 |
|
|
361 |
– |
|
370 |
|
end subroutine setCutoffEAM |
371 |
|
|
372 |
|
|
373 |
|
|
374 |
|
subroutine clean_EAM() |
375 |
< |
|
376 |
< |
! clean non-IS_MPI first |
375 |
> |
|
376 |
> |
! clean non-IS_MPI first |
377 |
|
frho = 0.0_dp |
378 |
|
rho = 0.0_dp |
379 |
|
dfrhodrho = 0.0_dp |
383 |
|
frho_col = 0.0_dp |
384 |
|
rho_row = 0.0_dp |
385 |
|
rho_col = 0.0_dp |
386 |
+ |
rho_tmp = 0.0_dp |
387 |
|
dfrhodrho_row = 0.0_dp |
388 |
|
dfrhodrho_col = 0.0_dp |
389 |
|
#endif |
493 |
|
integer :: myid_atom2 |
494 |
|
|
495 |
|
! check to see if we need to be cleaned at the start of a force loop |
496 |
< |
if (cleanme) call clean_EAM |
488 |
< |
cleanme = .false. |
489 |
< |
|
496 |
> |
|
497 |
|
|
498 |
+ |
|
499 |
+ |
|
500 |
|
#ifdef IS_MPI |
501 |
|
myid_atom1 = atid_Row(atom1) |
502 |
|
myid_atom2 = atid_Col(atom2) |
506 |
|
#endif |
507 |
|
|
508 |
|
if (r.lt.EAMList%EAMParams(myid_atom1)%eam_rcut) then |
500 |
– |
|
509 |
|
|
510 |
|
|
511 |
+ |
|
512 |
|
call eam_splint(EAMList%EAMParams(myid_atom1)%eam_nr, & |
513 |
|
EAMList%EAMParams(myid_atom1)%eam_rvals, & |
514 |
|
EAMList%EAMParams(myid_atom1)%eam_rho_r, & |
522 |
|
#else |
523 |
|
rho(atom2) = rho(atom2) + rho_i_at_j |
524 |
|
#endif |
525 |
+ |
! write(*,*) atom1,atom2,r,rho_i_at_j |
526 |
|
endif |
527 |
|
|
528 |
|
if (r.lt.EAMList%EAMParams(myid_atom2)%eam_rcut) then |
532 |
|
EAMList%EAMParams(myid_atom2)%eam_rho_r_pp, & |
533 |
|
r, rho_j_at_i,drho,d2rho) |
534 |
|
|
535 |
< |
|
535 |
> |
|
536 |
|
|
537 |
|
|
538 |
|
#ifdef IS_MPI |
541 |
|
rho(atom1) = rho(atom1) + rho_j_at_i |
542 |
|
#endif |
543 |
|
endif |
544 |
+ |
|
545 |
+ |
|
546 |
+ |
|
547 |
+ |
|
548 |
+ |
|
549 |
|
|
550 |
|
end subroutine calc_eam_prepair_rho |
551 |
|
|
562 |
|
integer :: atype1 |
563 |
|
integer :: me |
564 |
|
integer :: n_rho_points |
550 |
– |
! reset clean forces to be true at top of calc rho. |
551 |
– |
cleanme = .true. |
565 |
|
|
566 |
< |
!! Scatter the electron density from pre-pair calculation back to local atoms |
566 |
> |
|
567 |
> |
cleanme = .true. |
568 |
> |
!! Scatter the electron density from pre-pair calculation back to local atoms |
569 |
|
#ifdef IS_MPI |
570 |
|
call scatter(rho_row,rho,plan_row,eam_err) |
571 |
|
if (eam_err /= 0 ) then |
572 |
|
write(errMsg,*) " Error scattering rho_row into rho" |
573 |
|
call handleError(RoutineName,errMesg) |
574 |
|
endif |
575 |
< |
call scatter(rho_col,rho,plan_col,eam_err) |
575 |
> |
call scatter(rho_col,rho_tmp,plan_col,eam_err) |
576 |
|
if (eam_err /= 0 ) then |
577 |
|
write(errMsg,*) " Error scattering rho_col into rho" |
578 |
|
call handleError(RoutineName,errMesg) |
579 |
|
endif |
580 |
+ |
|
581 |
+ |
rho(1:nlocal) = rho(1:nlocal) + rho_tmp(1:nlocal) |
582 |
|
#endif |
583 |
|
|
584 |
|
|
585 |
+ |
|
586 |
|
!! Calculate F(rho) and derivative |
587 |
|
do atom = 1, nlocal |
588 |
|
me = atid(atom) |
606 |
|
end if |
607 |
|
|
608 |
|
|
609 |
< |
frho(i) = u |
610 |
< |
dfrhodrho(i) = u1 |
611 |
< |
d2frhodrhodrho(i) = u2 |
609 |
> |
frho(atom) = u |
610 |
> |
dfrhodrho(atom) = u1 |
611 |
> |
d2frhodrhodrho(atom) = u2 |
612 |
|
pot = pot + u |
613 |
+ |
|
614 |
|
enddo |
615 |
|
|
616 |
+ |
|
617 |
|
|
598 |
– |
|
618 |
|
#ifdef IS_MPI |
619 |
|
!! communicate f(rho) and derivatives back into row and column arrays |
620 |
|
call gather(frho,frho_row,plan_row, eam_err) |
644 |
|
endif |
645 |
|
#endif |
646 |
|
|
647 |
+ |
|
648 |
|
end subroutine calc_eam_preforce_Frho |
649 |
|
|
650 |
|
|
651 |
|
|
652 |
|
|
653 |
|
!! Does EAM pairwise Force calculation. |
654 |
< |
subroutine do_eam_pair(atom1,atom2,d,rij,r2,pot,f,do_pot,do_stress) |
654 |
> |
subroutine do_eam_pair(atom1, atom2, d, rij, r2, sw, vpair, fpair, & |
655 |
> |
pot, f, do_pot) |
656 |
|
!Arguments |
657 |
|
integer, intent(in) :: atom1, atom2 |
658 |
|
real( kind = dp ), intent(in) :: rij, r2 |
659 |
< |
real( kind = dp ) :: pot |
660 |
< |
real( kind = dp ), dimension(3,getNlocal()) :: f |
659 |
> |
real( kind = dp ) :: pot, sw, vpair |
660 |
> |
real( kind = dp ), dimension(3,nLocal) :: f |
661 |
|
real( kind = dp ), intent(in), dimension(3) :: d |
662 |
< |
logical, intent(in) :: do_pot, do_stress |
662 |
> |
real( kind = dp ), intent(inout), dimension(3) :: fpair |
663 |
> |
|
664 |
> |
logical, intent(in) :: do_pot |
665 |
|
|
666 |
|
real( kind = dp ) :: drdx,drdy,drdz |
667 |
|
real( kind = dp ) :: d2 |
680 |
|
integer :: mytype_atom1 |
681 |
|
integer :: mytype_atom2 |
682 |
|
|
660 |
– |
|
683 |
|
!Local Variables |
684 |
|
|
685 |
+ |
! write(*,*) "Frho: ", Frho(atom1) |
686 |
|
|
664 |
– |
|
687 |
|
phab = 0.0E0_DP |
688 |
|
dvpdr = 0.0E0_DP |
689 |
|
d2vpdrdr = 0.0E0_DP |
690 |
< |
|
669 |
< |
|
690 |
> |
|
691 |
|
if (rij .lt. EAM_rcut) then |
692 |
|
#ifdef IS_MPI |
693 |
|
!!!!! FIX ME |
774 |
|
#ifdef IS_MPI |
775 |
|
dudr = drhojdr*dfrhodrho_row(atom1)+drhoidr*dfrhodrho_col(atom2) & |
776 |
|
+ dvpdr |
777 |
< |
|
777 |
> |
|
778 |
|
#else |
779 |
|
dudr = drhojdr*dfrhodrho(atom1)+drhoidr*dfrhodrho(atom2) & |
780 |
|
+ dvpdr |
781 |
< |
|
781 |
> |
! write(*,*) "Atom1,Atom2, dfrhodrho(atom1) dfrhodrho(atom2): ", atom1,atom2,dfrhodrho(atom1),dfrhodrho(atom2) |
782 |
|
#endif |
783 |
|
|
784 |
|
fx = dudr * drdx |
800 |
|
f_Col(2,atom2) = f_Col(2,atom2) - fy |
801 |
|
f_Col(3,atom2) = f_Col(3,atom2) - fz |
802 |
|
#else |
803 |
< |
if(do_pot) pot = pot + phab |
804 |
< |
|
803 |
> |
|
804 |
> |
if(do_pot) then |
805 |
> |
pot = pot + phab |
806 |
> |
end if |
807 |
> |
|
808 |
|
f(1,atom1) = f(1,atom1) + fx |
809 |
|
f(2,atom1) = f(2,atom1) + fy |
810 |
|
f(3,atom1) = f(3,atom1) + fz |
814 |
|
f(3,atom2) = f(3,atom2) - fz |
815 |
|
#endif |
816 |
|
|
817 |
+ |
vpair = vpair + phab |
818 |
+ |
fpair(1) = fpair(1) + fx |
819 |
+ |
fpair(2) = fpair(2) + fy |
820 |
+ |
fpair(3) = fpair(3) + fz |
821 |
+ |
|
822 |
|
if (nmflag) then |
823 |
|
|
824 |
|
drhoidr = drha |
842 |
|
drhojdr*drhojdr*d2frhodrhodrho(atom1) |
843 |
|
#endif |
844 |
|
end if |
816 |
– |
|
817 |
– |
|
845 |
|
|
846 |
< |
|
820 |
< |
if (do_stress) then |
821 |
< |
|
822 |
< |
#ifdef IS_MPI |
823 |
< |
id1 = tagRow(atom1) |
824 |
< |
id2 = tagColumn(atom2) |
825 |
< |
#else |
826 |
< |
id1 = atom1 |
827 |
< |
id2 = atom2 |
828 |
< |
#endif |
829 |
< |
|
830 |
< |
if (molMembershipList(id1) .ne. molMembershipList(id2)) then |
831 |
< |
|
832 |
< |
|
833 |
< |
|
834 |
< |
|
835 |
< |
tau_Temp(1) = tau_Temp(1) - d(1) * fx |
836 |
< |
tau_Temp(2) = tau_Temp(2) - d(1) * fy |
837 |
< |
tau_Temp(3) = tau_Temp(3) - d(1) * fz |
838 |
< |
tau_Temp(4) = tau_Temp(4) - d(2) * fx |
839 |
< |
tau_Temp(5) = tau_Temp(5) - d(2) * fy |
840 |
< |
tau_Temp(6) = tau_Temp(6) - d(2) * fz |
841 |
< |
tau_Temp(7) = tau_Temp(7) - d(3) * fx |
842 |
< |
tau_Temp(8) = tau_Temp(8) - d(3) * fy |
843 |
< |
tau_Temp(9) = tau_Temp(9) - d(3) * fz |
844 |
< |
|
845 |
< |
virial_Temp = virial_Temp + & |
846 |
< |
(tau_Temp(1) + tau_Temp(5) + tau_Temp(9)) |
847 |
< |
|
848 |
< |
endif |
849 |
< |
endif |
850 |
< |
endif |
851 |
< |
|
852 |
< |
|
846 |
> |
endif |
847 |
|
end subroutine do_eam_pair |
848 |
|
|
849 |
|
|