Assignment 2
Assignment 2
Problem Statement:
Solve the 1D steady-state heat conduction problem in a large plate of thickness L = 2 cm. The
plate has a constant thermal conductivity k = 0.5 W/m/K and uniform internal heat
generation q = 1000 kW/m³. The two surfaces of the plate are maintained at constant
temperatures: 100°C and 300°C respectively. Assume temperature varies only in the x-direction.
Use the Finite Volume Method (FVM) to discretize the equation and solve numerically.
Compare the numerical results with the analytical solution. Plot the temperature distribution
across the plate thickness.
k=1000;
A=10*10^(-3);
aE=(k*A)/dx;
aW=aE;
Sp=0;
aP=aE+aW-Sp;
for j=2:nx-1
p(j,j)=aP;
p(j+1,j)=-aE;
p(j-1,j)=-aW;
b(j)=0.0;
end
Ta=100;
Tb=500;
aE=(k*A)/dx;
aW=0;
Sp=-(2.*k*A)/dx;
aP=aE+aW-Sp;
j=1;
p(1,j)=aP;
p(2,j)=-aE;
b(1)=(2.*k*A)/dx*Ta;
aE=0;
aW=(k*A)/dx;
Sp=-(2.*k*A)/dx;
aP=aE+aW-Sp;
j=nx;
p(ny,j)=aP;
p(ny-1,j)=-aW;
b(nx)=(2.*k*A)/dx*Tb;
T=p\b;
for i=2:ny+1
T_num(i,1)=T(i-1,1);
end
T_num(1,1)=Ta;
T_num(ny+2,1)=Tb;
xn(1,1)=0.0;
xn(ny+2,1)=L;
for i=1:ny
xn(i+1,1)=dx*(i-1)+(dx/2);
end
T_an1=800*xn+100;
plot(xn,T_an1);
hold on;
plot(xn,T_num,'*');
title('2-D Diffusion equation solver by FVM')
xlabel('Distance(m)');
ylabel('Temperature(in degree C)');
My Modified Code:
clc;
clear;
% Given data
L = 0.02; % Plate thickness in meters
k = 0.5; % Thermal conductivity in W/m/K
q = 1e6; % Internal heat generation in W/m^3
Ta = 100; % Left boundary temperature in deg C
Tb = 300; % Right boundary temperature in deg C
nx = 100; % Number of discretization nodes
% Loop over internal nodes and fill the matrix and source vector
for j = 2:nx-1
aE = (k*A)/dx; % East coefficient
aW = (k*A)/dx; % West coefficient
aP = aE + aW; % Central node coefficient