Is there any way to use multiple tolerances in ODE solvers?
이전 댓글 표시
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.
채택된 답변
추가 답변 (3개)
CARLOS RIASCOS
2018년 4월 5일
Hello friend, you could try, generate for example two systems of equations one with slow dynamics and another with fast dynamics, for the slow dynamics use a value of big h and for fast dynamics a value of small h, also consider in changing the limits of tspan, because if you are analyzing a dynamic that evolves in micro-seconds should not have limits like the code here example but rather tspan = 0: h_small: 0.01.
If you must make a model as a whole, you can see if the fast dynamics stabilize and if so you could even consider them as constants, but everything depends on the type of problem you have. I hope I've helped.
h=1;
tspan = 0:h:5;
y0 = 0;
[t,y] = ode45(@(t,y) 2*t, tspan, y0);
plot(t,y)
Torsten
2018년 5월 22일
0 개 추천
AbsTol can be a vector of the same size as the solution vector. Thus you can prescribe absolute tolerances for each solution component separately.
Best wishes
Torsten.
카테고리
도움말 센터 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!