How do I get the second solution?

7 ビュー (過去 30 日間)
Latifah
Latifah 2022 年 10 月 25 日
コメント済み: Torsten 2023 年 4 月 2 日
function Shrink;
format short
global lambda Pr
Pr = 1; %fixed
a = 0;
b = 10; % b = infinity
lambda =-1.1; %mixed convection parameter (lambda)
solinit = bvpinit(linspace(a,b,100),@Shrink_init);
options = bvpset('stats','on','RelTol',1e-10);
sol = bvp4c(@Shrink_ode,@Shrink_bc,solinit,options);
figure(1)
plot(sol.x,sol.y(2,:),'k--','linewidth',1)
xlabel('\eta','fontsize',16)
ylabel('f\prime(\eta)','fontsize',16)
hold on
figure(2)
plot(sol.x,sol.y(4,:),'k--','linewidth',1)
xlabel('\eta','fontsize',16)
ylabel('\theta(\eta)','fontsize',16)
hold on
sol.y(3,1) % The value of f''(0)
-sol.y(5,1) % The value of -theta'(0)
descris = [sol.x; sol.y];
save ('start_main.mat', '-struct', 'sol');
function dydx = Shrink_ode(x,y,Pr,lambda);
global Pr lambda
dydx = [y(2)
y(3)
y(2)^2-y(1)*y(3)-1-lambda*y(4)
y(5)
-Pr*y(1)*y(5)+Pr*y(2)*y(4)];
function res = Shrink_bc(ya,yb);
res = [ya(1)
ya(2)
yb(2)-1
ya(4)-1
yb(4)];
function v = Shrink_init(x);
v =[];???????????????
  1 件のコメント
Jan
Jan 2022 年 10 月 25 日
The question is not clear. Please take the time to explain any details.

サインインしてコメントする。

回答 (1 件)

Torsten
Torsten 2022 年 10 月 25 日
Pr = 1; %fixed
lambda =-1.1; %mixed convection parameter (lambda)
a = 0;
b = 10; % b = infinity
solinit = bvpinit(linspace(a,b,100),@Shrink_init);
options = bvpset('stats','on','RelTol',1e-10);
sol = bvp4c(@(x,y)Shrink_ode(x,y,Pr,lambda),@Shrink_bc,solinit,options);
Warning: Unable to meet the tolerance without using more than 2000 mesh points.
The last mesh of 887 points and the solution are available in the output argument.
The maximum residual is 2.0419e-06, while requested accuracy is 1e-10.
The solution was obtained on a mesh of 2631 points. The maximum residual is 2.042e-06. There were 55777 calls to the ODE function. There were 226 calls to the BC function.
figure(1)
plot(sol.x,sol.y(2,:),'k--','linewidth',1)
xlabel('\eta','fontsize',16)
ylabel('f\prime(\eta)','fontsize',16)
figure(2)
plot(sol.x,sol.y(4,:),'k--','linewidth',1)
xlabel('\eta','fontsize',16)
ylabel('\theta(\eta)','fontsize',16)
%hold on
sol.y(3,1) % The value of f''(0)
ans = -0.2153
-sol.y(5,1) % The value of -theta'(0)
ans = -0.1098
%descris = [sol.x; sol.y];
%save ('start_main.mat', '-struct', 'sol');
function dydx = Shrink_ode(x,y,Pr,lambda);
dydx = [y(2)
y(3)
y(2)^2-y(1)*y(3)-1-lambda*y(4)
y(5)
-Pr*y(1)*y(5)+Pr*y(2)*y(4)];
end
function res = Shrink_bc(ya,yb);
res = [ya(1)
ya(2)
yb(2)-1
ya(4)-1
yb(4)];
end
function v = Shrink_init(x);
v =[0 1 0 1 1];
end
  2 件のコメント
MOSLI KARIM
MOSLI KARIM 2023 年 4 月 1 日
Hi Mr. Torsten, I have a question, why did you choose the initial conditions
function v = Shrink_init(x);
v =[0 1 0 1 1];
end
Torsten
Torsten 2023 年 4 月 2 日
I took one of the boundary conditions as initial value for the complete region of integration.
Somewhat arbitrary - but often it works.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeWaveform Generation についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by