7017
|
1 # Copyright (C) 2002, 2003, 2004, 2005, 2007 John W. Eaton |
|
2 # |
|
3 # This file is part of Octave. |
|
4 # |
|
5 # Octave is free software; you can redistribute it and/or modify it |
|
6 # under the terms of the GNU General Public License as published by the |
|
7 # Free Software Foundation; either version 3 of the License, or (at |
|
8 # your option) any later version. |
|
9 # |
|
10 # Octave is distributed in the hope that it will be useful, but WITHOUT |
|
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 # for more details. |
|
14 # |
|
15 # You should have received a copy of the GNU General Public License |
|
16 # along with Octave; see the file COPYING. If not, see |
|
17 # <http://www.gnu.org/licenses/>. |
|
18 |
3998
|
19 CLASS = "DASPK" |
|
20 |
4044
|
21 INCLUDE = "DAE.h" |
|
22 |
3998
|
23 OPTION |
|
24 NAME = "absolute tolerance" |
4050
|
25 DOC_ITEM |
|
26 Absolute tolerance. May be either vector or scalar. If a vector, it |
|
27 must match the dimension of the state vector, and the relative |
|
28 tolerance must also be a vector of the same length. |
|
29 END_DOC_ITEM |
3998
|
30 TYPE = "Array<double>" |
|
31 SET_ARG_TYPE = "const $TYPE&" |
|
32 INIT_BODY |
|
33 $OPTVAR.resize (1); |
|
34 $OPTVAR(0) = ::sqrt (DBL_EPSILON); |
|
35 END_INIT_BODY |
|
36 SET_CODE |
|
37 void set_$OPT (double val) |
|
38 { |
|
39 $OPTVAR.resize (1); |
|
40 $OPTVAR(0) = (val > 0.0) ? val : ::sqrt (DBL_EPSILON); |
4049
|
41 reset = true; |
3998
|
42 } |
|
43 |
|
44 void set_$OPT (const $TYPE& val) |
4049
|
45 { $OPTVAR = val; reset = true; } |
3998
|
46 END_SET_CODE |
|
47 END_OPTION |
|
48 |
|
49 OPTION |
|
50 NAME = "relative tolerance" |
4050
|
51 DOC_ITEM |
|
52 Relative tolerance. May be either vector or scalar. If a vector, it |
|
53 must match the dimension of the state vector, and the absolute |
|
54 tolerance must also be a vector of the same length. |
|
55 |
|
56 The local error test applied at each integration step is |
|
57 |
|
58 @example |
5016
|
59 abs (local error in x(i)) |
|
60 <= rtol(i) * abs (Y(i)) + atol(i) |
4050
|
61 @end example |
|
62 END_DOC_ITEM |
3998
|
63 TYPE = "Array<double>" |
|
64 SET_ARG_TYPE = "const $TYPE&" |
|
65 INIT_BODY |
|
66 $OPTVAR.resize (1); |
|
67 $OPTVAR(0) = ::sqrt (DBL_EPSILON); |
|
68 END_INIT_BODY |
|
69 SET_CODE |
|
70 void set_$OPT (double val) |
|
71 { |
|
72 $OPTVAR.resize (1); |
|
73 $OPTVAR(0) = (val > 0.0) ? val : ::sqrt (DBL_EPSILON); |
4049
|
74 reset = true; |
3998
|
75 } |
|
76 |
|
77 void set_$OPT (const $TYPE& val) |
4049
|
78 { $OPTVAR = val; reset = true; } |
3998
|
79 END_SET_CODE |
|
80 END_OPTION |
|
81 |
|
82 OPTION |
4044
|
83 NAME = "compute consistent initial condition" |
4050
|
84 DOC_ITEM |
|
85 Denoting the differential variables in the state vector by @samp{Y_d} |
|
86 and the algebraic variables by @samp{Y_a}, @code{ddaspk} can solve |
|
87 one of two initialization problems: |
|
88 |
|
89 @enumerate |
|
90 @item Given Y_d, calculate Y_a and Y'_d |
|
91 @item Given Y', calculate Y. |
|
92 @end enumerate |
|
93 |
|
94 In either case, initial values for the given components are input, and |
|
95 initial guesses for the unknown components must also be provided as |
|
96 input. Set this option to 1 to solve the first problem, or 2 to solve |
|
97 the second (the default default is 0, so you must provide a set of |
|
98 initial conditions that are consistent). |
|
99 |
|
100 If this option is set to a nonzero value, you must also set the |
|
101 @code{\"algebraic variables\"} option to declare which variables in the |
|
102 problem are algebraic. |
|
103 END_DOC_ITEM |
5275
|
104 TYPE = "octave_idx_type" |
4050
|
105 INIT_VALUE = "0" |
|
106 SET_EXPR = "val" |
|
107 END_OPTION |
|
108 |
|
109 OPTION |
|
110 NAME = "use initial condition heuristics" |
|
111 DOC_ITEM |
|
112 Set to a nonzero value to use the initial condition heuristics options |
|
113 described below. |
|
114 END_DOC_ITEM |
5275
|
115 TYPE = "octave_idx_type" |
4050
|
116 INIT_VALUE = "0" |
|
117 SET_EXPR = "val" |
|
118 END_OPTION |
|
119 |
|
120 OPTION |
|
121 NAME = "initial condition heuristics" |
|
122 DOC_ITEM |
|
123 A vector of the following parameters that can be used to control the |
|
124 initial condition calculation. |
|
125 |
|
126 @table @code |
|
127 @item MXNIT |
|
128 Maximum number of Newton iterations (default is 5). |
|
129 @item MXNJ |
|
130 Maximum number of Jacobian evaluations (default is 6). |
|
131 @item MXNH |
|
132 Maximum number of values of the artificial stepsize parameter to be |
|
133 tried if the @code{\"compute consistent initial condition\"} option has |
|
134 been set to 1 (default is 5). |
|
135 |
7096
|
136 Note that the maximum total number of Newton iterations allowed is |
4050
|
137 @code{MXNIT*MXNJ*MXNH} if the @code{\"compute consistent initial |
|
138 condition\"} option has been set to 1 and @code{MXNIT*MXNJ} if it is |
|
139 set to 2. |
|
140 @item LSOFF |
|
141 Set to a nonzero value to disable the linesearch algorithm (default is |
|
142 0). |
|
143 @item STPTOL |
|
144 Minimum scaled step in linesearch algorithm (default is eps^(2/3)). |
|
145 @item EPINIT |
|
146 Swing factor in the Newton iteration convergence test. The test is |
|
147 applied to the residual vector, premultiplied by the approximate |
|
148 Jacobian. For convergence, the weighted RMS norm of this vector |
|
149 (scaled by the error weights) must be less than @code{EPINIT*EPCON}, |
|
150 where @code{EPCON} = 0.33 is the analogous test constant used in the |
|
151 time steps. The default is @code{EPINIT} = 0.01. |
|
152 @end table |
|
153 END_DOC_ITEM |
|
154 TYPE = "Array<double>" |
|
155 SET_ARG_TYPE = "const $TYPE&" |
|
156 INIT_BODY |
4548
|
157 $OPTVAR.resize (6); |
4050
|
158 $OPTVAR(0) = 5.0; |
|
159 $OPTVAR(1) = 6.0; |
|
160 $OPTVAR(2) = 5.0; |
|
161 $OPTVAR(3) = 0.0; |
|
162 $OPTVAR(4) = ::pow (DBL_EPSILON, 2.0/3.0); |
|
163 $OPTVAR(5) = 0.01; |
|
164 END_INIT_BODY |
|
165 SET_EXPR = "val" |
|
166 END_OPTION |
|
167 |
|
168 OPTION |
|
169 NAME = "print initial condition info" |
|
170 DOC_ITEM |
|
171 Set this option to a nonzero value to display detailed information |
|
172 about the initial condition calculation (default is 0). |
|
173 END_DOC_ITEM |
5275
|
174 TYPE = "octave_idx_type" |
4050
|
175 INIT_VALUE = "0" |
|
176 SET_EXPR = "val" |
|
177 END_OPTION |
|
178 |
|
179 OPTION |
|
180 NAME = "exclude algebraic variables from error test" |
|
181 DOC_ITEM |
|
182 Set to a nonzero value to exclude algebraic variables from the error |
|
183 test. You must also set the @code{\"algebraic variables\"} option to |
|
184 declare which variables in the problem are algebraic (default is 0). |
|
185 END_DOC_ITEM |
5275
|
186 TYPE = "octave_idx_type" |
4044
|
187 INIT_VALUE = "0" |
|
188 SET_EXPR = "val" |
|
189 END_OPTION |
|
190 |
|
191 OPTION |
4047
|
192 NAME = "algebraic variables" |
4050
|
193 DOC_ITEM |
|
194 A vector of the same length as the state vector. A nonzero element |
|
195 indicates that the corresponding element of the state vector is an |
|
196 algebraic variable (i.e., its derivative does not appear explicitly |
|
197 in the equation set. |
|
198 |
|
199 This option is required by the |
|
200 @code{compute consistent initial condition\"} and |
|
201 @code{\"exclude algebraic variables from error test\"} options. |
|
202 END_DOC_ITEM |
5275
|
203 TYPE = "Array<octave_idx_type>" |
4047
|
204 SET_ARG_TYPE = const $TYPE& |
|
205 INIT_BODY |
|
206 $OPTVAR.resize (1); |
|
207 $OPTVAR(0) = 0; |
|
208 END_INIT_BODY |
|
209 SET_CODE |
|
210 void set_$OPT (int val) |
|
211 { |
|
212 $OPTVAR.resize (1); |
|
213 $OPTVAR(0) = val; |
4049
|
214 reset = true; |
4047
|
215 } |
|
216 |
|
217 void set_$OPT (const $TYPE& val) |
4049
|
218 { $OPTVAR = val; reset = true; } |
4047
|
219 END_SET_CODE |
|
220 END_OPTION |
|
221 |
|
222 OPTION |
4044
|
223 NAME = "enforce inequality constraints" |
4050
|
224 DOC_ITEM |
|
225 Set to one of the following values to enforce the inequality |
|
226 constraints specified by the @code{\"inequality constraint types\"} |
|
227 option (default is 0). |
|
228 |
|
229 @enumerate |
|
230 @item To have constraint checking only in the initial condition calculation. |
|
231 @item To enforce constraint checking during the integration. |
|
232 @item To enforce both options 1 and 2. |
|
233 @end enumerate |
|
234 END_DOC_ITEM |
5275
|
235 TYPE = "octave_idx_type" |
4044
|
236 INIT_VALUE = "0" |
|
237 SET_EXPR = "val" |
|
238 END_OPTION |
|
239 |
|
240 OPTION |
|
241 NAME = "inequality constraint types" |
4050
|
242 DOC_ITEM |
|
243 A vector of the same length as the state specifying the type of |
|
244 inequality constraint. Each element of the vector corresponds to an |
|
245 element of the state and should be assigned one of the following |
|
246 codes |
|
247 |
|
248 @table @asis |
|
249 @item -2 |
|
250 Less than zero. |
|
251 @item -1 |
|
252 Less than or equal to zero. |
|
253 @item 0 |
|
254 Not constrained. |
|
255 @item 1 |
|
256 Greater than or equal to zero. |
|
257 @item 2 |
|
258 Greater than zero. |
|
259 @end table |
|
260 |
|
261 This option only has an effect if the |
|
262 @code{\"enforce inequality constraints\"} option is nonzero. |
|
263 END_DOC_ITEM |
5275
|
264 TYPE = "Array<octave_idx_type>" |
4044
|
265 SET_ARG_TYPE = const $TYPE& |
|
266 INIT_BODY |
|
267 $OPTVAR.resize (1); |
|
268 $OPTVAR(0) = 0; |
|
269 END_INIT_BODY |
|
270 SET_CODE |
5275
|
271 void set_$OPT (octave_idx_type val) |
4044
|
272 { |
|
273 $OPTVAR.resize (1); |
4047
|
274 $OPTVAR(0) = val; |
4049
|
275 reset = true; |
4044
|
276 } |
|
277 |
|
278 void set_$OPT (const $TYPE& val) |
4049
|
279 { $OPTVAR = val; reset = true; } |
4044
|
280 END_SET_CODE |
|
281 END_OPTION |
|
282 |
|
283 OPTION |
3998
|
284 NAME = "initial step size" |
4050
|
285 DOC_ITEM |
7001
|
286 Differential-algebraic problems may occasionally suffer from severe |
4050
|
287 scaling difficulties on the first step. If you know a great deal |
|
288 about the scaling of your problem, you can help to alleviate this |
|
289 problem by specifying an initial stepsize (default is computed |
|
290 automatically). |
|
291 END_DOC_ITEM |
3998
|
292 TYPE = "double" |
|
293 INIT_VALUE = "-1.0" |
|
294 SET_EXPR = "(val >= 0.0) ? val : -1.0" |
|
295 END_OPTION |
|
296 |
|
297 OPTION |
4044
|
298 NAME = "maximum order" |
4050
|
299 DOC_ITEM |
|
300 Restrict the maximum order of the solution method. This option must |
|
301 be between 1 and 5, inclusive (default is 5). |
|
302 END_DOC_ITEM |
5275
|
303 TYPE = "octave_idx_type" |
4050
|
304 INIT_VALUE = "5" |
4044
|
305 SET_EXPR = "val" |
|
306 END_OPTION |
|
307 |
|
308 OPTION |
3998
|
309 NAME = "maximum step size" |
4050
|
310 DOC_ITEM |
|
311 Setting the maximum stepsize will avoid passing over very large |
|
312 regions (default is not specified). |
|
313 END_DOC_ITEM |
3998
|
314 TYPE = "double" |
|
315 INIT_VALUE = "-1.0" |
|
316 SET_EXPR = "(val >= 0.0) ? val : -1.0" |
|
317 END_OPTION |