Вы находитесь на странице: 1из 8

1.

Matlab Code for the Solution of Fin Conduction Problem with TDMA Process:
disp('We will find the values of theta at the given grid points which is the difference between the temperature at the given grid point and the ambient temperature') n=input('Enter the value of n where n+1 is the total no of grids = '); a=input('Enter the value of a ='); b=input('Enter the value of b ='); c=input('Enter the value of c ='); L=input('Enter the length of the fin= '); g=L/n; for k=1:1:n+1 x(k)=(k-1)*g; D(k)=a+(b*x(k))+(c*x(k)^2); A(k)=pi/4*D(k)*D(k); P(k)=pi*D(k); end k=input('Enter the value of the thermal conductivity= '); h=input('Enter the value of the heat tranfer co-efficient= '); H=input('Enter the heat transfer co-effient of the convecting tip = '); TA=input('Enter the ambient temperature = '); TB=input('Enter the base temperature = '); %Storing the elements of the matrix for solution% for i=1 K(i,i)=1; for j=2:1:n+1 K(i,j)=0; end end for i=2:1:n K(i,i-1)=A(i-1)-(h*P(i-1)*g/1000*g/k); K(i,i)=-(A(i)+A(i-1)); K(i,i+1)=A(i); end for i=n+1 K(i,i-1)=-1; K(i,i)=1+(H*g*.001/k); end K(1,n+2)=TB-TA; for i=2:1:n

K(i,n+2)=0; end % The TDM Algorithm % Kn(1,1)=K(1,1); Kn(1,n+2)=K(1,n+2); for r=1:1:n Kn(r,r+1)=K(r,r+1); end for s=2:1:n+1 Kn(s,s)=K(s,s)-(K(s,s-1)*Kn(s-1,s)/Kn(s-1,s-1)); Kn(s,n+2)=K(s,n+2)-(K(s,s-1)*Kn(s-1,n+2)/Kn(s-1,s-1)); end Theta(n+1)=Kn(n+1,n+2)/Kn(n+1,n+1); for g=n:-1:2 Theta(g)=(Kn(g,n+2)-(K(g,g+1)*Theta(g+1)))/Kn(g,g); end fprintf('\nThe value of Theta at the grid point 1 : %i\n',Kn(1,n+2)) for s=2:1:n fprintf('\nThe value of Theta at the grid point %i is : %5.3f\n',s,Theta(s)) end fprintf('\nThe value of Theta at the grid point %i is : %f \n',n+1,Theta(n+1))

2. Matlab Code for the Solution of Fin Conduction Problem with Gauss- Siedel Process:
disp('We will find the values of theta at the given grid points which is the difference between the temperature at the given grid point and the ambient temperature') n=input('Enter the value of n where n+1 is the total no of grids = '); a=input('Enter the value of a ='); b=input('Enter the value of b ='); c=input('Enter the value of c ='); L=input('Enter the length of the fin= '); g=L/n; for k=1:1:n+1 x(k)=(k-1)*g; D(k)=a+(b*x(k))+(c*x(k)^2); A(k)=pi/4*D(k)*D(k); P(k)=pi*D(k); end

k=input('Enter the value of the thermal conductivity= '); h=input('Enter the value of the heat tranfer co-efficient= '); H=input('Enter the heat transfer co-effient of the convecting tip = '); TA=input('Enter the ambient temperature = '); TB=input('Enter the base temperature = '); %Storing the elements of the matrix for solution% for i=1 K(i,i)=1; for j=2:1:n+1 K(i,j)=0; end end for i=2:1:n K(i,i-1)=A(i-1)-(h*P(i-1)*g/1000*g/k); K(i,i)=-(A(i)+A(i-1)); K(i,i+1)=A(i); end for i=n+1 K(i,i-1)=-1; K(i,i)=1+(H*g*.001/k); end K(1,n+2)=TB-TA; for i=2:1:n K(i,n+2)=0; end disp(K) z=input('Enter the initial approximation = '); for j=1:1:n+1 Theta(j)=z; end for k=1:1:10 for i=1:1:n+1 s=K(i,n+2); for j=1:1:n+1 if j~=i s=(s-(K(i,j)*Theta(j))); end end Theta(i)=s/K(i,i);

end end fprintf('Solutiions are\n') for i=1:1:n+1 fprintf('Theta[%d]=%5.3f\n',i,Theta(i)) end

3. Matlab Code for the Solution of Fin Conduction Problem analytically:


n=input('Enter the value of n where n+1 is the total number of grid points = '); L=input('Enter the length of the fin = '); g=L/n; m=5.096; for i=1:1:n+1 x(i)=(i-1)*g/1000; Theta(i)=cosh(m*(L-x(i)))/cosh(m*L)*465; fprintf('\nThe value of Theta at the grid point %i is %5.3f\n',i,Theta(i)) end

4. Comparison of the Numerical results with the Analytical results for Code validation using TDMA Solution process:

5. Graphical Plot of the Case 1 using 30 grid Points(h=37W/m2oC;L=5 cm)

6. Graphical Plot of the Case 2 using 30 grid Points(Tb=500oC;L=5 cm)

7. Graphical Plot of the Case 3 using 30 grid Points (h=37W/m2oC;Tb=500oC)

Вам также может понравиться