Solvind ODE with sudden change od dy/dt function

3 visualizaciones (últimos 30 días)
Antonio
Antonio el 21 de Mayo de 2012
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 comentario
Teja Muppirala
Teja Muppirala el 21 de Mayo de 2012
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.

Iniciar sesión para comentar.

Respuestas (1)

Jan
Jan el 21 de Mayo de 2012
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 comentarios
Antonio
Antonio el 21 de Mayo de 2012
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 el 21 de Mayo de 2012
I am trying to increase the 'InitialStep' value, but this seems to give no better result.

Iniciar sesión para comentar.

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by