(How) can I get a numerical solution for an ODE (e.g. using ode15s) that respects monotonicity?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (2)
Sean de Wolski
le 19 Août 2016
Modifié(e) : Sean de Wolski
le 19 Août 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 commentaires
Robert Schiessl
le 19 Août 2016
1 commentaire
Sean de Wolski
le 19 Août 2016
What about dense sampling and then smoothing it to a coarser density after?
Voir également
Catégories
En savoir plus sur Ordinary Differential Equations dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!