fix the error please . AS SOON AS POSSIBLE !!1 PLEASE
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
HERES THE CODE
% TO CALCULATE MOMENTUM AND THERMAL BOUNDARY LAYER OVER A FLAT PLATE
%BY SHOOTING TECHNIQUE AND 4TH ORDER RUNGA KUTTA METHOD
Etta_max = 10;
h = 0.01; %the step size
n_max = Etta_max/h;
f = zeros(n_max,1);
G = zeros(n_max,1);
H = zeros(n_max,1);
Error = 0.000001;
H_I =zeros (2,1);
H_I(2) =5;
G_steady = zeros(2,1);
i = 0;
%SOLUTION OF MOMENTUM BOUNDARY LAYER
while (abs(G(size(G))-1)>Error), %For shooting
if i == 1,
G_steady(1)= G(n_max);
H(1) = H_I(2);
end
else
H(1)=(H_I(1)+H_I(2))/2;
end
for n = 1:n_max %Runga Kutta 4
k1 = h*G(n);
l1 = h*H(n);
m1 = -(h/2)*f(n)*H(n);
%
k2 = h*(G(n)+l1/2);
l2 = h*(H(n)+m1/2);
m2 = -(h/2)*(f(n)+ k1/2)*(H(n)+ m1/2);
k3 = h*(G(n)+ l2/2);
l3 = h*(H(n)+ m2/2);
m3 = -(h/2)*(f(n)+ k2/2)*(H(n)+ m2/2);
k4 = h*(G(n)+ l3);
l4 = -h*(H(n)+ m3) ;
m4 = -(h/2)*(f(n)+ k3)*(H(n)+ m3);
f (n+1) = f (n) + (l/6) * (k1 + 2* k2 + 2* k3 + k4);
G (n+1) = G (n) + (1/6) * (l1 + 2* l2 + 2* l3 + l4);
H (n+1) = H (n) + (l/6) * (m1 + 2* m2 + 2* m3 + m4);
end
i = i+1;
if i>l,
if G(n_max)<1,
G_steady(1)=G(n_max);
H_I(1)=H(1);
else
G_steadv(2)=G(n_max);
H_I(2)=H(1);
end
end
end
plot(G,' r ' ) ;
hold on;
%-------------------------------------------------------------------
%SOLUTION OF THERMAL BOUNDARY LAYER
fprintf('Enter lamda = 0 for constant wall temperature.\n');
fprintf('Enter lamda = 0.5 for constant wall heat flux.\n');
lamda = input('Enter the value of lamda: ');
nue = input('Enter the value of kinematic viscocity of fluid (in SI unit):');
alpha = input('Enter the value of thermal diffusivity of fluid (in SI unit):');
Pr = nue/alpha;
theta = ones(n_max,1);
Y = zeros(n_max,1);
theta_steady = zeros(2,1);
Y_I = ones(2,1);
Y_I(1) = -5; %INITIAL GUESS
Y(1) = Y_I(1);
i = 0;
while (abs(theta(n_max))>Error), %Shooting
if i == 1,
theta_steady(1)= theta(n_max);
Y(1) = Y_I(2);
end
if i>1
Y (1) = (Y_I (1)+Y_I (2) ) /2;
end
for n = 1:n_max %Runga Kutta 4
p1 = h*Y(n);
q1 = h*(lamda*Pr*G(n)*theta(n) - (Pr/2)*f (n)*Y(n));
p2 = h*(Y(n)+q1/2);
q2 = h*(lamda*Pr*G(n)* (theta(n)+p1/2) - (Pr/2)*f(n)*(Y(n)+ql/2))
p3 = h*(Y(n)+ q2/2);
q3 = h*(lamda*Pr*G (n)* (theta(n)+p2/2) - (Pr/2)*f(n)*(Y(n)+q2/2))
p4 = h*(Y(n)+ q3);
q4 = h*(lamda*Pr*G(n)* (theta(n)+p3) - (Pr/2)*f (n)*(Y(n)+q3));
theta (n+1) = theta (n)+ (1/6) * (p1+ 2*p2+ 2*p3+ p4);
Y (n+1) = Y(n)+ (1/5) * (q1+ 2*q2+ 2*q3+ q4) ;
end
i = i+1;
%theta(n_max)
if i>1,
if theta(n_max)<0,
theta_steady (1)=theta(n_max);
Y_I(1)=Y(1);
else
theta_steady(2)=theta(n_max) ;
Y_I(2)=Y(1);
end
end
end
%-----------------------------------------------------------------------
theta_star = 1 - theta;
plot(theta_star,'m');
%---------------------------------------------------------------------
U_inf = input ('Enter the value of free stream velocity (in m/s) :');
u = U_inf*G;
% Checking correlation
if lamda ==0,
T_w = input('Enter the wall temperature (in degree celcius):');
T_inf = input('Enter the free stream temperature (in degree elecius):')
T = T_inf + theta*(T_w - T_inf);
A = abs(Y(1))
B = 0.332*(Pr) ^ (1/3)
end
%------------------------------------------------------------------
%File printing and output segment
fid1 = fopen ('data1.txt' , 'w');
fprintf (fid1, 'SL.No.\t\tEtta\t\t f \t\t\t G \t\t\t H \t\t\tVelocity\n');
fid2 = fopen ('data2. txt' , 'w');
if lamda ==0,
fprintf (fid2,'SL.No.\t Etta\t\t Theta\t\t\tY \t\t Temp\n');
else
fprintf (fid2,'SL.No.\t Etta\t\t Theta\t\t\tY \n');
end
for i=1:40
Etta = etaa_max/40* (i -1) ;
k = Etta/h+1;
fprintf (fid1, '%d \t\t %f \t\t %f \t\t %f \t\t %f \t\t %f \n', i , Etta, f(k), G(k) , H(k),u(k));
if lamda==0,
fprintf (fid2,' %d \t\t %f \t\t %f \t\t %f \t\t %f \n', i, Etta, theta(k), Y(k), T(k));
else
fprintf (fid2,' %d \t\t %f \t\t %f \t\t %f \n', i, Etta, theta(k), Y(k));
end
end
fclose ('all');
hold off;
2 Commenti
John D'Errico
il 25 Apr 2018
Modificato: Walter Roberson
il 26 Apr 2018
YES SIR! We will jump right to solving your problem. As soon as you give people a clue as to what the problems is, and as soon as someone feels like answering it.
If you want help, then make it easy for someone to help you. Tell people what the problem is. If you had an error, then show the COMPLETE text of the error.
Risposte (1)
Image Analyst
il 25 Apr 2018
What's going on here:
%SOLUTION OF MOMENTUM BOUNDARY LAYER
while (abs(G(size(G))-1)>Error), %For shooting
if i == 1,
G_steady(1)= G(n_max);
H(1) = H_I(2);
end
else
H(1)=(H_I(1)+H_I(2))/2;
end
It looks like your end is in the wrong place. Move the end from before the else to after the else.
0 Commenti
Vedere anche
Categorie
Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!