changeset 20908:0fb9de5b7903

remove verbose warnings from ode solvers * scripts/ode/ode{23,45}.m: remove warnings about default values. * scripts/ode/module.mk: reorder files in alphabetical order. * scripts/ode/{ode_struct_value_check.m,odeget.m,odeset.m}: add options for integrators with fixed step.
author Carlo de Falco <carlo.defalco@polimi.it>
date Wed, 16 Dec 2015 10:25:05 +0100
parents 40e1134ec984
children 03e4ddd49396
files scripts/ode/module.mk scripts/ode/ode23.m scripts/ode/ode45.m scripts/ode/odeget.m scripts/ode/odeset.m scripts/ode/private/ode_struct_value_check.m
diffstat 6 files changed, 29 insertions(+), 86 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ode/module.mk	Tue Dec 15 19:25:43 2015 -0500
+++ b/scripts/ode/module.mk	Wed Dec 16 10:25:05 2015 +0100
@@ -8,19 +8,20 @@
   scripts/ode/private/integrate_const.m \
   scripts/ode/private/integrate_n_steps.m \
   scripts/ode/private/kahan.m \
+  scripts/ode/private/known_option_names \
   scripts/ode/private/ode_event_handler.m \
   scripts/ode/private/ode_struct_value_check.m \
+  scripts/ode/private/runge_kutta_23.m \
   scripts/ode/private/runge_kutta_45_dorpri.m \
   scripts/ode/private/runge_kutta_interpolate.m \
-  scripts/ode/private/starting_stepsize.m \
-  scripts/ode/private/runge_kutta_23.m
+  scripts/ode/private/starting_stepsize.m
 
-scripts_ode_FCN_FILES = \
+scripts_ode_FCN_FILES =  \
+  scripts/ode/ode23.m \
   scripts/ode/ode45.m \
   scripts/ode/odeset.m \
   scripts/ode/odeget.m \
-  scripts/ode/odeplot.m \
-  scripts/ode/ode23.m
+  scripts/ode/odeplot.m
 
 scripts_odedir = $(fcnfiledir)/ode
 
--- a/scripts/ode/ode23.m	Tue Dec 15 19:25:43 2015 -0500
+++ b/scripts/ode/ode23.m	Wed Dec 16 10:25:05 2015 +0100
@@ -195,9 +195,6 @@
 
   if (isempty (odeopts.RelTol) && ! odeopts.stepsizefixed)
     odeopts.RelTol = 1e-3;
-    warning ("Octave:invalid-input-arg",
-             "ode23: option \"RelTol\" not set, new value %f will be used\n",
-             odeopts.RelTol);
   elseif (! isempty (odeopts.RelTol) && odeopts.stepsizefixed)
     warning ("Octave:invalid-input-arg",
              ["ode23: option \"RelTol\" is ignored", ...
@@ -206,9 +203,6 @@
 
   if (isempty (odeopts.AbsTol) && ! odeopts.stepsizefixed)
     odeopts.AbsTol = 1e-6;
-    warning ("Octave:invalid-input-arg",
-             "ode23: option \"AbsTol\" not set, new value %f will be used\n",
-             odeopts.AbsTol);
   elseif (! isempty (odeopts.AbsTol) && odeopts.stepsizefixed)
     warning ("Octave:invalid-input-arg",
              ["ode23: option \"AbsTol\" is ignored", ...
@@ -248,22 +242,17 @@
   endif
 
   if (isempty (odeopts.InitialStep) && strcmp (integrate_func, "adaptive"))
-    odeopts.InitialStep = odeopts.direction* ...
-      starting_stepsize (order, fun, trange(1), init, odeopts.AbsTol,
-                         odeopts.RelTol, odeopts.normcontrol);
-    warning ("Octave:invalid-input-arg",
-             ["ode23: option \"InitialStep\" not set,", ...
-              " estimated value %f will be used\n"],
-             odeopts.InitialStep);
+    odeopts.InitialStep = odeopts.direction * ...
+                          starting_stepsize (order, fun, trange(1),
+                                             init, odeopts.AbsTol,
+                                             odeopts.RelTol,
+                                             odeopts.normcontrol);
   elseif (isempty (odeopts.InitialStep))
     odeopts.InitialStep = TimeStepSize;
   endif
 
   if (isempty (odeopts.MaxStep) && ! odeopts.stepsizefixed)
     odeopts.MaxStep = abs (trange(end) - trange(1)) / 10;
-    warning ("Octave:invalid-input-arg",
-             "ode23: option \"MaxStep\" not set, new value %f will be used\n",
-             odeopts.MaxStep);
   endif
 
   odeopts.haveeventfunction = ! isempty (odeopts.Events);
@@ -566,17 +555,6 @@
 %!  [t, y, vxe, ye, vie] = ode23 (@fpol, [0 10], [2 0], opt);
 %!  assert ([vie, vxe, ye], ...
 %!    [2.0, 2.496110, -0.830550, -2.677589], 1e-1);
-%!test ## Jacobian option
-%!  opt = odeset ("Jacobian", @fjac);
-%!  sol = ode23 (@fpol, [0 2], [2 0], opt);
-%!  assert ([sol.x(end), sol.y(end,:)], [2, fref], 1e-3);
-%!test ## Jacobian option and sparse return value
-%!  opt = odeset ("Jacobian", @fjcc);
-%!  sol = ode23 (@fpol, [0 2], [2 0], opt);
-%!  assert ([sol.x(end), sol.y(end,:)], [2, fref], 1e-3);
-%!
-%! ## test for JPattern option is missing
-%! ## test for Vectorized option is missing
 %!
 %!test ## Mass option as function
 %!  opt = odeset ("Mass", @fmas);
@@ -598,10 +576,6 @@
 %!  opt = odeset ("Mass", @fmas, "MStateDependence", "strong");
 %!  sol = ode23 (@fpol, [0 2], [2 0], opt);
 %!  assert ([sol.x(end), sol.y(end,:)], [2, fref], 1e-3);
-%!test ## Set BDF option to something else than default
-%!  opt = odeset ("BDF", "on");
-%!  [t, y] = ode23 (@fpol, [0 2], [2 0], opt);
-%!  assert ([t(end), y(end,:)], [2, fref], 1e-3);
 %!
 %! ## test for MvPattern option is missing
 %! ## test for InitialSlope option is missing
--- a/scripts/ode/ode45.m	Tue Dec 15 19:25:43 2015 -0500
+++ b/scripts/ode/ode45.m	Wed Dec 16 10:25:05 2015 +0100
@@ -178,9 +178,6 @@
 
   if (isempty (odeopts.RelTol) && ! odeopts.stepsizefixed)
     odeopts.RelTol = 1e-3;
-    warning ("Octave:invalid-input-arg",
-             "ode45: option 'RelTol' not set, new value %f will be used\n",
-             odeopts.RelTol);
   elseif (! isempty (odeopts.RelTol) && odeopts.stepsizefixed)
     warning ("Octave:invalid-input-arg",
              ["ode45: option 'RelTol' is ignored", ...
@@ -189,9 +186,6 @@
 
   if (isempty (odeopts.AbsTol) && ! odeopts.stepsizefixed)
     odeopts.AbsTol = 1e-6;
-    warning ("Octave:invalid-input-arg",
-             "ode45: option 'AbsTol' not set, new value %f will be used\n",
-             odeopts.AbsTol);
   elseif (! isempty (odeopts.AbsTol) && odeopts.stepsizefixed)
     warning ("Octave:invalid-input-arg",
              ["ode45: option 'AbsTol' is ignored", ...
@@ -237,19 +231,12 @@
                                                   odeopts.AbsTol,
                                                   odeopts.RelTol,
                                                   odeopts.normcontrol);
-    warning ("Octave:invalid-input-arg",
-             ["ode45: option 'InitialStep' not set,", ...
-              " estimated value %f will be used\n"],
-             odeopts.InitialStep);
   elseif (isempty (odeopts.InitialStep))
     odeopts.InitialStep = TimeStepSize;
   endif
 
   if (isempty (odeopts.MaxStep) && ! odeopts.stepsizefixed)
     odeopts.MaxStep = abs (trange(end) - trange(1)) / 10;
-    warning ("Octave:invalid-input-arg",
-             "ode45: option 'MaxStep' not set, new value %f will be used\n",
-             odeopts.MaxStep);
   endif
 
   odeopts.haveeventfunction = ! isempty (odeopts.Events);
@@ -569,18 +556,6 @@
 %! [t, y, vxe, ye, vie] = ode45 (@fpol, [0 10], [2 0], opt);
 %! assert ([vie, vxe, ye],
 %!         [2.0, 2.496110, -0.830550, -2.677589], 6e-1);
-%!test  # Jacobian option
-%! opt = odeset ("Jacobian", @fjac);
-%! sol = ode45 (@fpol, [0 2], [2 0], opt);
-%! assert ([sol.x(end), sol.y(end,:)], [2, fref], 1e-3);
-%!test  # Jacobian option and sparse return value
-%! opt = odeset ("Jacobian", @fjcc);
-%! sol = ode45 (@fpol, [0 2], [2 0], opt);
-%! assert ([sol.x(end), sol.y(end,:)], [2, fref], 1e-3);
-
-## test for JPattern option is missing
-## test for Vectorized option is missing
-
 %!test  # Mass option as function
 %! opt = odeset ("Mass", @fmas);
 %! sol = ode45 (@fpol, [0 2], [2 0], opt);
@@ -601,16 +576,3 @@
 %! opt = odeset ("Mass", @fmas, "MStateDependence", "strong");
 %! sol = ode45 (@fpol, [0 2], [2 0], opt);
 %! assert ([sol.x(end), sol.y(end,:)], [2, fref], 1e-3);
-%!test  # Set BDF option to something other than default
-%! opt = odeset ("BDF", "on");
-%! [t, y] = ode45 (@fpol, [0 2], [2 0], opt);
-%! assert ([t(end), y(end,:)], [2, fref], 1e-3);
-
-## test for MvPattern option is missing
-## test for InitialSlope option is missing
-## test for MaxOrder option is missing
-
-%!test
-%!
-%! #warning ("on", "Octave:invalid-input-arg");
-
--- a/scripts/ode/odeget.m	Tue Dec 15 19:25:43 2015 -0500
+++ b/scripts/ode/odeget.m	Wed Dec 16 10:25:05 2015 +0100
@@ -76,12 +76,7 @@
   ode_struct_value_check ("odeget", ode_opt);
 
   ## Define all the possible ODEOPT fields
-  persistent options = {"AbsTol"; "BDF"; "Events"; "InitialSlope";
-                        "InitialStep"; "Jacobian"; "JConstant"; "JPattern";
-                        "Mass"; "MassConstant"; "MassSingular"; "MaxOrder";
-                        "MaxStep"; "MStateDependence"; "MvPattern";
-                        "NonNegative"; "NormControl"; "OutputFcn"; "OutputSel";
-                        "Refine"; "RelTol"; "Stats"; "Vectorized"};
+  persistent options = known_option_names ();
 
   exactmatch = true;
   match = find (strcmpi (field, options));
--- a/scripts/ode/odeset.m	Tue Dec 15 19:25:43 2015 -0500
+++ b/scripts/ode/odeset.m	Wed Dec 16 10:25:05 2015 +0100
@@ -48,12 +48,7 @@
 function odestruct = odeset (varargin)
 
   ## Column vector of all possible ODE options
-  persistent options = {"AbsTol"; "BDF"; "Events"; "InitialSlope";
-                        "InitialStep"; "Jacobian"; "JConstant"; "JPattern";
-                        "Mass"; "MassConstant"; "MassSingular"; "MaxOrder";
-                        "MaxStep"; "MStateDependence"; "MvPattern";
-                        "NonNegative"; "NormControl"; "OutputFcn"; "OutputSel";
-                        "Refine"; "RelTol"; "Stats"; "Vectorized"};
+  persistent options = known_option_names ();
 
   if (nargin == 0)
     ## Special calling syntax to display defaults
--- a/scripts/ode/private/ode_struct_value_check.m	Tue Dec 15 19:25:43 2015 -0500
+++ b/scripts/ode/private/ode_struct_value_check.m	Wed Dec 16 10:25:05 2015 +0100
@@ -251,6 +251,22 @@
           endif
         endif
 
+      case "TimeStepSize"
+        if (! isempty (val))
+         if (! isscalar (val))
+              error ("Octave:invalid-input-arg",
+                     [caller ": invalid value assigned to field '%s'"], opt);
+         endif
+        endif
+        
+      case "TimeStepNumber"
+        if (! isempty (val))
+          if (! isscalar (val))
+            error ("Octave:invalid-input-arg",
+                   [caller ": invalid value assigned to field '%s'"], opt);
+          endif
+        endif
+
       otherwise
         warning ("Octave:invalid-input-arg",
                  [caller ": unknown field '%s' in ODE options\n"], opt);