You are on page 1of 3

8rlan klmball

ur Maranas
Ch L 360
Aprll 26 2011
llnal ro[ecL
1he below code models Lhe LemperaLure dlsLrlbuLlon of a Lrapezoldal plece of polymer fllm wlLh a
Lhermal dlffuslvlLy c
2
023 fL
2
/mln aL a Llme L 20 mln 1he dlmenslons of Lhe Lrapezold are L1 13 L2
3 and L3 10 1he lefL and rlghL boundarles are LreaLed as lnsulaLed whlle Lhe boLLom boundary ls
held aL 11 334 and Lhe Lop boundary ls held aL 14 441 1he lnlLlal LemperaLure dlsLrlbuLlon ls
modeled by Lhe equaLlon

0
(, ) =
1
+ -

- I
+

- I

0.5

1o ad[usL Lhe Llme sLep Lhe followlng equaLlon was used aL each polnL
(, , + A) = (, , ) + A - c
2
-
( - , , ) + ( + , , ) - - (, , )
A
2
+
(, - , ) + (, + , ) - - (, , )
A
2

1he grld was seL up ln a way LhaL each polnL on Lhe slanLed boundary ls on Lhe grld 1he lnsulaLed
boundary was accounLed for by creaLlng an exLra empLy column on each slde of Lhe maLrlx 1hls column
on Lhe oLher slde of Lhe lnlLlal condlLlon ls copled lnLo Lhe empLy column allowlng for Lhe same
equaLlon Lo be used when calculaLlng Lhe LemperaLure change ln Lhe lnsulaLed boundary
AfLer runnlng Lhe program lL was found LhaL Lhe flnal LemperaLure aL 20 mlns aL Lhe polnL (L1/2 L3/2)
ls equal Lo 4413327 degrees

MA1LA8 Code
%%% Ch E 360 Final Project %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%"A" is the matrix containing the temperature values. The matrix "B"
%contains values for the total number of active nodes in each column. The
%program accounts for the insulated boundary by creating an extra column on
%each side to mirror the points on the other side of the boundary.

%The variable "h" only determines the step size in the x direction. The
%program will automatically choose a y step size "dy" from the chosen x
%step size "dx" in a way that the slanted boundary is always on the grid.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Parameters
L1 = 15;
L2 = 5;
L3 = 10;
T1 = 334;
T4 = 441;

c2 = 0.25;
t = 20;
dt = 0.001;
h = 0.25;


%Mesh Creation
opposite = L3 - L2;
adjacent = L1;
tanx = (L3 - L2)/L1;
hx = ceil(L1/h);
dx = L1/hx;
dy = dxtanx;

Ln1 = round(L1/dx) + 3;
Ln3 = round(L3/dy);

A = zeros(Ln3,Ln1);
B = zeros(Ln1,1);

for i = 2:Ln1 - 1
x = (i - 2)dx;
y = (xtanx + L2)/dy + 1;
B(i,1) = round(y);
end


%Temperature Profile Initialization
for j = 2:Ln1 - 1
for i = 1:B(j,1)
x = (j - 2)dx;
y = (i - 1)dy;
A(i,j) = T1 + 200(0.5x/L1 + 0.5y/L3)^0.5;
end
end

for i = 2:Ln1 - 1
A(1,i) = T1;
A(B(i,1),i) = T4;
A(B(i,1)+1,i) = T4;
end


%Heat Conduction by Finite Differences
for i = 1:t/dt
A(:,1) = A(:,3);
A(:,Ln1) = A(:,Ln1 - 2);
C = A;
for j = 2:Ln1 - 1
for h = 2:B(j,1) - 1
A(h,j) = C(h,j) + (dtc2)((C(h,j-1) + C(h,j+1) - 2C(h,j))/dx^2
+ (C(h-1,j) + C(h+1,j) - 2C(h,j))/dy^2);
end
end
end
disp(A(ceil(Ln3/2),ceil(Ln1/2)))


%3D Plot
I = find(abs(A)<=0);
A(I) = NaN;
surf(A,'linestyle','none')
title('Temperature Profile: 20 min','FontWeight','bold')
xlabel('x')
ylabel('y')
zlabel('Temperature')
colorbar




1emperaLure aL (L1/2 L3/2) aL L 20 mlnuLes 1 4413327
0
20
10
0
80
0
50
100
150
300
350
100
150
500

x
Te mpe ra ture Prof|| e : 20 m| n
y

T
e
r
p
e
r
a
l
u
r
e
310
30
380
100
120
110
10

You might also like