Why does my ODE solver go slow when I specify the Jacobian
조회 수: 4 (최근 30일)
이전 댓글 표시
Hello,
I have a code that uses ode15s to solve a stiff ode system. The RHS is of size 32. I realized that when I specify the Jacobian using odeset, the code is very very slow and run for hours without completion (I track the time step it takes). However, if I don't specify the Jacobian, the code runs in less than a minute. Here is the ODE code.
options = odeset('BDF','on','MaxOrder',2,'Jacobian',@(t,u) MyJacobian(t,u,MM_params, RHS_params));
[time,u_sol] = ode15s(@(t,u) RHS(t,u, MM_params, RHS_params), 0:0.4:tspan, U_init, options);
Here, the Jacobian depends on time (t) and the solution (u). I will think specifying the Jacobian will give a more accurate and faster result.
I will appreciate comments and feedbacks on what I am doing wrong. Thanks
댓글 수: 1
Walter Roberson
2021년 11월 26일
Exact calculation methods are not always faster.
For example, one can imagine situations in which one could calculate the "exact" value of a parameter by doing a nonlinear curvefitting to fit an equation... but that at the same time, in practice, a bisection method might get to the same level of accuracy in a small number of faster calls.
So generalities, without seeing the code or knowing the shape of the function: what you describe is certainly possible.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!