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 2424 by chrisfen, Fri Nov 11 15:21:55 2005 UTC vs.
Revision 2715 by chrisfen, Sun Apr 16 02:51:16 2006 UTC

# Line 42 | Line 42 | module switcheroo
42   module switcheroo
43  
44    use definitions
45 +  use interpolation
46  
47    implicit none
48    PRIVATE
# Line 58 | Line 59 | module switcheroo
59  
60    logical, dimension(NSWITCHTYPES) :: isOK
61    logical, save :: haveFunctionType = .false.
62 +  logical, save :: haveSqrtSpline = .false.
63 +  logical, save :: useSpline = .true.
64    integer, save :: functionType = CUBIC
65  
66  
67 +  ! spline variables
68 +  type(cubicSpline), save :: scoef
69 +  real ( kind = dp ), dimension(SPLINE_SEGMENTS) :: xValues
70 +  real ( kind = dp ), dimension(SPLINE_SEGMENTS) :: yValues
71 +  real ( kind = dp ), save :: dSqrt1, dSqrtN, range, dX
72 +  real ( kind = dp ), save :: lowerBound
73 +  logical, save :: uniformSpline = .true.
74 +
75    public::set_switch
76    public::set_function_type
77    public::get_switch
# Line 71 | Line 82 | contains
82  
83      real ( kind = dp ), intent(in):: rinner, router
84      integer, intent(in) :: SwitchType
85 +    integer :: i
86  
87      if (SwitchType .gt. NSWITCHTYPES) then
88         write(default_error, *) &
# Line 98 | Line 110 | contains
110      rout2(SwitchType) = router * router
111      isOK(SwitchType) = .true.
112  
113 +    if (.not.haveSqrtSpline) then
114 +       ! fill arrays for building the spline
115 +       lowerBound = 1.0d0 ! the smallest value expected for r2
116 +       range = rout2(SwitchType) - lowerBound
117 +       dX = range / (SPLINE_SEGMENTS - 1)
118 +      
119 +       ! the spline is bracketed by lowerBound and rout2 endpoints
120 +       xValues(1) = lowerBound
121 +       yValues(1) = dsqrt(lowerBound)
122 +       do i = 1, SPLINE_SEGMENTS-1
123 +          xValues(i+1) = i * dX
124 +          yValues(i+1) = dsqrt( i * dX )
125 +       enddo
126 +      
127 +       ! set the endpoint derivatives
128 +       dSqrt1 = 1 / ( 2.0d0 * dsqrt( xValues(1) ) )
129 +       dSqrtN = 1 / ( 2.0d0 * dsqrt( xValues(SPLINE_SEGMENTS) ) )
130 +
131 +       ! call newSpline to fill the coefficient array
132 +       call newSpline(scoef, xValues, yValues, dSqrt1, dSqrtN, uniformSpline)
133 +      
134 +    endif
135 +    
136    end subroutine set_switch
137  
138    subroutine set_function_type(functionForm)
# Line 142 | Line 177 | contains
177            return
178  
179         else
180 +          if (useSpline) then
181 +             call lookup_uniform_spline(scoef, r2, r)
182 +          else
183 +             r = dsqrt(r2)
184 +          endif
185  
146          r = dsqrt(r2)
147
186            ron = rin(SwitchType)
187            roff = rout(SwitchType)
188  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines