odesolvers: preventing negative values



Hi,

I am solving systems of ODE using the matalb ode solvers (ode45 and
ode15s). THese odes represent physical quantitiies that must be
positive (e.g. concentrations or population densities), however, at
various times the some of the solution variables get very small and
numberical error means that sometimes the odesolvers give negative
values. For example, in solving some infectious disease models the
number oif infectives can become very small for a significant period
before the number of susceptibles grows to a sufficient number that the
epidemic rtakes off again. If the numerical method gives small, but
negative numbers, then


What is the best way to deal with this?

1. In my fubction for the RHS of the system, just set y to zero or y to
abs(y) before evaluating the RHS? This is what I currently do, and it
seems to work ok, but I am wondering if it is the best approach?

2. I have seen some mention of using the Event Handling to stop the
solution. But this may well happen lots of times i.e. at every time
step within certain time intervals.


3. Are there some numerical methods that preserve the 'positivity' of
the solution values?

Thanks, Glenn.

.



Relevant Pages

  • Re: questions on systems of ODEs
    ... I'm facing some questions on ODE. ... Is there an analytical solution to an ode with a rhs which is ... Once I must use RK4, I use if for everything but I ...
    (sci.math.num-analysis)
  • Re: questions on ODE
    ... I'm facing some questions on ODE. ... Is there an analytical solution to an ode with a rhs which is ... switch for one to another when crossing the absfrom - to + and ...
    (sci.math)
  • odesolvers: preventing negative values
    ... I am solving systems of ODE using the matalb ode solvers (ode45 and ... THese odes represent physical quantitiies that must be ... Go into the code of ode45, etc, and explicitly set y to ... Are there some numerical methods that preserve the 'positivity' of ...
    (comp.soft-sys.matlab)
  • questions on systems of ODEs
    ... I'm facing some questions on ODE. ... Is there an analytical solution to an ode with a rhs which is ...
    (sci.math.num-analysis)
  • questions on ODE
    ... I'm facing some questions on ODE. ... Is there an analytical solution to an ode with a rhs which is ...
    (sci.math)