2D heat conduction problem with exact solution
18 views (last 30 days)
Show older comments
I study Numerical analysis with FDM
and I tried to code about 2D heat conduction with jacobi method
I want to know something
1) Comparing with exact solution (Temperature along the vertical centerline)
2) I tried to write another Iterative method code (Gauss seidal method)
(Problem Fig)
(code)
clear all; clc; close all;
% Geometry of domain
W = 1; % Width of domain (in m)
H = 1; % Height of domain (in m)
Nx = 51; % Number of grids in X direction
Ny = 51; % Number of grids in Y direction
dx = W / (Nx - 1) % Width of element (in m)
dy = H / (Ny - 1) % Height of element(in m)
% Boundary and Initial conditions
T = zeros(Nx,Ny); % Temperature Array (in C)
TL = 0; % Letf wall temperature (in C)
TR = 0; % Right wall temperature (in C)
TT = 1; % Top wall temperature (in C)
TB = 0; % Bottom wall temperature (in C)
T(1, 2:Ny-1) = TL; %
T(2:Nx-1,Ny) = TT;
T(Nx, 2:Ny-1) = TR;
T(2:Nx-1, 1) = TB;
T(1,1) = (TL + TB) / 2;
T(Nx,1) = (TR + TB) / 2;
T(1,Ny) = (TL + TT) / 2;
T(Nx, Ny) = (TR + TT) / 2;
% Coumputation
Epsilon = 1e-6;
Error = 5;
it = 0;
while(Error > Epsilon)
it = it + 1
disp(it);
Told = T;
for j = 2:Ny-1
for i = 2:Nx-1
T(i,j) = (T(i+1,j) + T(i-1, j) + T(i, j-1) + T(i, j+1)) / 4;
end
end
Error = sqrt(sumsqr(T-Told));
disp(Error);
end
% Plotting the result
x = 0:dx:W; % Width array (in m)
y = 0:dy:H; % Height array (in m)
colormap(jet);
contourf(x, y, T', 15);
colorbar
title('Temperature Distribution')
xlabel('$Width (in m)')
ylabel('$Height (in m)$')
% Plotting Temperature along the centerline
figure(2)
plot(x, T(26,:), "b-")
xlabel('y (in x = 0.5)')
ylabel('Temperature')
title('Temperature along the vertical centerline')
2 Comments
Answers (1)
SAI SRUJAN
on 1 Nov 2023
Hi Minjik,
I understand that you are facing an issue in solving a 2D heat conduction problem.
The Jacobi method and the Gauss-Seidel method are two iterative methods used to solve systems of linear equations, including those arising from numerical methods for solving partial differential equations (PDEs) such as heat conduction problem.
In the Jacobi method, the system of equations is solved by iteratively updating the unknown variables using the values from the previous iteration. In the context of solving heat conduction problem, the Jacobi method updates the temperature values at each grid point using the average of the neighboring temperature values from the previous iteration.
You can follow the given iteration if you are using jacobi method,
T(i,j) = (Told(i+1,j) + Told(i-1, j) + Told(i, j-1) + Told(i, j+1)) / 4;
The Gauss-Seidel method is an improvement over the Jacobi method that updates the variables in a different order. The Gauss-Seidel method updates the temperature values at each grid point using the updated values of the neighboring grid points.
You can follow the given iteration if you are using Gauss-Seidal method,
T(i,j) = (T(i+1,j) + T(i-1, j) + T(i, j-1) + T(i, j+1)) / 4;
In Gauss-Seidal method, the updated values are used immediately in the subsequent updates leading to faster convergence compared to the Jacobi method.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!