(How) can I get a numerical solution for an ODE (e.g. using ode15s) that respects monotonicity?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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).
0 Kommentare
Antworten (2)
Sean de Wolski
am 19 Aug. 2016
Bearbeitet: Sean de Wolski
am 19 Aug. 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.
0 Kommentare
Robert Schiessl
am 19 Aug. 2016
1 Kommentar
Sean de Wolski
am 19 Aug. 2016
What about dense sampling and then smoothing it to a coarser density after?
Siehe auch
Kategorien
Mehr zu Ordinary Differential Equations finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!