%%%%%%%%%%%%%%%%%%%%%%%%%%Exercise(3-5c)%%%%%%%%%%%%%%%%%%%%%%%%%%
% Exercise (3-5c)- Temperature Distribution in Annular Fin
% with Hyperbolic Profile.
% Solution by Finite Difference Method
% ODE Model Equation: d/dr(r^-1*dTeta/dr)-m^2*r*Teta=0
% Teta=T-Tamb
% m^2 = h/b*k*Ri^2
% Boundary Condition
% r=Ri , Teta=Teta0
% r=Ro , dTeta/dr=0
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all
clc
% Input Constants
const;
% Equation Constant
m=sqrt(h/(b*K*Ri^2));
% r Vector & Step Size
r=linspace(Ri,Ro,n);
dr=(Ro-Ri)/(n-1);
% Creating Matrix of Coefficients and Vector of Constants
coeff;
% Solver by Gauss elimination in Matlab
b=A;
b(:,n+1)=c';
y=rref(b);
Teta=y(:,end);
T=Teta+Tamb;
% Plotting Results
plot(r*100,T-273.15,'r','LineWidth',2)
xlabel('r(cm)')
ylabel('T(C)')
axis tight
--------------------- const.m -----------------------
% Constants in SI Unit
Tamb=25+273.15; % K
T0=100+273.15; % K
h=20; % J/m^2.K
K=300; % J/m.K
b=0.01; % m
Ri=0.01; % M
Ro=0.1; % M
Teta0=T0-Tamb; % K
n=100;
----------------------coeff.m -----------------------
% Creating Matrix Coefficients(A) and Vector of Constants(c) in Linear
% Algebraic Equation (A*y = c )