Mercurial > octave
annotate scripts/ode/ode15i.m @ 22933:c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
* ode15i.m, ode15s.m: Use double quotes instead of single quotes. Wrap lines >
80 characters. Simplify calls to error() by placing name of field in error
string rather than using '%s'. Use space between function name and opening
parenthesis. End fail() lines with semicolon.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 22 Dec 2016 21:22:50 -0800 |
parents | 8133da976602 |
children | c9344df03da5 |
rev | line source |
---|---|
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1 ## Copyright (C) 2016, Francesco Faccio <francesco.faccio@mail.polimi.it> |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
2 ## |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
3 ## This file is part of Octave. |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
4 ## |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
5 ## Octave is free software; you can redistribute it and/or modify it |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
6 ## under the terms of the GNU General Public License as published by |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
8 ## your option) any later version. |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
9 ## |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
10 ## Octave is distributed in the hope that it will be useful, but |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
13 ## General Public License for more details. |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
14 ## |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
15 ## You should have received a copy of the GNU General Public License |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
16 ## along with Octave; see the file COPYING. If not, see |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
17 ## <http://www.gnu.org/licenses/>. |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
18 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
19 ## -*- texinfo -*- |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
20 ## @deftypefn {} {[@var{t}, @var{y}] =} ode15i (@var{fun}, @var{trange}, @var{y0}, @var{yp0}) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
21 ## @deftypefnx {} {[@var{t}, @var{y}] =} ode15i (@var{fun}, @var{trange}, @var{y0}, @var{yp0}, @var{ode_opt}) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
22 ## @deftypefnx {} {[@var{t}, @var{y}, @var{te}, @var{ye}, @var{ie}] =} ode15i (@dots{}) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
23 ## @deftypefnx {} {@var{solution} =} ode15i (@dots{}) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
24 ## |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22902
diff
changeset
|
25 ## Solve a set of full-implicit Ordinary Differential Equations and |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
26 ## Differential Algebraic Equations (DAEs) of index 1, with the variable-step, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
27 ## variable order BDF (Backward Differentiation Formula) method, which |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
28 ## ranges from order 1 to 5. |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
29 ## |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
30 ## @var{fun} is a function handle, inline function, or string containing the |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
31 ## name of the function that defines the ODE: |
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
32 ## @code{f(@var{t},@var{y},@var{yp})}. |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
33 ## The function must accept three inputs where the first is time @var{t}, the |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
34 ## second is a column vector of unknowns @var{y} and the third is a column |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22902
diff
changeset
|
35 ## vector of unknowns @var{yp}. |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
36 ## |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
37 ## @var{trange} specifies the time interval over which the ODE will be |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
38 ## evaluated. Typically, it is a two-element vector specifying the initial and |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
39 ## final times (@code{[tinit, tfinal]}). If there are more than two elements |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
40 ## then the solution will also be evaluated at these intermediate time. |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
41 ## |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
42 ## @var{y0} and @var{yp0} contain the initial values for the unknowns @var{y} |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
43 ## and @var{yp}. If they are row vectors then the solution @var{y} will be a |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
44 ## matrix in which each column is the solution for the corresponding initial |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
45 ## value in @var{y0} and @var{yp0}. |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
46 ## |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
47 ## @var{y0} and @var{yp0} must be consistent initial conditions, meaning that |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
48 ## @code{f(@var{t},@var{y0},@var{yp0})=0} is satisfied. You can use function |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
49 ## decic to compute consistent initial conditions, given initial guesses. |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
50 ## |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
51 ## The optional fifth argument @var{ode_opt} specifies non-default options to |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
52 ## the ODE solver. It is a structure generated by @code{odeset}. |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
53 ## |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
54 ## The function typically returns two outputs. Variable @var{t} is a |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
55 ## column vector and contains the times where the solution was found. The |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
56 ## output @var{y} is a matrix in which each column refers to a different |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
57 ## unknown of the problem and each row corresponds to a time in @var{t}. |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
58 ## |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
59 ## The output can also be returned as a structure @var{solution} which |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
60 ## has field @var{x} containing the time where the solution was evaluated and |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
61 ## field @var{y} containing the solution matrix for the times in @var{x}. |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
62 ## Use @code{fieldnames (@var{solution})} to see the other fields and |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
63 ## additional information returned. |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
64 ## |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
65 ## If using the @qcode{"Events"} option then three additional outputs may |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
66 ## be returned. @var{te} holds the time when an Event function returned a |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
67 ## zero. @var{ye} holds the value of the solution at time @var{te}. @var{ie} |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
68 ## contains an index indicating which Event function was triggered in the case |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
69 ## of multiple Event functions. |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
70 ## |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
71 ## This function can be called with two output arguments: @var{t} and @var{y}. |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
72 ## Variable @var{t} is a column vector and contains the time stamps, instead |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
73 ## @var{y} is a matrix in which each column refers to a different unknown of |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
74 ## the problem and the rows number is the same of @var{t} rows number so |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
75 ## that each row of @var{y} contains the values of all unknowns at the time |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
76 ## value contained in the corresponding row in @var{t}. |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
77 ## |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
78 ## Example: Solve the @nospell{Robetson}'s equations: |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
79 ## |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
80 ## @example |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
81 ## @group |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
82 ## function res = robertsidae(@var{t}, @var{y}, @var{yp}) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
83 ## res = [-(@var{yp}(1) + 0.04*@var{y}(1) - 1e4*@var{y}(2)*@var{y}(3)); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
84 ## -(@var{yp}(2) - 0.04*@var{y}(1) + 1e4*@var{y}(2)*@var{y}(3) + |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
85 ## 3e7*@var{y}(2)^2); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
86 ## @var{y}(1) + @var{y}(2) + @var{y}(3) - 1]; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
87 ## endfunction |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
88 ## [@var{t},@var{y}] = ode15i (@@robertsidae, [0 1e3], [1; 0; 0], [-1e-4; 1e-4; 0]); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
89 ## @end group |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
90 ## @end example |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
91 ## @seealso{decic, odeset, odeget} |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
92 ## @end deftypefn |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
93 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
94 function varargout = ode15i (fun, trange, y0, yp0, varargin) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
95 |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
96 solver = "ode15i"; |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22902
diff
changeset
|
97 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
98 if (nargin < 4) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
99 print_usage (); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
100 endif |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22902
diff
changeset
|
101 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
102 n = numel (y0); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22902
diff
changeset
|
103 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
104 if (nargin > 4) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
105 options = varargin{1}; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
106 else |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
107 options = odeset (); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
108 endif |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
109 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
110 ## Check fun, trange, y0, yp0 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
111 fun = check_default_input (fun, trange, solver, y0, yp0); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22902
diff
changeset
|
112 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
113 if (! isempty (options.Jacobian)) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
114 if (ischar (options.Jacobian)) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
115 try |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
116 options.Jacobian = str2func (options.Jacobian); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
117 catch |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
118 warning (lasterr); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
119 end_try_catch |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
120 if (! isa (options.Jacobian, "function_handle")) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
121 error ("Octave:invalid-input-arg", |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
122 [solver ": invalid value assigned to field 'Jacobian'"]); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
123 endif |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
124 endif |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
125 endif |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
126 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
127 if (! isempty (options.OutputFcn)) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
128 if (ischar (options.OutputFcn)) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
129 try |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
130 options.OutputFcn = str2func (options.OutputFcn); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
131 catch |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
132 warning (lasterr); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
133 end_try_catch |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
134 if (! isa (options.OutputFcn, "function_handle")) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
135 error ("Octave:invalid-input-arg", |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
136 [solver ": invalid value assigned to field 'OutputFcn'"); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
137 endif |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
138 endif |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
139 endif |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
140 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
141 if (! isempty (options.Events)) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
142 if (ischar (options.Events)) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
143 try |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
144 options.Events = str2func (options.Events); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
145 catch |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
146 warning (lasterr); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
147 end_try_catch |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
148 if (! isa (options.Events, "function_handle") |
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
149 && ! ismatrix (options.Events)) |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
150 error ("Octave:invalid-input-arg", |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
151 [solver ": invalid value assigned to field 'Events'"); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
152 endif |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
153 endif |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
154 endif |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
155 |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
156 [defaults, classes, attributes] = odedefaults (n, trange(1), trange(end)); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
157 |
22902
284bbb0328f2
Update odei5{i,s} code for Octave 4.3.0+ and Sundials 2.7.0.
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22901
diff
changeset
|
158 persistent ignorefields = {"NonNegative", "Mass", ... |
284bbb0328f2
Update odei5{i,s} code for Octave 4.3.0+ and Sundials 2.7.0.
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22901
diff
changeset
|
159 "MStateDependence", "MvPattern", ... |
284bbb0328f2
Update odei5{i,s} code for Octave 4.3.0+ and Sundials 2.7.0.
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22901
diff
changeset
|
160 "MassSingular", "InitialSlope", "BDF"}; |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22902
diff
changeset
|
161 |
22902
284bbb0328f2
Update odei5{i,s} code for Octave 4.3.0+ and Sundials 2.7.0.
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22901
diff
changeset
|
162 defaults = rmfield (defaults, ignorefields); |
284bbb0328f2
Update odei5{i,s} code for Octave 4.3.0+ and Sundials 2.7.0.
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22901
diff
changeset
|
163 classes = rmfield (classes, ignorefields); |
284bbb0328f2
Update odei5{i,s} code for Octave 4.3.0+ and Sundials 2.7.0.
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22901
diff
changeset
|
164 attributes = rmfield (attributes, ignorefields); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
165 |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
166 classes = odeset (classes, "Vectorized", {}); |
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
167 attributes = odeset (attributes, "Jacobian", {}, "Vectorized", {}); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
168 |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
169 options = odemergeopts ("ode15i", options, defaults, |
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
170 classes, attributes, solver); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
171 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
172 ## Jacobian |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
173 options.havejac = false; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
174 options.havejacsparse = false; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
175 options.havejacfun = false; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
176 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
177 if (! isempty (options.Jacobian)) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
178 options.havejac = true; |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22902
diff
changeset
|
179 if (iscell (options.Jacobian)) |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
180 if (numel (options.Jacobian) == 2) |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
181 if (issparse (options.Jacobian{1}) && issparse (options.Jacobian{2})) |
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
182 options.havejacsparse = true; # Jac is sparse cell |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
183 endif |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
184 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
185 if (any (size (options.Jacobian{1}) != [n n]) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
186 || any (size (options.Jacobian{2}) != [n n]) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
187 || ! isnumeric (options.Jacobian{1}) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
188 || ! isnumeric (options.Jacobian{2}) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
189 || ! isreal (options.Jacobian{1}) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
190 || ! isreal (options.Jacobian{2})) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
191 error ("Octave:invalid-input-arg", |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
192 [solver ": invalid value assigned to field 'Jacobian'"); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
193 endif |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
194 else |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
195 error ("Octave:invalid-input-arg", |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
196 [solver ": invalid value assigned to field 'Jacobian'"); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
197 endif |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
198 |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22902
diff
changeset
|
199 elseif (isa (options.Jacobian, "function_handle")) |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
200 options.havejacfun = true; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
201 if (nargin (options.Jacobian) == 3) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
202 [A, B] = options.Jacobian (trange(1), y0, yp0); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
203 if (issparse (A) && issparse (B)) |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
204 options.havejacsparse = true; # Jac is sparse fun |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
205 endif |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
206 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
207 if (any (size (A) != [n n]) || any (size (B) != [n n]) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
208 || ! isnumeric (A) || ! isnumeric (B) || ! isreal (A) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
209 || ! isreal (B)) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
210 error ("Octave:invalid-input-arg", |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
211 [solver ": invalid value assigned to field 'Jacobian'"); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
212 endif |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
213 else |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
214 error ("Octave:invalid-input-arg", |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
215 [solver ": invalid value assigned to field 'Jacobian'"); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
216 endif |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
217 else |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
218 error ("Octave:invalid-input-arg", |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
219 [solver ": invalid value assigned to field 'Jacobian'"); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
220 endif |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
221 endif |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22902
diff
changeset
|
222 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
223 ## Abstol and Reltol |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
224 options.haveabstolvec = false; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
225 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
226 if (numel (options.AbsTol) != 1 && numel (options.AbsTol) != n) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
227 error ("Octave:invalid-input-arg", |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
228 [solver ": invalid value assigned to field 'AbsTol'"); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22902
diff
changeset
|
229 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
230 elseif (numel (options.AbsTol) == n) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
231 options.haveabstolvec = true; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
232 endif |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
233 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
234 ## Stats |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22902
diff
changeset
|
235 options.havestats = false; |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
236 if (strcmp (options.Stats, "on")) |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22902
diff
changeset
|
237 options.havestats = true; |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
238 endif |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
239 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
240 ## Don't use Refine when the output is a structure |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
241 if (nargout == 1) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
242 options.Refine = 1; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
243 endif |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
244 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
245 ## OutputFcn and OutputSel |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
246 if (isempty (options.OutputFcn) && nargout == 0) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
247 options.OutputFcn = @odeplot; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
248 options.haveoutputfunction = true; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
249 else |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
250 options.haveoutputfunction = ! isempty (options.OutputFcn); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
251 endif |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22902
diff
changeset
|
252 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
253 options.haveoutputselection = ! isempty (options.OutputSel); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
254 if (options.haveoutputselection) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
255 options.OutputSel = options.OutputSel - 1; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
256 endif |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
257 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
258 ## Events |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
259 options.haveeventfunction = ! isempty (options.Events); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
260 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
261 [t, y, te, ye, ie] = __ode15__ (fun, trange, y0, yp0, options); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22902
diff
changeset
|
262 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
263 if (nargout == 2) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
264 varargout{1} = t; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
265 varargout{2} = y; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
266 elseif (nargout == 1) |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
267 varargout{1}.x = t; # Time stamps are saved in field x |
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
268 varargout{1}.y = y; # Results are saved in field y |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22902
diff
changeset
|
269 varargout{1}.solver = solver; |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
270 if (options.haveeventfunction) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
271 varargout{1}.xe = te; # Time info when an event occurred |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
272 varargout{1}.ye = ye; # Results when an event occurred |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
273 varargout{1}.ie = ie; # Index info which event occurred |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
274 endif |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
275 elseif (nargout == 5) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
276 varargout = cell (1,5); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
277 varargout{1} = t; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
278 varargout{2} = y; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
279 if (options.haveeventfunction) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
280 varargout{3} = te; # Time info when an event occurred |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
281 varargout{4} = ye; # Results when an event occurred |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
282 varargout{5} = ie; # Index info which event occurred |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
283 endif |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
284 endif |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
285 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
286 endfunction |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
287 |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
288 |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22902
diff
changeset
|
289 %!demo |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
290 %! ## Solve Robertson's equations with ode15i |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
291 %! fun = @(t, y, yp) [-(yp(1) + 0.04*y(1) - 1e4*y(2)*y(3)); |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
292 %! -(yp(2) - 0.04*y(1) + 1e4*y(2)*y(3) + 3e7*y(2)^2); |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
293 %! y(1) + y(2) + y(3) - 1]; |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
294 %! |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
295 %! opt = odeset ("RelTol", 1e-4, "AbsTol", [1e-8, 1e-14, 1e-6]); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
296 %! y0 = [1; 0; 0]; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
297 %! yp0 = [-1e-4; 1e-4; 0]; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
298 %! tspan = [0 4*logspace(-6, 6)]; |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22902
diff
changeset
|
299 %! |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
300 %! [t, y] = ode15i (fun, tspan, y0, yp0, opt); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
301 %! |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
302 %! y(:,2) = 1e4 * y(:, 2); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
303 %! figure (2); |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
304 %! semilogx (t, y, "o"); |
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
305 %! xlabel ("time"); |
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
306 %! ylabel ("species concentration"); |
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
307 %! title ("Robertson DAE problem with a Conservation Law"); |
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
308 %! legend ("y1", "y2", "y3"); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
309 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
310 %!function res = rob (t, y, yp) |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
311 %! res =[-(yp(1) + 0.04*y(1) - 1e4*y(2)*y(3)); |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
312 %! -(yp(2) - 0.04*y(1) + 1e4*y(2)*y(3) + 3e7*y(2)^2); |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
313 %! y(1) + y(2) + y(3) - 1]; |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
314 %!endfunction |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
315 %! |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
316 %!function ref = fref () |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
317 %! ref = [100, 0.617234887614937, 0.000006153591397, 0.382758958793666]; |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
318 %!endfunction |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
319 %! |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
320 %!function ref2 = fref2 () |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
321 %! ref2 = [4e6 0 0 1]; |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
322 %!endfunction |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
323 %! |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
324 %!function [DFDY, DFDYP] = jacfundense (t, y, yp) |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
325 %! DFDY = [-0.04, 1e4*y(3), 1e4*y(2); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
326 %! 0.04, -1e4*y(3)-6e7*y(2), -1e4*y(2); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
327 %! 1, 1, 1]; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
328 %! DFDYP = [-1, 0, 0; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
329 %! 0, -1, 0; |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22902
diff
changeset
|
330 %! 0, 0, 0]; |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
331 %!endfunction |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
332 %! |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
333 %!function [DFDY, DFDYP] = jacfunsparse (t, y, yp) |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
334 %! DFDY = sparse ([-0.04, 1e4*y(3), 1e4*y(2); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
335 %! 0.04, -1e4*y(3)-6e7*y(2), -1e4*y(2); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
336 %! 1, 1, 1]); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
337 %! DFDYP = sparse ([-1, 0, 0; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
338 %! 0, -1, 0; |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22902
diff
changeset
|
339 %! 0, 0, 0]); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
340 %!endfunction |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
341 %! |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
342 %!function [DFDY, DFDYP] = jacwrong (t, y, yp) |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
343 %! DFDY = [-0.04, 1e4*y(3); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
344 %! 0.04, -1e4*y(3)-6e7*y(2)]; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
345 %! DFDYP = [-1, 0; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
346 %! 0, -1]; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
347 %!endfunction |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
348 %! |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
349 %!function [DFDY, DFDYP, A] = jacwrong2 (t, y, yp) |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
350 %! DFDY = [-0.04, 1e4*y(3), 1e4*y(2); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
351 %! 0.04, -1e4*y(3)-6e7*y(2), -1e4*y(2); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
352 %! 1, 1, 1]; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
353 %! DFDYP = [-1, 0, 0; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
354 %! 0, -1, 0; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
355 %! 0, 0, 0]; |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22902
diff
changeset
|
356 %! A = DFDY; |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
357 %!endfunction |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
358 %! |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
359 %!function [val, isterminal, direction] = ff (t, y, yp) |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
360 %! isterminal = [0, 1]; |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
361 %! if (t < 1e1) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
362 %! val = [-1, -2]; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
363 %! else |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
364 %! val = [1, 3]; |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
365 %! endif |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22902
diff
changeset
|
366 %! |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
367 %! direction = [1, 0]; |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
368 %!endfunction |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
369 |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
370 ## anonymous function instead of real function |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
371 %!testif HAVE_SUNDIALS |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
372 %! ref = 0.049787079136413; |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
373 %! ff = @(t, u, udot) udot + 3 * u; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
374 %! [t, y] = ode15i (ff, 0:1, 1, -3); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
375 %! assert ([t(end), y(end)], [1, ref], 1e-3); |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
376 |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
377 ## function passed as string |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
378 %!testif HAVE_SUNDIALS |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
379 %! [t, y] = ode15i ("rob", [0, 100, 200], [1; 0; 0], [-1e-4; 1e-4; 0]); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
380 %! assert ([t(2), y(2,:)], fref, 1e-3); |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
381 |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
382 ## solve in intermidiate step |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
383 %!testif HAVE_SUNDIALS |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
384 %! [t, y] = ode15i (@rob, [0, 100, 200], [1; 0; 0], [-1e-4; 1e-4; 0]); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
385 %! assert ([t(2), y(2,:)], fref, 1e-3); |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
386 |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
387 ## numel(trange) = 2 final value |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
388 %!testif HAVE_SUNDIALS |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
389 %! [t, y] = ode15i (@rob, [0, 100], [1; 0; 0], [-1e-4; 1e-4; 0]); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
390 %! assert ([t(end), y(end,:)], fref, 1e-5); |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
391 |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
392 ## With empty options |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
393 %!testif HAVE_SUNDIALS |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
394 %! opt = odeset(); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
395 %! [t, y] = ode15i (@rob, [0, 1e6, 2e6, 3e6, 4e6], [1; 0; 0], |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
396 %! [-1e-4; 1e-4; 0], opt); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
397 %! assert ([t(end), y(end,:)], fref2, 1e-3); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
398 %! opt = odeset(); |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
399 |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
400 ## Without options |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
401 %!testif HAVE_SUNDIALS |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
402 %! [t, y] = ode15i (@rob, [0, 1e6, 2e6, 3e6, 4e6], [1; 0; 0],[-1e-4; 1e-4; 0]); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
403 %! assert ([t(end), y(end,:)], fref2, 1e-3); |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
404 |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
405 ## InitialStep option |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
406 %!testif HAVE_SUNDIALS |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
407 %! opt = odeset ("InitialStep", 1e-8); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
408 %! [t, y] = ode15i (@rob, [0, 100], [1; 0; 0], [-1e-4; 1e-4; 0], opt); |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
409 %! assert (t(2)-t(1), 1e-8, 1e-9); |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
410 |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
411 ## MaxStep option |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
412 %!testif HAVE_SUNDIALS |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
413 %! opt = odeset ("MaxStep", 1e-3); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
414 %! [t, y] = ode15i (@rob, [0, 100], [1; 0; 0], [-1e-4; 1e-4; 0]); |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
415 %! assert (t(5)-t(4), 1e-3, 1e-3); |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
416 |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
417 ## AbsTol scalar option |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
418 %!testif HAVE_SUNDIALS |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
419 %! opt = odeset ("AbsTol", 1e-8); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
420 %! [t, y] = ode15i (@rob, [0, 100], [1; 0; 0], [-1e-4; 1e-4; 0], opt); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
421 %! assert ([t(end), y(end,:)], fref, 1e-3); |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
422 |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
423 ## AbsTol scalar and RelTol option |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
424 %!testif HAVE_SUNDIALS |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
425 %! opt = odeset ("AbsTol", 1e-8, "RelTol", 1e-6); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
426 %! [t, y] = ode15i (@rob, [0, 100], [1; 0; 0], [-1e-4; 1e-4; 0], opt); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
427 %! assert ([t(end), y(end,:)], fref, 1e-3); |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
428 |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
429 ## AbsTol vector option |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
430 %!testif HAVE_SUNDIALS |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
431 %! opt = odeset ("AbsTol", [1e-8, 1e-14, 1e-6]); |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
432 %! [t, y] = ode15i (@rob, [0, 100], [1; 0; 0], [-1e-4; 1e-4; 0], opt); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
433 %! assert ([t(end), y(end,:)], fref, 1e-3); |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
434 |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
435 ## AbsTol vector and RelTol option |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
436 %!testif HAVE_SUNDIALS |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
437 %! opt = odeset ("AbsTol", [1e-8, 1e-14,1e-6], "RelTol", 1e-6); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
438 %! [t, y] = ode15i (@rob, [0, 100], [1; 0; 0], [-1e-4;1e-4;0], opt); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
439 %! assert ([t(end), y(end,:)], fref, 1e-3); |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
440 |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
441 ## RelTol option |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
442 %!testif HAVE_SUNDIALS |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
443 %! opt = odeset ("RelTol", 1e-6); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
444 %! [t, y] = ode15i (@rob, [0, 100], [1; 0; 0], [-1e-4; 1e-4; 0], opt); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
445 %! assert ([t(end), y(end,:)], fref, 1e-3); |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
446 |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
447 ## Jacobian fun dense |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
448 %!testif HAVE_SUNDIALS |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
449 %! opt = odeset ("Jacobian", @jacfundense); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
450 %! [t, y] = ode15i (@rob, [0, 100], [1; 0; 0], [-1e-4; 1e-4; 0], opt); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
451 %! assert ([t(end), y(end,:)], fref, 1e-3); |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
452 |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
453 ## Jacobian fun dense as string |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
454 %!testif HAVE_SUNDIALS |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
455 %! opt = odeset ("Jacobian", "jacfundense"); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
456 %! [t, y] = ode15i (@rob, [0, 100], [1; 0; 0], [-1e-4; 1e-4; 0], opt); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
457 %! assert ([t(end), y(end,:)], fref, 1e-3); |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
458 |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
459 ## Jacobian fun sparse |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
460 %!testif HAVE_SUNDIALS |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
461 %! opt = odeset ("Jacobian", @jacfunsparse, "AbsTol", 1e-7, "RelTol", 1e-7); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
462 %! [t, y] = ode15i (@rob, [0, 100], [1; 0; 0], [-1e-4; 1e-4; 0], opt); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
463 %! assert ([t(end), y(end,:)], fref, 1e-3); |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
464 |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
465 ## Solve in backward direction starting at t=100 |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
466 %!testif HAVE_SUNDIALS |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
467 %! YPref = [-0.001135972751027; -0.000000027483627; 0.001136000234654]; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
468 %! Yref = [0.617234887614937, 0.000006153591397, 0.382758958793666]; |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
469 %! [t, y] = ode15i (@rob, [0, 100], [1; 0; 0], [-1e-4; 1e-4; 0]); |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
470 %! [t2, y2] = ode15i (@rob, [100, 0], Yref', YPref); |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
471 %! assert ([t2(end), y2(end,:)], [0, 1, 0, 0], 2e-2); |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
472 |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
473 ## Solve in backward direction with MaxStep option |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
474 #%!testif HAVE_SUNDIALS |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
475 %! YPref = [-0.001135972751027; -0.000000027483627; 0.001136000234654]; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
476 %! Yref = [0.617234887614937, 0.000006153591397, 0.382758958793666]; |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
477 %! opt = odeset ("MaxStep", 1e-2); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
478 %! [t, y] = ode15i (@rob, [0, 100], [1; 0; 0], [-1e-4; 1e-4; 0]); |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
479 %! [t2, y2] = ode15i (@rob, [100, 0], Yref', YPref, opt); |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
480 %! assert ([t2(end), y2(end,:)], [0, 1, 0, 0], 2e-2); |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
481 %! assert (t2(9)-t2(10), 1e-2, 1e-2); |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
482 |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
483 ## Solve in backward direction starting with intermediate step |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
484 #%!testif HAVE_SUNDIALS |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
485 %! YPref = [-0.001135972751027; -0.000000027483627; 0.001136000234654]; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
486 %! Yref = [0.617234887614937, 0.000006153591397, 0.382758958793666]; |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
487 %! [t, y] = ode15i (@rob, [0, 100], [1; 0; 0], [-1e-4; 1e-4; 0]); |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
488 %! [t2, y2] = ode15i (@rob, [100, 5, 0], Yref', YPref); |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
489 %! assert ([t2(end), y2(end,:)], [0, 1, 0, 0], 2e-2); |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
490 |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
491 ## Refine |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
492 %!testif HAVE_SUNDIALS |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
493 %! opt = odeset ("Refine", 3); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
494 %! [t, y] = ode15i (@rob, [0, 100], [1; 0; 0], [-1e-4; 1e-4; 0]); |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
495 %! [t2, y2] = ode15i (@rob, [0, 100], [1; 0; 0], [-1e-4; 1e-4; 0], opt); |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
496 %! assert (numel (t2), numel (t) * 3, 3); |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
497 |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
498 ## Refine ignored if numel (trange) > 2 |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
499 %!testif HAVE_SUNDIALS |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
500 %! opt = odeset ("Refine", 3); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
501 %! [t, y] = ode15i (@rob, [0, 10, 100], [1; 0; 0], [-1e-4; 1e-4; 0]); |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
502 %! [t2, y2] = ode15i (@rob, [0, 10, 100], [1; 0; 0], [-1e-4; 1e-4; 0], opt); |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
503 %! assert (numel (t2), numel (t)); |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
504 |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
505 ## Events option add further elements in sol |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
506 %!testif HAVE_SUNDIALS |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
507 %! opt = odeset ("Events", @ff); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
508 %! sol = ode15i (@rob, [0, 100], [1; 0; 0], [-1e-4; 1e-4; 0], opt); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
509 %! assert (isfield (sol, "ie")); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
510 %! assert (sol.ie, [0;1]); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
511 %! assert (isfield (sol, "xe")); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
512 %! assert (isfield (sol, "ye")); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
513 %! assert (sol.x(end), 10, 1); |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
514 |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
515 ## Events option, five output arguments |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
516 %!testif HAVE_SUNDIALS |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
517 %! opt = odeset ("Events", @ff); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
518 %! [t, y, te, ye, ie] = ode15i (@rob, [0, 100], [1; 0; 0], |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
519 %! [-1e-4; 1e-4; 0], opt); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22902
diff
changeset
|
520 %! assert ([t(end), te', ie'], [10, 10, 10, 0, 1], [1, 0.2, 0.2, 0, 0]); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
521 |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
522 ## Jacobian fun wrong dimension |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
523 %!testif HAVE_SUNDIALS |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
524 %! opt = odeset ("Jacobian", @jacwrong); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
525 %! fail ("[t, y] = ode15i (@rob, [0, 4e6], [1; 0; 0], [-1e-4; 1e-4; 0], opt)", |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
526 %! "ode15i: invalid value assigned to field 'Jacobian'"); |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
527 |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
528 ## Jacobian cell dense wrong dimension |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
529 %!testif HAVE_SUNDIALS |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
530 %! DFDY = [-0.04, 1; |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
531 %! 0.04, 1]; |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
532 %! DFDYP = [-1, 0, 0; |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
533 %! 0, -1, 0; |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
534 %! 0, 0, 0]; |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
535 %! opt = odeset ("Jacobian", {DFDY, DFDYP}); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
536 %! fail ("[t, y] = ode15i (@rob, [0, 4e6], [1; 0; 0], [-1e-4; 1e-4; 0], opt)", |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
537 %! "invalid value assigned to field 'Jacobian'"); |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
538 |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
539 ## Jacobian cell sparse wrong dimension |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
540 %!testif HAVE_SUNDIALS |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
541 %! DFDY = sparse ([-0.04, 1; |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
542 %! 0.04, 1]); |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
543 %! DFDYP = sparse ([-1, 0, 0; |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
544 %! 0, -1, 0; |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
545 %! 0, 0, 0]); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
546 %! opt = odeset ("Jacobian", {DFDY, DFDYP}); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
547 %! fail ("[t, y] = ode15i (@rob, [0, 4e6], [1; 0; 0], [-1e-4; 1e-4; 0], opt)", |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
548 %! "invalid value assigned to field 'Jacobian'"); |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
549 |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
550 ## Jacobian cell wrong number of matrices |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
551 %!testif HAVE_SUNDIALS |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
552 %! A = [1 2 3; 4 5 6; 7 8 9]; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
553 %! opt = odeset ("Jacobian", {A,A,A}); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
554 %! fail ("[t, y] = ode15i (@rob, [0, 4e6], [1; 0; 0], [-1e-4; 1e-4; 0], opt)", |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
555 %! "invalid value assigned to field 'Jacobian'"); |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
556 |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
557 ## Jacobian single matrix |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
558 %!testif HAVE_SUNDIALS |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
559 %! opt = odeset ("Jacobian", [1 2 3; 4 5 6; 7 8 9]); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
560 %! fail ("[t, y] = ode15i (@rob, [0, 4e6], [1; 0; 0], [-1e-4; 1e-4; 0], opt)", |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
561 %! "invalid value assigned to field 'Jacobian'"); |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
562 |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
563 ## Jacobian single matrix wrong dimension |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
564 %!testif HAVE_SUNDIALS |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
565 %! opt = odeset ("Jacobian", [1 2 3; 4 5 6]); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
566 %! fail ("[t, y] = ode15i (@rob, [0, 4e6], [1; 0; 0], [-1e-4; 1e-4; 0], opt)", |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
567 %! "invalid value assigned to field 'Jacobian'"); |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
568 |
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
569 ## Jacobian strange field |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
570 ## FIXME: we need a better way to silence the warning from odeset. |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
571 %!testif HAVE_SUNDIALS |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
572 %! saved_opts = warning (); |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
573 %! warning ("off", "all"); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
574 %! opt = odeset ("Jacobian", "foo"); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
575 %! fail ("[t, y] = ode15i (@rob, [0, 4e6], [1; 0; 0], [-1e-4; 1e-4; 0], opt)", |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
576 %! "invalid value assigned to field 'Jacobian'"); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
577 %! warning (saved_opts); |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
578 |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22902
diff
changeset
|
579 %!function ydot = fun (t, y, yp) |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
580 %! ydot = [y - yp]; |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
581 %!endfunction |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
582 |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
583 %!testif HAVE_SUNDIALS |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
584 %! fail ("ode15i ()", "Invalid call to ode15i"); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
585 |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
586 %!testif HAVE_SUNDIALS |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
587 %! fail ("ode15i (1)", "Invalid call to ode15i"); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
588 |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
589 %!testif HAVE_SUNDIALS |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
590 %! fail ("ode15i (1, 1)", "Invalid call to ode15i"); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
591 |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
592 %!testif HAVE_SUNDIALS |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
593 %! fail ("ode15i (1, 1, 1)", "Invalid call to ode15i"); |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
594 |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
595 %!testif HAVE_SUNDIALS |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
596 %! fail ("ode15i (1, 1, 1, 1)", "ode15i: fun must be of class:"); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
597 |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
598 %!testif HAVE_SUNDIALS |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
599 %! fail ("ode15i (1, 1, 1, 1, 1)", "ode15i: fun must be of class:"); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
600 |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
601 %!testif HAVE_SUNDIALS |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
602 %! fail ("ode15i (1, 1, 1, 1, 1, 1)", "ode15i: fun must be of class:"); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
603 |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
604 %!testif HAVE_SUNDIALS |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
605 %! fail ("ode15i (@fun, 1, 1, 1)", |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
606 %! "ode15i: invalid value assigned to field 'trange'"); |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
607 |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
608 %!testif HAVE_SUNDIALS |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
609 %! fail ("ode15i (@fun, [1, 1], 1, 1)", |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
610 %! "ode15i: invalid value assigned to field 'trange'"); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
611 |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
612 %!testif HAVE_SUNDIALS |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
613 %! fail ("ode15i (@fun, [1, 2], 1, [1, 2])", |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
614 %! "ode15i: y0 must have 2 elements"); |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
615 |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
616 %!testif HAVE_SUNDIALS |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
617 %! opt = odeset ("RelTol", "foo"); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
618 %! fail ("[t, y] = ode15i (@fun, [0, 2], 2, 2, opt)", |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
619 %! "ode15i: RelTol must be of class:"); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
620 |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
621 %!testif HAVE_SUNDIALS |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
622 %! opt = odeset ("RelTol", [1, 2]); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
623 %! fail ("[t, y] = ode15i (@fun, [0, 2], 2, 2, opt)", |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
624 %! "ode15i: RelTol must be scalar"); |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
625 |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
626 %!testif HAVE_SUNDIALS |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
627 %! opt = odeset ("RelTol", -2); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
628 %! fail ("[t, y] = ode15i (@fun, [0, 2], 2, 2, opt)", |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
629 %! "ode15i: RelTol must be positive"); |
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
630 |
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
631 %!testif HAVE_SUNDIALS |
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
632 %! opt = odeset ("AbsTol", "foo"); |
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
633 %! fail ("[t, y] = ode15i (@fun, [0, 2], 2, 2, opt)", |
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
634 %! "ode15i: AbsTol must be of class:"); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
635 |
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
636 %!testif HAVE_SUNDIALS |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
637 %! opt = odeset ("AbsTol", -1); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
638 %! fail ("[t, y] = ode15i (@fun, [0, 2], 2, 2, opt)", |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
639 %! "ode15i: AbsTol must be positive"); |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
640 |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
641 %!testif HAVE_SUNDIALS |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
642 %! opt = odeset ("AbsTol", [1, 1, 1]); |
22931
8133da976602
* ode15i.m: Make error tests conditional on HAVE_SUNDIALS.
John W. Eaton <jwe@octave.org>
parents:
22928
diff
changeset
|
643 %! fail ("[t, y] = ode15i (@fun, [0, 2], 2, 2, opt)", |
22933
c3428bb9aca9
ode15i.m, ode15s.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22931
diff
changeset
|
644 %! "ode15i: invalid value assigned to field 'AbsTol'"); |
22928
dec22bceafa2
use testif HAVE_SUNDIALS for ode15 tests
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
645 |