Clear Filters
Clear Filters

ode15s Preparation

3 views (last 30 days)
C
C on 22 Jun 2021
Answered: Samay Sagar on 24 May 2024
Hi all
I notice that when I use ode15s (or any other solver, really), it calls my derivative function ("odefun") multiple times at t=0 (given tspan=[0 T]). It seems the larger the problem, the more times odefun is called at t=0. What is it evaluating?
For more info, these t=0 calls are before the backwards steps taken (to estimate an appropriate initial step size I guess).
Calls at 0 step size also seem to occur throughout integration. Not sure if it's for the same purpose as the first set of t=0 (and so 0 step size) calls.
Thanks in advance.
MATLAB2021a

Answers (1)

Samay Sagar
Samay Sagar on 24 May 2024
When using numerical solvers like "ode15s", multiple calls to the derivative function ("odefun") at t = 0 can occur for various reasons:
  • Initialization: The solver needs to initialize the integration process, which involves estimating an appropriate initial step size. This initialization may require evaluating the derivative function at t = 0 multiple times to gather information about the system's behaviour.
  • Step Size Adjustment: During the initialization phase and throughout the integration process, the solver may adjust the step size dynamically to ensure accuracy and stability. This adjustment may involve evaluating the derivative function at t = 0 and at other points to determine an optimal step size for the next integration step.
  • Adaptive Time Stepping: Many numerical solvers use adaptive time-stepping techniques, where the step size is adjusted based on the local behaviour of the solution. This adaptation process may lead to additional evaluations of the derivative function at t = 0 and other points to refine the integration.
  • Event Handling: If your system includes events (e.g., discontinuities, zero crossings), the solver may need to refine the solution around these events, which could result in additional evaluations of the derivative function at t = 0 and other relevant points.
  • According to the official MathWorks documentation available here https://www.mathworks.com/help/releases/R2021a/matlab/ref/ode15s.html#bu8tot8:~:text=the%20solver%20detected.-,Algorithms,-ode15s%20is%20a , the solver can optionally use backward differentiation formulas (BDFs, also known as Gear's method) that are usually less efficient.
Hope this helps !

Tags

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!