Асья (isfo@info-esta) (asya) wrote in matlab_help,
Асья (isfo@info-esta)
asya
matlab_help

a singular Jacobian encountered

Hi, guys! I was solving ODE when I struggled with this mistake.
when l is lower then 0.01 it matlab writes 'Unable to solve the collocation equations -- a singular Jacobian encountered'.

xinit = [0 hd/4 hd/2 3*hd/4 hd hd hd+hm/4 hd+hm/2 hd+3*hm/4 hd+hm];
yinit = [0 0 0 0];
solinit = bvpinit(xinit, yinit);
l1 = 0.01*10^(2);
l2 = 0.45*10^(3);
n=10;
dl = (l2-l1)/n;
i = 0;
for l=l1:dl:l2
  i = i+1;
   sol = bvp4c(@f,@bc,solinit) 
   R1d = sol.y(1,:);
   R1m = sol.y(3,:);
%-----------------------------------------------
X1 = 0:hd/90:hd;
X2 = hd:(hm)/90:hd+hm;
V1 = deval(sol, X1);
V2 = deval(sol, X2);
Y1 = V1(1,:);
Y2 = V2(3,:);
Z1 = 1/2*l*Pd*trapz(X1,Y1);
Z2 = 1/2*l*Pm*trapz(X2,Y2);
Z=Z1+Z2;
U(i)=Z;
E(i)=1/2*l*(hd+hm)*P^2/U(i)
%--------------------------------------------------
end
figure(1)
plot([l1:dl:l2],E/1e9,'g')
grid on;
function dydx = f(x,y,region)
%правая часть системы
dydx = zeros(4,1);
dydx(1) = y(2);  
dydx(2) = (Ed*y(1)-Pd)*(12/(Gd*l^2)); %y''d
dydx(3) = y(4); 
dydx(4) = (Em*y(3)-Pm)*(12/(Gm*l^2)); %y''m
end
function res = bc(YL, YR)
res = [Gd*YL(2,1)
YR(1,1) - YL(3,end)
(Gd*YR(2,1)) - (Gm*YL(4,2))
Gm*YR(4,2)
YR(1,1) - YL(1,2)
YR(2,1) - YL(2,2)
YR(3,1) - YL(3,2)
YR(4,1) - YL(4,2) 
];
end
end


When solving analytically the integration constants take the form:
betm = 0.000000000000000001; %zero
betd = 0.000000000000000001; %zero

Cdb = Em * betm * hm / (Em * betm * hm + Ed * betd * hd);
Cmb =- Ed * betd * hd / (Em * betm * hm + Ed * betd * hd);

instead of


bd=1/l*sqrt(12*Ed/Gd);
bm=1/l*sqrt(12*Em/Gm);
betm=tanh(bm*hm)/bm/hm;

betd=tanh(bd*hd)/bd/hd;
Cdb=Em*betm*hm/(Em*betm*hm+Ed*betd*hd);
Cmb=-Ed*betd*hd/(Em*betm*hm+Ed*betd*hd);

And I really don't know how to code it.:\

  • Post a new comment

    Error

    default userpic
  • 0 comments