4 |
|
|
5 |
|
!! @author Charles F. Vardeman II |
6 |
|
!! @author Matthew Meineke |
7 |
< |
!! @version $Id: do_Forces.F90,v 1.6 2003-03-31 22:09:39 chuckv Exp $, $Date: 2003-03-31 22:09:39 $, $Name: not supported by cvs2svn $, $Revision: 1.6 $ |
7 |
> |
!! @version $Id: do_Forces.F90,v 1.18 2003-07-14 21:28:54 mmeineke Exp $, $Date: 2003-07-14 21:28:54 $, $Name: not supported by cvs2svn $, $Revision: 1.18 $ |
8 |
|
|
9 |
|
module do_Forces |
10 |
|
use force_globals |
140 |
|
|
141 |
|
if (FF_uses_GB .and. FF_uses_LJ) then |
142 |
|
endif |
143 |
< |
|
143 |
> |
if (.not. do_forces_initialized) then |
144 |
> |
!! Create neighbor lists |
145 |
> |
call expandNeighborList(getNlocal(), my_status) |
146 |
> |
if (my_Status /= 0) then |
147 |
> |
write(default_error,*) "SimSetup: ExpandNeighborList returned error." |
148 |
> |
thisStat = -1 |
149 |
> |
return |
150 |
> |
endif |
151 |
> |
endif |
152 |
|
|
153 |
|
do_forces_initialized = .true. |
154 |
|
|
176 |
|
logical :: do_pot |
177 |
|
logical :: do_stress |
178 |
|
#ifdef IS_MPI |
179 |
< |
real( kind = DP ) :: pot_local = 0.0_dp |
179 |
> |
real( kind = DP ) :: pot_local |
180 |
|
integer :: nrow |
181 |
|
integer :: ncol |
182 |
|
#endif |
197 |
|
!! initialize local variables |
198 |
|
|
199 |
|
#ifdef IS_MPI |
200 |
+ |
pot_local = 0.0_dp |
201 |
|
nlocal = getNlocal() |
202 |
|
nrow = getNrow(plan_row) |
203 |
|
ncol = getNcol(plan_col) |
205 |
|
nlocal = getNlocal() |
206 |
|
natoms = nlocal |
207 |
|
#endif |
208 |
< |
|
208 |
> |
|
209 |
|
call getRcut(rcut,rc2=rcutsq) |
210 |
|
call getRlist(rlist,rlistsq) |
211 |
|
|
254 |
|
|
255 |
|
!! save current configuration, construct neighbor list, |
256 |
|
!! and calculate forces |
257 |
< |
call saveNeighborList(q) |
257 |
> |
call saveNeighborList(nlocal, q) |
258 |
|
|
259 |
|
neighborListSize = size(list) |
260 |
|
nlist = 0 |
286 |
|
|
287 |
|
if (rijsq < rcutsq) then |
288 |
|
call do_pair(i, j, rijsq, d, do_pot, do_stress, & |
289 |
< |
u_l, A, f, t,pot) |
289 |
> |
u_l, A, f, t, pot_local) |
290 |
|
endif |
291 |
|
endif |
292 |
|
enddo inner |
308 |
|
|
309 |
|
call get_interatomic_vector(q_Row(:,i), q_Col(:,j), d, rijsq) |
310 |
|
call do_pair(i, j, rijsq, d, do_pot, do_stress, & |
311 |
< |
u_l, A, f, t,pot) |
311 |
> |
u_l, A, f, t, pot_local) |
312 |
|
|
313 |
|
enddo |
314 |
|
endif |
321 |
|
|
322 |
|
! save current configuration, contruct neighbor list, |
323 |
|
! and calculate forces |
324 |
< |
call saveNeighborList(q) |
324 |
> |
call saveNeighborList(natoms, q) |
325 |
|
|
326 |
|
neighborListSize = size(list) |
327 |
|
|
355 |
|
|
356 |
|
if (rijsq < rcutsq) then |
357 |
|
call do_pair(i, j, rijsq, d, do_pot, do_stress, & |
358 |
< |
u_l, A, f, t,pot) |
358 |
> |
u_l, A, f, t, pot) |
359 |
|
endif |
360 |
|
endif |
361 |
|
enddo inner |
377 |
|
|
378 |
|
call get_interatomic_vector(q(:,i), q(:,j), d, rijsq) |
379 |
|
call do_pair(i, j, rijsq, d, do_pot, do_stress, & |
380 |
< |
u_l, A, f, t,pot) |
380 |
> |
u_l, A, f, t, pot) |
381 |
|
|
382 |
|
enddo |
383 |
|
endif |
481 |
|
#ifdef IS_MPI |
482 |
|
|
483 |
|
if (do_pot) then |
484 |
< |
pot = pot_local |
484 |
> |
pot = pot + pot_local |
485 |
|
!! we assume the c code will do the allreduce to get the total potential |
486 |
|
!! we could do it right here if we needed to... |
487 |
|
endif |
488 |
|
|
489 |
|
if (do_stress) then |
490 |
< |
call mpi_allreduce(tau, tau_Temp,9,mpi_double_precision,mpi_sum, & |
490 |
> |
call mpi_allreduce(tau_Temp, tau, 9,mpi_double_precision,mpi_sum, & |
491 |
|
mpi_comm_world,mpi_err) |
492 |
< |
call mpi_allreduce(virial, virial_Temp,1,mpi_double_precision,mpi_sum, & |
492 |
> |
call mpi_allreduce(virial_Temp, virial,1,mpi_double_precision,mpi_sum, & |
493 |
|
mpi_comm_world,mpi_err) |
494 |
|
endif |
495 |
|
|
502 |
|
|
503 |
|
#endif |
504 |
|
|
505 |
+ |
write(*,*) 'T(1) = ' |
506 |
+ |
write(*,'(3es12.3)') t(1,1), t(1,2), t(1,3) |
507 |
+ |
write(*,*) |
508 |
+ |
|
509 |
+ |
write(*,*) 'T(2) = ' |
510 |
+ |
write(*,'(3es12.3)') t(2,1), t(2,2), t(2,3) |
511 |
+ |
write(*,*) |
512 |
+ |
|
513 |
|
end subroutine do_force_loop |
514 |
|
|
515 |
< |
subroutine do_pair(i, j, rijsq, d, do_pot, do_stress, u_l, A, f, t,pot) |
515 |
> |
subroutine do_pair(i, j, rijsq, d, do_pot, do_stress, u_l, A, f, t, pot) |
516 |
|
|
517 |
|
real( kind = dp ) :: pot |
518 |
< |
real( kind = dp ), dimension(:,:) :: u_l |
519 |
< |
real (kind=dp), dimension(:,:) :: A |
520 |
< |
real (kind=dp), dimension(:,:) :: f |
521 |
< |
real (kind=dp), dimension(:,:) :: t |
518 |
> |
real( kind = dp ), dimension(3,getNlocal()) :: u_l |
519 |
> |
real (kind=dp), dimension(9,getNlocal()) :: A |
520 |
> |
real (kind=dp), dimension(3,getNlocal()) :: f |
521 |
> |
real (kind=dp), dimension(3,getNlocal()) :: t |
522 |
|
|
523 |
|
logical, intent(inout) :: do_pot, do_stress |
524 |
|
integer, intent(in) :: i, j |
533 |
|
|
534 |
|
r = sqrt(rijsq) |
535 |
|
|
536 |
+ |
write(*,*) 'ul(1) = ' |
537 |
+ |
write(*,'(3es12.3)') u_l(1,1), u_l(1,2), u_l(1,3) |
538 |
+ |
write(*,*) |
539 |
+ |
|
540 |
+ |
write(*,*) 'ul(2) = ' |
541 |
+ |
write(*,'(3es12.3)') u_l(2,1), u_l(2,2), u_l(2,3) |
542 |
+ |
write(*,*) |
543 |
+ |
|
544 |
+ |
|
545 |
+ |
write(*,*) 'A(1) = ' |
546 |
+ |
write(*,'(3es12.3)') A(1,1), A(2,1), A(3,1) |
547 |
+ |
write(*,'(3es12.3)') A(4,1), A(5,1), A(6,1) |
548 |
+ |
write(*,'(3es12.3)') A(7,1), A(8,1), A(9,1) |
549 |
+ |
write(*,*) |
550 |
+ |
write(*,*) 'A(2) = ' |
551 |
+ |
write(*,'(3es12.3)') A(1,2), A(2,2), A(3,2) |
552 |
+ |
write(*,'(3es12.3)') A(4,2), A(5,2), A(6,2) |
553 |
+ |
write(*,'(3es12.3)') A(7,2), A(8,2), A(9,2) |
554 |
+ |
write(*,*) |
555 |
+ |
|
556 |
+ |
|
557 |
|
#ifdef IS_MPI |
558 |
+ |
if (tagRow(i) .eq. tagColumn(j)) then |
559 |
+ |
write(0,*) 'do_pair is doing', i , j, tagRow(i), tagColumn(j) |
560 |
+ |
endif |
561 |
|
|
562 |
|
me_i = atid_row(i) |
563 |
|
me_j = atid_col(j) |
616 |
|
endif |
617 |
|
endif |
618 |
|
|
619 |
+ |
|
620 |
+ |
|
621 |
|
end subroutine do_pair |
622 |
|
|
623 |
|
|
626 |
|
real (kind = dp), dimension(3) :: q_i |
627 |
|
real (kind = dp), dimension(3) :: q_j |
628 |
|
real ( kind = dp ), intent(out) :: r_sq |
629 |
< |
real( kind = dp ) :: d(3) |
630 |
< |
real( kind = dp ) :: d_old(3) |
631 |
< |
d(1:3) = q_i(1:3) - q_j(1:3) |
632 |
< |
d_old = d |
629 |
> |
real( kind = dp ) :: d(3), scaled(3) |
630 |
> |
integer i |
631 |
> |
|
632 |
> |
d(1:3) = q_j(1:3) - q_i(1:3) |
633 |
> |
|
634 |
|
! Wrap back into periodic box if necessary |
635 |
|
if ( SimUsesPBC() ) then |
636 |
|
|
637 |
< |
d(1:3) = d(1:3) - box(1:3) * sign(1.0_dp,d(1:3)) * & |
638 |
< |
int(abs(d(1:3)/box(1:3)) + 0.5_dp) |
637 |
> |
if( .not.boxIsOrthorhombic ) then |
638 |
> |
! calc the scaled coordinates. |
639 |
> |
|
640 |
> |
scaled = matmul(HmatInv, d) |
641 |
> |
|
642 |
> |
! wrap the scaled coordinates |
643 |
> |
|
644 |
> |
scaled = scaled - anint(scaled) |
645 |
> |
|
646 |
> |
|
647 |
> |
! calc the wrapped real coordinates from the wrapped scaled |
648 |
> |
! coordinates |
649 |
> |
|
650 |
> |
d = matmul(Hmat,scaled) |
651 |
> |
|
652 |
> |
else |
653 |
> |
! calc the scaled coordinates. |
654 |
> |
|
655 |
> |
do i = 1, 3 |
656 |
> |
scaled(i) = d(i) * HmatInv(i,i) |
657 |
> |
|
658 |
> |
! wrap the scaled coordinates |
659 |
> |
|
660 |
> |
scaled(i) = scaled(i) - anint(scaled(i)) |
661 |
> |
|
662 |
> |
! calc the wrapped real coordinates from the wrapped scaled |
663 |
> |
! coordinates |
664 |
> |
|
665 |
> |
d(i) = scaled(i)*Hmat(i,i) |
666 |
> |
enddo |
667 |
> |
endif |
668 |
|
|
669 |
|
endif |
670 |
+ |
|
671 |
|
r_sq = dot_product(d,d) |
672 |
< |
|
672 |
> |
|
673 |
|
end subroutine get_interatomic_vector |
674 |
< |
|
674 |
> |
|
675 |
|
subroutine check_initialization(error) |
676 |
|
integer, intent(out) :: error |
677 |
|
|
728 |
|
rf = 0.0_dp |
729 |
|
tau_Temp = 0.0_dp |
730 |
|
virial_Temp = 0.0_dp |
657 |
– |
|
731 |
|
end subroutine zero_work_arrays |
732 |
|
|
733 |
|
function skipThisPair(atom1, atom2) result(skip_it) |
771 |
|
#else |
772 |
|
unique_id_2 = atom2 |
773 |
|
#endif |
774 |
< |
|
774 |
> |
|
775 |
|
#ifdef IS_MPI |
776 |
|
!! this situation should only arise in MPI simulations |
777 |
|
if (unique_id_1 == unique_id_2) then |
781 |
|
|
782 |
|
!! this prevents us from doing the pair on multiple processors |
783 |
|
if (unique_id_1 < unique_id_2) then |
784 |
< |
if (mod(unique_id_1 + unique_id_2,2) == 0) skip_it = .true. |
785 |
< |
return |
784 |
> |
if (mod(unique_id_1 + unique_id_2,2) == 0) then |
785 |
> |
skip_it = .true. |
786 |
> |
return |
787 |
> |
endif |
788 |
|
else |
789 |
< |
if (mod(unique_id_1 + unique_id_2,2) == 1) skip_it = .true. |
790 |
< |
return |
789 |
> |
if (mod(unique_id_1 + unique_id_2,2) == 1) then |
790 |
> |
skip_it = .true. |
791 |
> |
return |
792 |
> |
endif |
793 |
|
endif |
794 |
|
#endif |
795 |
< |
|
795 |
> |
|
796 |
|
!! the rest of these situations can happen in all simulations: |
797 |
|
do i = 1, nExcludes_global |
798 |
|
if ((excludesGlobal(i) == unique_id_1) .or. & |
801 |
|
return |
802 |
|
endif |
803 |
|
enddo |
804 |
< |
|
804 |
> |
|
805 |
|
do i = 1, nExcludes_local |
806 |
|
if (excludesLocal(1,i) == unique_id_1) then |
807 |
|
if (excludesLocal(2,i) == unique_id_2) then |