ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-1.0/libmdtools/switch_module.F90
Revision: 1334
Committed: Fri Jul 16 18:58:03 2004 UTC (19 years, 11 months ago) by gezelter
File size: 2450 byte(s)
Log Message:
Initial import of OOPSE-1.0 source tree

File Contents

# User Rev Content
1 gezelter 1334 module switcheroo
2    
3     use definitions
4    
5     implicit none
6     PRIVATE
7    
8     #define __FORTRAN90
9     #include "fSwitchingFunction.h"
10    
11     real ( kind = dp ), dimension(NSWITCHTYPES) :: rin
12     real ( kind = dp ), dimension(NSWITCHTYPES) :: rout
13     real ( kind = dp ), dimension(NSWITCHTYPES) :: rin2
14     real ( kind = dp ), dimension(NSWITCHTYPES) :: rout2
15    
16     logical, dimension(NSWITCHTYPES) :: isOK
17    
18    
19     public::set_switch
20     public::get_switch
21    
22     contains
23    
24     subroutine set_switch(SwitchType, rinner, router)
25    
26     real ( kind = dp ), intent(in):: rinner, router
27     integer, intent(in) :: SwitchType
28    
29     if (SwitchType .gt. NSWITCHTYPES) then
30     write(default_error, *) &
31     'set_switch: not that many switch types! '
32     return
33     endif
34    
35     isOK(SwitchType) = .false.
36    
37     if (router .lt. rinner) then
38     write(default_error, *) &
39     'set_switch: router is less than rinner '
40     return
41     endif
42    
43     if ((router .lt. 0.0d0) .or. (rinner .lt. 0.0d0)) then
44     write(default_error, *) &
45     'set_switch: one of the switches is negative!'
46     return
47     endif
48    
49     rin(SwitchType) = rinner
50     rout(SwitchType) = router
51     rin2(SwitchType) = rinner * rinner
52     rout2(SwitchType) = router * router
53     isOK(SwitchType) = .true.
54    
55     end subroutine set_switch
56    
57     subroutine get_switch(r2, sw, dswdr, r, SwitchType, in_switching_region)
58    
59     real( kind = dp ), intent(in) :: r2
60     real( kind = dp ), intent(inout) :: sw, dswdr, r
61     real( kind = dp ) :: ron, roff
62     integer, intent(in) :: SwitchType
63     logical, intent(inout) :: in_switching_region
64    
65     sw = 0.0d0
66     dswdr = 0.0d0
67     in_switching_region = .false.
68    
69     if (.not.isOK(SwitchType)) then
70     write(default_error, *) &
71     'get_switch: this switching function has not been set up!'
72     return
73     endif
74    
75     if (r2.lt.rout2(SwitchType)) then
76     if (r2.lt.rin2(SwitchType)) then
77    
78     sw = 1.0d0
79     dswdr = 0.0d0
80     return
81    
82     else
83    
84     r = dsqrt(r2)
85    
86     ron = rin(SwitchType)
87     roff = rout(SwitchType)
88    
89     sw = (roff + 2.0d0*r - 3.0d0*ron)*(roff-r)**2/ ((roff-ron)**3)
90     dswdr = 6.0d0*(r*r - r*ron - r*roff +roff*ron)/((roff-ron)**3)
91    
92     in_switching_region = .true.
93     return
94     endif
95     else
96     return
97     endif
98    
99     end subroutine get_switch
100     end module switcheroo