Professional Documents
Culture Documents
Computational Project A
April 2, 2015
Rafael Silva
ID: 010068565
Schematic
Assumptions
1.
2.
3.
4.
5.
6.
Equations
We have defined: = =
General equation: + = 0
Internal nodes, i.e., for m = 2 to M-1 and n = 2 to N-1:
, =
2
)
, =
2 ,+1 + +1, + 1, +
, =
2 2
+
)
2(2 +
)
(2 1, + ,1 + ,+1 +
Corners:
1, =
(2, + 1,1 +
1,1 =
,1 =
,1 =
, =
Temperatures profiles:
2
)
2
2
(2,1 + 1,2 +
2
)
2
2
2
+
)
4
2
(2 +
)
2
(1,1 + ,2 +
2
+
)
2
(2 +
)
(1,1 + ,2 +
2
+
)
2
(2 +
)
(,1 + 1, +
Finding the equations proved itself to be the most challenging part of this whole assignment the numerical method
itself if relativity easy. Particularly, the corners equations were hard to obtain. As can be noticed in the figures 2 and
11, the corners introduce a discontinuity into the temperature function T(m,n). This phenomenon can explain why
the heat flux at y = 0 is not null, differently of what is expected. Since the boundary condition has stated this border
is adiabatic. So, we conclude that the heat is escaping through the corners.
This heat transfer problem has 201x101 equations and took 1172 iterations to converge for a 0.1 tolerance, which is
quite big when comparing with the ones that in fact used in numerical methods, however 0.1 tolerance served well
for our propose. These numbers point out that is humanly impossible to achieve a solution for this problem with
such precision as we got.
Appendix
Matlab code:
% ME-114 Heat Transfer
% Computational Project - Part A
% Student: Rafael Silva
% email: rafaelggustavo@gmail.com
clear all
close all
Lx = 0.4;
Ly = 0.2;
egen = 10;
k = 5;
Tinf = 400;
h = 10;
% Drawing the schematic:
plot([0 0], [0 Ly]);
hold on
plot([Lx Lx], [0 Ly]);
plot([0 Lx], [0 0]);
plot([0 Lx], [Ly Ly]);
xlabel('x');
ylabel('y');
% Show the numerical grids on the schematic
delta = 0.002; % deltax = deltay = delta
% Plotting the vertical lines of the grid:
control = 0;
for m = 0: Lx/delta
control = (m)*delta;
plot([control control], [0 Ly], 'k');
end
% Plotting the horizontal lines of the grid:
for m = 0: Ly/delta
control = (m)*delta;
plot([0 Lx], [control control], 'k');
end
title('Schematic - Grids')
% Gauss-Seidel Numerical Method
M = Lx/delta + 1; % Number of elements in x axis
N = Ly/delta + 1; % Number of elements in y axis
T = ones(M, N); % Temperature Matrix
count = 0; % Gives the number of iterations done
error = 1;
while (error > 0.1) % Tolerance of 0.1
Tpre = T; %Temperature matrix one iteration behind
for m = 1: M
for n = 1:N
if((m > 1)&(m < M)&(n == N)) % At n = N;
T(m,n) = 350;
end
if ((n > 1)&(n < N)&(m == 1)) % At m = 1;
T(m,n) = 300;
end
if ((m > 1)&(m < M)&(n == 1)) % At n = 1;
xlabel('y (m)')
ylabel('Temperature (K)')
grid on
figure
%Plotting T at y = 0, 5, 10 and 20cm
plot(x, T(:, 1))
title('T for y = 0cm')
xlabel('x (m)')
ylabel('Temperature (K)')
grid on
figure
plot(x, T(:, 0.05/delta + 1))
title('T for y = 5cm')
xlabel('x (m)')
ylabel('Temperature (K)')
grid on
figure
plot(x, T(:, 0.1/delta + 1))
title('T for y = 10cm')
xlabel('x (m)')
ylabel('Temperature (K)')
grid on
figure
plot(x, T(:, 0.2/delta + 1))
title('T for y = 20cm')
xlabel('x (m)')
ylabel('Temperature (K)')
grid on
% Heat flux throughout the borders:
heat_m_M = 0; % Heat flux at x = Lx
for i = 1: N
if (i == 1 | i == N)
heat_m_M = heat_m_M - k*(T(M, i) - T(M - 1, i))/2;
else
heat_m_M = heat_m_M - k*(T(M, i) - T(M - 1, i));
end
end
heat_m_M = heat_m_M/Ly;
heat_m_1 = 0; % Heat flux at x = 0
for i = 1: N
if (i == 1 | i == N)
heat_m_1 = heat_m_1 - k*(T(1, i) - T(2, i))/2;
else
heat_m_1 = heat_m_1 - k*(T(1, i) - T(2, i));
end
end
heat_m_1 = heat_m_1/Ly;
heat_n_1 = 0; % Heat flux at y = 0
for i = 1: M
if (i == 1 | i == N)
heat_n_1 = heat_n_1 - k*(T(i, 1) - T(i, 2))/2;
else
heat_n_1 = heat_n_1 - k*(T(i, 1) - T(i, 2));
end
end
heat_n_1 = heat_n_1 + h*delta*(Tinf - T(M,1))/2; % Heat coming through convection in the corner
heat_n_1 = heat_n_1/Lx;
heat_n_N = 0; % Heat flux at y = Ly
for i = 1: M
if (i == 1 | i == N)
heat_n_N = heat_n_N - k*(T(i, 1) - T(i, 2))/2;
else
heat_n_N = heat_n_N - k*(T(i, 1) - T(i, 2));
end
end
heat_n_N = heat_n_N + h*delta*(Tinf - T(M,N))/2; % Heat coming through convection in the corner
heat_n_N = heat_n_N/Lx;
% End of the code