ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/do_Forces.F90
(Generate patch)

Comparing trunk/OOPSE/libmdtools/do_Forces.F90 (file contents):
Revision 439 by chuckv, Mon Mar 31 22:09:39 2003 UTC vs.
Revision 571 by gezelter, Tue Jul 1 22:39:53 2003 UTC

# Line 4 | Line 4
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.16 2003-07-01 22:39:53 gezelter Exp $, $Date: 2003-07-01 22:39:53 $, $Name: not supported by cvs2svn $, $Revision: 1.16 $
8  
9   module do_Forces
10    use force_globals
# Line 140 | Line 140 | contains
140  
141      if (FF_uses_GB .and. FF_uses_LJ) then
142      endif
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  
144
153      do_forces_initialized = .true.    
154  
155    end subroutine init_FF
# Line 168 | Line 176 | contains
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
# Line 189 | Line 197 | contains
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)
# Line 196 | Line 205 | contains
205      nlocal = getNlocal()
206      natoms = nlocal
207   #endif
208 <
208 >  
209      call getRcut(rcut,rc2=rcutsq)
210      call getRlist(rlist,rlistsq)
211      
# Line 245 | Line 254 | contains
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      
# Line 277 | Line 286 | contains
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
# Line 299 | Line 308 | contains
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
# Line 312 | Line 321 | contains
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    
# Line 346 | Line 355 | contains
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
# Line 368 | Line 377 | contains
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
# Line 472 | Line 481 | contains
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  
# Line 495 | Line 504 | contains
504      
505    end subroutine do_force_loop
506  
507 <  subroutine do_pair(i, j, rijsq, d, do_pot, do_stress, u_l, A, f, t,pot)
507 >  subroutine do_pair(i, j, rijsq, d, do_pot, do_stress, u_l, A, f, t, pot)
508  
509      real( kind = dp ) :: pot
510 <    real( kind = dp ), dimension(:,:) :: u_l
511 <    real (kind=dp), dimension(:,:) :: A
512 <    real (kind=dp), dimension(:,:) :: f
513 <    real (kind=dp), dimension(:,:) :: t
510 >    real( kind = dp ), dimension(3,getNlocal()) :: u_l
511 >    real (kind=dp), dimension(9,getNlocal()) :: A
512 >    real (kind=dp), dimension(3,getNlocal()) :: f
513 >    real (kind=dp), dimension(3,getNlocal()) :: t
514  
515      logical, intent(inout) :: do_pot, do_stress
516      integer, intent(in) :: i, j
# Line 516 | Line 525 | contains
525  
526      r = sqrt(rijsq)
527  
528 +
529 +
530   #ifdef IS_MPI
531 +    if (tagRow(i) .eq. tagColumn(j)) then
532 +       write(0,*) 'do_pair is doing', i , j, tagRow(i), tagColumn(j)
533 +    endif
534  
535      me_i = atid_row(i)
536      me_j = atid_col(j)
# Line 583 | Line 597 | contains
597      real (kind = dp), dimension(3) :: q_i
598      real (kind = dp), dimension(3) :: q_j
599      real ( kind = dp ), intent(out) :: r_sq
600 <    real( kind = dp ) :: d(3)
601 <    real( kind = dp ) :: d_old(3)
602 <    d(1:3) = q_i(1:3) - q_j(1:3)
603 <    d_old = d
600 >    real( kind = dp ) :: d(3), scaled(3)
601 >    integer i
602 >
603 >    d(1:3) = q_j(1:3) - q_i(1:3)
604 >
605      ! Wrap back into periodic box if necessary
606      if ( SimUsesPBC() ) then
607        
608 <       d(1:3) = d(1:3) - box(1:3) * sign(1.0_dp,d(1:3)) * &
609 <            int(abs(d(1:3)/box(1:3)) + 0.5_dp)
608 >       if( .not.boxIsOrthorhombic ) then
609 >          ! calc the scaled coordinates.
610 >          
611 >          scaled = matmul(d, HmatInv)
612 >          
613 >          ! wrap the scaled coordinates
614 >
615 >          do i = 1, 3
616 >             scaled(i) = scaled(i) - anint(scaled(i))
617 >          enddo
618 >
619 >          ! calc the wrapped real coordinates from the wrapped scaled
620 >          ! coordinates
621 >
622 >          d = matmul(scaled,Hmat)
623 >
624 >       else
625 >          ! calc the scaled coordinates.
626 >          
627 >          do i = 1, 3
628 >             scaled(i) = d(i) * HmatInv(i,i)
629 >            
630 >             ! wrap the scaled coordinates
631 >            
632 >             scaled(i) = scaled(i) - anint(scaled(i))
633 >            
634 >             ! calc the wrapped real coordinates from the wrapped scaled
635 >             ! coordinates
636 >
637 >             d(i) = scaled(i)*Hmat(i,i)
638 >          enddo
639 >       endif
640        
641      endif
642 +    
643      r_sq = dot_product(d,d)
644 <        
644 >    
645    end subroutine get_interatomic_vector
646 <
646 >  
647    subroutine check_initialization(error)
648      integer, intent(out) :: error
649      
# Line 654 | Line 700 | contains
700      rf = 0.0_dp
701      tau_Temp = 0.0_dp
702      virial_Temp = 0.0_dp
657    
703    end subroutine zero_work_arrays
704    
705    function skipThisPair(atom1, atom2) result(skip_it)
# Line 698 | Line 743 | contains
743   #else
744      unique_id_2 = atom2
745   #endif
746 <    
746 >
747   #ifdef IS_MPI
748      !! this situation should only arise in MPI simulations
749      if (unique_id_1 == unique_id_2) then
# Line 708 | Line 753 | contains
753      
754      !! this prevents us from doing the pair on multiple processors
755      if (unique_id_1 < unique_id_2) then
756 <       if (mod(unique_id_1 + unique_id_2,2) == 0) skip_it = .true.
757 <       return
756 >       if (mod(unique_id_1 + unique_id_2,2) == 0) then
757 >          skip_it = .true.
758 >          return
759 >       endif
760      else                
761 <       if (mod(unique_id_1 + unique_id_2,2) == 1) skip_it = .true.
762 <       return
761 >       if (mod(unique_id_1 + unique_id_2,2) == 1) then
762 >          skip_it = .true.
763 >          return
764 >       endif
765      endif
766   #endif
767 <
767 >
768      !! the rest of these situations can happen in all simulations:
769      do i = 1, nExcludes_global      
770         if ((excludesGlobal(i) == unique_id_1) .or. &
# Line 724 | Line 773 | contains
773            return
774         endif
775      enddo
776 <
776 >
777      do i = 1, nExcludes_local
778         if (excludesLocal(1,i) == unique_id_1) then
779            if (excludesLocal(2,i) == unique_id_2) then

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines