# BVP4C Unable to solve the collocation equations -- a singular Jacobian encountered

2 views (last 30 days)
Luke Maran on 25 Apr 2021
Answered: Divija Aleti on 24 Jun 2021
Hello, I am receiving this error attempting to solve a 2nd order ODE with BVP4c.
I am solving for the internal temperature distribution of a nuclear fuel rod using the ode: with Boundary Conditions: where R = 0.2m and is the outer diameter
Let me know if you need anything else.
q and k are constants
%These are my setup functions.
function dydx = rod_BV(r,y) % Details ODE to be solved
dydx = zeros(2,1);
dydx(1) = y(2)
dydx(2) = -(q/k)-((1/r)*y(1)) % This equation is invalid at r = 0
end
function res = rod_BC(ya,yb) % Details boundary conditions
res = zeros(2,1);
res(1) = ya(2);
res(2) = yb(1) - T_s;
end
% here is my implementation of BVP4C
solinit = bvpinit(linspace(0,R,4),[0,0]); % I have tried setting these 0 values to realmin
options = bvpset('RelTol', 10e-4,'AbsTol',10e-7);
sol = bvp4c(@rod_BV,@rod_BC,solinit,options)

Divija Aleti on 24 Jun 2021
Hi Luke,
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.
A detailed explanation and possible solutions for this error are given in the link below:
Also, based on the picture of the equation you are solving, I believe the rod_BV function should be written as follows:
function dydx = rod_BV(r,y) % Details ODE to be solved
dydx = zeros(2,1);
dydx(1) = y(2)
dydx(2) = -(q/r)-((1/r)*y(2)) % This equation is invalid at r = 0
end
This is because T = y(1), T' = y(2), which implies, T'' = -(q/r)-(1/r)*y(2).
Hope this helps!
Regards,
Divija