Error using bvp4c (line 251) Unable to solve the collocation equations -- a singular Jacobian encountered.

92 ビュー (過去 30 日間)
Hello
I'm trying to solve an ODE, but getting the following error:
Error using bvp4c (line 251)
Unable to solve the collocation equations -- a singular Jacobian encountered.
Here is my code:
Diff=7.0000e-11;
koffPart=5.1910e-06;
konPart=6.7702e-18;
CT=1.2044e+17;
LT=1.2044e+16;
xmesh = linspace(0,1000,100);
solinit = bvpinit(xmesh, @guess);
sol = bvp4c(@(t,C) odefcn(t,C,Diff,konPart,koffPart,CT,LT), @(Ca,Cb) bcfcn(Ca,Cb,CT), solinit);
Here is my ODE function:
function dCdt = odefcn(t,C,Diff,konPart,koffPart,CT,LT)
dCdt=zeros(2,1);
dCdt(1)=C(2);
dCdt(2)=(C(2)+konPart*C(1)*(LT-CT+C(1))-koffPart*(CT-C(1)))/Diff;
end
Here are my boundary conditions:
function res = bcfcn(Ca,Cb,CT)
res = [Ca(1)-CT
Cb(2)];
end
And my guess:
function g = guess(x)
g = [exp(-x)
-exp(-x)];
end
I'd really appreiate any help.
Thanks!
Ben
  6 件のコメント
Muhammad Safdar Nadeem
Muhammad Safdar Nadeem 2022 年 10 月 30 日
please help me in this error
Error using bvp4c (line 251)
Unable to solve the collocation equations -- a singular Jacobian encountered.
Error in newpapercodeH (line 28)
sol1 = bvp4c(@bvpexam2, @bcexam2, sol);
Torsten
Torsten 2022 年 10 月 30 日
編集済み: Torsten 2022 年 10 月 30 日
You use
res=[y0(1)+2*S/m+1;y0(2)-0;y0(4)-1;yinf(2)-1;yinf(4)-0];
in your code, but m = 0. So S/m means that you divide by 0.
Maybe you meant S/(m+1) instead of S/m+1.

サインインしてコメントする。

採用された回答

Harshendra Shah
Harshendra Shah 2020 年 4 月 7 日
Hi Ben,
A singular Jacobian indicates that the initial guess causes the solution to diverge. The BVP4C function finds the solution by solving a system of nonlinear algebraic equations. Nonlinear solvers are only as effective as the initial guess they start with, so changing your starting guess may help. Also, BVP4C is responsible for providing a guess for the solution from one iteration to another.
This MATLAB Answer also suggests some workarounds to solve this issue.
I hope this helps.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeConfigure Simulation Conditions についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by