0% found this document useful (0 votes)
3 views8 pages

Assignment 2

The document outlines an assignment focused on solving a 1D steady-state heat conduction problem in a plate using the Finite Volume Method (FVM). It provides a problem statement with specific parameters, a sample code for implementation, and a modified version of the code to achieve the solution. The task includes comparing numerical results with an analytical solution and plotting the temperature distribution across the plate's thickness.

Uploaded by

lugnipvt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views8 pages

Assignment 2

The document outlines an assignment focused on solving a 1D steady-state heat conduction problem in a plate using the Finite Volume Method (FVM). It provides a problem statement with specific parameters, a sample code for implementation, and a modified version of the code to achieve the solution. The task includes comparing numerical results with an analytical solution and plotting the temperature distribution across the plate's thickness.

Uploaded by

lugnipvt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Assignment 2 - Computational Heat Transfer and Fluid Dynamics

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.

Sample Code Provided:


clc
clear
nx=3;
ny=3;
L=0.5;
dx=L/(nx);
p=zeros(ny,nx);
pn=zeros(ny,nx);
b=zeros(ny,1);
T=zeros(ny,1);
T_num=zeros(ny+2,1);
T_an=zeros(ny+2,1);
xn=zeros(ny+2,1);

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

% Geometry and area


dx = L/(nx-1); % Control volume width
A = 1; % Cross-sectional area assumed as 1 m^2

% Initialize coefficient matrix (p) and source vector (b)


p = zeros(nx, nx);
b = zeros(nx, 1);

% 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

% Assigning coefficients to the matrix


p(j, j) = aP;
p(j, j+1) = -aE;
p(j, j-1) = -aW;

% Source term contribution for internal nodes


b(j) = q*A*dx;
end

% Boundary condition at node 1 (Left)


p(1,1) = 1;
b(1) = Ta + q*A*(dx/2); % Include half control volume source

% Boundary condition at node nx (Right)


p(nx, nx) = 1;
b(nx) = Tb + q*A*(dx/2); % Include half control volume source

% Solving the linear system of equations


T = p\b;

% X-position along the plate


x = linspace(0, L, nx);

% Analytical solution for comparison


T_analytical = (-q/(2*k))*x.^2 + ((Tb-Ta)/L + (q*L)/(2*k))*x + Ta;

% Plotting both numerical and analytical solutions


figure;
plot(x, T_analytical, 'r-', 'LineWidth', 2);
hold on;
plot(x, T, 'bo--', 'LineWidth', 1.5);
xlabel('Distance along plate thickness (m)');
ylabel('Temperature (°C)');
legend('Analytical Solution', 'Numerical Solution (FVM)');
title('Temperature Distribution Across the Plate');
grid on;
Graph:

Fig:1: Temperature V/s Distance graph across the plate

You might also like