[Scilab-users] ODE is returning a vector of wrong size

Tim Wescott tim at wescottdesign.com
Mon Dec 29 21:25:24 CET 2014


On Mon, 2014-12-29 at 17:11 -0300, Ezequiel Soule wrote:
> Hello, when ODE is called to solve a differential equation:
> 
> x=ode(y0, t0, t, f)
> 
> "t" is the vector containing the times at which the solution is computed.
> 
> In some cases, it returns a vector x which has less elements than t!
> 
> When this happens I get a warning message:
> 
> lsoda--  at t (=r1) and step h (=r2), the
>     corrector does not converge
>        with abs(h) = hmin
>        where r1 is :   0.4573527645205D+02   and r2 : 0.1425423380287D-03
> Advertencia: Los resultados pueden ser inexactos.
> 
> Why is this happening and how can it be corrected?

I'm not 100% familiar with Scilab's ODE solver, but it looks like the
simulation is hitting a state where the solver cannot easily converge. 

It's most likely that you're simulating a system which, when linearized,
has eigenvalues that span a wide range, or that change values over a
wide range for different states.  (A classic example of this is a
simulation of a bouncing rubber ball -- the equations of motion for the
ball has two eigenvalues equal (or very close) to zero when the ball is
in the air, but very large compared to the bounce period when the ball
is in contact with the surface it's bouncing on.  The sudden change in
eigenvalues is tough for a solver to cope with.)

The four things that I know of that might help are to:

1: Try a different solver algorithm (see the help page for ODE -- I'd
try "stiff" first, particularly if I were doing something like the
bouncing ball problem)

2: Reduce the time step in t.  This will force the solver to go to a
finer level of detail, and may help it to solve your problem at the cost
of taking longer.

3: Recast your problem so that the system is not so difficult.  This is
not at all possible in many cases, it requires some knowledge of how a
solver works, and in those cases where you and the problem are amenable
to change, it still requires much tedious reworking of the problem --
and often results that are more obscure.

4: Calculate the Jacobian for the solver (i.e., feed it the 'jac'
function).  This can be a big help with difficult systems, particularly
if the Jacobian has discontinuities (as in the bouncing ball problem).

-- 

Tim Wescott
www.wescottdesign.com
Control & Communications systems, circuit & software design.
Phone: 503.631.7815
Cell:  503.349.8432




More information about the users mailing list