0% found this document useful (0 votes)
209 views4 pages

2D Heat Equation Iteration Method

The document describes using the Gauss-Jacobi method to iteratively solve the heat equation to model the steady-state temperature distribution across a plate with specified boundary temperatures and a uniform internal heat source. It prompts the user for parameters, initializes the temperature array T with boundary conditions, then iteratively calculates temperatures at internal points using the Gauss-Jacobi formula until values converge within a tolerance. Finally, it plots the solved temperature distribution.

Uploaded by

pravesh1992
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)
209 views4 pages

2D Heat Equation Iteration Method

The document describes using the Gauss-Jacobi method to iteratively solve the heat equation to model the steady-state temperature distribution across a plate with specified boundary temperatures and a uniform internal heat source. It prompts the user for parameters, initializes the temperature array T with boundary conditions, then iteratively calculates temperatures at internal points using the Gauss-Jacobi formula until values converge within a tolerance. Finally, it plots the solved temperature distribution.

Uploaded by

pravesh1992
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/ 4

%2D Heat Equation iteration method.

L = input('Length of the plate');


n = 11;
TL = input('Temprature at left wall');
TT = input('Temprature at top wall');
TR = input('Temprature at right wall');
TB = input('Temprature at bottom wall');
S = input('uniformly ditributed source strength per unit
volume');
k = input('thermal conductivity');
dx =L/n ;
x = linspace(0,1,n); y = x; dy = dx;
TOL = 1e-6;
T = zeros(n);
T(1,1:n) = TT;
T(n,1:n) = TB;
T(1:n,1) = TL;
T(1:n,n) = TR;
error = 1; k = 0;
while error > TOL
k = k+1;
Told = T;
for i = 2:n-1
for j = 2:n-1
T(i,j) = 0.25*(Told(i-1,j)
+Told(i,j+1)+Told(i+1,j)+Told(i,j-1)+(S*dx/k))
end
end
error = max(max(abs(Told-T)));
end
subplot(2,1,1),contour(x,y,T),
title('Temperature (Steady
State)'),xlabel('x'),ylabel('y'),colorbar
subplot(2,1,2),pcolor(x,y,T),shading interp,
title('Temperature (Steady
State)'),xlabel('x'),ylabel('y'),colorbar

OUTPUT
Length of the plate(M)1
Temprature at left wall(K)300
Temprature at top wall(K)300
Temprature at right wall(K)300
Temprature at bottom wall(K)1000
uniformly ditributed source strength per unit volume(w/m^3)5
thermal conductivity(w/m^2*K)25

% guass jacobi method


L = input('Length of the plate(M)');
n = 11;
TL = input('Temprature at left wall(K)');
TT = input('Temprature at top wall(K)');
TR = input('Temprature at right wall(K)');
TB = input('Temprature at bottom wall(K)');
S = input('uniformly ditributed source strength per unit
volume(w/m^3)');
k = input('thermal conductivity(w/m^2*K)');
dx =L/n ;
x = linspace(0,1,n); y = x;
% Initialize function
T = zeros(n);
% Initialize boundary conditions
T(1,1:n) = TT;
T(n,1:n) = TB;
T(1:n,1) = TL;
T(1:n,n) = TR;
% Calculate temperature distribution
flag = 1;
while flag == 1
flag = 0;
Told = T;
for i = 2:n-1
for j = 2:n-1
T(i,j) = 0.25*(Told(i-1,j)+Told(i,j+1)+Told(i+1,j)
+Told(i,j-1)+(S*dx/k))
error = abs((T(i,j)-Told(i,j))/Told(i,j));
if error > 0.01
flag = 1;
end
end
end
end
subplot(2,1,1),contour(x,y,T),
title('Temperature (Steady
State)'),xlabel('x'),ylabel('y'),colorbar
subplot(2,1,2),pcolor(x,y,T),shading interp,
title('Temperature (Steady
State)'),xlabel('x'),ylabel('y'),colorbar

OUTPUT

Length of the plate(M)1


Temprature at left wall(K)300
Temprature at top wall(K)300
Temprature at right wall(K)300
Temprature at bottom wall(K)1000
uniformly ditributed source strength per unit volume(w/m^3)5
thermal conductivity(w/m^2*K)25

You might also like