ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE_old/src/mdtools/libmdCode/do_Forces.F90
(Generate patch)

Comparing trunk/OOPSE_old/src/mdtools/libmdCode/do_Forces.F90 (file contents):
Revision 329 by gezelter, Wed Mar 12 22:27:59 2003 UTC vs.
Revision 331 by chuckv, Thu Mar 13 00:33:18 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.15 2003-03-12 22:27:59 gezelter Exp $, $Date: 2003-03-12 22:27:59 $, $Name: not supported by cvs2svn $, $Revision: 1.15 $
7 > !! @version $Id: do_Forces.F90,v 1.17 2003-03-13 00:33:18 chuckv Exp $, $Date: 2003-03-13 00:33:18 $, $Name: not supported by cvs2svn $, $Revision: 1.17 $
8  
9  
10  
# Line 13 | Line 13 | module do_Forces
13    use definitions
14    use atype_module
15    use neighborLists  
16 <  use lj_FF
17 <  use sticky_FF
16 >  use lj
17 >  use sticky_pair
18    use dipole_dipole
19  use gb_FF
19  
20   #ifdef IS_MPI
21    use mpiSimulation
# Line 34 | Line 33 | module do_Forces
33  
34  
35    public :: init_FF
36 <  public :: do_forces
36 >  public :: do_force_loop
37  
38   contains
39  
40    subroutine init_FF(thisStat)
41 <  
42 <    integer, intent(out) :: my_status
43 <    integer :: thisStat = 0
41 >    integer, intent(out) :: thisStat  
42 >    integer :: my_status
43 >    character(len = 100) :: mix_Policy
44  
45      ! be a smarter subroutine.
46 <
47 <    
48 <    call init_lj_FF(my_status)
46 >    mix_Policy = "FIXME"
47 >    thisStat = 0
48 >    call init_lj_FF(mix_Policy,my_status)
49      if (my_status /= 0) then
50         thisStat = -1
51         return
# Line 86 | Line 85 | contains
85      logical :: do_stress
86   #ifdef IS_MPI
87      real( kind = DP ) :: pot_local
89    integer :: nlocal
88      integer :: nrow
89      integer :: ncol
90   #endif
91 +    integer :: nlocal
92      integer :: natoms    
93      logical :: update_nlist  
94      integer :: i, j, jbeg, jend, jnab
95      integer :: nlist
96      real( kind = DP ) ::  rijsq, rlistsq, rcutsq, rlist, rcut
97 +    real(kind=dp),dimension(3) :: d
98 +    real(kind=dp) :: rfpot, mu_i, virial
99 +    integer :: me_i
100 +    logical :: is_dp_i
101      integer :: neighborListSize
102 <    integer :: listerror
102 >    integer :: listerror, error
103 >    integer :: localError
104  
105      !! initialize local variables  
106  
# Line 109 | Line 113 | contains
113      natoms = nlocal
114   #endif
115  
116 <    call getRcut(rcut,rcut2=rcutsq)
116 >    call getRcut(rcut,rc2=rcutsq)
117      call getRlist(rlist,rlistsq)
118      
119 <    call check_initialization()
119 >    call check_initialization(localError)
120 >    if ( localError .ne. 0 ) then
121 >       error = -1
122 >       return
123 >    end if
124      call zero_work_arrays()
125  
126      do_pot = do_pot_c
# Line 163 | Line 171 | contains
171            
172            inner: do j = 1, ncol
173              
174 <             if (check_exclude(i,j)) cycle inner:
174 >             if (checkExcludes(i,j)) cycle inner
175              
176               call get_interatomic_vector(q_Row(:,i), q_Col(:,j), d, rijsq)
177 <            
177 >            
178               if (rijsq <  rlistsq) then            
179                  
180                  nlist = nlist + 1
# Line 227 | Line 235 | contains
235            
236            inner: do j = i+1, natoms
237              
238 <             if (check_exclude(i,j)) cycle inner:
238 >             if (checkExcludes(i,j)) cycle inner
239              
240               call get_interatomic_vector(q(:,i), q(:,j), d, rijsq)
241            
# Line 258 | Line 266 | contains
266      else !! (update)
267        
268         ! use the list to find the neighbors
269 <       do i = 1, nrow
269 >       do i = 1, natoms-1
270            JBEG = POINT(i)
271            JEND = POINT(i+1) - 1
272            ! check thiat molecule i has neighbors
# Line 314 | Line 322 | contains
322            pot_local = pot_local + pot_Temp(i)
323         enddo
324        
325 <    endif
326 <    
325 >    endif    
326 > #endif
327 >
328      if (FF_RequiresPostpairCalc() .and. SimRequiresPostpairCalc()) then
329        
330         if (FF_uses_RF .and. SimUsesRF()) then
# Line 330 | Line 339 | contains
339            
340            do i = 1, getNlocal()
341  
342 +             rfpot = 0.0_DP
343   #ifdef IS_MPI
344               me_i = atid_row(i)
345   #else
# Line 343 | Line 353 | contains
353                  call accumulate_self_rf(i, mu_i, u_l)            
354                  !! Get the reaction field contribution to the
355                  !! potential and torques:
356 <                call reaction_field(i, mu_i, u_l, rfpot, t, do_pot)
356 >                call reaction_field_final(i, mu_i, u_l, rfpot, t, do_pot)
357   #ifdef IS_MPI
358                  pot_local = pot_local + rfpot
359   #else
# Line 364 | Line 374 | contains
374      endif
375  
376      if (do_stress) then
377 <       mpi_allreduce(tau, tau_Temp,9,mpi_double_precision,mpi_sum, &
377 >       call mpi_allreduce(tau, tau_Temp,9,mpi_double_precision,mpi_sum, &
378              mpi_comm_world,mpi_err)
379 <       mpi_allreduce(virial, virial_Temp,1,mpi_double_precision,mpi_sum, &
379 >       call mpi_allreduce(virial, virial_Temp,1,mpi_double_precision,mpi_sum, &
380              mpi_comm_world,mpi_err)
381      endif
382  
# Line 390 | Line 400 | contains
400  
401    end subroutine do_preForce
402  
403 < !! Calculate any post force loop components, i.e. reaction field, etc.
403 >  !! Calculate any post force loop components, i.e. reaction field, etc.
404    subroutine do_postForce()
405  
406  
# Line 399 | Line 409 | contains
409  
410    subroutine do_pair(i, j, rijsq, d, do_pot, do_stress)
411  
412 +    real( kind = dp ) :: pot
413 +    real( kind = dp ), dimension(3,getNlocal()) :: u_l
414 +    real (kind=dp), dimension(9,getNlocal()) :: A
415 +    real (kind=dp), dimension(3,getNlocal()) :: f
416 +    real (kind=dp), dimension(3,getNlocal()) :: t
417 +
418      logical, intent(inout) :: do_pot, do_stress
419      integer, intent(in) :: i, j
420 <    real ( kind = dp ), intent(in)    :: rijsq
420 >    real ( kind = dp ), intent(inout)    :: rijsq
421      real ( kind = dp )                :: r
422      real ( kind = dp ), intent(inout) :: d(3)
407
408    r = sqrt(rijsq)
409    
423      logical :: is_LJ_i, is_LJ_j
424      logical :: is_DP_i, is_DP_j
425      logical :: is_Sticky_i, is_Sticky_j
426      integer :: me_i, me_j
427  
428 +    r = sqrt(rijsq)
429 +    
430   #ifdef IS_MPI
431  
432      me_i = atid_row(i)
# Line 434 | Line 449 | contains
449      endif
450        
451  
452 <    if (FF_uses_DP .and. SimUsesDP()) then
452 >    if (FF_uses_dipoles .and. SimUsesDipoles()) then
453         call getElementProperty(atypes, me_i, "is_DP", is_DP_i)
454         call getElementProperty(atypes, me_j, "is_DP", is_DP_j)
455        
# Line 476 | Line 491 | contains
491      d(1:3) = q_i(1:3) - q_j(1:3)
492      
493      ! Wrap back into periodic box if necessary
494 <    if ( isPBC() ) then
495 <       d(1:3) = d(1:3) - thisSim%box(1:3) * sign(1.0_dp,thisSim%box(1:3)) * &
496 <            int(abs(d(1:3)/thisSim%box(1:3) + 0.5_dp)
494 >    if ( SimUsesPBC() ) then
495 >       d(1:3) = d(1:3) - box(1:3) * sign(1.0_dp,box(1:3)) * &
496 >            int(abs(d(1:3)/box(1:3) + 0.5_dp))
497      endif
498      
499      r_sq = dot_product(d,d)
# Line 540 | Line 555 | contains
555    end subroutine zero_work_arrays
556    
557  
558 < !! Function to properly build neighbor lists in MPI using newtons 3rd law.
559 < !! We don't want 2 processors doing the same i j pair twice.
560 < !! Also checks to see if i and j are the same particle.
558 >  !! Function to properly build neighbor lists in MPI using newtons 3rd law.
559 >  !! We don't want 2 processors doing the same i j pair twice.
560 >  !! Also checks to see if i and j are the same particle.
561 >
562    function checkExcludes(atom1,atom2) result(do_cycle)
563 < !--------------- Arguments--------------------------
564 < ! Index i
563 >    !--------------- Arguments--------------------------
564 >    ! Index i
565      integer,intent(in) :: atom1
566 < ! Index j
566 >    ! Index j
567      integer,intent(in), optional :: atom2
568 < ! Result do_cycle
568 >    ! Result do_cycle
569      logical :: do_cycle
570 < !--------------- Local variables--------------------
570 >    !--------------- Local variables--------------------
571      integer :: tag_i
572      integer :: tag_j
573 <    integer :: i
574 < !--------------- END DECLARATIONS------------------  
573 >    integer :: i, j
574 >    !--------------- END DECLARATIONS------------------  
575      do_cycle = .false.
576 <
576 >    
577   #ifdef IS_MPI
578      tag_i = tagRow(atom1)
579   #else
580      tag_i = tag(atom1)
581   #endif
582 <
583 < !! Check global excludes first
582 >    
583 >    !! Check global excludes first
584      if (.not. present(atom2)) then
585 <       do i = 1,nGlobalExcludes
585 >       do i = 1, nExcludes_global
586            if (excludeGlobal(i) == tag_i) then
587               do_cycle = .true.
588               return
# Line 575 | Line 591 | contains
591         return !! return after checking globals
592      end if
593  
594 < !! we return if j not present here.
595 <    tag_j = tagColumn(j)
596 <
581 <
582 <
594 >    !! we return if atom2 not present here.
595 >    tag_j = tagColumn(atom2)
596 >    
597      if (tag_i == tag_j) then
598         do_cycle = .true.
599         return
600      end if
601 <
601 >    
602      if (tag_i < tag_j) then
603         if (mod(tag_i + tag_j,2) == 0) do_cycle = .true.
604         return
605      else                
606         if (mod(tag_i + tag_j,2) == 1) do_cycle = .true.
607      endif
608 <
609 <
610 <
597 <    do i = 1, nLocalExcludes
598 <       if (tag_i = excludes(1,i) .and. excludes(2,i) < 0) then
608 >            
609 >    do i = 1, nExcludes_local
610 >       if ((tag_i == excludesLocal(1,i)) .and. (excludesLocal(2,i) < 0)) then
611            do_cycle = .true.
612            return
613         end if
614      end do
615 <      
616 <
615 >    
616 >    
617    end function checkExcludes
618  
619    function FF_UsesDirectionalAtoms() result(doesit)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines