% Fin_Efficiency_circular_fin.m
% [1]                         26.12.2022
% Fin efficiency of a circular fin with
% rectangular section, and adiabatic tip 

clear;clc

% Input variables
dep = 25.4;	    % mm	   Pipe exterior diameter 	
w =	6.35;	    % mm	   Fin length	
t =	1.59;	    % mm	   Fin thickness	
h =	568;	    % W/(m*K)  Convection coefficient	
k =	26.0;	    % W/(m*K)  Thermal conductivity	

% Units change
dep = dep / 1000;   %(m)
w = w / 1000;       %(m)
t = t / 1000;       %(m)

% Auxiliary variables
di = dep;              % interior diameter of fin
ri = di / 2;           % interior fin radius
radE = ri + w;         % exterior fin radius
rec = radE + (t / 2);  % corrected exterior radius

Ra = (2) ^ 0.5 / (1 - ri / rec);
Rb = (ri / rec) * Ra;
wc = w + t / 2;
a = t * wc;
X = wc ^ (3 / 2) * (h / (k * a)) ^ 0.5;

% Fin efficiency
% e = eA * eB

eA = ((2) ^ (1 / 2) / X) / (1 + rec / ri);

% eB = Numerator / Denominator

%Numerator

%Bi(1,Ra*x)
B_i_Ra_x_1 = besseli(1,Ra * X);
%Bk(1,Rb*x)
B_k_Rb_x_1 = besselk(1,Rb * X);
%Bi(1,Rb*x)
B_i_Rb_x_1 = besseli(1,Rb * X);
%Bk(1,Ra*x)
B_k_Ra_x_1 = besselk(1,Ra * X);
Num = B_i_Ra_x_1 * B_k_Rb_x_1 - B_i_Rb_x_1 * B_k_Ra_x_1;

%Denominator

%Bi(1,Ra*x)
B_i_Ra_x_1 = besseli(1,Ra * X);
%Bk(0,Rb*x)
B_k_Rb_x_0 = besselk(0,Rb * X);
%Bi(0,Rb*x)
B_i_Rb_x_0 = besseli(0,Rb * X);
%Bk(1,Ra*x)
B_k_Ra_x_1 = besselk(1,Ra * X);
Den = B_i_Ra_x_1 * B_k_Rb_x_0 + B_i_Rb_x_0 * B_k_Ra_x_1;

eB = Num / Den;

Fin_Efficiency = eA * eB
 
%__________________________________________________

% Note 1. Requirement: Bessel functions must be active

% The functions I are the modified Bessel functions of the first class
% of zero order besseli(0,x) and of first order besseli(1,x).
% The functions K are the modified Bessel functions of the second kind
% of zero order Besselk(0,x) and of first order Besselk(1,x).


%Reference
% [1] Conduction heat transfer, P. J. Schneider
%     Department of Mechanical Engineering
%     University of Minesota
%     Addison-Wesley Pub. Co., Six edition 1974
%     Equation 4-36, page 84