I am unable to converge the blasius equation using shooting technique

2 views (last 30 days)
clear all
clc
eta = 10;
dt = 0.01;
N = eta/dt + 1;
t = linspace(0,eta, N);
K = 1001;
tol = 1e-5;
fid1 = fopen('blasius_eta_data.txt', 'wt');
fid2 = fopen('blasius_f_data.txt', 'wt');
fid3 = fopen('blasius_g_data.txt', 'wt');
fid4 = fopen('blasius_h_data.txt', 'wt');
fid5 = fopen('guessdata.txt', 'at');
f = zeros(N,K);
g = zeros(N,K);
h = zeros(N,K);
f(1,:) = 0;
g(1,:) = 0;
h(1,1) = 5;
h(1,2) = 7;
for k = 1:K-1
for i = 2:N
f(i,k) = f(i-1, k) + g(i-1, k)*dt;
g(i,k) = g(i-1, k) + h(i-1, k)*dt;
h(i,k) = h(i-1, k) - (f(i-1, k)*h(i-1, k)*dt)/2;
end
% if tolerance is met, iter = k and break out of the loop
if abs(g(N,k) - 1) < tol
iter = k
break
end
% want to skip this case
if k == 1
continue;
else
% applying shooting method to determine the next guess
h(1, k+1) = h(1,k) + (1 - g(N,k))*(h(1,k) - h(1, k-1))/(g(N, k) - g(N, k-1));
% condition on h(1,:) - cannot be a negative value
if sign(h(1, (k+1))) == 1
h(1, k+1) = -h(1, k+1);
end
end
end
%transporting for data collection purposes
t_col = transpose(t);
fprintf(fid1, '%.5f\n', t_col);
fprintf(fid1, '%.5f\n', f(:, iter));
fprintf(fid1, '%.5f\n', g(:, iter));
fprintf(fid1, '%.5f\n', h(:, iter));
fprintf(fid1, '%.5f %.5f\n', [dt; h(1, iter)]);
%
% plotting
plot(f(:, iter), t);
hold on
plot(g(:, iter), t);
plot(h(:, iter), t);

Answers (1)

Divyam
Divyam on 5 Sep 2024
To improve the chances of convergence, you must first improve the initial guesses & based on your data. You can also further decrease the step size and the tolerance of the function.
Upon examining the code for the shooting star method, the implementation for the sign flip seems to be incorrect as the fluid acceleration at the boundary layer should be positive due to the nature of flow. Here is the correct implementation for the sign flip condition,
if h(1, k+1) < 0
h(1, k+1) = abs(h(1, k+1)); % Make it positive if it's negative
end
You can also utilize this file exchange code for solving the Blasius equation boundary layer flow over a flat plate: https://www.mathworks.com/matlabcentral/fileexchange/69310-solving-blasius-equation-with-the-shooting-method

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!