help-octave
[Top][All Lists]
Advanced

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

Re: Help with ODE solver


From: Michael Hanke
Subject: Re: Help with ODE solver
Date: Thu, 12 Sep 2002 08:31:23 +0200

Hi:

If I understand you correctly, the first property will defin itely not work. 
There are two reasons for that:
1. The identity t==t_i will almost never be fulfilled because the integration 
routine adapts the values where f is called according to your problem and 
accuracy requirements. Even if it would take t_i theoretically, equality is 
very unlikely to be fulfilled because of possible rounding errors. In short: 
Never check floating point numbers for equatlity!
2. Changing state variables leads to a discontinuity in the right hand side 
of your problem. This will lead to a breakdown of the control structures. 
Most common, you will obtain stepsize underflow near t_i. You must give the 
code a chance to reinitialize. This is only possible with the second approach.

HTH

Michael

Am Mittwoch 11 September 2002 22:09 schrieb Marco Antoniotti:
> Hi
>
> I am using the LSODE solver for my research and now need to do the
> following.
>
> At a time t_i, I need to change the value of one (or more) of the
> variable(s) involved.
>
> I think I understand I have two avenues to follow to achieve this
> goal, but, given my inexperience with Octave (and/or Matlab) I don't
> know which is the best one.
>
> 1 - I could insert a specific test in the derivative function
>
>   function xdot = f(x, t)
>     xdot = zeros(rows(x), 1);
>
>     if (t == t_i)
>        ## set x(k) to M
>     endif
>
>     xdot(1) = ...
>     ...
>     xdot(n) = ...
>
>   endfunction
>
>
> 2 - I could break down the integration into intervals and set the
>     variable value between integrations.
>
> I'd like some comments about what would be the "best" (for an
> approrpiate definition of "best") way to achieve this goal.
>
> Thanks

-- 
+---------------------------------------------------------------+
|  Michael Hanke                Royal Institute of Technology   |
|                               NADA                            |
|                               S-10044 Stockholm               |
|                               Sweden                          |
+---------------------------------------------------------------+
|  Visiting address:            Lindstedtsvaegen 3              |
|  Phone:                       + (46) (8) 790 6278             |
|  Fax:                         + (46) (8) 790 0930             |
|  Email:                       address@hidden               |
|                               address@hidden       |
+---------------------------------------------------------------+



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

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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