MATLAB: How does the time step affect the results of ODE solvers

odeode solver

Hello all,
I got question about ODE solvers. I have a rough understanding on how the calculations behind the solver are done and have read the documentation and other posts in other forums about them. I also have done a few tests, changing my time step and the solvers used (although I know my problem is a stiff one). Anyway, I have just started investigating these solutions and I was wondering: how does the time-step that I use affect the results. I am asking this because, in my understanding, the time step within the solver itself does not change. While, the initial conditions can affect a lot behavior of the solution.
I inherited a code from a peer and I am trying to optimize it. The ODE solver part of the code has the following structure, just to be clear on what I mean by "time step".
Tot_time = 2000; % s
interval = 0.05; % dt Integration time step
tot_it = Tot_time/interval;
while m <= tot_it
time0 = interval*(m-1);
timef = interval*m;
[tt, YY] = ode15s(@my_function, [time0 timef] ,dT, options);
dT = YY(end,:);
end
PS: this is just illustrative and it's just a piece of it to explain what I mean by time step, or dt.
I see different behaviors when I change he time step, but if the "internal" solver time-step does not change, how does the dt affect the solution? By affecting too much "initial" conditions? Just trying to understand this better.
Thank you!
🙂

Best Answer

The way you call ode15s you simply chop up the time-intervall into sub-intervalls and integrate sub-intervall by sub-intervall. ode15s adaptively determines what time-steps it needs to take in order to reach some absolute and relative error-tolerances (within limits, if those break it typically throws an error to get out of numerical trouble, or aborts). Those time-steps you can control by adjusting the reltol and abstol field in the options-struct. The ode-integrating functions also determine what points in time is relevant for you, that's "typically" good. If you want more detailed help we'll need to see your my_function - that might help.
HTH