Heat Transfer Lessons With Examples Solved — By Matlab Rapidshare Added Patched
Goal: temperature vs time for small Biot number (lumped) and for 1D slab by finite difference.
Key equations:
Example (lumped): Sphere, ρ=7800 kg/m3, c=470 J/kgK, r=0.01 m, h=50 W/m2K, T0=200°C, T_inf=20°C. Compute T at t=10 s.
MATLAB (lumped):
rho=7800; c=470; r=0.01; h=50; T0=200; Tinf=20; t=10;
V=4/3*pi*r^3; A=4*pi*r^2;
T = Tinf + (T0-Tinf)*exp(-h*A/(rho*V*c)*t);
fprintf('T(10s)=%.2f °C\n',T);
Example (1D slab explicit FD): slab thickness L=0.02 m, k=16 W/mK, rho=7800, c=460, initial T0=100°C, boundaries T=20°C, simulate to 50 s.
MATLAB (explicit FD):
L=0.02; nx=51; dx=L/(nx-1);
k=16; rho=7800; c=460; alpha=k/(rho*c);
dt=0.01; nt=5000; % ensure dt <= dx^2/(2*alpha)
x=linspace(0,L,nx);
T = 100*ones(1,nx);
T([1,end])=20;
for n=1:nt
Tn=T;
for i=2:nx-1
T(i)=Tn(i)+alpha*dt/dx^2*(Tn(i+1)-2*Tn(i)+Tn(i-1));
end
end
plot(x,T); xlabel('x'); ylabel('T (°C)');
The old days of “rapidshare added patched” are over – and good riddance. Today, you have: Goal: temperature vs time for small Biot number
Problem: 4×4 grid, fixed boundary conditions. Solve using Gauss-Seidel.
% 2D steady conduction - Finite Difference Method clear; clc;nx = 5; ny = 5; % 5x5 nodes (4x4 internal) T = zeros(nx, ny);
% Boundary conditions T(:,1) = 100; % left wall 100°C T(:,end) = 0; % right wall 0°C T(1,:) = 50; % top wall 50°C T(end,:) = 50; % bottom wall 50°C Example (lumped): Sphere, ρ=7800 kg/m3, c=470 J/kgK, r=0
% Gauss-Seidel iteration max_iter = 5000; tolerance = 1e-6; for iter = 1:max_iter T_old = T; for i = 2:nx-1 for j = 2:ny-1 T(i,j) = (T(i+1,j) + T(i-1,j) + T(i,j+1) + T(i,j-1)) / 4; end end if max(abs(T - T_old), [], 'all') < tolerance break; end end
% Plot [X, Y] = meshgrid(1:nx, 1:ny); surf(X, Y, T'); xlabel('X nodes'); ylabel('Y nodes'); zlabel('Temp (°C)'); title('2D Steady Conduction (FDM)'); colorbar;
Result: A smooth temperature hill – hot left side, cold right, warm top/bottom.



