Solving for temperatures of interior nodes for 2-D convection, steady-state, constant properties, and heat generation.

Problem Statement:

Consider steady two-dimensional heat transfer in a long solid body whose cross section is given in the figure. The measured temperatures at selected points of the outer surfaces are as shown. The thermal conductivity of the body is k = 2 W/m • °C and there is a uniform heat generation of 3000 W/m3. The dimension of the solid body is 1.5m x 1m. Using the finite difference method with a mesh size of Δx = Δy = 10.0 cm.

Write a computer code to solve for temperatures of interior nodes.

Determine the temperature of all interior nodes.

Present the temperature values in a Table. Plot a contour plot for the temperatures of the domain.

Solution:

Heat-Transfer-Project-Ghannami

MATLAB Code:


% Numerical 2-D Steady Heat Transfer

clear;clc;

% Given

k = 2; % in W/mC
h = 70; % on W/m2
T_surf = 25; % in C
q_gen = 3000; % in W/m3
q_flux = 50; % in W/m2 (Plane with uniform heat flux)
T_inf = 25; % in C
dim = [1.5 1]; % in m
dx = 0.1; % in m
dy = dx; % in m


% Grid Generation (Domain & Step)
m = (dim(2)/dx) + 1;
n = (dim(1)/dy) + 1;



temp = zeros(m,n);
temp(:,1) = T_surf;
temp(1,:) = T_surf;


for iterations = 1:5000
   
    % Top and Bottom Right Corners, Bottom-Left
    temp(1,end) = 25; % Top-Right corner
    temp(end,end) = (temp(end,end-1) + temp(end-1,end) + q_flux*dx/k + (q_gen/2)...
        *dx^2/2 + T_inf*h*dx/k)/(2 + h*dx/k); % Bottom-Right corner  
    temp(end,1) = 25; % Bottom-Left corner

   
    % Bottom Wall
    for j = 2:n-1
        temp(end,j) = (2*temp(end-1,j) + temp(end,j-1) + temp(end,j+1) + 2 ...
        *q_flux*dx/k+(q_gen/2)*dx^2)/4; % Bottom wall
    end
   
   
   
    % Right Wall
    for i = 2:(m-1)
        temp(i,end)=(2*temp(i,end-1)+temp(i-1,end)+temp(i+1,end)+2*h*dx...
            *T_inf/k+(q_gen/2)*dx^2)/(2*((h*dx/k)+2)); % Right wall
    end
   
    % Interior Nodes
    for i=2:(m-1)
        for j= 2:(n-1)
            temp(i,j) = ( temp(i-1,j) + temp(i+1,j) + temp(i,j-1) + temp(i,j+1) ...
                + ((q_gen/2)*dx^2))/4; % interior
 
        end
    end

end




% Graph for the temperature distribution

rev = temp;
 
w = linspace(0,dim(1),n);
h = linspace(0,dim(2),m);

 for i=1:m
    for j= 1:n
         temp(i,j) = rev(m-i+1,j);
     end
 end

contour(w,h,temp)
shading interp
title('Temperature (Steady State)')
xlabel('x - domain')
ylabel('y - domain')
c = colorbar;



% Nodal Network Tabulated
format short
rev = round(rev,3,'significant');
Table = array2table(rev,'VariableNames',{'1','2','3','4','5','6','7','8'...
    ,'9','10','11','12','13','14','15','16'})

% n.b. the full Table is not visible via PDF, only visible in the code.