Download - Matlab Project 406
-
8/2/2019 Matlab Project 406
1/16
1 Term Project
King Saud University
College of Engineering
Chemical Engineering Department
ChE 406: Computational Techniques
Term Project
By
Jassim Mohammed AlDraisi 428101168
-
8/2/2019 Matlab Project 406
2/16
2 Term Project
Study the heat conduction in cylindrical metallic rod extended surface
Part1: Steady State Analysis
Steady state systems:
This can be discretized by find it difference AND WE CAN DEFAINE A SYSTEM OF LINEAR EQUATIONS:
THE OBGCTOR OF THE GIVEN MATLAB PROGRAM IS TO DEFINE THR
MATRIX "A"
AND THE VECROT "B" THEN SOLVE FOR "T"
-
8/2/2019 Matlab Project 406
3/16
3 Term Project
A=ZERO(npoints, npoints)
B=-b * ONE(npoints,1)
=-b *
FOR LOOP
i = 1 - 4
j =1 4IF i=j
=, A(i,j) = -a = -(2+( )) = - (2+ )Else if j=i+1 or j=i-1A(i,j)=1
Else if
A(i,j)=0
-
8/2/2019 Matlab Project 406
4/16
4 Term Project
A=
B(1)=-b- =-112.5
B(end)= -b-
B=
=
(
)
Commend to slove TT=A\B
-
8/2/2019 Matlab Project 406
5/16
5 Term Project
Matlab Codes
% working out problems of midterm one spring 2012% solution of prblem
% A Matlab program to solve a system of %linearequations toobtain
% the temperature profile in a metallic %rodsubject toabasetemperatureof%100deg-C% Define all known parameters%(1.2)Obtain and plot the solution for npoints=20 and for (k=50W/m/K) for natural
convection (h=5W/m2/K) when d=2mm, L=50cm
Too=25;To=100;TL=Too;h=5;k=50;L=0.5;D=0.002;P=0.15;S=0.002;
% calculate defined parametersnpoints=20;m=h*P/(k*S);Dx=L/(npoints+1);a=2+(m*Dx^2);b=(m*Dx^2)*Too;A=zeros(npoints,npoints);B=-b*ones(npoints,1);% Define the system: matrix A and vector B%for i=1:npointsfor j=1:npointsif i==j
A(i,j)=-a;elseif j==i+1 | j==i-1A(i,j)=1;
elseA(i,j)=0;endendendB(1)=-b-To;B(end)=-b-TL;%% Compute the solution T=[T1 T2 T3 T4]%T=A\B;
%% Display the result in a graphic form%plot([0:Dx:L],[To;T;TL],'*b')xlabel('Position in (m)');ylabel('Temperature in deg-C');
-
8/2/2019 Matlab Project 406
6/16
6 Term Project
-
8/2/2019 Matlab Project 406
7/16
7 Term Project
%(1.3) Obtain and plot the solution for various thermal conductivities (k=[50])
Too=25;To=100;TL=Too;h=5;k=50;L=0.5;D=0.002;P=0.15;
S=0.002;% calculate defined parametersnpoints=20;m=h*P/(k*S);Dx=L/(npoints+1);a=2+(m*Dx^2);b=(m*Dx^2)*Too;A=zeros(npoints,npoints);B=-b*ones(npoints,1);% Define the system: matrix A and vector B%for i=1:npointsfor j=1:npointsif i==jA(i,j)=-a;elseif j==i+1 | j==i-1A(i,j)=1;
elseA(i,j)=0;endendendB(1)=-b-To;B(end)=-b-TL;%% Compute the solution T=[T1 T2 T3 T4]%T=A\B;
%% Display the result in a graphic form%plot([0:Dx:L],[To;T;TL],'*b')xlabel('Position in (m)');ylabel('Temperature in deg-C');
-
8/2/2019 Matlab Project 406
8/16
8 Term Project
-
8/2/2019 Matlab Project 406
9/16
9 Term Project
%(1.3) Obtain and plot the solution for various thermal conductivities (k=[100])
Too=25;To=100;TL=Too;h=5;k=100;L=0.5;D=0.002;
P=0.15;S=0.002;% calculate defined parametersnpoints=20;m=h*P/(k*S);Dx=L/(npoints+1);a=2+(m*Dx^2);b=(m*Dx^2)*Too;A=zeros(npoints,npoints);B=-b*ones(npoints,1);% Define the system: matrix A and vector B%for i=1:npointsfor j=1:npointsif i==jA(i,j)=-a;elseif j==i+1 | j==i-1A(i,j)=1;
elseA(i,j)=0;endendendB(1)=-b-To;B(end)=-b-TL;%% Compute the solution T=[T1 T2 T3 T4]%
T=A\B;%% Display the result in a graphic form%plot([0:Dx:L],[To;T;TL],'*b')xlabel('Position in (m)');ylabel('Temperature in deg-C');
-
8/2/2019 Matlab Project 406
10/16
10 Term Project
-
8/2/2019 Matlab Project 406
11/16
11 Term Project
%(1.3) Obtain and plot the solution for various thermal conductivities (k=[150])
Too=25;To=100;TL=Too;h=5;k=150;L=0.5;D=0.002;P=0.15;
S=0.002;% calculate defined parametersnpoints=20;m=h*P/(k*S);Dx=L/(npoints+1);a=2+(m*Dx^2);b=(m*Dx^2)*Too;A=zeros(npoints,npoints);B=-b*ones(npoints,1);% Define the system: matrix A and vector B%for i=1:npointsfor j=1:npointsif i==jA(i,j)=-a;elseif j==i+1 | j==i-1A(i,j)=1;
elseA(i,j)=0;endendendB(1)=-b-To;B(end)=-b-TL;%% Compute the solution T=[T1 T2 T3 T4]%T=A\B;
%% Display the result in a graphic form%plot([0:Dx:L],[To;T;TL],'*b')xlabel('Position in (m)');ylabel('Temperature in deg-C');
-
8/2/2019 Matlab Project 406
12/16
12 Term Project
-
8/2/2019 Matlab Project 406
13/16
-
8/2/2019 Matlab Project 406
14/16
14 Term Project
%(1.4) For a value of k=500 (highly conductive metal) natural convection (h=5)
Too=25;
To=100;TL=Too;h=5;k=500;L=0.5;
D=0.002;P=0.15;S=0.002;% calculate defined parametersnpoints=20;m=h*P/(k*S);Dx=L/(npoints+1);a=2+(m*Dx^2);b=(m*Dx^2)*Too;A=zeros(npoints,npoints);B=-b*ones(npoints,1);% Define the system: matrix A and vector Bfor i=1:npointsfor j=1:npointsif i==jA(i,j)=-a;elseif j==i+1 | j==i-1A(i,j)=1;
elseA(i,j)=0;endendend
-
8/2/2019 Matlab Project 406
15/16
15 Term Project
B(1)=-b-To;B(end)=-b-TL;%% Compute the solution T=[T1 T2 T3 T4]T=A\B;% Display the result in a graphic formplot([0:Dx:L],[To;T;TL],'*b')xlabel('Position in (m)');ylabel('Temperature in deg-C');
-
8/2/2019 Matlab Project 406
16/16
16 Term Project
Refrance
Bathe K.J., Finite Element Procedures In Engineering Analysis, Prentice-Hall,1982