Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a MATLAB function to solve generic heat transfer problems. The function sh

ID: 1858335 • Letter: W

Question

Write a MATLAB function to solve generic heat transfer
problems. The function should be able to accommodate any number of materials in the wall and
should take as input the thermal conductivity, k, of each material, the thickness of each material,
the temperatures of the inside and outside air, and the velocities of the inside and outside air.
The function should output the temperatures throughout the wall and a graph of the temperature variation within the
wall. Make sure to indicate the units that need to be input for each value. A prototype call and
help is given below. You may modify the prototype comments as necessary.

%function T = heattrans_AMS(k, deltax, Ti, To, Vi, Vo, Area)
% The purpose of this function is to determine the temperature
% distribution throughout the wall.

% Inputs:
% k - vector containing the thermal conductivity of each material
% deltax - vector containing thickness of each material
% Note: k and deltax should be the same size
% Ti - inside temperature
% To - outside temperature
% Vi - velocity of inside air
% Vo - velocity of outside air
% Area - area of system
% Outputs:
% T - temperatures at each interface
% Note: T will be one element larger than k and deltax
% plot of T throughout the wall


function T = heattrans_AMS(k, deltax, Ti, To, Vi, Vo, Area)

Explanation / Answer

%Heat Transfer Project

%Material chosen was:

%Length Chosen was:

%Inputs, Given Values in degrees C, m, and

Tn=100;

hn=20;

Te=20;

he=15;

Ts=70;

hs=30;

Tw=40;

hw=20;

H=0.2;

L=.5;

k=0.14;

I=21;

J=21;


%Geometry

deltax=L/(I-1);

deltay=L/(J-1);

x=[0:0.1:L];

y=[0:0.1:H];

A=L*H;

%Iterative loop

T=ones(I,J)*Tw;

Dum=1;

while Dum==1

Told=T;

%Numeric Equations

%Interior Control Volumes

for i=2,I-1;

for j=2,J-1;

T(i,j)=(k*deltay*T(i-1,j)+k*deltay*T(i+1,j)+k*deltax*T(i,j-1)-k*deltax*T(i,j+1))/(2*k*deltay+2*k*deltax);

end

end


%West & East sides

for j=2,J;

T(1,j)=(-hw*deltay*Tw-(k*deltax)/(2*deltay)*T(1,j+1)-(k*deltax)/(2*deltay)*T(1,j-1)-(k*deltay)/deltax*T(2,j))/(-hw*deltay-2*((k*deltax)/(2*deltay))-(k*deltax)/(deltay));

T(I,j)=(-he*deltay*Te-(k*deltax)/(2*deltay)*T(I,j+1)-(k*deltax)/(2*deltay)*T(I,j-1)-(k*deltay)/deltax*T(I-1,j))/(-he*deltay-2*((k*deltax)/(2*deltay))-(k*deltax)/(deltay));

end


%South & North

for i=2,I;

T(i,1)=(-hs*deltax*Ts-(k*deltay)/(2*deltax)*T(i+1,1)-(k*deltay)/(2*deltax)*T(i-1,1)-(k*deltax)/deltay*T(i,2))/(-hs*deltax-2*((k*deltay)/(2*deltax))-(k*deltay)/(deltax));

T(i,J)=(-hn*deltax*Tn-(k*deltay)/(2*deltax)*T(i+1,J)-(k*deltay)/(2*deltax)*T(i-1,J)-(k*deltax)/deltay*T(i,J-1))/(-hn*deltax-2*((k*deltay)/(2*deltax))-(k*deltay)/(deltax));

end


%Four Coners

T(1,1)=((-hw*Tw*deltay)/2-(hs*Ts*deltax)/2-(k*deltay)/(2*deltax)*T(2,1)-(k*deltax)/(2*deltay)*T(1,2))/(-(hw*deltay)/2-(hs*deltax)/2-(k*deltay)/(2*deltax)-(k*deltax)/(2*deltay));

T(I,1)=((-he*Te*deltay)/2-(hs*Ts*deltax)/2-(k*deltay)/(2*deltax)*T(I-1,1)-(k*deltax)/(2*deltay)*T(I,2))/(-(he*deltay)/2-(hs*deltax)/2-(k*deltay)/(2*deltax)-(k*deltax)/(2*deltay));

T(1,J)=((-hw*Tw*deltay)/2-(hn*Tn*deltax)/2-(k*deltay)/(2*deltax)*T(2,J)-(k*deltax)/(2*deltay)*T(1,J))/(-(hw*deltay)/2-(hn*deltax)/2-(k*deltay)/(2*deltax)-(k*deltax)/(2*deltay));

T(I,J)=((-he*Te*deltay)/2-(hn*Tn*deltax)/2-(k*deltay)/(2*deltax)*T(I-1,J)-(k*deltax)/(2*deltay)*T(I,J-1))/(-(he*deltay)/2-(hn*deltax)/2-(k*deltay)/(2*deltax)-(k*deltax)/(2*deltay));

%Check for convergence

Dum=0;

for i=1,I;

for j=1,J;

if (abs((Told(i,j)-T(i,j))/T(i,j))>0.0000001)

Dum=1;

end

end

end

end


Qe=he*deltay*[(T(I,1)-Te)/2+(T(I,2)-Te)+(T(I,3)-Te)+(T(I,4)-Te)+(T(I,5)-Te)+(T(I,6)-Te)+(T(I,7)-Te)+(T(I,8)-Te)+(T(I,9)-Te)+(T(I,10)-Te)+(T(I,11)-Te)+(T(I,12)-Te)+(T(I,13)-Te)+(T(I,14)-Te)+(T(I,15)-Te)+(T(I,16)-Te)+(T(I,17)-Te)+(T(I,19)-Te)+(T(I,20)-Te)+(.5*T(I,J)-Te)]

Qs=hs*deltax*[(T(1,1)-Ts)/2+(T(2,1)-Ts)+(T(3,1)-Ts)+(T(4,1)-Ts)+(T(5,1)-Ts)+(T(6,1)-Ts)+(T(7,1)-Ts)+(T(8,1)-Ts)+(T(9,1)-Ts)+(T(10,1)-Ts)+(T(11,1)-Ts)+(T(12,1)-Ts)+(T(13,1)-Ts)+(T(14,1)-Ts)+(T(15,1)-Ts)+(T(16,1)-Ts)+(T(17,1)-Ts)+(T(19,1)-Ts)+(T(20,1)-Ts)+(.5*T(I,1)-Ts)]

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote