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

1 次查看(过去 30 天)
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).

回答(2 个)

Sean de Wolski
Sean de Wolski 2016-8-19
编辑:Sean de Wolski 2016-8-19
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 2016-8-19
Dear Sean,
thanks for the answer, but even very dense sampling (tspan=linspace(0,500,1000000)) does not solve the problem.
Robert

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by