MM 218 Programming Assignment
GROUP 40:
ANSY JENA:22B2513
T
ASHUTOSH GANDHE:22B2409
PRATHAMESH YEOLE:22B2541
PROBLEM 4:
onsidertwoplates,AandB,thatareeachinitiallyisothermalandeachofthicknessL=5mm.The
C
faces of the plates are suddenly brought into contact in a joining process. Material A is acrylic,
initiallyatTi,A=20oCwithρA =1990kg/m3,cA =1470J/kg.KandkA =0.21W/m.K.MaterialBissteelinitially
atTi,B =300oCwithρB =7800kg/m3, cB =500J/kg.KandkB =45W/m.K.Theexternal(back)surfacesof
the acrylic and steel are insulated. Neglecting the thermal contact resistancebetweentheplates,
determine how long it will take for the external surface of the acrylic to reach its softening
temperature, Tsoft = 90oC. Plot the acrylic’s external surface temperature as well as the average
temperatures of both materials over the time span . Use 20 equally spaced nodal points.
MATLAB CODE
%we will make an array of 300/delt x 20 shape
%the 20 columns will denote the temperature of each node
%at the time instance denoted by the row number
%rows denote time instances
%we can set delt = 0.0001 seconds (Using the stablility condition)
%Total time instances = 3000001
%3000000 starting from t = 0.0 and the 1 extra for when we reach t=300
T= zeros(3000001, 20);
%array for calculating average temp
T_a_avg = zeros(3000001, 1);
T_b_avg = zeros(3000001, 1);
%Constants
delt = 0.0001;
delx = 5 * 10^(-3)/9.5;
%For A
ka = 0.21;
ca = 1470;
pa = 1990;
%Note: lambda = k/(c*p) * (delt/(delx)^2
lam_a = ka/(ca*pa) * delt/(delx)^2;
%For B
kb = 45;
cb = 500;
pb = 7800;
lam_b = kb/(cb*pb) * delt/(delx)^2;
%resistance at the interface
R = delx/(2*ka) + delx/(2*kb);
%now for the initial temperatures of the two materials
%nodes 1 to 10 belonged to material A and hence their
%initial temp = 20 deg celcius
T(:, 1:10) = 20+273.15;
%similar for material B, from nodes 11 to 20
%initial temp = 300 deg celcius
T(:, 11:20) = 300+273.15;
%Implement 1 round of gauss seidel below
%going by time instances denoted by L
%counter to print 90 degree celcius
z=0;
for
L = 1:300000
0
%now to
column by column to perform gauss seidel
%at each node
for
i=1:20
%for node 1
if
i ==1
T(L+1,i) = 2*lam_a * (T(L, i+1) - T(L,i)) + T(L,i);
end
%for nodes 2 to 9
if
i >1 && i<10
T(L+1,i) = (lam_a * (T(L, i+1) + - 2*T(L,i) + T(L, i-1))+ T(L,i));
end
%for node 10
if
i == 10
T(L+1,i) = (lam_a*delx/(ka*R)) * (T(L, i+1) - T(L,i)) + lam_a* (T(L,
i-1) - T(L,i))+ T(L,i);
end
%for node 11
if
i == 11
T(L+1,i) = (lam_b*delx/(kb*R)) * (T(L, i-1) - T(L,i)) + lam_b*(T(L,
i+1) - T(L,i))+ T(L,i);
end
%for nodes 12 to 19
if
i >11 && i<20
T(L+1,i) = (lam_b * (T(L, i+1) + - 2*T(L,i) + T(L, i-1))+ T(L,i));
end
%for node 20
if
i == 20
T(L+1,i) = 2*lam_b * (T(L, i-1) - T(L,i)) + T(L,i);
end
end
%to print the instance at which
%temperature of external acrylic surface becomes 90 degrees celcius
%we set a tolerable value around which we wish to see
%the temperature to reach nearly 90 degrees
if
(abs(T(L, 1) - (90+273)) < 0.001 && z == 0)
fprintf(
"The time at which temperature is 90 degrees = %9.9f seconds \n"
,
L * 0.0001);
z=1;
end
end
%calculating average temp
for
j = 1:3000001
%to calculate the sum
sum_a = 0;
sum_b = 0;
for
k = 1: 20
%for material A
if
(k<11)
%delx/2 for node 1
if
(k == 1)
sum_a = sum_a + 0.5*T(j,k);
%using delx for node 2 to 10
else
sum_a = sum_a + T(j,k);
end
end
if
k>10
%using delx/2 for node 20
if
k == 20
sum_b = sum_b + 0.5*T(j,k);
%using delx for node 11-19
else
sum_b = sum_b + T(j,k);
end
end
end
T_a_avg(j) = sum_a/9.5;
T_b_avg(j) = sum_b/9.5;
end
%now for plotting purposes
x = linspace(1, 3000001, 3000001);
time_range = x*0.0001;
%we plot the surface temperature
plot(time_range(1:3000000), T(1:3000000, 1));
xlabel(
'time in seconds'
);
ylabel(
'Temperature (K)'
);
title(
'External Temperature of Acrylic'
);
grid
on
;
print(
'External Temp of Acrylic'
,
'-dpng'
);
figure;
%now to plot the average surface temperatures
%for material A
plot(time_range(1:3000000), T_a_avg(1:3000000));
hold
on
;
%for material B
plot(time_range(1:3000000), T_b_avg(1:3000000));
xlabel(
'Time in seconds'
);
ylabel(
'Temperature of Surfaces (K)'
);
legend(
'Material A'
,
'Material B'
);
title(
'Average Temperatures of Materials'
)
grid
on
;
print(
'Average Surface Temp'
,
'-dpng'
);