Solvind ODE with sudden change od dy/dt function

5 次查看(过去 30 天)
Hi all, I have a problem. I am trying to solve an ODE with ode45, but the dy/dt function has to change abruptly at a certain time t_intermediate. How do you treat this problem? If I try to use two solver and pass to the second the last solution of the first one the solution seems not to be correct.
Is there a way to manage this?
Thanks!
  1 个评论
Teja Muppirala
Teja Muppirala 2012-5-21
Just as another suggestion, are you also familiar with Simulink? It is my experience that Simulink out-of-the-box can generally handle these sorts of problems easier than MATLAB.
But if you want to do it with ODE45, I think Jan has the right idea.

请先登录,再进行评论。

回答(1 个)

Jan
Jan 2012-5-21
ODE45 requires a smooth function. Discontinuos changes of dy/dt let ODE45 reduce the stepsize until the rounding error exceeds the error caused by the jump. Finally the accumulated rounding errors will dominate the result.
Therefore you have to integrate from t_0 to t_intermediate and use the intermediate results as initial values of the integration from t_intermediate to t_end using the modified function.
It would be nice if the event functions are powerful enough to trigger such a change of the parameters, but they aren't.
  2 个评论
Antonio
Antonio 2012-5-21
Yes, I am already doing what you suggest, but this seems to give errors.
E.g. a trivial example
computing the evolution for a (time dependent) function for a time T, or computing it into two pieces T/2, T/2, with the same function, passing the last solution of the first system to the second one, seems to give two different outputs.
Antonio
Antonio 2012-5-21
I am trying to increase the 'InitialStep' value, but this seems to give no better result.

请先登录,再进行评论。

类别

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