Singular Jacobian using bvp4c
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I know similar questions have been asked, but I am wondering if there any tricks to help out here. I've tried changing variables, but the divergence just moves around...
I am trying to solve a second order equation, given in the screen shot below, and the associated code is attached:
I did not impose the condition f>=0, so maybe that is my issue? The hyperbolic tanh might also be a good initial guess, but I was relying on the Sxint = deval() to get me started. Any obvious problems? Thanks in advanced for any help!
xl = 0;
xr = 10;
[Sxint, xint] =bvp4c_mathworks_Abrikosov(xl,xr);
plot(xint,Sxint)
function [Sxint, xint] =bvp4c_mathworks_Abrikosov(xl,xr)
N = 500;
xint = linspace(xl,xr,N);
solinit = bvpinit(xint,[0 0]);
sol = bvp4c(@myode,@mybc,solinit);
Sxint = deval(sol,xint);
end
function dy = myode(r,y)
k = 1/sqrt(1.8);
dy(1,1) = y(2);
dy(2,1) = k^2*(y(1)^2-1)*y(1)+y(1)/r^2-y(2)/r;
end
function res = mybc(ya,yb)
res = [ya(1)
yb(1)-1];
end
0 comentarios
Respuestas (1)
Neelanshu
el 29 de Feb. de 2024
Hello Marcus,
I understand that you're encountering the "Singular Jacobian using bvp4c" error while attempting to solve a boundary value problem.
Upon inspecting the code, it appears that the issue arises when the function 'myode' is called with the value of 'r' being zero, as shown:
This results in the computation of 'dy(2,1)' to be 'NaN' because it involves division of zero by zero, which leads to the error you're experiencing. To rectify this, you should either initialize 'r' with a non-zero value or adjust the formula used to compute 'dy(2,1)' to handle the case when 'r' is zero.
Hope this helps.
0 comentarios
Ver también
Categorías
Más información sobre Boundary Value Problems en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!