Can someone help me to correct the code ​​for this problem using ode45 solver?

조회 수: 10 (최근 30일)
VAIDEHI
VAIDEHI 2023년 3월 9일
댓글: Alex Sha 2023년 3월 12일
Question is:
Governing equations:
Boundary conditions:
f'(10)= 0, (assume )
As tried here, I want to plot graphs for velocity profile using parameters like Pr, beta, and N.
I tried giving 'for' loop, but it failed.
How to enter the code command to plot a graph for velocity profile with different beta parameter?
Trial code
function dy=vj_Casson()
clc; clear all;
betava=[0.5 1 2 5];
for i=1:4
beta=betava(i);
tspan = [0 10];
S = 0.5;
y0 = [S 0 0 1 1];
% y0 = [S 1 0 1 0];
[eta,y] = ode45(@fun,tspan,y0);
plot(eta, y(:,1));
xlabel('\bf\eta','FontSize',20,'FontWeight','bold');
ylabel('f(\eta)','FontSize',10,'FontWeight','bold');
legend('\beta=0.5','\beta=1','\beta=2','\beta=5')
hold on
end
end
function dy = fun(eta,y)
dy = zeros(5,1);
Pr=0.3; N=0.1; beta=0.5;
dy(1) = y(2);
dy(2)=y(3);
dy(3)=(((2*y(2))^(2))-y(1)*y(3))./((1+(1./beta)));
dy(4) =y(5);
dy(5)=-(((3*Pr)*(y(1)*y(5)-y(2)*y(4)))/(4*N+3));
end
  댓글 수: 1
Alex Sha
Alex Sha 2023년 3월 12일
The results below are what you want?
1: f' = df/dt = f'
2: f'' = df'/dt = f''
3: theta' = dtheta/dt = theta'
4: f''' = df''/dt = (2*(f')^2-f*f'')/(1+1/0.5)
5: theta'' = dtheta'/dt = 0.3*(f'*theta-f*theta')/(1+4/3*0.1)
Objective Function: 1.41854343905794E-26
Boundary Values Estimated:
f''(t=0): -0.887446621710334
theta'(t=0): -0.36495059823582

댓글을 달려면 로그인하십시오.

답변 (1개)

Torsten
Torsten 2023년 3월 9일
This is a boundary value problem, not an initial value problem since conditions on f and theta are given on both ends of the integration interval (eta = 0 and eta = 10). You have to use bvp4c or bvp5c instead of ode45 to solve.
  댓글 수: 3
Torsten
Torsten 2023년 3월 10일
편집: Torsten 2023년 3월 10일
You cannot use conditions at eta = 10 if you use ode45. You must assume two further conditions at eta = 0 to make ode45 work and try to adjust these conditions in several runs such that you arrive at your two conditions at eta = 10. Look up "shooting method" for more details.
I can assure you: the simpler way for you to go is to use bvp4c or bvp5c.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by