0% found this document useful (0 votes)
48 views

Plots of Question 3.2 and 3.4

This Matlab code implements an algorithm to solve the Falkner-Skan equation for boundary layer flow over a flat plate for different values of β. It uses an ODE solver and secant method to iteratively solve for the value of f''(0) that satisfies the boundary condition f'(∞)=1 for each β value. The code plots f' and f'' versus the similarity variable η for different β, as well as plots of f' and f'' versus β.

Uploaded by

Carlos Alberto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

Plots of Question 3.2 and 3.4

This Matlab code implements an algorithm to solve the Falkner-Skan equation for boundary layer flow over a flat plate for different values of β. It uses an ODE solver and secant method to iteratively solve for the value of f''(0) that satisfies the boundary condition f'(∞)=1 for each β value. The code plots f' and f'' versus the similarity variable η for different β, as well as plots of f' and f'' versus β.

Uploaded by

Carlos Alberto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Plots of question 3.2 and 3.

Implemented Matlab algorithm:


function q3
%% ================================ parameters ================================
clear all;close all;
%% ================================ constant variables ========================
eta_max = 10; % guessed good enough value for eta -> infinity
threshold = 1e-4; % abs(f'(eta_max) - 1) < threshold
nu = 1.568*10-5; %[m2/s] - assuming sea level conditions
n = 100; %number of lines of the arrays that will be ploted
global beta
%beta values that are used in this simulation
beta_range = [ -.19 -.08 .1 .53 .56];
%beta_range = [ -.18 -.08 .56];
%% ================================ plot variables ============================
% we defined the two below variables to storage that data that must be ploted
% each column represent a different beta value
f_line_plot = zeros (n,length(beta_range)); %storage the f' at each iteration of beta
f_line2_plot = zeros (n,length(beta_range)); %f'' = zeros (n,length(beta_range));
%% ================================ computing f ==============================
options = odeset('InitialStep', 0.0001, 'MaxStep', 0.001);
for i = 1 : length(beta_range)
%% ==================================== range of beta values ==================
% favorable dp/dx < 0 0 < beta < 2
% adverse
dp/dx > 0 beta < 0 or beta > 2
beta = beta_range(i);
%% ================================ setting the initial guess =================
%
%
%
%
%

take two initial guesses to start the secant method


the initial guesses were choose based on the beta value, initially we
used just one value for alpha_0, but that value wasn't a good guess
for beta higher than .5, so used a if-else structure to correct that
problem

if beta > .5
alpha_0 = 1;
else
alpha_0 = .2;
end
alpha_1 = alpha_0 * 1.001;
%% ================================ call ode45 to start secant method =========
[eta,f_0] = ode45(@falkner_skan_ode,linspace(0,eta_max,n),[0 0 alpha_0],options);
error = f_0(end,2) - 1;
converged = 0;
if (abs(error) < threshold)
fprintf(1,'Converged. Value of f``(0) is %f\n',alpha_0);
converged = 1;
end
if converged == 0
% second guess
[eta,f_1] = ode45(@falkner_skan_ode,linspace(0,eta_max,n),[0 0 alpha_1],options);
error = f_1(end,2) - 1;
if (abs(error) < threshold)
fprintf(1,'Converged. Value of f``(0) is %f\n',alpha_1);
converged = 1;

end
end
if converged == 0
alpha_cur = alpha_1;
alpha_old = alpha_0;
% now we start the secant iteration
while (abs(error) > threshold)
slope = (f_1(end,2) - f_0(end,2)) / (alpha_cur - alpha_old);
correction = -error / slope;
alpha_old = alpha_cur; f_0 = f_1;
alpha_cur = alpha_cur + correction;
[eta,f_1] = ode45(@falkner_skan_ode,linspace(0,eta_max,n),[0 0 alpha_cur],options);
error = f_1(end,2) - 1;
end
fprintf(1,'Converged.

Value of f``(0) is %f\n',alpha_cur);


end
%% ================================ post-processing ================================
%x range
xf = 10;
%defining a linear U_inf(x) as function of the pressure gradient
x = linspace(0,xf,n);
%calculating the B.L thickness
a = -.5; %the result from blasius eq.
m = 2 * a + 1;
A = 2 * nu / ( m + 1 );
% copying f and f_line
f_line = f_1(:,2);
f_line2 = f_1(:,3);
%calculating the B.L thickness and its derivative at x_pos
f_line_plot(:,i) = f_line;
f_line2_plot(:,i) = f_line2;
end
%% ================================ plotting the data ================================
%------------------------- f' over eta------------------------figure();
plot(eta,f_line_plot(:,1),'*');
hold on;
plot(eta,f_line_plot(:,2),'o');
hold on;
plot(eta,f_line_plot(:,3),'s');
hold on;
leg1 = strcat('\beta = ',mat2str(beta_range(1)));
leg2 = strcat('\beta = ',mat2str(beta_range(2)));
leg3 = strcat('\beta = ',mat2str(beta_range(3)));
legend(leg1,leg2,leg3);
xlabel('\eta', 'FontSize', 20);ylabel(sprintf(['f\\prime']), 'FontSize', 20);
axis([0 5 min(f_line_plot(:,1)) max(f_line_plot(:,1))]);
%------------------------- f'' over eta------------------------figure();
plot(eta,f_line2_plot(:,1),'*');
hold on;

plot(eta,f_line2_plot(:,2),'o');
hold on;
plot(eta,f_line2_plot(:,3),'s');
hold on;
leg1 = strcat('\beta = ',mat2str(beta_range(1)));
leg2 = strcat('\beta = ',mat2str(beta_range(2)));
leg3 = strcat('\beta = ',mat2str(beta_range(3)));
legend(leg1,leg2,leg3);
xlabel('\eta', 'FontSize', 20);ylabel(sprintf(['f\\prime\\prime']), 'FontSize', 20);
axis([0 5 min(f_line2_plot(:,1)) 1]);
%------------------------- f' over beta------------------------figure();
plot(beta_range,f_line_plot(2,:),'LineWidth',3);
hold on;
xlabel('\beta', 'FontSize', 20);ylabel(sprintf(['f\\prime']), 'FontSize', 20);
axis([min(beta_range) max(beta_range) min(f_line_plot(:,1)) max(f_line_plot(:,1))]);
%------------------------- f'' over beta------------------------figure();
plot(beta_range,f_line2_plot(1,:),'LineWidth',3);
hold on;
xlabel('\beta', 'FontSize', 20);ylabel(sprintf(['f\\prime\\prime']), 'FontSize', 20);
axis([min(beta_range) max(beta_range) min(f_line_plot(:,1)) max(f_line_plot(:,1))]);
end

function [fdot] = falkner_skan_ode(eta, f)


global beta
fdot(1,1) = f(2);
fdot(2,1) = f(3);
fdot(3,1) = -(f(1)*f(3)+beta*(1-f(2)^2));
end

You might also like