Why does my ODE solver go slow when I specify the Jacobian

3 ビュー (過去 30 日間)
Gideon Idumah
Gideon Idumah 2021 年 11 月 26 日
コメント済み: Walter Roberson 2021 年 11 月 26 日
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
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 ExchangeOrdinary Differential Equations についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by