ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/UseTheForce/DarkSide/sticky.F90
(Generate patch)

Comparing trunk/OOPSE-4/src/UseTheForce/DarkSide/sticky.F90 (file contents):
Revision 1621 by gezelter, Wed Oct 20 21:52:20 2004 UTC vs.
Revision 1930 by gezelter, Wed Jan 12 22:41:40 2005 UTC

# Line 1 | Line 1
1 + !!
2 + !! Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
3 + !!
4 + !! The University of Notre Dame grants you ("Licensee") a
5 + !! non-exclusive, royalty free, license to use, modify and
6 + !! redistribute this software in source and binary code form, provided
7 + !! that the following conditions are met:
8 + !!
9 + !! 1. Acknowledgement of the program authors must be made in any
10 + !!    publication of scientific results based in part on use of the
11 + !!    program.  An acceptable form of acknowledgement is citation of
12 + !!    the article in which the program was described (Matthew
13 + !!    A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher
14 + !!    J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented
15 + !!    Parallel Simulation Engine for Molecular Dynamics,"
16 + !!    J. Comput. Chem. 26, pp. 252-271 (2005))
17 + !!
18 + !! 2. Redistributions of source code must retain the above copyright
19 + !!    notice, this list of conditions and the following disclaimer.
20 + !!
21 + !! 3. Redistributions in binary form must reproduce the above copyright
22 + !!    notice, this list of conditions and the following disclaimer in the
23 + !!    documentation and/or other materials provided with the
24 + !!    distribution.
25 + !!
26 + !! This software is provided "AS IS," without a warranty of any
27 + !! kind. All express or implied conditions, representations and
28 + !! warranties, including any implied warranty of merchantability,
29 + !! fitness for a particular purpose or non-infringement, are hereby
30 + !! excluded.  The University of Notre Dame and its licensors shall not
31 + !! be liable for any damages suffered by licensee as a result of
32 + !! using, modifying or distributing the software or its
33 + !! derivatives. In no event will the University of Notre Dame or its
34 + !! licensors be liable for any lost revenue, profit or data, or for
35 + !! direct, indirect, special, consequential, incidental or punitive
36 + !! damages, however caused and regardless of the theory of liability,
37 + !! arising out of the use of or inability to use software, even if the
38 + !! University of Notre Dame has been advised of the possibility of
39 + !! such damages.
40 + !!
41 +
42   !! This Module Calculates forces due to SSD potential and VDW interactions
43   !! [Chandra and Ichiye, J. Chem. Phys. 111, 2701 (1999)].
44  
# Line 9 | Line 50
50   !! @author Matthew Meineke
51   !! @author Christopher Fennel
52   !! @author J. Daniel Gezelter
53 < !! @version $Id: sticky.F90,v 1.2 2004-10-20 21:52:20 gezelter Exp $, $Date: 2004-10-20 21:52:20 $, $Name: not supported by cvs2svn $, $Revision: 1.2 $
53 > !! @version $Id: sticky.F90,v 1.3 2005-01-12 22:40:45 gezelter Exp $, $Date: 2005-01-12 22:40:45 $, $Name: not supported by cvs2svn $, $Revision: 1.3 $
54  
55 < module sticky_pair
55 > module sticky
56  
57    use force_globals
58    use definitions
59 +  use atype_module
60 +  use vector_class
61    use simulation
62 +  use status
63   #ifdef IS_MPI
64    use mpiSimulation
65   #endif
22
66    implicit none
67  
68    PRIVATE
69  
70 <  logical, save :: sticky_initialized = .false.
28 <  real( kind = dp ), save :: SSD_w0 = 0.0_dp
29 <  real( kind = dp ), save :: SSD_v0 = 0.0_dp
30 <  real( kind = dp ), save :: SSD_v0p = 0.0_dp
31 <  real( kind = dp ), save :: SSD_rl = 0.0_dp
32 <  real( kind = dp ), save :: SSD_ru = 0.0_dp
33 <  real( kind = dp ), save :: SSD_rlp = 0.0_dp
34 <  real( kind = dp ), save :: SSD_rup = 0.0_dp
35 <  real( kind = dp ), save :: SSD_rbig = 0.0_dp
36 <
37 <  public :: check_sticky_FF
38 <  public :: set_sticky_params
70 >  public :: newStickyType
71    public :: do_sticky_pair
72  
73 +
74 +  type :: StickyList
75 +     integer :: c_ident
76 +     real( kind = dp ) :: w0 = 0.0_dp
77 +     real( kind = dp ) :: v0 = 0.0_dp
78 +     real( kind = dp ) :: v0p = 0.0_dp
79 +     real( kind = dp ) :: rl = 0.0_dp
80 +     real( kind = dp ) :: ru = 0.0_dp
81 +     real( kind = dp ) :: rlp = 0.0_dp
82 +     real( kind = dp ) :: rup = 0.0_dp
83 +     real( kind = dp ) :: rbig = 0.0_dp
84 +  end type StickyList
85 +  
86 +  type(StickyList), dimension(:),allocatable :: StickyMap
87 +
88   contains
89  
90 <  subroutine check_sticky_FF(status)
44 <    integer :: status
45 <    status = -1
46 <    if (sticky_initialized) status = 0
47 <    return
48 <  end subroutine check_sticky_FF
90 >  subroutine newStickyType(c_ident, w0, v0, v0p, rl, ru, rlp, rup, isError)
91  
92 <  subroutine set_sticky_params(sticky_w0, sticky_v0, sticky_v0p, &
93 <       sticky_rl, sticky_ru, sticky_rlp, sticky_rup)
92 >    integer, intent(in) :: c_ident
93 >    integer, intent(inout) :: isError
94 >    real( kind = dp ), intent(in) :: w0, v0, v0p
95 >    real( kind = dp ), intent(in) :: rl, ru
96 >    real( kind = dp ), intent(in) :: rlp, rup
97 >    integer :: nATypes, myATID
98  
53    real( kind = dp ), intent(in) :: sticky_w0, sticky_v0, sticky_v0p
54    real( kind = dp ), intent(in) :: sticky_rl, sticky_ru
55    real( kind = dp ), intent(in) :: sticky_rlp, sticky_rup
99      
100 +    isError = 0
101 +    myATID = getFirstMatchingElement(atypes, "c_ident", c_ident)
102 +    
103 +    !! Be simple-minded and assume that we need a StickyMap that
104 +    !! is the same size as the total number of atom types
105 +
106 +    if (.not.allocated(StickyMap)) then
107 +
108 +       nAtypes = getSize(atypes)
109 +
110 +       if (nAtypes == 0) then
111 +          isError = -1
112 +          return
113 +       end if
114 +
115 +       if (.not. allocated(StickyMap)) then
116 +          allocate(StickyMap(nAtypes))
117 +       endif
118 +
119 +    end if
120 +
121 +    if (myATID .gt. size(StickyMap)) then
122 +       isError = -1
123 +       return
124 +    endif
125 +
126 +    ! set the values for StickyMap for this atom type:
127 +
128 +    StickyMap(myATID)%c_ident = c_ident
129 +
130      ! we could pass all 5 parameters if we felt like it...
131      
132 <    SSD_w0 = sticky_w0
133 <    SSD_v0 = sticky_v0
134 <    SSD_v0p = sticky_v0p
135 <    SSD_rl = sticky_rl
136 <    SSD_ru = sticky_ru
137 <    SSD_rlp = sticky_rlp
138 <    SSD_rup = sticky_rup
132 >    StickyMap(myATID)%w0 = w0
133 >    StickyMap(myATID)%v0 = v0
134 >    StickyMap(myATID)%v0p = v0p
135 >    StickyMap(myATID)%rl = rl
136 >    StickyMap(myATID)%ru = ru
137 >    StickyMap(myATID)%rlp = rlp
138 >    StickyMap(myATID)%rup = rup
139  
140 <    if (SSD_ru .gt. SSD_rup) then
141 <       SSD_rbig = SSD_ru
140 >    if (StickyMap(myATID)%ru .gt. StickyMap(myATID)%rup) then
141 >       StickyMap(myATID)%rbig = StickyMap(myATID)%ru
142      else
143 <       SSD_rbig = SSD_rup
143 >       StickyMap(myATID)%rbig = StickyMap(myATID)%rup
144      endif
145    
73    sticky_initialized = .true.
146      return
147 <  end subroutine set_sticky_params
147 >  end subroutine newStickyType
148  
149    subroutine do_sticky_pair(atom1, atom2, d, rij, r2, sw, vpair, fpair, &
150         pot, A, f, t, do_pot)
# Line 113 | Line 185 | contains
185      real (kind=dp) :: radcomxi, radcomyi, radcomzi
186      real (kind=dp) :: radcomxj, radcomyj, radcomzj
187      integer :: id1, id2
188 +    integer :: me1, me2
189 +   real (kind=dp) :: w0, v0, v0p, rl, ru, rlp, rup, rbig
190  
191 <    if (.not.sticky_initialized) then
192 <       write(*,*) 'Sticky forces not initialized!'
191 > if (.not.allocated(StickyMap)) then
192 >       call handleError("sticky", "no StickyMap was present before first call of do_sticky_pair!")
193         return
194 +    end if
195 +    
196 + #ifdef IS_MPI
197 +    me1 = atid_Row(atom1)
198 +    me2 = atid_Col(atom2)
199 + #else
200 +    me1 = atid(atom1)
201 +    me2 = atid(atom2)
202 + #endif
203 +
204 +    if (me1.eq.me2) then
205 +       w0  = StickyMap(me1)%w0
206 +       v0  = StickyMap(me1)%v0
207 +       v0p = StickyMap(me1)%v0p
208 +       rl  = StickyMap(me1)%rl
209 +       ru  = StickyMap(me1)%ru
210 +       rlp = StickyMap(me1)%rlp
211 +       rup = StickyMap(me1)%rup
212 +       rbig = StickyMap(me1)%rbig
213 +    else
214 +       ! This is silly, but if you want 2 sticky types in your
215 +       ! simulation, we'll let you do it with the Lorentz-
216 +       ! Berthelot mixing rules.
217 +       ! (Warning: you'll be SLLLLLLLLLLLLLLLOOOOOOOOOOWWWWWWWWWWW)
218 +       rl   = 0.5_dp * ( StickyMap(me1)%rl + StickyMap(me2)%rl )
219 +       ru   = 0.5_dp * ( StickyMap(me1)%ru + StickyMap(me2)%ru )
220 +       rlp  = 0.5_dp * ( StickyMap(me1)%rlp + StickyMap(me2)%rlp )
221 +       rup  = 0.5_dp * ( StickyMap(me1)%rup + StickyMap(me2)%rup )
222 +       rbig = max(ru, rup)
223 +       w0  = sqrt( StickyMap(me1)%w0   * StickyMap(me2)%w0  )
224 +       v0  = sqrt( StickyMap(me1)%v0   * StickyMap(me2)%v0  )
225 +       v0p = sqrt( StickyMap(me1)%v0p  * StickyMap(me2)%v0p )
226      endif
227  
228 +    if ( rij .LE. rbig ) then
229  
123    if ( rij .LE. SSD_rbig ) then
124
230         r3 = r2*rij
231         r5 = r3*r2
232  
# Line 165 | Line 270 | contains
270         yj2 = yj*yj
271         zj2 = zj*zj
272  
273 <       call calc_sw_fnc(rij, s, sp, dsdr, dspdr)
273 >       call calc_sw_fnc(rij, rl, ru, rlp, rup, s, sp, dsdr, dspdr)
274  
275         wi = 2.0d0*(xi2-yi2)*zi / r3
276         wj = 2.0d0*(xj2-yj2)*zj / r3
# Line 177 | Line 282 | contains
282         zjf = zj/rij - 0.6d0
283         zjs = zj/rij + 0.8d0
284  
285 <       wip = zif*zif*zis*zis - SSD_w0
286 <       wjp = zjf*zjf*zjs*zjs - SSD_w0
285 >       wip = zif*zif*zis*zis - w0
286 >       wjp = zjf*zjf*zjs*zjs - w0
287         wp = wip + wjp
288  
289 <       vpair = vpair + 0.5d0*(SSD_v0*s*w + SSD_v0p*sp*wp)
289 >       vpair = vpair + 0.5d0*(v0*s*w + v0p*sp*wp)
290         if (do_pot) then
291   #ifdef IS_MPI
292 <          pot_row(atom1) = pot_row(atom1) + 0.25d0*(SSD_v0*s*w + SSD_v0p*sp*wp)*sw
293 <          pot_col(atom2) = pot_col(atom2) + 0.25d0*(SSD_v0*s*w + SSD_v0p*sp*wp)*sw
292 >          pot_row(atom1) = pot_row(atom1) + 0.25d0*(v0*s*w + v0p*sp*wp)*sw
293 >          pot_col(atom2) = pot_col(atom2) + 0.25d0*(v0*s*w + v0p*sp*wp)*sw
294   #else
295 <          pot = pot + 0.5d0*(SSD_v0*s*w + SSD_v0p*sp*wp)*sw
295 >          pot = pot + 0.5d0*(v0*s*w + v0p*sp*wp)*sw
296   #endif  
297         endif
298  
# Line 229 | Line 334 | contains
334         ! do the torques first since they are easy:
335         ! remember that these are still in the body fixed axes
336  
337 <       txi = 0.5d0*(SSD_v0*s*dwidux + SSD_v0p*sp*dwipdux)*sw
338 <       tyi = 0.5d0*(SSD_v0*s*dwiduy + SSD_v0p*sp*dwipduy)*sw
339 <       tzi = 0.5d0*(SSD_v0*s*dwiduz + SSD_v0p*sp*dwipduz)*sw
337 >       txi = 0.5d0*(v0*s*dwidux + v0p*sp*dwipdux)*sw
338 >       tyi = 0.5d0*(v0*s*dwiduy + v0p*sp*dwipduy)*sw
339 >       tzi = 0.5d0*(v0*s*dwiduz + v0p*sp*dwipduz)*sw
340  
341 <       txj = 0.5d0*(SSD_v0*s*dwjdux + SSD_v0p*sp*dwjpdux)*sw
342 <       tyj = 0.5d0*(SSD_v0*s*dwjduy + SSD_v0p*sp*dwjpduy)*sw
343 <       tzj = 0.5d0*(SSD_v0*s*dwjduz + SSD_v0p*sp*dwjpduz)*sw
341 >       txj = 0.5d0*(v0*s*dwjdux + v0p*sp*dwjpdux)*sw
342 >       tyj = 0.5d0*(v0*s*dwjduy + v0p*sp*dwjpduy)*sw
343 >       tzj = 0.5d0*(v0*s*dwjduz + v0p*sp*dwjpduz)*sw
344  
345         ! go back to lab frame using transpose of rotation matrix:
346  
# Line 266 | Line 371 | contains
371  
372         ! first rotate the i terms back into the lab frame:
373  
374 <       radcomxi = (SSD_v0*s*dwidx+SSD_v0p*sp*dwipdx)*sw
375 <       radcomyi = (SSD_v0*s*dwidy+SSD_v0p*sp*dwipdy)*sw
376 <       radcomzi = (SSD_v0*s*dwidz+SSD_v0p*sp*dwipdz)*sw
374 >       radcomxi = (v0*s*dwidx+v0p*sp*dwipdx)*sw
375 >       radcomyi = (v0*s*dwidy+v0p*sp*dwipdy)*sw
376 >       radcomzi = (v0*s*dwidz+v0p*sp*dwipdz)*sw
377  
378 <       radcomxj = (SSD_v0*s*dwjdx+SSD_v0p*sp*dwjpdx)*sw
379 <       radcomyj = (SSD_v0*s*dwjdy+SSD_v0p*sp*dwjpdy)*sw
380 <       radcomzj = (SSD_v0*s*dwjdz+SSD_v0p*sp*dwjpdz)*sw
378 >       radcomxj = (v0*s*dwjdx+v0p*sp*dwjpdx)*sw
379 >       radcomyj = (v0*s*dwjdy+v0p*sp*dwjpdy)*sw
380 >       radcomzj = (v0*s*dwjdz+v0p*sp*dwjpdz)*sw
381  
382   #ifdef IS_MPI    
383         fxii = a_Row(1,atom1)*(radcomxi) + &
# Line 326 | Line 431 | contains
431  
432         ! now assemble these with the radial-only terms:
433  
434 <       fxradial = 0.5d0*(SSD_v0*dsdr*drdx*w + SSD_v0p*dspdr*drdx*wp + fxii + fxji)
435 <       fyradial = 0.5d0*(SSD_v0*dsdr*drdy*w + SSD_v0p*dspdr*drdy*wp + fyii + fyji)
436 <       fzradial = 0.5d0*(SSD_v0*dsdr*drdz*w + SSD_v0p*dspdr*drdz*wp + fzii + fzji)
434 >       fxradial = 0.5d0*(v0*dsdr*drdx*w + v0p*dspdr*drdx*wp + fxii + fxji)
435 >       fyradial = 0.5d0*(v0*dsdr*drdy*w + v0p*dspdr*drdy*wp + fyii + fyji)
436 >       fzradial = 0.5d0*(v0*dsdr*drdz*w + v0p*dspdr*drdz*wp + fzii + fzji)
437  
438   #ifdef IS_MPI
439         f_Row(1,atom1) = f_Row(1,atom1) + fxradial
# Line 367 | Line 472 | contains
472    end subroutine do_sticky_pair
473  
474    !! calculates the switching functions and their derivatives for a given
475 <  subroutine calc_sw_fnc(r, s, sp, dsdr, dspdr)
475 >  subroutine calc_sw_fnc(r, rl, ru, rlp, rup, s, sp, dsdr, dspdr)
476      
477 <    real (kind=dp), intent(in) :: r
477 >    real (kind=dp), intent(in) :: r, rl, ru, rlp, rup
478      real (kind=dp), intent(inout) :: s, sp, dsdr, dspdr
479      
480      ! distances must be in angstroms
481      
482 <    if (r.lt.SSD_rl) then
482 >    if (r.lt.rl) then
483         s = 1.0d0
484         dsdr = 0.0d0
485 <    elseif (r.gt.SSD_ru) then
485 >    elseif (r.gt.ru) then
486         s = 0.0d0
487         dsdr = 0.0d0
488      else
489 <       s = ((SSD_ru + 2.0d0*r - 3.0d0*SSD_rl) * (SSD_ru-r)**2) / &
490 <            ((SSD_ru - SSD_rl)**3)
491 <       dsdr = 6.0d0*(r-SSD_ru)*(r-SSD_rl)/((SSD_ru - SSD_rl)**3)
489 >       s = ((ru + 2.0d0*r - 3.0d0*rl) * (ru-r)**2) / &
490 >            ((ru - rl)**3)
491 >       dsdr = 6.0d0*(r-ru)*(r-rl)/((ru - rl)**3)
492      endif
493  
494 <    if (r.lt.SSD_rlp) then
494 >    if (r.lt.rlp) then
495         sp = 1.0d0      
496         dspdr = 0.0d0
497 <    elseif (r.gt.SSD_rup) then
497 >    elseif (r.gt.rup) then
498         sp = 0.0d0
499         dspdr = 0.0d0
500      else
501 <       sp = ((SSD_rup + 2.0d0*r - 3.0d0*SSD_rlp) * (SSD_rup-r)**2) / &
502 <            ((SSD_rup - SSD_rlp)**3)
503 <       dspdr = 6.0d0*(r-SSD_rup)*(r-SSD_rlp)/((SSD_rup - SSD_rlp)**3)      
501 >       sp = ((rup + 2.0d0*r - 3.0d0*rlp) * (rup-r)**2) / &
502 >            ((rup - rlp)**3)
503 >       dspdr = 6.0d0*(r-rup)*(r-rlp)/((rup - rlp)**3)      
504      endif
505      
506      return
507    end subroutine calc_sw_fnc
508 < end module sticky_pair
508 > end module sticky
509  
510 <  subroutine makeStickyType(sticky_w0, sticky_v0, sticky_v0p, &
511 <       sticky_rl, sticky_ru, sticky_rlp, sticky_rup)
510 >  subroutine newStickyType(c_ident, w0, v0, v0p, rl, ru, rlp, rup, isError)
511 >
512      use definitions, ONLY : dp  
513 <    use sticky_pair, ONLY : set_sticky_params
514 <    real( kind = dp ), intent(inout) :: sticky_w0, sticky_v0, sticky_v0p
515 <    real( kind = dp ), intent(inout) :: sticky_rl, sticky_ru
516 <    real( kind = dp ), intent(inout) :: sticky_rlp, sticky_rup
513 >    use sticky, ONLY : module_newStickyType => newStickyType
514 >
515 >    integer, intent(inout) :: c_ident, isError
516 >    real( kind = dp ), intent(inout) :: w0, v0, v0p, rl, ru, rlp, rup
517      
518 <    call set_sticky_params(sticky_w0, sticky_v0, sticky_v0p, &
519 <       sticky_rl, sticky_ru, sticky_rlp, sticky_rup)
520 <      
521 <  end subroutine makeStickyType
518 >    call module_newStickyType(c_ident, w0, v0, v0p, rl, ru, rlp, rup, &
519 >         isError)
520 >    
521 >  end subroutine newStickyType

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines