From owner-bug-octave at bevo dot che dot wisc dot edu Thu Oct 17 02:54:46 1996 Subject: Bug in Octave's LSODE-function From: Janne Karonen To: bug-octave at che dot utexas dot edu Date: Thu, 17 Oct 1996 08:48:51 -0700 BUG REPORT Author: Janne Karonen E-mail: janne dot karonen at kemira dot com Date: 17.10.1996 NOTE: This bug report has nothing to do with Kemira Oy, author is just speaking for himself. BACKGROUND This bug report deals with Octave's (version 1.1.1) built-in function LSODE and it's use for simulation of set of ODEs. System description Computer: 486 DX/33- clone OS: Linux, kernel 1.2.13 (Slackware 3.0) Octave version: 1.1.1 (binary distribution) PROBLEM DESCRIPTION Introduction Problem with the LSODE function occurred when it was used to simulate laboratory scale heat exchanger. Heat-exchanger model consists of set of temperature derivatives. Model was verified with real input data which was passed to the model as global variables because LSODE doesn't allow more than two arguments for m-file model. Because heat exchanger model is quite large package of files a similar case was conducted to demonstrate the bug. Problem To recreate the bogus behaviour issue the following commands in Octave's command window. Before that make sure you have m-file bug.m in the working directory. lsode_options("relative tolerance",1e-3) lsode_options("absolute tolerance",1e-3) data=lsode("bug",[0],(t=linspace(0,20,21)')); This will lead to the following error messages. error: matrix index = 23 exceeds maximum dimension = 21 error: evaluating index expression near line 9, column 3 error: evaluating assignment expression near line 9, column 2 error: called from 'bug' in file '/home/jkaronen/octave/bug.m' error: lsode: evaluation of user-supplied function failed Simulation of the 'bug.m' can be performed if the maximum step size is set to 1 with the following command. lsode_options("maximum step size",1) When 'bug.m' file is modified commenting out the line which returns the simulation time 't' on every round it can be seen that the last value of 't' is 22,289. This is for some unknown reason over the end point of the simulation. M-FILE --------------------------------------------------------------------- function f=bug(x,t) a=[5 5 5 6 6 6 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2]'; # Comment this out to see how Octave chooses simulation time steps. # t index=(t-(t-floor(t)))+1; b=a(index); f=1/(1+x^2)-b*x^2; endfunction ---------------------------------------------------------------------