1 %# Copyright (C) 2006-2012, Thomas Treichl <treichl@users.sourceforge.net>
2 %# OdePkg - A package for solving ordinary differential equations and more
4 %# This program is free software; you can redistribute it and/or modify
5 %# it under the terms of the GNU General Public License as published by
6 %# the Free Software Foundation; either version 2 of the License, or
7 %# (at your option) any later version.
9 %# This program is distributed in the hope that it will be useful,
10 %# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 %# GNU General Public License for more details.
14 %# You should have received a copy of the GNU General Public License
15 %# along with this program; If not, see <http://www.gnu.org/licenses/>.
18 %# @deftypefn {Function File} {[@var{}] =} odepkg ()
20 %# OdePkg is part of the GNU Octave Repository (the Octave--Forge project). The package includes commands for setting up various options, output functions etc. before solving a set of differential equations with the solver functions that are also included. At this time OdePkg is under development with the main target to make a package that is mostly compatible to proprietary solver products.
22 %# If this function is called without any input argument then open the OdePkg tutorial in the Octave window. The tutorial can also be opened with the following command
29 function [] = odepkg (vstr)
31 %# Check number and types of all input arguments
35 error ('Number of input arguments must be zero or one');
36 elseif (ischar (vstr))
39 error ('Input argument must be a valid string');
42 function [] = odepkg_validate_mfiles ()
44 %# From command line in the 'inst' directory do something like this:
45 %# octave --quiet --eval "odepkg ('odepkg_validate_mfiles')"
47 vfun = {'ode23', 'ode45', 'ode54', 'ode78', ...
48 'ode23d', 'ode45d', 'ode54d', 'ode78d', ...
49 'odeget', 'odeset', 'odeplot', 'odephas2', 'odephas3', 'odeprint', ...
50 'odepkg_structure_check', 'odepkg_event_handle', ...
51 'odepkg_testsuite_calcscd', 'odepkg_testsuite_calcmescd'};
52 %# vfun = sort (vfun);
54 for vcnt=1:length(vfun)
55 printf ('Testing function %s ... ', vfun{vcnt});
56 test (vfun{vcnt}, 'quiet'); fflush (1);
59 function [] = odepkg_validate_ccfiles ()
61 %# From command line in the 'src' directory do something like this:
62 %# octave --quiet --eval "odepkg ('odepkg_validate_ccfiles')"
64 vfile = {'odepkg_octsolver_mebdfdae.cc', 'odepkg_octsolver_mebdfi.cc', ...
65 'odepkg_octsolver_ddaskr.cc', ...
66 'odepkg_octsolver_radau.cc', 'odepkg_octsolver_radau5.cc', ...
67 'odepkg_octsolver_rodas.cc', 'odepkg_octsolver_seulex.cc'};
68 vsolv = {'odebda', 'odebdi', 'odekdi', ...
69 'ode2r', 'ode5r', 'oders', 'odesx'};
70 %# vfile = {'odepkg_octsolver_ddaskr.cc'};
71 %# vsolv = {'odekdi'};
73 for vcnt=1:length(vfile)
74 printf ('Testing function %s ... ', vsolv{vcnt});
75 autoload (vsolv{vcnt}, which ('dldsolver.oct'));
76 test (vfile{vcnt}, 'quiet'); fflush (1);
79 function [] = odepkg_internal_mhelpextract ()
81 %# In the inst directory do
82 %# octave --quiet --eval "odepkg ('odepkg_internal_mhelpextract')"
84 vfun = {'odepkg', 'odeget', 'odeset', ...
85 'ode23', 'ode45', 'ode54', 'ode78', ...
86 'ode23d', 'ode45d', 'ode54d', 'ode78d', ...
88 'odeplot', 'odephas2', 'odephas3', 'odeprint', ...
89 'odepkg_structure_check', 'odepkg_event_handle', ...
90 'odepkg_testsuite_calcscd', 'odepkg_testsuite_calcmescd', ...
91 'odepkg_testsuite_oregonator', 'odepkg_testsuite_pollution', ...
92 'odepkg_testsuite_hires', ...
93 'odepkg_testsuite_robertson', 'odepkg_testsuite_chemakzo', ...
94 'odepkg_testsuite_transistor', ...
95 'odepkg_testsuite_implrober', 'odepkg_testsuite_implakzo', ...
96 'odepkg_testsuite_imptrans', ...
97 'odeexamples', 'odepkg_examples_ode', 'odepkg_examples_dae', ...
98 'odepkg_examples_ide', 'odepkg_examples_dde'};
101 [vout, vmsg] = fopen ('../doc/mfunref.texi', 'w');
102 if ~(isempty (vmsg)), error (vmsg); end
103 for vcnt = 1:length (vfun)
104 if (exist (vfun{vcnt}, 'file'))
105 [vfid, vmsg] = fopen (which (vfun{vcnt}), 'r');
106 if ~(isempty (vmsg)), error (vmsg); end
109 if ~(ischar (vlin)), break; end
110 if (regexp (vlin, '^(%# -\*- texinfo -\*-)'))
111 while (~isempty (regexp (vlin, '^(%#)')) && ...
112 isempty (regexp (vlin, '^(%# @end deftypefn)')))
114 if (length (vlin) > 3), fprintf (vout, '%s', vlin(4:end));
115 else fprintf (vout, '%s', vlin(3:end));
118 fprintf (vout, '\n');
126 function [] = odepkg_internal_octhelpextract ()
128 %# In the src directory do
129 %# octave --quiet --eval "odepkg ('odepkg_internal_octhelpextract')"
131 vfiles = {'../src/odepkg_octsolver_mebdfdae.cc', ...
132 '../src/odepkg_octsolver_mebdfi.cc', ...
133 '../src/odepkg_octsolver_ddaskr.cc', ...
134 '../src/odepkg_octsolver_radau.cc', ...
135 '../src/odepkg_octsolver_radau5.cc', ...
136 '../src/odepkg_octsolver_rodas.cc', ...
137 '../src/odepkg_octsolver_seulex.cc', ...
139 %# vfiles = sort (vfiles); Don't sort these files
141 [vout, vmsg] = fopen ('../doc/dldfunref.texi', 'w');
142 if ~(isempty (vmsg)), error (vmsg); end
143 for vcnt = 1:length (vfiles)
144 if (exist (vfiles{vcnt}, 'file'))
145 [vfid, vmsg] = fopen (vfiles{vcnt}, 'r');
146 if ~(isempty (vmsg)), error (vmsg); end
149 if ~(ischar (vlin)), break; end
150 if (regexp (vlin, '^("-\*- texinfo -\*-\\n\\)')) %#"
151 vlin = ' * '; %# Needed for the first call of while()
152 while (isempty (regexp (vlin, '^(@end deftypefn)')) && ischar (vlin))
154 vlin = sprintf (regexprep (vlin, '\\n\\', ''));
155 vlin = regexprep (vlin, '\\"', '"');
156 fprintf (vout, '%s', vlin);
158 fprintf (vout, '\n');
166 function [] = odepkg_performance_mathires ()
167 vfun = {@ode113, @ode23, @ode45, ...
168 @ode15s, @ode23s, @ode23t, @ode23tb};
169 for vcnt=1:length(vfun)
170 vsol{vcnt, 1} = odepkg_testsuite_hires (vfun{vcnt}, 1e-7);
172 odepkg_testsuite_write (vsol);
174 function [] = odepkg_performance_octavehires ()
175 vfun = {@ode23, @ode45, @ode54, @ode78, ...
176 @ode2r, @ode5r, @oders, @odesx, @odebda};
177 for vcnt=1:length(vfun)
178 vsol{vcnt, 1} = odepkg_testsuite_hires (vfun{vcnt}, 1e-7);
180 odepkg_testsuite_write (vsol);
182 function [] = odepkg_performance_matchemakzo ()
183 vfun = {@ode23, @ode45, ...
184 @ode15s, @ode23s, @ode23t, @ode23tb};
185 for vcnt=1:length(vfun)
186 vsol{vcnt, 1} = odepkg_testsuite_chemakzo (vfun{vcnt}, 1e-7);
188 odepkg_testsuite_write (vsol);
190 function [] = odepkg_performance_octavechemakzo ()
191 vfun = {@ode23, @ode45, @ode54, @ode78, ...
192 @ode2r, @ode5r, @oders, @odesx, @odebda};
193 for vcnt=1:length(vfun)
194 vsol{vcnt, 1} = odepkg_testsuite_chemakzo (vfun{vcnt}, 1e-7);
196 odepkg_testsuite_write (vsol);
198 function [] = odepkg_testsuite_write (vsol)
200 fprintf (1, ['-----------------------------------------------------------------------------------------\n']);
201 fprintf (1, [' Solver RelTol AbsTol Init Mescd Scd Steps Accept FEval JEval LUdec Time\n']);
202 fprintf (1, ['-----------------------------------------------------------------------------------------\n']);
204 [vlin, vcol] = size (vsol);
206 if (isempty (vsol{vcntlin}{9})), vsol{vcntlin}{9} = 0; end
207 %# if (vcntlin > 1) %# Delete solver name if it is the same as before
208 %# if (strcmp (func2str (vsol{vcntlin}{1}), func2str (vsol{vcntlin-1}{1})))
209 %# vsol{vcntlin}{1} = ' ';
212 fprintf (1, ['%7s %6.0g %6.0g %6.0g %5.2f %5.2f %5.0d %6.0d %5.0d %5.0d %5.0d %6.3f\n'], ...
213 func2str (vsol{vcntlin}{1}), vsol{vcntlin}{2:12});
215 fprintf (1, ['-----------------------------------------------------------------------------------------\n']);
217 function [] = odepkg_internal_demos ()
219 vfun = {'odepkg', 'odeget', 'odeset', ...
220 'ode23', 'ode45', 'ode54', 'ode78', ...
221 'ode23d', 'ode45d', 'ode54d', 'ode78d', ...
222 'odeplot', 'odephas2', 'odephas3', 'odeprint', ...
223 'odepkg_structure_check', 'odepkg_event_handle'};
226 for vcnt = 1:length (vfun), demo (vfun{vcnt}); end
228 %# Local Variables: ***