# 2D Transient Heat Transfer

Im trying to write a matlab code for 2d transient heat transfer. The problem is a titanium block in the shape of a rectangle is staring at a specified temperature and is being exposed to a much hotter surrounding temperature. The dimensions, coefficients of heat transfer, and temperatures are all given. We are suppose to write a code for the temperature of the block as a function of time. I understand the basics of the problem, but Im having trouble understanding how to relate the boundary conditions to the initial temperature. We worked a problem similar, but the boundary conditions were that the walls were held at a specified temperature. With this problem though, the wall temperatures are a function of time. I started writing the code below and setup the temperatures of the nodes on the wall and at the corners using nodal finite-difference equations from our textbook. My main question is even though i setup the temperature of the walls of the block, Im not sure how to relate it to the initial temperature and making it a function of time. I know the next step will be to write the equations for the interior nodes, but I want to get the temperature of the nodes on the wall first. I also attached the problem statement in case my description isnt clear. Thanks for your time.

%Dimensions of the block
L=1.2;
H=1;

%Heat Transfer Coeffcients
h=150;

%Distance between nodes
dx=.005;

%Number of nodes in each direction
m=L/dx+1;
n=H/dx+1;

%Given Temperatures
To=278;
Tinf=533;

%Biot number equation
Bi=(h*dx)/k;

for j=2:n-1
%Left Wall
T(1,j)=((2*T(i+1,j)+T(i,j+1)+T(i,j-1))+2*Bi*Tinf)/(2*(Bi+2));
%Right Wall
T(m,j)=((2*T(i-1,j)+T(i,j+1)+T(i,j-1))+2*Bi*Tinf)/(2*(Bi+2));
end

for i=2:m-1
%Bottom Wall
T(i,1)=((2*T(i,j+1)+T(i-1,j)+T(i+1,j))+2*Bi*Tinf)/(2*(Bi+2));
%Top Wall
T(i,n)=((2*T(i,j-1)+T(i-1,j)+T(i+1,j))+2*Bi*Tinf)/(2*(Bi+2));
end

%Bottom Left Corner
T(1,1)=((T(i,j+1)+T(i+1,j))+2*Bi*Tinf)/(2*(Bi+1));
%Bottom Right Corner
T(m,1)=((T(i,j+1)+T(i-1,j))+2*Bi*Tinf)/(2*(Bi+1));
%Top Left Corner
T(1,n)=((T(i,j-1)+T(i+1,j))+2*Bi*Tinf)/(2*(Bi+1));
%Top Right Corner
T(m,n)=((T(i,j-1)+T(i-1,j))+2*Bi*Tinf)/(2*(Bi+1));

#### Attachments

• HT_Project.pdf
66.6 KB · Views: 453