function mnhf_fin3(n,Bi) %MNHF_FIN3 solves for the 1D temperature distribution in a cooling fin % of variable cross-sectional area subject to Dirichlet BCs. % % n - number of interior grid points. % Bi - modified Biot number. % % Usage mnhf_fin3(100,1e-1) % Set grid spacing, i.e. define \delta \xi. dxi = (1.0-0.0)/(n+1); %% Initialize arrays. xi = linspace(dxi,1.0-dxi,n); maindiag = -2.0*(2.0-xi+Bi*dxi^2.0); % Main diagonal. supdiag = 2.0-xi(1:end-1)-0.5*dxi; % Super diagonal. subdiag = 2.0-xi(2:end)+0.5*dxi; % Sub diagonal. T = diag(maindiag,0)+diag(supdiag,1)+diag(subdiag,-1); % Put it together. b = zeros(n,1); % Define RHS vector. b(1) = -1.0*(2.0-xi(1)+0.5*dxi); % Solve linear system using Thomas's algorithm then plot solution. theta = mnhf_thomas(T,b); theta = [1.0 theta' 0.0]; xi = linspace(0.0,1.0,n+2); figure(1); hold on; box on; set(gca,'fontsize',14) plot(xi,theta,'k--','linewidth',2); %% Add axis labels and a title to the figure. xlabel('{\it \xi=x/L}'); ylabel('{\it \theta=(T-T_\infty)/(T_0-T_\infty)}'); title('Cooling fin (variable cross-section, Dirichlet BCs)','fontsize',12)