Afficher commentaires plus anciens
Hi
Ive written a matlab code to solve nonlinear set of equations and it stops in the middle of running and says:
??? Error using ==> bvp4c at 252
Unable to solve the collocation equations -- a singular Jacobian encountered
Error in ==> example77k at 49
Sol = bvp4c(@fun1,@fun1bc,solinit,option) ;
my code is:
ca0 = 0.02*cfin;
cb0 = 0.03*cfin;
cc0 = 5e-4*cfin;
T=550;
solinit = bvpinit(linspace(eps,r,100),[ca0 cb0 cc0 T]);
Sol = bvp4c(@fun1,@fun1bc,solinit);
function dy = fun1(x,y)
% ca = y(1)
% dca = y(2)
% d2ca = dy(2)
% cb = y(3)
% dcb = y(4)
% d2cb = dy(4)
% cc = y(5)
% dca = y(6)
% d2ca = dy(6)
%T(temprature)=y(7)
%dT=y(8)
%d2T=dy(8)
disp('------------------')
dy = zeros(8,1);
k1 = k10*exp(-E1/y(7))
k2 = k20*exp(-E2/y(7))
ka = ka0*exp(-Ea/y(7))
kc = kc0*exp(-Ec/y(7))
r1 = (k1*y(1)*y(3))/(1+ka*y(1)+kc*y(5))^2
r2 = (k2*y(5)*y(3))/(1+ka*y(1)+kc*y(5))^2
dy(1)=y(2);
dy(2)=r1/Da-(2/x*y(2));
dy(3)=y(4);
dy(4)=((1/2)*r1+(9/2)*r2)/Db-(2/x*y(4));
dy(5)=y(6);
dy(6)=r2/Dc-(2/x*y(6));
dy(7)=y(8);
zigmadeltah=dhr1*r1+dhr2*r2
disp('..............')
fprintf('%e\n %e\n',y,x)
dy(8)=zigmadeltah/k-2*y(8)/x;
end
function bcd = fun1bc(ya,yb)
bcd=zeros(8,1);
bcd(1)=ya(2);
bcd(2)=-Da*yb(2)+kma*(c0(1)-yb(1));
bcd(3)=ya(4);
bcd(4)=-Db*yb(4)+kmb*(c0(2)-yb(3));
bcd(5)=ya(6);
bcd(6)=-Dc*yb(6)+kmc*(c0(3)-yb(5));
bcd(7)=ya(8);
bcd(8)=yb(7)-c0(4);
end
Réponses (1)
Walter Roberson
le 28 Avr 2011
1 vote
Try passing in an option set that has a SingularTerms value; see http://www.mathworks.com/help/techdoc/ref/bvpset.html
2 commentaires
Zeynab Mousavi.K
le 28 Avr 2011
Walter Roberson
le 28 Avr 2011
Sol = bvp4c(@fun1,@fun1bc,solinit, bvpset('SingularTerms', 12345) )
where 12345 should be the value you want to have used when a singular term is detected. For more information, read the documentation I provided the link to.
Catégories
En savoir plus sur Instrument Control Toolbox dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!