-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathHeat_transfer_fins.m
72 lines (57 loc) · 1.41 KB
/
Heat_transfer_fins.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
function Heat_transfer_fins
%% Steady state heat transfer in extended surfaces
%
% You'll learn:
% +: How to solve a BVP with the shooting method
%
%% The problem
%
% Differential Equations:
% -kA*d^2T/dx^2 = hP*(Tinf - T)
%
% Boundary Conditions:
% x = 0 ... T = Tc
% x = L ... -k*dT/dx = 0
%
% ============================================================
% Author: [email protected]
% homepage: github.com/asanet
% Date: 2018-07-05
% Matlab version: R2018a
% Contact me for help/personal classes!
%% Problem setup
addpath('AuxFunctions')
% The parameters
h = 100;
d = 0.5;
L = 2;
P = pi*d;
A = pi*d^2/4;
k = 237;
Tinf = 298.15;
Tc = 800;
% fsolve configuration
op = optimoptions(@fsolve,'Algorithm','levenberg-marquardt','TolFun',1e-10,'TolX',1e-10, ...
'Display','iter-detailed','MaxIter',5000,'MaxFunEvals',10000);
% find the initial condition for u
u0_0 = 0;
u0 = fsolve(@shooting,u0_0,op);
% solve the BVP as a PVI
[x,yc] = ode15s(@model,[0 L],[Tc u0]);
% plot the profile
figured;
plot(x,yc(:,1),'LineWidth',1.5)
xlabel('Length')
ylabel('Temperature')
function dy = model(~,y)
T = y(1);
u = y(2);
dy(1,1) = u;
dy(2,1) = -h*P/k/A*(Tinf - T);
end
function f = shooting(u0)
y0 = [Tc u0]';
[~,y] = ode15s(@model,[0 L],y0);
f = y(end,2) - 0;
end
end