4 |
|
|
5 |
|
!! @author Charles F. Vardeman II |
6 |
|
!! @author Matthew Meineke |
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 $ |
7 |
> |
!! @version $Id: do_Forces.F90,v 1.64 2004-05-27 15:21:20 gezelter Exp $, $Date: 2004-05-27 15:21:20 $, $Name: not supported by cvs2svn $, $Revision: 1.64 $ |
8 |
|
|
9 |
|
module do_Forces |
10 |
|
use force_globals |
33 |
|
#include "fForceField.h" |
34 |
|
#include "fSwitchingFunction.h" |
35 |
|
|
36 |
+ |
INTEGER, PARAMETER:: PREPAIR_LOOP = 1 |
37 |
+ |
INTEGER, PARAMETER:: PAIR_LOOP = 2 |
38 |
+ |
|
39 |
|
logical, save :: haveRlist = .false. |
40 |
|
logical, save :: haveNeighborList = .false. |
41 |
|
logical, save :: havePolicies = .false. |
375 |
|
!! Position array provided by C, dimensioned by getNlocal |
376 |
|
real ( kind = dp ), dimension(3, nLocal) :: q |
377 |
|
!! molecular center-of-mass position array |
378 |
< |
real ( kind = dp ), dimension(3, nGroup) :: q_group |
378 |
> |
real ( kind = dp ), dimension(3, nGroups) :: q_group |
379 |
|
!! Rotation Matrix for each long range particle in simulation. |
380 |
|
real( kind = dp), dimension(9, nLocal) :: A |
381 |
|
!! Unit vectors for dipoles (lab frame) |
394 |
|
logical :: in_switching_region |
395 |
|
#ifdef IS_MPI |
396 |
|
real( kind = DP ) :: pot_local |
397 |
< |
integer :: nrow |
398 |
< |
integer :: ncol |
397 |
> |
integer :: nAtomsInRow |
398 |
> |
integer :: nAtomsInCol |
399 |
|
integer :: nprocs |
400 |
< |
integer :: nrow_group |
401 |
< |
integer :: ncol_group |
400 |
> |
integer :: nGroupsInRow |
401 |
> |
integer :: nGroupsInCol |
402 |
|
#endif |
403 |
|
integer :: natoms |
404 |
|
logical :: update_nlist |
405 |
< |
integer :: i, j, jbeg, jend, jnab |
406 |
< |
integer :: istart, iend, jstart |
405 |
> |
integer :: i, j, jstart, jend, jnab |
406 |
> |
integer :: istart, iend |
407 |
|
integer :: ia, jb, atom1, atom2 |
408 |
|
integer :: nlist |
409 |
|
real( kind = DP ) :: ratmsq, rgrpsq, rgrp, vpair, vij |
416 |
|
integer :: listerror, error |
417 |
|
integer :: localError |
418 |
|
integer :: propPack_i, propPack_j |
419 |
+ |
integer :: loopStart, loopEnd, loop |
420 |
|
|
421 |
|
real(kind=dp) :: listSkin = 1.0 |
422 |
|
|
424 |
|
|
425 |
|
#ifdef IS_MPI |
426 |
|
pot_local = 0.0_dp |
427 |
< |
nrow = getNrow(plan_row) |
428 |
< |
ncol = getNcol(plan_col) |
429 |
< |
nrow_group = getNrowGroup(plan_row) |
430 |
< |
ncol_group = getNcolGroup(plan_col) |
427 |
> |
nAtomsInRow = getNatomsInRow(plan_atom_row) |
428 |
> |
nAtomsInCol = getNatomsInCol(plan_atom_col) |
429 |
> |
nGroupsInRow = getNgroupsInRow(plan_group_row) |
430 |
> |
nGroupsInCol = getNgroupsInCol(plan_group_col) |
431 |
|
#else |
432 |
|
natoms = nlocal |
433 |
|
#endif |
447 |
|
|
448 |
|
#ifdef IS_MPI |
449 |
|
|
450 |
< |
call gather(q, q_Row, plan_row3d) |
451 |
< |
call gather(q, q_Col, plan_col3d) |
450 |
> |
call gather(q, q_Row, plan_atom_row_3d) |
451 |
> |
call gather(q, q_Col, plan_atom_col_3d) |
452 |
|
|
453 |
< |
call gather(q_group, q_group_Row, plan_row_Group_3d) |
454 |
< |
call gather(q_group, q_group_Col, plan_col_Group_3d) |
453 |
> |
call gather(q_group, q_group_Row, plan_group_row_3d) |
454 |
> |
call gather(q_group, q_group_Col, plan_group_col_3d) |
455 |
|
|
456 |
|
if (FF_UsesDirectionalAtoms() .and. SIM_uses_directional_atoms) then |
457 |
< |
call gather(u_l,u_l_Row,plan_row3d) |
458 |
< |
call gather(u_l,u_l_Col,plan_col3d) |
457 |
> |
call gather(u_l, u_l_Row, plan_atom_row_3d) |
458 |
> |
call gather(u_l, u_l_Col, plan_atom_col_3d) |
459 |
|
|
460 |
< |
call gather(A,A_Row,plan_row_rotation) |
461 |
< |
call gather(A,A_Col,plan_col_rotation) |
460 |
> |
call gather(A, A_Row, plan_atom_row_rotation) |
461 |
> |
call gather(A, A_Col, plan_atom_col_rotation) |
462 |
|
endif |
463 |
|
|
464 |
|
#endif |
469 |
|
nloops = nloops + 1 |
470 |
|
#endif |
471 |
|
|
472 |
+ |
loopEnd = PAIR_LOOP |
473 |
|
if (FF_RequiresPrepairCalc() .and. SIM_requires_prepair_calc) then |
474 |
< |
!! See if we need to update neighbor lists |
475 |
< |
|
476 |
< |
call checkNeighborList(nGroup, q_group, listSkin, update_nlist) |
474 |
> |
loopStart = PREPAIR_LOOP |
475 |
> |
else |
476 |
> |
loopStart = PAIR_LOOP |
477 |
> |
endif |
478 |
|
|
479 |
< |
!! if_mpi_gather_stuff_for_prepair |
474 |
< |
!! do_prepair_loop_if_needed |
475 |
< |
!! if_mpi_scatter_stuff_from_prepair |
476 |
< |
!! if_mpi_gather_stuff_from_prepair_to_main_loop |
477 |
< |
|
478 |
< |
!--------------------PREFORCE LOOP----------->>>>>>>>>>>>>>>>>>>>>>>>>>> |
479 |
> |
do loop = loopStart, loopEnd |
480 |
|
|
481 |
+ |
! See if we need to update neighbor lists |
482 |
+ |
! (but only on the first time through): |
483 |
+ |
if (loop .eq. loopStart) then |
484 |
+ |
call checkNeighborList(nGroups, q_group, listSkin, update_nlist) |
485 |
+ |
endif |
486 |
+ |
|
487 |
|
if (update_nlist) then |
488 |
< |
|
482 |
< |
!! save current configuration, construct neighbor list, |
483 |
< |
!! and calculate forces |
484 |
< |
|
485 |
< |
call saveNeighborList(nGroup, q_group) |
486 |
< |
|
487 |
< |
neighborListSize = size(list) |
488 |
< |
nlist = 0 |
489 |
< |
|
490 |
< |
istart = 1 |
488 |
> |
!! save current configuration and construct neighbor list |
489 |
|
#ifdef IS_MPI |
490 |
< |
iend = nrow_group |
490 |
> |
call saveNeighborList(nGroupsInRow, q_group) |
491 |
|
#else |
492 |
< |
iend = nGroup - 1 |
493 |
< |
#endif |
494 |
< |
do i = istart, iend |
495 |
< |
|
496 |
< |
point(i) = nlist + 1 |
497 |
< |
|
498 |
< |
n_in_i = groupStart(i+1) - groupStart(i) |
499 |
< |
|
500 |
< |
#ifdef IS_MPI |
503 |
< |
jstart = 1 |
504 |
< |
jend = ncol_group |
492 |
> |
call saveNeighborList(nGroups, q_group) |
493 |
> |
#endif |
494 |
> |
neighborListSize = size(list) |
495 |
> |
nlist = 0 |
496 |
> |
endif |
497 |
> |
|
498 |
> |
istart = 1 |
499 |
> |
#ifdef IS_MPI |
500 |
> |
iend = nGroupsInRow |
501 |
|
#else |
502 |
+ |
iend = nGroups - 1 |
503 |
+ |
#endif |
504 |
+ |
outer: do i = istart, iend |
505 |
+ |
|
506 |
+ |
if (update_nlist) point(i) = nlist + 1 |
507 |
+ |
|
508 |
+ |
n_in_i = groupStartRow(i+1) - groupStartRow(i) |
509 |
+ |
|
510 |
+ |
if (update_nlist) then |
511 |
+ |
#ifdef IS_MPI |
512 |
+ |
jstart = 1 |
513 |
+ |
jend = nGroupsInCol |
514 |
+ |
#else |
515 |
|
jstart = i+1 |
516 |
< |
jend = nGroup |
516 |
> |
jend = nGroups |
517 |
|
#endif |
518 |
< |
do j = jstart, jend |
519 |
< |
|
518 |
> |
else |
519 |
> |
jstart = point(i) |
520 |
> |
jend = point(i+1) - 1 |
521 |
> |
! make sure group i has neighbors |
522 |
> |
if (jstart .gt. jend) cycle outer |
523 |
> |
endif |
524 |
> |
|
525 |
> |
do jnab = jstart, jend |
526 |
> |
if (update_nlist) then |
527 |
> |
j = jnab |
528 |
> |
else |
529 |
> |
j = list(jnab) |
530 |
> |
endif |
531 |
> |
|
532 |
|
#ifdef IS_MPI |
533 |
< |
call get_interatomic_vector(q_group_Row(:,i), & |
534 |
< |
q_group_Col(:,j), d_grp, rgrpsq) |
533 |
> |
call get_interatomic_vector(q_group_Row(:,i), & |
534 |
> |
q_group_Col(:,j), d_grp, rgrpsq) |
535 |
|
#else |
536 |
< |
call get_interatomic_vector(q_group(:,i), & |
537 |
< |
q_group(:,j), d_grp, rgrpsq) |
538 |
< |
#endif |
539 |
< |
if (rgrpsq < rlistsq) then |
536 |
> |
call get_interatomic_vector(q_group(:,i), & |
537 |
> |
q_group(:,j), d_grp, rgrpsq) |
538 |
> |
#endif |
539 |
> |
|
540 |
> |
if (rgrpsq < rlistsq) then |
541 |
> |
if (update_nlist) then |
542 |
|
nlist = nlist + 1 |
543 |
|
|
544 |
|
if (nlist > neighborListSize) then |
545 |
< |
call expandNeighborList(nGroup, listerror) |
545 |
> |
#ifdef IS_MPI |
546 |
> |
call expandNeighborList(nGroupsInRow, listerror) |
547 |
> |
#else |
548 |
> |
call expandNeighborList(nGroups, listerror) |
549 |
> |
#endif |
550 |
|
if (listerror /= 0) then |
551 |
|
error = -1 |
552 |
|
write(DEFAULT_ERROR,*) "ERROR: nlist > list size and max allocations exceeded." |
555 |
|
neighborListSize = size(list) |
556 |
|
endif |
557 |
|
|
558 |
< |
list(nlist) = j |
558 |
> |
list(nlist) = j |
559 |
> |
endif |
560 |
> |
|
561 |
> |
if (loop .eq. PAIR_LOOP) then |
562 |
> |
vij = 0.0d0 |
563 |
> |
fij(1:3) = 0.0d0 |
564 |
> |
endif |
565 |
> |
|
566 |
> |
call get_switch(rgrpsq, sw, dswdr, rgrp, group_switch, & |
567 |
> |
in_switching_region) |
568 |
> |
|
569 |
> |
n_in_j = groupStartCol(j+1) - groupStartCol(j) |
570 |
> |
|
571 |
> |
do ia = groupStartRow(i), groupStartRow(i+1)-1 |
572 |
|
|
573 |
< |
call get_switch(rgrpsq, sw, dswdr, rgrp, group_switch, & |
534 |
< |
in_switching_region) |
573 |
> |
atom1 = groupListRow(ia) |
574 |
|
|
575 |
< |
n_in_j = groupStart(j+1) - groupStart(j) |
537 |
< |
|
538 |
< |
do ia = groupStart(i), groupStart(i+1)-1 |
539 |
< |
atom1 = groupList(ia) |
575 |
> |
inner: do jb = groupStartCol(j), groupStartCol(j+1)-1 |
576 |
|
|
577 |
< |
prepair_inner1: do jb = groupStart(j), groupStart(j+1)-1 |
578 |
< |
atom2 = groupList(jb) |
579 |
< |
|
580 |
< |
if (skipThisPair(atom1, atom2)) cycle prepair_inner1 |
581 |
< |
|
582 |
< |
if ((n_in_i .eq. 1).and.(n_in_j .eq. 1)) then |
583 |
< |
d_atm(1:3) = d_grp(1:3) |
584 |
< |
ratmsq = rgrpsq |
549 |
< |
else |
577 |
> |
atom2 = groupListCol(jb) |
578 |
> |
|
579 |
> |
if (skipThisPair(atom1, atom2)) cycle inner |
580 |
> |
|
581 |
> |
if ((n_in_i .eq. 1).and.(n_in_j .eq. 1)) then |
582 |
> |
d_atm(1:3) = d_grp(1:3) |
583 |
> |
ratmsq = rgrpsq |
584 |
> |
else |
585 |
|
#ifdef IS_MPI |
586 |
< |
call get_interatomic_vector(q_Row(:,atom1), & |
587 |
< |
q_Col(:,atom2), d_atm, ratmsq) |
586 |
> |
call get_interatomic_vector(q_Row(:,atom1), & |
587 |
> |
q_Col(:,atom2), d_atm, ratmsq) |
588 |
|
#else |
589 |
< |
call get_interatomic_vector(q(:,atom1), & |
590 |
< |
q(:,atom2), d_atm, ratmsq) |
589 |
> |
call get_interatomic_vector(q(:,atom1), & |
590 |
> |
q(:,atom2), d_atm, ratmsq) |
591 |
|
#endif |
592 |
< |
endif |
592 |
> |
endif |
593 |
> |
if (loop .eq. PREPAIR_LOOP) then |
594 |
|
#ifdef IS_MPI |
595 |
|
call do_prepair(atom1, atom2, ratmsq, d_atm, sw, & |
596 |
|
rgrpsq, d_grp, do_pot, do_stress, & |
600 |
|
rgrpsq, d_grp, do_pot, do_stress, & |
601 |
|
u_l, A, f, t, pot) |
602 |
|
#endif |
603 |
< |
enddo prepair_inner1 |
604 |
< |
enddo |
605 |
< |
|
606 |
< |
end if |
607 |
< |
enddo |
572 |
< |
enddo |
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 |
< |
|
584 |
< |
istart = 1 |
585 |
< |
#ifdef IS_MPI |
586 |
< |
iend = nrow_group |
603 |
> |
else |
604 |
> |
#ifdef IS_MPI |
605 |
> |
call do_pair(atom1, atom2, ratmsq, d_atm, sw, & |
606 |
> |
do_pot, & |
607 |
> |
u_l, A, f, t, pot_local, vpair, fpair) |
608 |
|
#else |
609 |
< |
iend = nGroup - 1 |
609 |
> |
call do_pair(atom1, atom2, ratmsq, d_atm, sw, & |
610 |
> |
do_pot, & |
611 |
> |
u_l, A, f, t, pot, vpair, fpair) |
612 |
|
#endif |
613 |
< |
|
614 |
< |
do i = istart, iend |
615 |
< |
|
616 |
< |
n_in_i = groupStart(i+1) - groupStart(i) |
617 |
< |
|
595 |
< |
JBEG = POINT(i) |
596 |
< |
JEND = POINT(i+1) - 1 |
597 |
< |
! check that group i has neighbors |
598 |
< |
if (jbeg .le. jend) then |
613 |
> |
vij = vij + vpair |
614 |
> |
fij(1:3) = fij(1:3) + fpair(1:3) |
615 |
> |
endif |
616 |
> |
enddo inner |
617 |
> |
enddo |
618 |
|
|
619 |
< |
do jnab = jbeg, jend |
620 |
< |
j = list(jnab) |
621 |
< |
|
619 |
> |
if (loop .eq. PAIR_LOOP) then |
620 |
> |
if (in_switching_region) then |
621 |
> |
swderiv = vij*dswdr/rgrp |
622 |
> |
fij(1) = fij(1) + swderiv*d_grp(1) |
623 |
> |
fij(2) = fij(2) + swderiv*d_grp(2) |
624 |
> |
fij(3) = fij(3) + swderiv*d_grp(3) |
625 |
> |
|
626 |
> |
do ia=groupStartRow(i), groupStartRow(i+1)-1 |
627 |
> |
atom1=groupListRow(ia) |
628 |
> |
mf = mfactRow(atom1) |
629 |
|
#ifdef IS_MPI |
630 |
< |
call get_interatomic_vector(q_group_Row(:,i), & |
631 |
< |
q_group_Col(:,j), d_grp, rgrpsq) |
630 |
> |
f_Row(1,atom1) = f_Row(1,atom1) + swderiv*d_grp(1)*mf |
631 |
> |
f_Row(2,atom1) = f_Row(2,atom1) + swderiv*d_grp(2)*mf |
632 |
> |
f_Row(3,atom1) = f_Row(3,atom1) + swderiv*d_grp(3)*mf |
633 |
|
#else |
634 |
< |
call get_interatomic_vector(q_group(:,i), & |
635 |
< |
q_group(:,j), d_grp, rgrpsq) |
636 |
< |
#endif |
637 |
< |
call get_switch(rgrpsq, sw, dswdr, rgrp, group_switch, & |
638 |
< |
in_switching_region) |
612 |
< |
|
613 |
< |
n_in_j = groupStart(j+1) - groupStart(j) |
614 |
< |
|
615 |
< |
do ia = groupStart(i), groupStart(i+1)-1 |
616 |
< |
atom1 = groupList(ia) |
634 |
> |
f(1,atom1) = f(1,atom1) + swderiv*d_grp(1)*mf |
635 |
> |
f(2,atom1) = f(2,atom1) + swderiv*d_grp(2)*mf |
636 |
> |
f(3,atom1) = f(3,atom1) + swderiv*d_grp(3)*mf |
637 |
> |
#endif |
638 |
> |
enddo |
639 |
|
|
640 |
< |
prepair_inner2: do jb = groupStart(j), groupStart(j+1)-1 |
641 |
< |
|
642 |
< |
atom2 = groupList(jb) |
621 |
< |
|
622 |
< |
if (skipThisPair(atom1, atom2)) cycle prepair_inner2 |
623 |
< |
|
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 |
640 |
> |
do jb=groupStartCol(j), groupStartCol(j+1)-1 |
641 |
> |
atom2=groupListCol(jb) |
642 |
> |
mf = mfactCol(atom2) |
643 |
|
#ifdef IS_MPI |
644 |
< |
call get_interatomic_vector(q_Row(:,atom1), & |
645 |
< |
q_Col(:,atom2), d_atm, ratmsq) |
644 |
> |
f_Col(1,atom2) = f_Col(1,atom2) - swderiv*d_grp(1)*mf |
645 |
> |
f_Col(2,atom2) = f_Col(2,atom2) - swderiv*d_grp(2)*mf |
646 |
> |
f_Col(3,atom2) = f_Col(3,atom2) - swderiv*d_grp(3)*mf |
647 |
|
#else |
648 |
< |
call get_interatomic_vector(q(:,atom1), & |
649 |
< |
q(:,atom2), d_atm, ratmsq) |
648 |
> |
f(1,atom2) = f(1,atom2) - swderiv*d_grp(1)*mf |
649 |
> |
f(2,atom2) = f(2,atom2) - swderiv*d_grp(2)*mf |
650 |
> |
f(3,atom2) = f(3,atom2) - swderiv*d_grp(3)*mf |
651 |
|
#endif |
652 |
< |
endif |
653 |
< |
|
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 |
< |
#endif |
646 |
< |
enddo prepair_inner2 |
647 |
< |
enddo |
648 |
< |
enddo |
649 |
< |
endif |
650 |
< |
enddo |
651 |
< |
endif |
652 |
< |
!! Do rest of preforce calculations |
653 |
< |
!! do necessary preforce calculations |
654 |
< |
call do_preforce(nlocal,pot) |
655 |
< |
! we have already updated the neighbor list set it to false... |
656 |
< |
update_nlist = .false. |
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 |
< |
end if |
661 |
< |
|
662 |
< |
!---------------------------------MAIN Pair LOOP->>>>>>>>>>>>> |
663 |
< |
|
664 |
< |
if (update_nlist) then |
665 |
< |
|
666 |
< |
!! save current configuration, construct neighbor list, |
667 |
< |
!! and calculate forces |
668 |
< |
|
669 |
< |
call saveNeighborList(nGroup, q_group) |
670 |
< |
|
671 |
< |
neighborListSize = size(list) |
672 |
< |
nlist = 0 |
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 |
< |
#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 |
< |
#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 |
< |
|
705 |
< |
if (nlist > neighborListSize) then |
706 |
< |
call expandNeighborList(nGroup, listerror) |
707 |
< |
if (listerror /= 0) then |
708 |
< |
error = -1 |
709 |
< |
write(DEFAULT_ERROR,*) "ERROR: nlist > list size and max allocations exceeded." |
710 |
< |
return |
711 |
< |
end if |
712 |
< |
neighborListSize = size(list) |
713 |
< |
endif |
714 |
< |
|
715 |
< |
list(nlist) = j |
716 |
< |
|
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 |
< |
|
723 |
< |
n_in_j = groupStart(j+1) - groupStart(j) |
724 |
< |
|
725 |
< |
do ia = groupStart(i), groupStart(i+1)-1 |
726 |
< |
atom1 = groupList(ia) |
652 |
> |
enddo |
653 |
> |
endif |
654 |
|
|
655 |
< |
inner1: do jb = groupStart(j), groupStart(j+1)-1 |
729 |
< |
atom2 = groupList(jb) |
730 |
< |
|
731 |
< |
if (skipThisPair(atom1, atom2)) cycle inner1 |
732 |
< |
|
733 |
< |
if ((n_in_i .eq. 1).and.(n_in_j .eq. 1)) then |
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 |
< |
#ifdef IS_MPI |
746 |
< |
call do_pair(atom1, atom2, ratmsq, d_atm, sw, & |
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 |
655 |
> |
if (do_stress) call add_stress_tensor(d_grp, fij) |
656 |
|
endif |
794 |
– |
|
795 |
– |
if (do_stress) call add_stress_tensor(d_grp, fij) |
796 |
– |
|
657 |
|
end if |
658 |
|
enddo |
659 |
< |
enddo |
660 |
< |
|
659 |
> |
enddo outer |
660 |
> |
|
661 |
> |
if (update_nlist) then |
662 |
|
#ifdef IS_MPI |
663 |
< |
point(nrow_group + 1) = nlist + 1 |
663 |
> |
point(nGroupsInRow + 1) = nlist + 1 |
664 |
|
#else |
665 |
< |
point(nGroup) = nlist + 1 |
665 |
> |
point(nGroups) = nlist + 1 |
666 |
|
#endif |
667 |
< |
|
668 |
< |
else !! (of update_check) |
669 |
< |
|
670 |
< |
! use the list to find the neighbors |
671 |
< |
|
672 |
< |
istart = 1 |
673 |
< |
#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) |
823 |
< |
JEND = POINT(i+1) - 1 |
824 |
< |
! check that group i has neighbors |
825 |
< |
if (jbeg .le. jend) then |
667 |
> |
if (loop .eq. PREPAIR_LOOP) then |
668 |
> |
! we just did the neighbor list update on the first |
669 |
> |
! pass, so we don't need to do it |
670 |
> |
! again on the second pass |
671 |
> |
update_nlist = .false. |
672 |
> |
endif |
673 |
> |
endif |
674 |
|
|
675 |
< |
do jnab = jbeg, jend |
676 |
< |
j = list(jnab) |
677 |
< |
|
678 |
< |
#ifdef IS_MPI |
679 |
< |
call get_interatomic_vector(q_group_Row(:,i), & |
832 |
< |
q_group_Col(:,j), d_grp, rgrpsq) |
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 |
< |
|
843 |
< |
n_in_j = groupStart(j+1) - groupStart(j) |
844 |
< |
|
845 |
< |
do ia = groupStart(i), groupStart(i+1)-1 |
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 |
853 |
< |
|
854 |
< |
if ((n_in_i .eq. 1).and.(n_in_j .eq. 1)) then |
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 |
< |
#ifdef IS_MPI |
867 |
< |
call do_pair(atom1, atom2, ratmsq, d_atm, sw, & |
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) |
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 |
894 |
< |
#else |
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 |
< |
if (do_stress) call add_stress_tensor(d_grp, fij) |
917 |
< |
|
918 |
< |
enddo |
919 |
< |
endif |
920 |
< |
enddo |
921 |
< |
endif |
922 |
< |
|
923 |
< |
! phew, done with main loop. |
675 |
> |
if (loop .eq. PREPAIR_LOOP) then |
676 |
> |
call do_preforce(nlocal, pot) |
677 |
> |
endif |
678 |
> |
|
679 |
> |
enddo |
680 |
|
|
681 |
|
!! Do timing |
682 |
|
#ifdef PROFILE |
688 |
|
!!distribute forces |
689 |
|
|
690 |
|
f_temp = 0.0_dp |
691 |
< |
call scatter(f_Row,f_temp,plan_row3d) |
691 |
> |
call scatter(f_Row,f_temp,plan_atom_row_3d) |
692 |
|
do i = 1,nlocal |
693 |
|
f(1:3,i) = f(1:3,i) + f_temp(1:3,i) |
694 |
|
end do |
695 |
|
|
696 |
|
f_temp = 0.0_dp |
697 |
< |
call scatter(f_Col,f_temp,plan_col3d) |
697 |
> |
call scatter(f_Col,f_temp,plan_atom_col_3d) |
698 |
|
do i = 1,nlocal |
699 |
|
f(1:3,i) = f(1:3,i) + f_temp(1:3,i) |
700 |
|
end do |
701 |
|
|
702 |
|
if (FF_UsesDirectionalAtoms() .and. SIM_uses_directional_atoms) then |
703 |
|
t_temp = 0.0_dp |
704 |
< |
call scatter(t_Row,t_temp,plan_row3d) |
704 |
> |
call scatter(t_Row,t_temp,plan_atom_row_3d) |
705 |
|
do i = 1,nlocal |
706 |
|
t(1:3,i) = t(1:3,i) + t_temp(1:3,i) |
707 |
|
end do |
708 |
|
t_temp = 0.0_dp |
709 |
< |
call scatter(t_Col,t_temp,plan_col3d) |
709 |
> |
call scatter(t_Col,t_temp,plan_atom_col_3d) |
710 |
|
|
711 |
|
do i = 1,nlocal |
712 |
|
t(1:3,i) = t(1:3,i) + t_temp(1:3,i) |
715 |
|
|
716 |
|
if (do_pot) then |
717 |
|
! scatter/gather pot_row into the members of my column |
718 |
< |
call scatter(pot_Row, pot_Temp, plan_row) |
718 |
> |
call scatter(pot_Row, pot_Temp, plan_atom_row) |
719 |
|
|
720 |
|
! scatter/gather pot_local into all other procs |
721 |
|
! add resultant to get total pot |
725 |
|
|
726 |
|
pot_Temp = 0.0_DP |
727 |
|
|
728 |
< |
call scatter(pot_Col, pot_Temp, plan_col) |
728 |
> |
call scatter(pot_Col, pot_Temp, plan_atom_col) |
729 |
|
do i = 1, nlocal |
730 |
|
pot_local = pot_local + pot_Temp(i) |
731 |
|
enddo |
738 |
|
if (FF_uses_RF .and. SIM_uses_RF) then |
739 |
|
|
740 |
|
#ifdef IS_MPI |
741 |
< |
call scatter(rf_Row,rf,plan_row3d) |
742 |
< |
call scatter(rf_Col,rf_Temp,plan_col3d) |
741 |
> |
call scatter(rf_Row,rf,plan_atom_row_3d) |
742 |
> |
call scatter(rf_Col,rf_Temp,plan_atom_col_3d) |
743 |
|
do i = 1,nlocal |
744 |
|
rf(1:3,i) = rf(1:3,i) + rf_Temp(1:3,i) |
745 |
|
end do |
799 |
|
endif |
800 |
|
|
801 |
|
#endif |
802 |
< |
|
1047 |
< |
|
802 |
> |
|
803 |
|
end subroutine do_force_loop |
1049 |
– |
|
804 |
|
|
805 |
|
subroutine do_pair(i, j, rijsq, d, sw, do_pot, & |
806 |
|
u_l, A, f, t, pot, vpair, fpair) |
825 |
|
fpair(1:3) = 0.0d0 |
826 |
|
|
827 |
|
#ifdef IS_MPI |
828 |
< |
if (tagRow(i) .eq. tagColumn(j)) then |
829 |
< |
write(0,*) 'do_pair is doing', i , j, tagRow(i), tagColumn(j) |
828 |
> |
if (AtomRowToGlobal(i) .eq. AtomColToGlobal(j)) then |
829 |
> |
write(0,*) 'do_pair is doing', i , j, AtomRowToGlobal(i), AtomColToGlobal(j) |
830 |
|
endif |
831 |
|
me_i = atid_row(i) |
832 |
|
me_j = atid_col(j) |
929 |
|
|
930 |
|
|
931 |
|
#ifdef IS_MPI |
932 |
< |
if (tagRow(i) .eq. tagColumn(j)) then |
933 |
< |
write(0,*) 'do_prepair is doing', i , j, tagRow(i), tagColumn(j) |
932 |
> |
if (AtomRowToGlobal(i) .eq. AtomColToGlobal(j)) then |
933 |
> |
write(0,*) 'do_prepair is doing', i , j, AtomRowToGlobal(i), AtomColToGlobal(j) |
934 |
|
endif |
935 |
|
|
936 |
|
me_i = atid_row(i) |
1077 |
|
|
1078 |
|
#ifdef IS_MPI |
1079 |
|
!! in MPI, we have to look up the unique IDs for each atom |
1080 |
< |
unique_id_1 = tagRow(atom1) |
1080 |
> |
unique_id_1 = AtomRowToGlobal(atom1) |
1081 |
|
#else |
1082 |
|
!! in the normal loop, the atom numbers are unique |
1083 |
|
unique_id_1 = atom1 |
1096 |
|
end if |
1097 |
|
|
1098 |
|
#ifdef IS_MPI |
1099 |
< |
unique_id_2 = tagColumn(atom2) |
1099 |
> |
unique_id_2 = AtomColToGlobal(atom2) |
1100 |
|
#else |
1101 |
|
unique_id_2 = atom2 |
1102 |
|
#endif |