MATLAB: Is there any way to use multiple tolerances in ODE solvers

computing timeMATLABodespeedtime steptolerance

I'm frequently using systems of ODEs to simulate the dynamics of ecological communities. The number of equations is large: from hundreds to thousands, and running times are sometimes desperately long. The diversity of species’ characteristics implies that some of them have dynamics which are orders of magnitude faster than others: like the difference between a bacteria and a tree. The ‘faster’ species require tighter tolerances which, in turn, result in smaller time steps, but that is usually unnecessarily small for the ‘slower’ species, which are essentially constants (or very slowly varying) at that time scale (e.g. hours vs. months or years) and could use much larger tolerances and longer time-steps. I guess this, if possible, would save computing time, which is the goal here. So, my question is: is there any way to set at least two different tolerances for different groups of equations in a system of ODEs? Or any other way to get around this problem? I use MATLAB R2017b.

Best Answer

No, there is no way to avoid the application of the small time steps to all components of the trajectory using the ODE integrators of Matlab. The only exception is, that the integrations can be separated, if the different components do not interact with each other.
This is a common problem at simulation large system, e.g. the global weather, a organism with resolution of single cells, the mass distribution of the universe, or a vehicle simulation considering high frequency vibrations of small elements. If you want to simulate the whole system, the part with the highest frequency determines the step size.
It is possible to create integrators, which identify high frequency parts dynamically. Then these parts are integrated with a smaller steps until the changes reach a limit, in which the other components are affected. The implementation is hard and needs some heuristics, because the identification of the low and high frequency parts require to simulate the system at first...
Using a vector of tolerances is equivalent to scaling the components, e.g. if a certain component is measured in meter or nanometer. This influences, how the different components are used to determine the step size, but again the steps are applied to all components.
Related Question