4 |
|
|
5 |
|
!! @author Charles F. Vardeman II |
6 |
|
!! @author Matthew Meineke |
7 |
< |
!! @version $Id: do_Forces.F90,v 1.60 2004-05-21 15:58:40 gezelter Exp $, $Date: 2004-05-21 15:58:40 $, $Name: not supported by cvs2svn $, $Revision: 1.60 $ |
7 |
> |
!! @version $Id: do_Forces.F90,v 1.61 2004-05-24 21:03:25 gezelter Exp $, $Date: 2004-05-24 21:03:25 $, $Name: not supported by cvs2svn $, $Revision: 1.61 $ |
8 |
|
|
9 |
|
module do_Forces |
10 |
|
use force_globals |
400 |
|
integer :: natoms |
401 |
|
logical :: update_nlist |
402 |
|
integer :: i, j, jbeg, jend, jnab |
403 |
+ |
integer :: istart, iend, jstart |
404 |
|
integer :: ia, jb, atom1, atom2 |
405 |
|
integer :: nlist |
406 |
|
real( kind = DP ) :: ratmsq, rgrpsq, rgrp, vpair, vij |
407 |
|
real( kind = DP ) :: sw, dswdr, swderiv, mf |
408 |
< |
real(kind=dp),dimension(3) :: d_atm, d_grp |
408 |
> |
real(kind=dp),dimension(3) :: d_atm, d_grp, fpair, fij |
409 |
|
real(kind=dp) :: rfpot, mu_i, virial |
410 |
|
integer :: me_i, me_j, n_in_i, n_in_j |
411 |
|
logical :: is_dp_i |
476 |
|
!! if_mpi_gather_stuff_from_prepair_to_main_loop |
477 |
|
|
478 |
|
!--------------------PREFORCE LOOP----------->>>>>>>>>>>>>>>>>>>>>>>>>>> |
479 |
< |
#ifdef IS_MPI |
479 |
< |
|
479 |
> |
|
480 |
|
if (update_nlist) then |
481 |
|
|
482 |
|
!! save current configuration, construct neighbor list, |
483 |
|
!! and calculate forces |
484 |
< |
|
484 |
> |
|
485 |
|
call saveNeighborList(nGroup, q_group) |
486 |
|
|
487 |
|
neighborListSize = size(list) |
488 |
|
nlist = 0 |
489 |
|
|
490 |
< |
do i = 1, nrow_group |
490 |
> |
istart = 1 |
491 |
> |
#ifdef IS_MPI |
492 |
> |
iend = nrow_group |
493 |
> |
#else |
494 |
> |
iend = nGroup - 1 |
495 |
> |
#endif |
496 |
> |
do i = istart, iend |
497 |
> |
|
498 |
|
point(i) = nlist + 1 |
499 |
|
|
500 |
< |
do j = 1, ncol_group |
500 |
> |
n_in_i = groupStart(i+1) - groupStart(i) |
501 |
> |
|
502 |
> |
#ifdef IS_MPI |
503 |
> |
jstart = 1 |
504 |
> |
jend = ncol_group |
505 |
> |
#else |
506 |
> |
jstart = i+1 |
507 |
> |
jend = nGroup |
508 |
> |
#endif |
509 |
> |
do j = jstart, jend |
510 |
|
|
511 |
+ |
#ifdef IS_MPI |
512 |
|
call get_interatomic_vector(q_group_Row(:,i), & |
513 |
|
q_group_Col(:,j), d_grp, rgrpsq) |
514 |
< |
|
514 |
> |
#else |
515 |
> |
call get_interatomic_vector(q_group(:,i), & |
516 |
> |
q_group(:,j), d_grp, rgrpsq) |
517 |
> |
#endif |
518 |
|
if (rgrpsq < rlistsq) then |
519 |
|
nlist = nlist + 1 |
520 |
|
|
528 |
|
neighborListSize = size(list) |
529 |
|
endif |
530 |
|
|
531 |
< |
list(nlist) = j |
531 |
> |
list(nlist) = j |
532 |
|
|
533 |
+ |
call get_switch(rgrpsq, sw, dswdr, rgrp, group_switch, & |
534 |
+ |
in_switching_region) |
535 |
+ |
|
536 |
+ |
n_in_j = groupStart(j+1) - groupStart(j) |
537 |
+ |
|
538 |
|
do ia = groupStart(i), groupStart(i+1)-1 |
539 |
|
atom1 = groupList(ia) |
540 |
< |
|
540 |
> |
|
541 |
|
prepair_inner1: do jb = groupStart(j), groupStart(j+1)-1 |
542 |
< |
atom2 = groupList(jb) |
542 |
> |
atom2 = groupList(jb) |
543 |
|
|
544 |
|
if (skipThisPair(atom1, atom2)) cycle prepair_inner1 |
545 |
|
|
546 |
< |
call get_interatomic_vector(q_Row(:,atom1), & |
547 |
< |
q_Col(:,atom2), d_atm, ratmsq) |
548 |
< |
|
549 |
< |
call do_prepair(atom1, atom2, ratmsq, d_atm, & |
546 |
> |
if ((n_in_i .eq. 1).and.(n_in_j .eq. 1)) then |
547 |
> |
d_atm(1:3) = d_grp(1:3) |
548 |
> |
ratmsq = rgrpsq |
549 |
> |
else |
550 |
> |
#ifdef IS_MPI |
551 |
> |
call get_interatomic_vector(q_Row(:,atom1), & |
552 |
> |
q_Col(:,atom2), d_atm, ratmsq) |
553 |
> |
#else |
554 |
> |
call get_interatomic_vector(q(:,atom1), & |
555 |
> |
q(:,atom2), d_atm, ratmsq) |
556 |
> |
#endif |
557 |
> |
endif |
558 |
> |
#ifdef IS_MPI |
559 |
> |
call do_prepair(atom1, atom2, ratmsq, d_atm, sw, & |
560 |
|
rgrpsq, d_grp, do_pot, do_stress, & |
561 |
|
u_l, A, f, t, pot_local) |
562 |
< |
|
562 |
> |
#else |
563 |
> |
call do_prepair(atom1, atom2, ratmsq, d_atm, sw, & |
564 |
> |
rgrpsq, d_grp, do_pot, do_stress, & |
565 |
> |
u_l, A, f, t, pot) |
566 |
> |
#endif |
567 |
|
enddo prepair_inner1 |
568 |
|
enddo |
569 |
+ |
|
570 |
|
end if |
571 |
|
enddo |
572 |
|
enddo |
573 |
< |
point(nrow_group + 1) = nlist + 1 |
574 |
< |
|
573 |
> |
|
574 |
> |
#ifdef IS_MPI |
575 |
> |
point(nrow_group + 1) = nlist + 1 |
576 |
> |
#else |
577 |
> |
point(nGroup) = nlist + 1 |
578 |
> |
#endif |
579 |
> |
|
580 |
|
else !! (of update_check) |
581 |
|
|
582 |
|
! use the list to find the neighbors |
583 |
< |
do i = 1, nrow_group |
583 |
> |
|
584 |
> |
istart = 1 |
585 |
> |
#ifdef IS_MPI |
586 |
> |
iend = nrow_group |
587 |
> |
#else |
588 |
> |
iend = nGroup - 1 |
589 |
> |
#endif |
590 |
> |
|
591 |
> |
do i = istart, iend |
592 |
> |
|
593 |
> |
n_in_i = groupStart(i+1) - groupStart(i) |
594 |
> |
|
595 |
|
JBEG = POINT(i) |
596 |
|
JEND = POINT(i+1) - 1 |
597 |
|
! check that group i has neighbors |
600 |
|
do jnab = jbeg, jend |
601 |
|
j = list(jnab) |
602 |
|
|
603 |
< |
do ia = groupStart(i), groupStart(i+1)-1 |
604 |
< |
atom1 = groupList(ia) |
605 |
< |
|
550 |
< |
prepair_inner2: do jb = groupStart(j), groupStart(j+1)-1 |
551 |
< |
atom2 = groupList(jb) |
552 |
< |
|
553 |
< |
if (skipThisPair(atom1, atom2)) cycle prepair_inner2 |
554 |
< |
|
555 |
< |
call get_interatomic_vector(q_Row(:,atom1), & |
556 |
< |
q_Col(:,atom2), d_atm, ratmsq) |
557 |
< |
|
558 |
< |
call do_prepair(atom1, atom2, ratmsq, d_atm, & |
559 |
< |
rgrpsq, d_grp, do_pot, do_stress, & |
560 |
< |
u_l, A, f, t, pot_local) |
561 |
< |
|
562 |
< |
enddo prepair_inner2 |
563 |
< |
enddo |
564 |
< |
enddo |
565 |
< |
endif |
566 |
< |
enddo |
567 |
< |
endif |
568 |
< |
|
603 |
> |
#ifdef IS_MPI |
604 |
> |
call get_interatomic_vector(q_group_Row(:,i), & |
605 |
> |
q_group_Col(:,j), d_grp, rgrpsq) |
606 |
|
#else |
607 |
< |
|
608 |
< |
if (update_nlist) then |
609 |
< |
|
610 |
< |
!! save current configuration, construct neighbor list, |
611 |
< |
!! and calculate forces |
575 |
< |
|
576 |
< |
call saveNeighborList(nGroup, q_group) |
577 |
< |
|
578 |
< |
neighborListSize = size(list) |
579 |
< |
nlist = 0 |
580 |
< |
|
581 |
< |
do i = 1, nGroup-1 |
582 |
< |
point(i) = nlist + 1 |
583 |
< |
|
584 |
< |
do j = i+1, nGroup |
585 |
< |
|
586 |
< |
call get_interatomic_vector(q_group(:,i), & |
587 |
< |
q_group(:,j), d_grp, rgrpsq) |
588 |
< |
|
589 |
< |
if (rgrpsq < rlistsq) then |
590 |
< |
nlist = nlist + 1 |
591 |
< |
|
592 |
< |
if (nlist > neighborListSize) then |
593 |
< |
call expandNeighborList(nGroup, listerror) |
594 |
< |
if (listerror /= 0) then |
595 |
< |
error = -1 |
596 |
< |
write(DEFAULT_ERROR,*) "ERROR: nlist > list size and max allocations exceeded." |
597 |
< |
return |
598 |
< |
end if |
599 |
< |
neighborListSize = size(list) |
600 |
< |
endif |
607 |
> |
call get_interatomic_vector(q_group(:,i), & |
608 |
> |
q_group(:,j), d_grp, rgrpsq) |
609 |
> |
#endif |
610 |
> |
call get_switch(rgrpsq, sw, dswdr, rgrp, group_switch, & |
611 |
> |
in_switching_region) |
612 |
|
|
613 |
< |
list(nlist) = j |
613 |
> |
n_in_j = groupStart(j+1) - groupStart(j) |
614 |
|
|
615 |
|
do ia = groupStart(i), groupStart(i+1)-1 |
616 |
|
atom1 = groupList(ia) |
617 |
|
|
607 |
– |
prepair_inner1: do jb = groupStart(j), groupStart(j+1)-1 |
608 |
– |
atom2 = groupList(jb) |
609 |
– |
|
610 |
– |
if (skipThisPair(atom1, atom2)) cycle prepair_inner1 |
611 |
– |
|
612 |
– |
call get_interatomic_vector(q(:,atom1), & |
613 |
– |
q(:,atom2), d_atm, ratmsq) |
614 |
– |
|
615 |
– |
call do_prepair(atom1, atom2, ratmsq, d_atm, & |
616 |
– |
rgrpsq, d_grp, do_pot, do_stress, & |
617 |
– |
u_l, A, f, t, pot) |
618 |
– |
|
619 |
– |
enddo prepair_inner1 |
620 |
– |
enddo |
621 |
– |
end if |
622 |
– |
enddo |
623 |
– |
enddo |
624 |
– |
point(nGroup) = nlist + 1 |
625 |
– |
|
626 |
– |
else !! (of update_check) |
627 |
– |
|
628 |
– |
! use the list to find the neighbors |
629 |
– |
do i = 1, nGroup-1 |
630 |
– |
JBEG = POINT(i) |
631 |
– |
JEND = POINT(i+1) - 1 |
632 |
– |
! check that group i has neighbors |
633 |
– |
if (jbeg .le. jend) then |
634 |
– |
|
635 |
– |
do jnab = jbeg, jend |
636 |
– |
j = list(jnab) |
637 |
– |
|
638 |
– |
do ia = groupStart(i), groupStart(i+1)-1 |
639 |
– |
atom1 = groupList(ia) |
640 |
– |
|
618 |
|
prepair_inner2: do jb = groupStart(j), groupStart(j+1)-1 |
619 |
+ |
|
620 |
|
atom2 = groupList(jb) |
621 |
|
|
622 |
|
if (skipThisPair(atom1, atom2)) cycle prepair_inner2 |
645 |
– |
|
646 |
– |
call get_interatomic_vector(q(:,atom1), & |
647 |
– |
q(:,atom2), d_atm, ratmsq) |
623 |
|
|
624 |
< |
call do_prepair(atom1, atom2, ratmsq, d_atm, & |
624 |
> |
if ((n_in_i .eq. 1).and.(n_in_j .eq. 1)) then |
625 |
> |
d_atm(1:3) = d_grp(1:3) |
626 |
> |
ratmsq = rgrpsq |
627 |
> |
else |
628 |
> |
#ifdef IS_MPI |
629 |
> |
call get_interatomic_vector(q_Row(:,atom1), & |
630 |
> |
q_Col(:,atom2), d_atm, ratmsq) |
631 |
> |
#else |
632 |
> |
call get_interatomic_vector(q(:,atom1), & |
633 |
> |
q(:,atom2), d_atm, ratmsq) |
634 |
> |
#endif |
635 |
> |
endif |
636 |
> |
|
637 |
> |
#ifdef IS_MPI |
638 |
> |
call do_prepair(atom1, atom2, ratmsq, d_atm, sw, & |
639 |
|
rgrpsq, d_grp, do_pot, do_stress, & |
640 |
+ |
u_l, A, f, t, pot_local) |
641 |
+ |
#else |
642 |
+ |
call do_prepair(atom1, atom2, ratmsq, d_atm, sw, & |
643 |
+ |
rgrpsq, d_grp, do_pot, do_stress, & |
644 |
|
u_l, A, f, t, pot) |
645 |
< |
|
645 |
> |
#endif |
646 |
|
enddo prepair_inner2 |
647 |
|
enddo |
648 |
|
enddo |
649 |
|
endif |
650 |
|
enddo |
651 |
|
endif |
659 |
– |
|
660 |
– |
#endif |
661 |
– |
|
652 |
|
!! Do rest of preforce calculations |
653 |
|
!! do necessary preforce calculations |
654 |
|
call do_preforce(nlocal,pot) |
657 |
|
else |
658 |
|
!! See if we need to update neighbor lists for non pre-pair |
659 |
|
call checkNeighborList(nGroup, q_group, listSkin, update_nlist) |
660 |
< |
endif |
660 |
> |
end if |
661 |
|
|
662 |
|
!---------------------------------MAIN Pair LOOP->>>>>>>>>>>>> |
663 |
< |
|
674 |
< |
#ifdef IS_MPI |
675 |
< |
|
663 |
> |
|
664 |
|
if (update_nlist) then |
665 |
|
|
666 |
|
!! save current configuration, construct neighbor list, |
670 |
|
|
671 |
|
neighborListSize = size(list) |
672 |
|
nlist = 0 |
673 |
< |
|
674 |
< |
do i = 1, nrow_group |
673 |
> |
|
674 |
> |
istart = 1 |
675 |
> |
#ifdef IS_MPI |
676 |
> |
iend = nrow_group |
677 |
> |
#else |
678 |
> |
iend = nGroup - 1 |
679 |
> |
#endif |
680 |
> |
do i = istart, iend |
681 |
|
|
682 |
|
point(i) = nlist + 1 |
683 |
|
|
684 |
|
n_in_i = groupStart(i+1) - groupStart(i) |
685 |
|
|
686 |
< |
do j = 1, ncol_group |
686 |
> |
#ifdef IS_MPI |
687 |
> |
jstart = 1 |
688 |
> |
jend = ncol_group |
689 |
> |
#else |
690 |
> |
jstart = i+1 |
691 |
> |
jend = nGroup |
692 |
> |
#endif |
693 |
> |
do j = jstart, jend |
694 |
|
|
695 |
+ |
#ifdef IS_MPI |
696 |
|
call get_interatomic_vector(q_group_Row(:,i), & |
697 |
|
q_group_Col(:,j), d_grp, rgrpsq) |
698 |
< |
|
698 |
> |
#else |
699 |
> |
call get_interatomic_vector(q_group(:,i), & |
700 |
> |
q_group(:,j), d_grp, rgrpsq) |
701 |
> |
#endif |
702 |
|
if (rgrpsq < rlistsq) then |
703 |
|
nlist = nlist + 1 |
704 |
|
|
714 |
|
|
715 |
|
list(nlist) = j |
716 |
|
|
717 |
< |
vij = 0.0d0 |
718 |
< |
|
717 |
> |
vij = 0.0d0 |
718 |
> |
fij(1:3) = 0.0d0 |
719 |
> |
|
720 |
|
call get_switch(rgrpsq, sw, dswdr, rgrp, group_switch, & |
721 |
|
in_switching_region) |
722 |
|
|
734 |
|
d_atm(1:3) = d_grp(1:3) |
735 |
|
ratmsq = rgrpsq |
736 |
|
else |
737 |
+ |
#ifdef IS_MPI |
738 |
|
call get_interatomic_vector(q_Row(:,atom1), & |
739 |
|
q_Col(:,atom2), d_atm, ratmsq) |
740 |
+ |
#else |
741 |
+ |
call get_interatomic_vector(q(:,atom1), & |
742 |
+ |
q(:,atom2), d_atm, ratmsq) |
743 |
+ |
#endif |
744 |
|
endif |
745 |
< |
|
745 |
> |
#ifdef IS_MPI |
746 |
|
call do_pair(atom1, atom2, ratmsq, d_atm, sw, & |
747 |
< |
do_pot, do_stress, & |
748 |
< |
u_l, A, f, t, pot_local, vpair) |
749 |
< |
|
747 |
> |
do_pot, & |
748 |
> |
u_l, A, f, t, pot_local, vpair, fpair) |
749 |
> |
#else |
750 |
> |
call do_pair(atom1, atom2, ratmsq, d_atm, sw, & |
751 |
> |
do_pot, & |
752 |
> |
u_l, A, f, t, pot, vpair, fpair) |
753 |
> |
#endif |
754 |
|
vij = vij + vpair |
755 |
+ |
fij(1:3) = fij(1:3) + fpair(1:3) |
756 |
+ |
|
757 |
|
enddo inner1 |
758 |
|
enddo |
759 |
|
|
760 |
|
if (in_switching_region) then |
761 |
|
swderiv = vij*dswdr/rgrp |
762 |
+ |
fij(1) = fij(1) + swderiv*d_grp(1) |
763 |
+ |
fij(2) = fij(2) + swderiv*d_grp(2) |
764 |
+ |
fij(3) = fij(3) + swderiv*d_grp(3) |
765 |
|
|
766 |
|
do ia=groupStart(i), groupStart(i+1)-1 |
767 |
|
atom1=groupList(ia) |
768 |
|
mf = mfact(atom1) |
769 |
+ |
#ifdef IS_MPI |
770 |
|
f_Row(1,atom1) = f_Row(1,atom1) + swderiv*d_grp(1)*mf |
771 |
|
f_Row(2,atom1) = f_Row(2,atom1) + swderiv*d_grp(2)*mf |
772 |
|
f_Row(3,atom1) = f_Row(3,atom1) + swderiv*d_grp(3)*mf |
773 |
+ |
#else |
774 |
+ |
f(1,atom1) = f(1,atom1) + swderiv*d_grp(1)*mf |
775 |
+ |
f(2,atom1) = f(2,atom1) + swderiv*d_grp(2)*mf |
776 |
+ |
f(3,atom1) = f(3,atom1) + swderiv*d_grp(3)*mf |
777 |
+ |
#endif |
778 |
|
enddo |
779 |
|
|
780 |
|
do jb=groupStart(j), groupStart(j+1)-1 |
781 |
|
atom2=groupList(jb) |
782 |
|
mf = mfact(atom2) |
783 |
+ |
#ifdef IS_MPI |
784 |
|
f_Col(1,atom2) = f_Col(1,atom2) - swderiv*d_grp(1)*mf |
785 |
|
f_Col(2,atom2) = f_Col(2,atom2) - swderiv*d_grp(2)*mf |
786 |
|
f_Col(3,atom2) = f_Col(3,atom2) - swderiv*d_grp(3)*mf |
787 |
+ |
#else |
788 |
+ |
f(1,atom2) = f(1,atom2) - swderiv*d_grp(1)*mf |
789 |
+ |
f(2,atom2) = f(2,atom2) - swderiv*d_grp(2)*mf |
790 |
+ |
f(3,atom2) = f(3,atom2) - swderiv*d_grp(3)*mf |
791 |
+ |
#endif |
792 |
|
enddo |
793 |
|
endif |
794 |
|
|
795 |
+ |
if (do_stress) call add_stress_tensor(d_grp, fij) |
796 |
+ |
|
797 |
|
end if |
798 |
|
enddo |
799 |
|
enddo |
800 |
|
|
801 |
< |
point(nrow_group + 1) = nlist + 1 |
801 |
> |
#ifdef IS_MPI |
802 |
> |
point(nrow_group + 1) = nlist + 1 |
803 |
> |
#else |
804 |
> |
point(nGroup) = nlist + 1 |
805 |
> |
#endif |
806 |
|
|
807 |
|
else !! (of update_check) |
808 |
|
|
809 |
|
! use the list to find the neighbors |
772 |
– |
do i = 1, nrow_group |
810 |
|
|
811 |
+ |
istart = 1 |
812 |
+ |
#ifdef IS_MPI |
813 |
+ |
iend = nrow_group |
814 |
+ |
#else |
815 |
+ |
iend = nGroup - 1 |
816 |
+ |
#endif |
817 |
+ |
|
818 |
+ |
do i = istart, iend |
819 |
+ |
|
820 |
|
n_in_i = groupStart(i+1) - groupStart(i) |
821 |
|
|
822 |
|
JBEG = POINT(i) |
827 |
|
do jnab = jbeg, jend |
828 |
|
j = list(jnab) |
829 |
|
|
830 |
+ |
#ifdef IS_MPI |
831 |
|
call get_interatomic_vector(q_group_Row(:,i), & |
832 |
|
q_group_Col(:,j), d_grp, rgrpsq) |
833 |
< |
|
833 |
> |
#else |
834 |
> |
call get_interatomic_vector(q_group(:,i), & |
835 |
> |
q_group(:,j), d_grp, rgrpsq) |
836 |
> |
#endif |
837 |
|
vij = 0.0d0 |
838 |
+ |
fij(1:3) = 0.0d0 |
839 |
+ |
|
840 |
|
call get_switch(rgrpsq, sw, dswdr, rgrp, group_switch, & |
841 |
|
in_switching_region) |
842 |
|
|
846 |
|
atom1 = groupList(ia) |
847 |
|
|
848 |
|
inner2: do jb = groupStart(j), groupStart(j+1)-1 |
849 |
+ |
|
850 |
|
atom2 = groupList(jb) |
851 |
|
|
852 |
|
if (skipThisPair(atom1, atom2)) cycle inner2 |
855 |
|
d_atm(1:3) = d_grp(1:3) |
856 |
|
ratmsq = rgrpsq |
857 |
|
else |
858 |
+ |
#ifdef IS_MPI |
859 |
|
call get_interatomic_vector(q_Row(:,atom1), & |
860 |
|
q_Col(:,atom2), d_atm, ratmsq) |
861 |
+ |
#else |
862 |
+ |
call get_interatomic_vector(q(:,atom1), & |
863 |
+ |
q(:,atom2), d_atm, ratmsq) |
864 |
+ |
#endif |
865 |
|
endif |
866 |
< |
|
866 |
> |
#ifdef IS_MPI |
867 |
|
call do_pair(atom1, atom2, ratmsq, d_atm, sw, & |
868 |
< |
do_pot, do_stress, & |
869 |
< |
u_l, A, f, t, pot_local, vpair) |
870 |
< |
|
868 |
> |
do_pot, & |
869 |
> |
u_l, A, f, t, pot_local, vpair, fpair) |
870 |
> |
#else |
871 |
> |
call do_pair(atom1, atom2, ratmsq, d_atm, sw, & |
872 |
> |
do_pot, & |
873 |
> |
u_l, A, f, t, pot, vpair, fpair) |
874 |
> |
#endif |
875 |
|
vij = vij + vpair |
876 |
+ |
fij(1:3) = fij(1:3) + fpair(1:3) |
877 |
|
|
878 |
|
enddo inner2 |
879 |
|
enddo |
880 |
|
|
881 |
|
if (in_switching_region) then |
882 |
|
swderiv = vij*dswdr/rgrp |
883 |
+ |
fij(1) = fij(1) + swderiv*d_grp(1) |
884 |
+ |
fij(2) = fij(2) + swderiv*d_grp(2) |
885 |
+ |
fij(3) = fij(3) + swderiv*d_grp(3) |
886 |
|
|
887 |
|
do ia=groupStart(i), groupStart(i+1)-1 |
888 |
|
atom1=groupList(ia) |
889 |
< |
mf = mfact(atom1) |
889 |
> |
mf = mfact(atom1) |
890 |
> |
#ifdef IS_MPI |
891 |
|
f_Row(1,atom1) = f_Row(1,atom1) + swderiv*d_grp(1)*mf |
892 |
|
f_Row(2,atom1) = f_Row(2,atom1) + swderiv*d_grp(2)*mf |
893 |
|
f_Row(3,atom1) = f_Row(3,atom1) + swderiv*d_grp(3)*mf |
827 |
– |
enddo |
828 |
– |
|
829 |
– |
do jb=groupStart(j), groupStart(j+1)-1 |
830 |
– |
atom2=groupList(jb) |
831 |
– |
mf = mfact(atom2) |
832 |
– |
f_Col(1,atom2) = f_Col(1,atom2) - swderiv*d_grp(1)*mf |
833 |
– |
f_Col(2,atom2) = f_Col(2,atom2) - swderiv*d_grp(2)*mf |
834 |
– |
f_Col(3,atom2) = f_Col(3,atom2) - swderiv*d_grp(3)*mf |
835 |
– |
enddo |
836 |
– |
endif |
837 |
– |
|
838 |
– |
enddo |
839 |
– |
endif |
840 |
– |
enddo |
841 |
– |
endif |
842 |
– |
|
894 |
|
#else |
844 |
– |
|
845 |
– |
if (update_nlist) then |
846 |
– |
|
847 |
– |
!! save current configuration, construct neighbor list, |
848 |
– |
!! and calculate forces |
849 |
– |
|
850 |
– |
call saveNeighborList(nGroup, q_group) |
851 |
– |
|
852 |
– |
neighborListSize = size(list) |
853 |
– |
nlist = 0 |
854 |
– |
|
855 |
– |
do i = 1, nGroup-1 |
856 |
– |
|
857 |
– |
point(i) = nlist + 1 |
858 |
– |
n_in_i = groupStart(i+1) - groupStart(i) |
859 |
– |
|
860 |
– |
do j = i+1, nGroup |
861 |
– |
|
862 |
– |
call get_interatomic_vector(q_group(:,i), & |
863 |
– |
q_group(:,j), d_grp, rgrpsq) |
864 |
– |
|
865 |
– |
if (rgrpsq < rlistsq) then |
866 |
– |
nlist = nlist + 1 |
867 |
– |
|
868 |
– |
if (nlist > neighborListSize) then |
869 |
– |
call expandNeighborList(nGroup, listerror) |
870 |
– |
if (listerror /= 0) then |
871 |
– |
error = -1 |
872 |
– |
write(DEFAULT_ERROR,*) "ERROR: nlist > list size and max allocations exceeded." |
873 |
– |
return |
874 |
– |
end if |
875 |
– |
neighborListSize = size(list) |
876 |
– |
endif |
877 |
– |
|
878 |
– |
list(nlist) = j |
879 |
– |
|
880 |
– |
vij = 0.0d0 |
881 |
– |
|
882 |
– |
call get_switch(rgrpsq, sw, dswdr, rgrp, group_switch, & |
883 |
– |
in_switching_region) |
884 |
– |
|
885 |
– |
n_in_j = groupStart(j+1) - groupStart(j) |
886 |
– |
|
887 |
– |
do ia = groupStart(i), groupStart(i+1)-1 |
888 |
– |
atom1 = groupList(ia) |
889 |
– |
|
890 |
– |
inner1: do jb = groupStart(j), groupStart(j+1)-1 |
891 |
– |
atom2 = groupList(jb) |
892 |
– |
|
893 |
– |
if (skipThisPair(atom1, atom2)) cycle inner1 |
894 |
– |
|
895 |
– |
if ((n_in_i .eq. 1).and.(n_in_j .eq. 1)) then |
896 |
– |
d_atm(1:3) = d_grp(1:3) |
897 |
– |
ratmsq = rgrpsq |
898 |
– |
else |
899 |
– |
call get_interatomic_vector(q(:,atom1), & |
900 |
– |
q(:,atom2), d_atm, ratmsq) |
901 |
– |
endif |
902 |
– |
|
903 |
– |
call do_pair(atom1, atom2, ratmsq, d_atm, sw, & |
904 |
– |
do_pot, do_stress, & |
905 |
– |
u_l, A, f, t, pot, vpair) |
906 |
– |
|
907 |
– |
vij = vij + vpair |
908 |
– |
|
909 |
– |
enddo inner1 |
910 |
– |
enddo |
911 |
– |
|
912 |
– |
if (in_switching_region) then |
913 |
– |
swderiv = vij*dswdr/rgrp |
914 |
– |
do ia=groupStart(i), groupStart(i+1)-1 |
915 |
– |
atom1=groupList(ia) |
916 |
– |
mf = mfact(atom1) |
895 |
|
f(1,atom1) = f(1,atom1) + swderiv*d_grp(1)*mf |
896 |
|
f(2,atom1) = f(2,atom1) + swderiv*d_grp(2)*mf |
897 |
|
f(3,atom1) = f(3,atom1) + swderiv*d_grp(3)*mf |
898 |
+ |
#endif |
899 |
|
enddo |
900 |
|
|
901 |
|
do jb=groupStart(j), groupStart(j+1)-1 |
902 |
|
atom2=groupList(jb) |
903 |
|
mf = mfact(atom2) |
904 |
+ |
#ifdef IS_MPI |
905 |
+ |
f_Col(1,atom2) = f_Col(1,atom2) - swderiv*d_grp(1)*mf |
906 |
+ |
f_Col(2,atom2) = f_Col(2,atom2) - swderiv*d_grp(2)*mf |
907 |
+ |
f_Col(3,atom2) = f_Col(3,atom2) - swderiv*d_grp(3)*mf |
908 |
+ |
#else |
909 |
|
f(1,atom2) = f(1,atom2) - swderiv*d_grp(1)*mf |
910 |
|
f(2,atom2) = f(2,atom2) - swderiv*d_grp(2)*mf |
911 |
|
f(3,atom2) = f(3,atom2) - swderiv*d_grp(3)*mf |
912 |
+ |
#endif |
913 |
|
enddo |
914 |
|
endif |
915 |
|
|
916 |
< |
end if |
932 |
< |
enddo |
933 |
< |
enddo |
934 |
< |
point(nGroup) = nlist + 1 |
935 |
< |
|
936 |
< |
else !! (of update_check) |
937 |
< |
|
938 |
< |
! use the list to find the neighbors |
939 |
< |
do i = 1, nGroup-1 |
940 |
< |
|
941 |
< |
n_in_i = groupStart(i+1) - groupStart(i) |
942 |
< |
|
943 |
< |
JBEG = POINT(i) |
944 |
< |
JEND = POINT(i+1) - 1 |
945 |
< |
! check that group i has neighbors |
946 |
< |
if (jbeg .le. jend) then |
947 |
< |
|
948 |
< |
do jnab = jbeg, jend |
949 |
< |
j = list(jnab) |
950 |
< |
|
951 |
< |
call get_interatomic_vector(q_group(:,i), & |
952 |
< |
q_group(:,j), d_grp, rgrpsq) |
916 |
> |
if (do_stress) call add_stress_tensor(d_grp, fij) |
917 |
|
|
954 |
– |
vij = 0.0d0 |
955 |
– |
|
956 |
– |
call get_switch(rgrpsq, sw, dswdr, rgrp, group_switch, & |
957 |
– |
in_switching_region) |
958 |
– |
|
959 |
– |
n_in_j = groupStart(j+1) - groupStart(j) |
960 |
– |
|
961 |
– |
do ia = groupStart(i), groupStart(i+1)-1 |
962 |
– |
atom1 = groupList(ia) |
963 |
– |
|
964 |
– |
inner2: do jb = groupStart(j), groupStart(j+1)-1 |
965 |
– |
atom2 = groupList(jb) |
966 |
– |
|
967 |
– |
if (skipThisPair(atom1, atom2)) cycle inner2 |
968 |
– |
|
969 |
– |
if ((n_in_i .eq. 1).and.(n_in_j .eq. 1)) then |
970 |
– |
d_atm(1:3) = d_grp(1:3) |
971 |
– |
ratmsq = rgrpsq |
972 |
– |
else |
973 |
– |
call get_interatomic_vector(q(:,atom1), & |
974 |
– |
q(:,atom2), d_atm, ratmsq) |
975 |
– |
endif |
976 |
– |
|
977 |
– |
call do_pair(atom1, atom2, ratmsq, d_atm, sw, & |
978 |
– |
do_pot, do_stress, & |
979 |
– |
u_l, A, f, t, pot, vpair) |
980 |
– |
|
981 |
– |
vij = vij + vpair |
982 |
– |
|
983 |
– |
enddo inner2 |
984 |
– |
enddo |
985 |
– |
|
986 |
– |
if (in_switching_region) then |
987 |
– |
swderiv = vij*dswdr/rgrp |
988 |
– |
|
989 |
– |
do ia=groupStart(i), groupStart(i+1)-1 |
990 |
– |
atom1=groupList(ia) |
991 |
– |
mf = mfact(atom1) |
992 |
– |
f(1,atom1) = f(1,atom1) + swderiv*d_grp(1)*mf |
993 |
– |
f(2,atom1) = f(2,atom1) + swderiv*d_grp(2)*mf |
994 |
– |
f(3,atom1) = f(3,atom1) + swderiv*d_grp(3)*mf |
995 |
– |
enddo |
996 |
– |
|
997 |
– |
do jb=groupStart(j), groupStart(j+1)-1 |
998 |
– |
atom2=groupList(jb) |
999 |
– |
mf = mfact(atom2) |
1000 |
– |
f(1,atom2) = f(1,atom2) - swderiv*d_grp(1)*mf |
1001 |
– |
f(2,atom2) = f(2,atom2) - swderiv*d_grp(2)*mf |
1002 |
– |
f(3,atom2) = f(3,atom2) - swderiv*d_grp(3)*mf |
1003 |
– |
enddo |
1004 |
– |
endif |
918 |
|
enddo |
919 |
|
endif |
920 |
|
enddo |
921 |
|
endif |
922 |
|
|
1010 |
– |
#endif |
1011 |
– |
|
923 |
|
! phew, done with main loop. |
924 |
|
|
925 |
|
!! Do timing |
1048 |
|
end subroutine do_force_loop |
1049 |
|
|
1050 |
|
|
1051 |
< |
subroutine do_pair(i, j, rijsq, d, sw, do_pot, do_stress, & |
1052 |
< |
u_l, A, f, t, pot, vpair) |
1051 |
> |
subroutine do_pair(i, j, rijsq, d, sw, do_pot, & |
1052 |
> |
u_l, A, f, t, pot, vpair, fpair) |
1053 |
|
|
1054 |
|
real( kind = dp ) :: pot, vpair, sw |
1055 |
+ |
real( kind = dp ), dimension(3) :: fpair |
1056 |
|
real( kind = dp ), dimension(nLocal) :: mfact |
1057 |
|
real( kind = dp ), dimension(3,nLocal) :: u_l |
1058 |
|
real( kind = dp ), dimension(9,nLocal) :: A |
1059 |
|
real( kind = dp ), dimension(3,nLocal) :: f |
1060 |
|
real( kind = dp ), dimension(3,nLocal) :: t |
1061 |
|
|
1062 |
< |
logical, intent(inout) :: do_pot, do_stress |
1062 |
> |
logical, intent(inout) :: do_pot |
1063 |
|
integer, intent(in) :: i, j |
1064 |
|
real ( kind = dp ), intent(inout) :: rijsq |
1065 |
|
real ( kind = dp ) :: r |
1068 |
|
|
1069 |
|
r = sqrt(rijsq) |
1070 |
|
vpair = 0.0d0 |
1071 |
+ |
fpair(1:3) = 0.0d0 |
1072 |
|
|
1073 |
|
#ifdef IS_MPI |
1074 |
|
if (tagRow(i) .eq. tagColumn(j)) then |
1090 |
|
!write(*,'(3es12.3)') sw, vpair, pot |
1091 |
|
!write(*,*) |
1092 |
|
|
1093 |
< |
call do_lj_pair(i, j, d, r, rijsq, sw, vpair, pot, f, do_pot, & |
1181 |
< |
do_stress) |
1093 |
> |
call do_lj_pair(i, j, d, r, rijsq, sw, vpair, fpair, pot, f, do_pot) |
1094 |
|
endif |
1095 |
|
|
1096 |
|
endif |
1098 |
|
if (FF_uses_charges .and. SIM_uses_charges) then |
1099 |
|
|
1100 |
|
if (PropertyMap(me_i)%is_Charge .and. PropertyMap(me_j)%is_Charge) then |
1101 |
< |
call do_charge_pair(i, j, d, r, rijsq, sw, vpair, pot, f, do_pot, & |
1190 |
< |
do_stress) |
1101 |
> |
call do_charge_pair(i, j, d, r, rijsq, sw, vpair, fpair, pot, f, do_pot) |
1102 |
|
endif |
1103 |
|
|
1104 |
|
endif |
1106 |
|
if (FF_uses_dipoles .and. SIM_uses_dipoles) then |
1107 |
|
|
1108 |
|
if ( PropertyMap(me_i)%is_DP .and. PropertyMap(me_j)%is_DP) then |
1109 |
< |
call do_dipole_pair(i, j, d, r, rijsq, sw, vpair, pot, u_l, f, t, & |
1110 |
< |
do_pot, do_stress) |
1109 |
> |
call do_dipole_pair(i, j, d, r, rijsq, sw, vpair, fpair, pot, u_l, f, t, & |
1110 |
> |
do_pot) |
1111 |
|
if (FF_uses_RF .and. SIM_uses_RF) then |
1112 |
|
call accumulate_rf(i, j, r, u_l, sw) |
1113 |
< |
call rf_correct_forces(i, j, d, r, u_l, sw, f, do_stress) |
1113 |
> |
call rf_correct_forces(i, j, d, r, u_l, sw, f, fpair) |
1114 |
|
endif |
1115 |
|
endif |
1116 |
|
|
1119 |
|
if (FF_uses_Sticky .and. SIM_uses_sticky) then |
1120 |
|
|
1121 |
|
if ( PropertyMap(me_i)%is_Sticky .and. PropertyMap(me_j)%is_Sticky) then |
1122 |
< |
call do_sticky_pair(i, j, d, r, rijsq, sw, vpair, pot, A, f, t, & |
1123 |
< |
do_pot, do_stress) |
1122 |
> |
call do_sticky_pair(i, j, d, r, rijsq, sw, vpair, fpair, pot, A, f, t, & |
1123 |
> |
do_pot) |
1124 |
|
endif |
1125 |
|
|
1126 |
|
endif |
1129 |
|
if (FF_uses_GB .and. SIM_uses_GB) then |
1130 |
|
|
1131 |
|
if ( PropertyMap(me_i)%is_GB .and. PropertyMap(me_j)%is_GB) then |
1132 |
< |
call do_gb_pair(i, j, d, r, rijsq, sw, vpair, pot, u_l, f, t, & |
1133 |
< |
do_pot, do_stress) |
1132 |
> |
call do_gb_pair(i, j, d, r, rijsq, sw, vpair, fpair, pot, u_l, f, t, & |
1133 |
> |
do_pot) |
1134 |
|
endif |
1135 |
|
|
1136 |
|
endif |
1138 |
|
if (FF_uses_EAM .and. SIM_uses_EAM) then |
1139 |
|
|
1140 |
|
if ( PropertyMap(me_i)%is_EAM .and. PropertyMap(me_j)%is_EAM) then |
1141 |
< |
call do_eam_pair(i, j, d, r, rijsq, sw, vpair, pot, f, & |
1142 |
< |
do_pot, do_stress) |
1141 |
> |
call do_eam_pair(i, j, d, r, rijsq, sw, vpair, fpair, pot, f, & |
1142 |
> |
do_pot) |
1143 |
|
endif |
1144 |
|
|
1145 |
|
endif |
1146 |
|
|
1147 |
|
end subroutine do_pair |
1148 |
|
|
1149 |
< |
subroutine do_prepair(i, j, rijsq, d, rcijsq, dc, & |
1149 |
> |
subroutine do_prepair(i, j, rijsq, d, sw, rcijsq, dc, & |
1150 |
|
do_pot, do_stress, u_l, A, f, t, pot) |
1151 |
< |
real( kind = dp ) :: pot |
1151 |
> |
|
1152 |
> |
real( kind = dp ) :: pot, sw |
1153 |
|
real( kind = dp ), dimension(3,nLocal) :: u_l |
1154 |
|
real (kind=dp), dimension(9,nLocal) :: A |
1155 |
|
real (kind=dp), dimension(3,nLocal) :: f |
1176 |
|
|
1177 |
|
#ifdef IS_MPI |
1178 |
|
if (tagRow(i) .eq. tagColumn(j)) then |
1179 |
< |
write(0,*) 'do_pair is doing', i , j, tagRow(i), tagColumn(j) |
1179 |
> |
write(0,*) 'do_prepair is doing', i , j, tagRow(i), tagColumn(j) |
1180 |
|
endif |
1181 |
|
|
1182 |
|
me_i = atid_row(i) |
1188 |
|
me_j = atid(j) |
1189 |
|
|
1190 |
|
#endif |
1191 |
< |
|
1191 |
> |
|
1192 |
|
if (FF_uses_EAM .and. SIM_uses_EAM) then |
1193 |
< |
|
1193 |
> |
|
1194 |
|
if (PropertyMap(me_i)%is_EAM .and. PropertyMap(me_j)%is_EAM) & |
1195 |
|
call calc_EAM_prepair_rho(i, j, d, r, rijsq ) |
1196 |
< |
|
1196 |
> |
|
1197 |
|
endif |
1198 |
|
|
1199 |
|
end subroutine do_prepair |
1200 |
< |
|
1201 |
< |
|
1290 |
< |
|
1291 |
< |
|
1200 |
> |
|
1201 |
> |
|
1202 |
|
subroutine do_preforce(nlocal,pot) |
1203 |
|
integer :: nlocal |
1204 |
|
real( kind = dp ) :: pot |
1411 |
|
#endif |
1412 |
|
|
1413 |
|
!! This cleans componets of force arrays belonging only to fortran |
1414 |
+ |
|
1415 |
+ |
subroutine add_stress_tensor(dpair, fpair) |
1416 |
+ |
|
1417 |
+ |
real( kind = dp ), dimension(3), intent(in) :: dpair, fpair |
1418 |
+ |
|
1419 |
+ |
! because the d vector is the rj - ri vector, and |
1420 |
+ |
! because fx, fy, fz are the force on atom i, we need a |
1421 |
+ |
! negative sign here: |
1422 |
+ |
|
1423 |
+ |
tau_Temp(1) = tau_Temp(1) - dpair(1) * fpair(1) |
1424 |
+ |
tau_Temp(2) = tau_Temp(2) - dpair(1) * fpair(2) |
1425 |
+ |
tau_Temp(3) = tau_Temp(3) - dpair(1) * fpair(3) |
1426 |
+ |
tau_Temp(4) = tau_Temp(4) - dpair(2) * fpair(1) |
1427 |
+ |
tau_Temp(5) = tau_Temp(5) - dpair(2) * fpair(2) |
1428 |
+ |
tau_Temp(6) = tau_Temp(6) - dpair(2) * fpair(3) |
1429 |
+ |
tau_Temp(7) = tau_Temp(7) - dpair(3) * fpair(1) |
1430 |
+ |
tau_Temp(8) = tau_Temp(8) - dpair(3) * fpair(2) |
1431 |
+ |
tau_Temp(9) = tau_Temp(9) - dpair(3) * fpair(3) |
1432 |
+ |
|
1433 |
+ |
!write(*,'(6es12.3)') fpair(1:3), tau_Temp(1), tau_Temp(5), tau_temp(9) |
1434 |
+ |
virial_Temp = virial_Temp + & |
1435 |
+ |
(tau_Temp(1) + tau_Temp(5) + tau_Temp(9)) |
1436 |
+ |
|
1437 |
+ |
end subroutine add_stress_tensor |
1438 |
|
|
1439 |
|
end module do_Forces |
1440 |
+ |
|