-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
191 additions
and
18 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
%% RK4 numerical solver modified for solving Falkner-Skan equation. | ||
|
||
function [f_next, g_next] = F2_RK4_ThermalBL(dh, d_eta, f, g, i, Pr, f_blasius) | ||
|
||
if i > 117 | ||
f_blasius(i) = f_blasius(117) + d_eta * (i - 117); | ||
end | ||
|
||
dg1 = d_eta * dh(Pr, f_blasius(i), g(i)); | ||
df1 = d_eta * g(i); | ||
|
||
dg2 = d_eta * dh(Pr, f_blasius(i), g(i) + dg1 * 0.5); | ||
df2 = d_eta * (g(i) + dg1 * 0.5); | ||
|
||
dg3 = d_eta * dh(Pr, f_blasius(i), g(i) + dg2 * 0.5); | ||
df3 = d_eta * (g(i) + dg2 * 0.5); | ||
|
||
dg4 = d_eta * dh(Pr, f_blasius(i), g(i) + dg3 * 0.5); | ||
df4 = d_eta * (g(i) + dg3); | ||
|
||
g(i + 1) = g(i) + (dg1 + 2*dg2 + 2*dg3 + dg4) / 6; | ||
f(i + 1) = f(i) + (df1 + 2*df2 + 2*df3 + df4) / 6; | ||
|
||
f_next = f; | ||
g_next = g; | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
clear; clc; | ||
|
||
load thermalBlasius.mat | ||
|
||
prandtl_arr = [0.02 0.9 1 90]; | ||
|
||
d_eta = 0.05; | ||
eta_max = 30; | ||
Kp = 0.001; % step size for Newton. | ||
acc_target = 1e-4; % target accuracy. | ||
|
||
|
||
eta_master = zeros(ceil(eta_max/d_eta), 4); | ||
t_master = eta_master; | ||
dt_master = t_master; | ||
|
||
|
||
dt_inits = zeros(1,4); | ||
last_etas = zeros(1,4); | ||
dh = @(p, f, dt) -p * f * dt; | ||
|
||
for pr_index = 1:length(prandtl_arr) | ||
pr = prandtl_arr(pr_index); | ||
|
||
eta = 0:d_eta:eta_max; | ||
N = length(eta); | ||
|
||
t = zeros(N,1); % t(eta) = θ | ||
dt = t; % dt(eta) = θ' | ||
|
||
t(1) = 1; % θ(0) = 1 | ||
|
||
dt(1) = -0.2; % initial guess. | ||
dt_last = dt(1); | ||
t_inf = 0; % free-stream boundary condition | ||
|
||
iteration = 0; % iteration count over initial guess. | ||
|
||
while true | ||
iteration = iteration + 1; | ||
|
||
for i = 1:(N - 1) | ||
[t, dt] = F2_RK4_ThermalBL(dh, d_eta, t, dt, i, pr, f_blasius); | ||
if abs(dt(i)) < acc_target | ||
t_inf = t(i); | ||
c_index = i; | ||
break | ||
end | ||
if i == (N - 1) | ||
t_inf = t(N - 1); | ||
c_index = N - 1; | ||
end | ||
end | ||
|
||
|
||
if abs(t_inf) > acc_target | ||
t = zeros(N,1); % reset matrices for next iteration | ||
t(1) = 1; | ||
dt = t; | ||
dt(1) = dt_last - t_inf * Kp; | ||
dt_last = dt(1); | ||
else | ||
disp("Target accuracy reached. dt(0) = " + string(dt(1))) | ||
disp(iteration + " iterations completed.") | ||
eta = eta(1:c_index); | ||
t = t(1:c_index); | ||
dt = dt(1:c_index); | ||
break | ||
end | ||
end | ||
|
||
eta_master(1:c_index,pr_index) = eta; | ||
t_master(1:c_index, pr_index) = t; | ||
dt_master(1:c_index, pr_index) = dt; | ||
dt_inits(pr_index) = dt(1); | ||
last_etas(pr_index) = c_index; | ||
|
||
end | ||
|
||
run("M4_ThermalVisualizer.m") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
%% This .m file contains the visualization part of the HW and is seperated | ||
% with the intention of decluttering the main code. | ||
|
||
|
||
%% theta plot | ||
figure(1); | ||
plot(eta_master(1:last_etas(1),1), t_master(1:last_etas(1),1),"Color", "#071013", "LineWidth", 1.5) | ||
hold on | ||
xlabel("\eta", 'FontSize', 10) | ||
ylabel("\theta", 'FontSize', 10) | ||
grid on | ||
|
||
plot(eta_master(1:last_etas(2),2), t_master(1:last_etas(2),2),"Color", "#23b5d3", "LineWidth", 1.5) | ||
plot(eta_master(1:last_etas(3),3), t_master(1:last_etas(3),3),"Color", "#B4DC7F", "LineWidth", 1.5) | ||
plot(eta_master(1:last_etas(4),4), t_master(1:last_etas(4),4),"Color", "#dc602e", "LineWidth", 1.5) | ||
|
||
legend("Pr = 0.02","Pr = 0.9", "Pr = 1", "Pr = 90", "Location","northeast") | ||
|
||
ax = gca; | ||
ax.FontSize = 10; | ||
|
||
%% f'' plot | ||
figure(2) | ||
plot(eta_master(1:last_etas(1),1), dt_master(1:last_etas(1),1),"Color", "#071013", "LineWidth", 1.5) | ||
|
||
hold on | ||
xlabel("\eta", 'FontSize', 10) | ||
ylabel("f''(\eta)", 'FontSize', 10) | ||
grid on | ||
|
||
plot(eta_master(1:last_etas(2),2), dt_master(1:last_etas(2),2),"Color", "#23b5d3", "LineWidth", 1.5) | ||
plot(eta_master(1:last_etas(3),3), dt_master(1:last_etas(3),3),"Color", "#B4DC7F", "LineWidth", 1.5) | ||
plot(eta_master(1:last_etas(4),4), dt_master(1:last_etas(4),4),"Color", "#dc602e", "LineWidth", 1.5) | ||
|
||
legend("Pr = 0.02","Pr = 0.9", "Pr = 1", "Pr = 90", "Location","southeast") | ||
|
||
|
Binary file not shown.