(How) can I get a numerical solution for an ODE (e.g. using ode15s) that respects monotonicity?

1 visualización (últimos 30 días)
I am solving an ODE (IVP) yp=f(t,y) with guaranteed nonnegative yp. Mathematically, the solution y(t) is guaranteed to be monotonically non-decreasing; however, numerically it is not always.
Simple example:
>> yp=@(t,y) sin(y.^4).^2; % yp guaranteed nonnegative
>> [t,y] = ode15s(yp,[0,500],1); % solve OVP …
>> any(diff(y)<0) % … but numerical solution is not monotonically increasing ans = 1
This violation of monotonicity is a spurious effect only, and it can be reduced somewhat by changing the tolerances for the ode-solver. However, I find no way to reliably remove it alltogether.
Note that the "NonNegative"-option of the ODE solvers does not help here.
Post-processing the solution from ode15s (by re-evaluating yp for each timestep output by the ODE-solver and updating the solution accordingly) is possible, but I find this a bit dowdy and clumsy.
Use of an implicit solver (like ode15s) is mandatory for the actual ODE I am solving (a very stiff problem).

Respuestas (2)

Sean de Wolski
Sean de Wolski el 19 de Ag. de 2016
Editada: Sean de Wolski el 19 de Ag. de 2016
Have you tried defining every point in tspan?
tspan = linspace(0,500,100000);
You could perhaps sample it more often near where there is a non-increasing point, or do a simple smoothing after.

Robert Schiessl
Robert Schiessl el 19 de Ag. de 2016
Dear Sean,
thanks for the answer, but even very dense sampling (tspan=linspace(0,500,1000000)) does not solve the problem.
Robert

Categorías

Más información sobre Ordinary Differential Equations en Help Center y File Exchange.

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by