[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help with ODE solver

From: John W. Eaton
Subject: Re: Help with ODE solver
Date: Thu, 12 Sep 2002 09:19:13 -0500

On 12-Sep-2002, Martin Senator <address@hidden> wrote:

| Is there a way to use the interpolation feature of LSODE when the
| function
| xdot = f(x,t) changes abruptly at a particular value of one of the
| components of the dependent variable?  There is no problem with
| integrating past the change using the old value of the function.  I have
| been leaving the integration routine and doing the interpolations myself
| and would be happy to find a way to let LSODE handle the job.

If I understand your question correctly, then this is exactly what the
tcrit argument for lsode is all about.  Perhaps my previous message
wasn't clear.  Use the tcrit argument to tell lsode about the
discontinuities.  If you want to ensure that tout includes all those
points too, then do something like the following:

  tout = (0:100)';  ## or whatever;
  tcrit = [ some; list; of; points; where; rhs; function; changes ];
  ## now, merge the to sets of output points, delete duplicates, and
  ## make sure they are in ascending order:
  tout = sort (create_set ([tout, tcrit]));
  x = lsode ('f', x0, tout, tcrit);

Now, x will contain solutions at all the tout points.  In this
example, tout includes all the tcrit points, but it is not necessary
to merge them unless you want to see the output at those points too.
You do not have to break up the interval and call lsode multiple times
in a loop -- lsode will reset itself when it hits the tcrit points.

This feature should work in both the current 2.0.x and 2.1.x
versions.  If not, then please submit a complete bug report.



Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:
How to fund new projects:
Subscription information:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]