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

Comparing trunk/OOPSE-4/src/UseTheForce/DarkSide/switcheroo.F90 (file contents):
Revision 1608 by gezelter, Wed Oct 20 04:02:48 2004 UTC vs.
Revision 2424 by chrisfen, Fri Nov 11 15:21:55 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   module switcheroo
43  
44    use definitions
# Line 7 | Line 48 | module switcheroo
48  
49   #define __FORTRAN90
50   #include "UseTheForce/fSwitchingFunction.h"
51 + #include "UseTheForce/DarkSide/fSwitchingFunctionType.h"
52  
53    real ( kind = dp ), dimension(NSWITCHTYPES) :: rin
54    real ( kind = dp ), dimension(NSWITCHTYPES) :: rout
55    real ( kind = dp ), dimension(NSWITCHTYPES) :: rin2
56    real ( kind = dp ), dimension(NSWITCHTYPES) :: rout2
57 +  real ( kind = dp ), save :: c0, c1, c2, c3, c4, c5
58  
59    logical, dimension(NSWITCHTYPES) :: isOK
60 +  logical, save :: haveFunctionType = .false.
61 +  integer, save :: functionType = CUBIC
62  
63  
64    public::set_switch
65 +  public::set_function_type
66    public::get_switch
67  
68   contains
# Line 45 | Line 91 | contains
91              'set_switch:  one of the switches is negative!'
92         return
93      endif
94 <    
94 >
95      rin(SwitchType) = rinner
96      rout(SwitchType) = router
97      rin2(SwitchType) = rinner * rinner
# Line 54 | Line 100 | contains
100  
101    end subroutine set_switch
102  
103 +  subroutine set_function_type(functionForm)
104 +    integer, intent(in) :: functionForm    
105 +    functionType = functionForm
106 +
107 +    if (functionType .eq. FIFTH_ORDER_POLY) then
108 +       c0 = 1.0d0
109 +       c1 = 0.0d0
110 +       c2 = 0.0d0
111 +       c3 = -10.0d0
112 +       c4 = 15.0d0
113 +       c5 = -6.0d0
114 +    endif
115 +  end subroutine set_function_type
116 +
117    subroutine get_switch(r2, sw, dswdr, r, SwitchType, in_switching_region)
118  
119      real( kind = dp ), intent(in) :: r2
120      real( kind = dp ), intent(inout) :: sw, dswdr, r
121      real( kind = dp ) :: ron, roff
122 +    real( kind = dp ) :: rval, rval2, rval3, rval4, rval5
123 +    real( kind = dp ) :: rvaldi, rvaldi2, rvaldi3, rvaldi4, rvaldi5
124      integer, intent(in)    :: SwitchType
125      logical, intent(inout) :: in_switching_region
126  
# Line 74 | Line 136 | contains
136  
137      if (r2.lt.rout2(SwitchType)) then
138         if (r2.lt.rin2(SwitchType)) then
139 <          
139 >
140            sw = 1.0d0
141            dswdr = 0.0d0
142            return
143 <          
143 >
144         else
145 <          
145 >
146            r = dsqrt(r2)
147 <          
147 >
148            ron = rin(SwitchType)
149            roff = rout(SwitchType)
150 <          
151 <          sw = (roff + 2.0d0*r - 3.0d0*ron)*(roff-r)**2/ ((roff-ron)**3)
152 <          dswdr = 6.0d0*(r*r - r*ron - r*roff +roff*ron)/((roff-ron)**3)
153 <          
150 >
151 >          if (functionType .eq. FIFTH_ORDER_POLY) then
152 >             rval = ( r - ron )
153 >             rval2 = rval*rval
154 >             rval3 = rval2*rval
155 >             rval4 = rval2*rval2
156 >             rval5 = rval3*rval2
157 >             rvaldi = 1.0d0/( roff - ron )
158 >             rvaldi2 = rvaldi*rvaldi
159 >             rvaldi3 = rvaldi2*rvaldi
160 >             rvaldi4 = rvaldi2*rvaldi2
161 >             rvaldi5 = rvaldi3*rvaldi2
162 >             sw = c0 + c1*rval*rvaldi + c2*rval2*rvaldi2 + c3*rval3*rvaldi3 &
163 >                  + c4*rval4*rvaldi4 + c5*rval5*rvaldi5
164 >             dswdr = c1*rvaldi + 2.0d0*c2*rval*rvaldi2 &
165 >                  + 3.0d0*c3*rval2*rvaldi3 + 4.0d0*c4*rval3*rvaldi4 &
166 >                  + 5.0d0*c5*rval4*rvaldi5
167 >
168 >          else
169 >             sw = (roff + 2.0d0*r - 3.0d0*ron)*(roff-r)**2/ ((roff-ron)**3)
170 >             dswdr = 6.0d0*(r*r - r*ron - r*roff +roff*ron)/((roff-ron)**3)
171 >
172 >          endif
173            in_switching_region = .true.
174            return          
175         endif
176      else
177         return
178 <    endif    
179 <      
178 >    endif
179 >
180    end subroutine get_switch
181 +
182   end module switcheroo

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines