Is it possible to adjust the maximum step size ('MaxStep') while an ode15i solver is running according to a certain value?

2 Ansichten (letzte 30 Tage)
Hi everyone, hi Matlab-Support-Team,
I've built up a quite complexe set of differential algebraic equations. I used also some 'heaviside' and 'rectangularPulse' functions, to change equation with reagrd to changing values. Unfortunately this opens some numeric troubles, since a certain value or its derivative can change abruptly, which might cause a non-stabile solver afterwards.
I thought about two tasks which might help:
  • building kind of a time dependant ramp, which smoothes the course of a value or its derivative
  • reducing the maximum step size 'MaxStep' while the ode15i solver is running.
However both ways did not work out to my pleasure, since there are still boundary conditions, which causes these numerical mistakes. Could you give me a few hints in general, please?
Thank you very much in advance.
Have a nice weekend.
Lukas

Akzeptierte Antwort

Steven Lord
Steven Lord am 19 Aug. 2022
If you know the times at which you want to change functions and/or initial conditions ahead of time, run ode15i repeatedly for small pieces of the time step. So for example run ode15i from time t = 0 to time t = 2, change functions and/or ICs, then run ode15i a second time from time t = 2 to time t = 5. Change, run, change, run, etc.
If you don't know the times at which you want to change functions and/or initial conditions, use the Events functionality. The ballode example is the standard one that I recommend as a model. That example doesn't hard code when the ball will reach the ground, it detects when the ball's height above the ground crosses through 0.
  1 Kommentar
Lukas Siebler
Lukas Siebler am 19 Aug. 2022
Thank you very much for the quick answer...
Your solution sounds feasible, but tedious. However, I wonder if there are more suitable functions like rectangularPulse, heaviside, triangularPulse which are more suitable for changing equations as they produce a sudden and sometimes extreme change in values. And often these very time steps cause numerical problems. Do you have any recommendations for an alternative that changes equations more smoothly and avoids numerical errors?
Thank you very much in advance. I really appreciate your help.
Lukas

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by