File: Ex-dassl.f

package info (click to toggle)
scilab 4.0-12
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 100,640 kB
  • ctags: 57,333
  • sloc: ansic: 377,889; fortran: 242,862; xml: 179,819; tcl: 42,062; sh: 10,593; ml: 9,441; makefile: 4,377; cpp: 1,354; java: 621; csh: 260; yacc: 247; perl: 130; lex: 126; asm: 72; lisp: 30
file content (166 lines) | stat: -rw-r--r-- 3,862 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
C     Examples for dassl system and jacobian 
C     --------------------------------------

c     Copyright INRIA
      subroutine res1(t,y,ydot,delta,ires,rpar,ipar)
      implicit double precision (a-h,o-z)
      dimension y(*), ydot(*), delta(*),rpar(*)
      neq=1
c
c     check y to make sure that it is valid input.
c     if y is less than or equal to zero, this is invalid input.
c
      if (y(1) .le. 0.0d0) then
         ires = -1
      else
c
c        call f to obtain f(t,y)
c
         call f1(neq,t,y,delta)
c
c        form f = f'-f(t,y)
c
         do 10 i = 1,neq
            delta(i) = ydot(i) - delta(i)
 10      continue
      endif
c
      return
      end
c
      subroutine f1 (neq, t, y, ydot)
      integer neq
      double precision t, y, ydot
      dimension y(*), ydot(*)
      ydot(1) = ((2.0d0*log(y(1)) + 8.0d0)/t - 5.0d0)*y(1)
      return
      end
c

      subroutine res2(t,y,ydot,delta,ires,rpar,ipar)
      implicit double precision (a-h,o-z)
      integer neq
      dimension y(*), ydot(*), delta(*)
      neq=2
c
c     call f to obtain f(t,y)
c
      call f2(neq,t,y,delta)
c
c     form f = f'-f(t,y)
c
      do 10 i = 1,neq
         delta(i) = ydot(i) - delta(i)
 10   continue
c
      return
      end
c
      subroutine f2 (neq, t, y, ydot)
      implicit double precision (a-h,o-z)
      integer neq
      double precision t, y, ydot
      dimension y(*), ydot(*)
      ydot(1) = y(2)
      ydot(2) = 100.0d0*(1.0d0 - y(1)*y(1))*y(2) - y(1)
      return
      end

      subroutine dres1(t,y,ydot,res,ires,rpar,ipar)
      implicit double precision(a-h,o-z)
      dimension y(*),ydot(*),res(*),rpar(*)
      res(1) = ydot(1) + 10.0d0*y(1)
      res(2) = y(2) + y(1) - 1.0d0
      return
      end


      subroutine dres2(t,y,ydot,res,ires,rpar,ipar)
      implicit double precision(a-h,o-z)
      dimension y(*),ydot(*),res(*),rpar(*)
      data alph1/1.0d0/, alph2/1.0d0/, ng/5/
      do 10 j = 1,ng
      do 10 i = 1,ng
        k = i + (j - 1)*ng
        d = -2.0d0*y(k)
        if (i .ne. 1) d = d + y(k-1)*alph1
        if (j .ne. 1) d = d + y(k-ng)*alph2
 10     res(k) = d - ydot(k)
      return
      end


C     Jacobian part 
C     --------------------------------------
      

      subroutine jac2 (t, y, ydot, pd, cj, rpar, ipar)
      implicit double precision (a-h,o-z)
      integer  nrowpd
      double precision t, y, pd
      parameter (nrowpd=2)
      dimension y(2), pd(nrowpd,2)
c
c first define the jacobian matrix for the right hand side
c of the ode: f' = f(t,y) , i.e. df/dy)
c
      pd(1,1) = 0.0d0
      pd(1,2) = 1.0d0
      pd(2,1) = -200.0d0*y(1)*y(2) - 1.0d0
      pd(2,2) = 100.0d0*(1.0d0 - y(1)*y(1))
c
c next update the jacobian with the right hand side to form the
c dae jacobian: d(f'-f)/dy = df'/dy - df/dy = i - df/dy
c
      pd(1,1) = cj - pd(1,1)
      pd(1,2) =    - pd(1,2)
      pd(2,1) =    - pd(2,1)
      pd(2,2) = cj - pd(2,2)
c
      return
      end


      subroutine djac1(t,y,yprime,pd,cj,rpar,ipar)
      implicit double precision(a-h,o-z)
      dimension y(*),yprime(*),pd(2,2)
      pd(1,1) = cj + 10.0d0
      pd(1,2) = 0.0d0
      pd(2,1) = 1.0d0
      pd(2,2) = 1.0d0
      return
      end

      subroutine djac2(t,y,yprime,pd,cj,rpar,ipar)
      implicit double precision(a-h,o-z)
      dimension y(*), pd(11,*), yprime(*),rpar(*)
      data alph1/1.0d0/, alph2/1.0d0/, ng/5/
      data ml/5/, mu/0/, neq/25/
      mband = ml + mu + 1
      mbandp1 = mband + 1
      mbandp2 = mband + 2
      mbandp3 = mband + 3
      mbandp4 = mband + 4
      mbandp5 = mband + 5
      do 10 j = 1,neq
        pd(mband,j) = -2.0d0 - cj
        pd(mbandp1,j) = alph1
        pd(mbandp2,j) = 0.0d0
        pd(mbandp3,j) = 0.0d0
        pd(mbandp4,j) = 0.0d0
 10     pd(mbandp5,j) = alph2
      do 20 j = 1,neq,ng
 20     pd(mbandp1,j) = 0.0d0
      return
      end