Hi, i have a problem when use the Ode45 slover. Hope someone can help me, thank you in advance!!! The problem will be described step by step as follows:
I have a boundary-value problem expressed by
I use the bvp5c solver to deal with this problem. The code is given as:
function main
solinit = bvpinit([0:0.001:L],zeros(1,6));
sol = bvp5c(@Fun,@bvpf,solinit);
plot(sol.x,sol.y(3,:))
end
function dy = Fun(x,y)
f0=230;
L=0.5;
G0=6.5282; Gw1 =1.8855e+006; Gw2 =-1.3920e-012; Gw3 =6.5986e-008; Gw4 =4.4582e-012;Gw5 =6.3222e+007;
Gz1 =1.4801e+004; Gz2 =-0.3122; Gz3 =4.5925e-014; f0=230;
dy = zeros(6,1);
dy(1) = y(2);
dy(2) = Gz1*(y(1)+y(4))-Gz2*y(6)-Gz3*y(4)*y(5);
dy(3) = y(4);
dy(4) = y(5);
dy(5) = y(6);
dy(6) = Gw1*(y(2)+y(5))+Gw2*y(5)^2+Gw3*y(4)^2+Gw3*y(4)*y(1)+Gw4*y(2)*y(5)+ ...
Gw5*y(4)*y(4)*y(5)+f0/G0*sin(pi*x/L);
end
function dy = bvpf(ya,yb)
dy = [
ya(1)
yb(1)
ya(3)
yb(3)
ya(4)
yb(4)
];
end
According to the code above, the solution is obtained readily and validated by other numerical method. The solution at x and L is obtained as
sol.y(:,1)=[0; -0.0022477; 0; 0; 0.0069115; -5.607309];
sol.y(:,end)=[0; -0.0022477; 0; 0; 0.0069115; -5.607309];
Now, i use the Ode45 solver to re-compute the problem, where the initial value is set to be sol.y(:,1):
function main
options = odeset('RelTol',1e-9,'AbsTol',1e-12);
span=[0 L]
[x,y1]=ode45(@Fun,span,sol.y(:,1),options);
end
Obviously, the solution y1(:,end) should be equal to sol.y(:,end), but ode45 solver did not even finish the computation. I don't know why this happened.
3 Comments
David Wilson (view profile)
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/486515-a-problem-that-the-ode45-solver-did-not-finish-the-computations#comment_758506
Xuan Ling Zhang (view profile)
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/486515-a-problem-that-the-ode45-solver-did-not-finish-the-computations#comment_758509
Xuan Ling Zhang (view profile)
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/486515-a-problem-that-the-ode45-solver-did-not-finish-the-computations#comment_758851
Sign in to comment.