All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Abstract : The heat conduction equation is a partial differential equation that describes the distribution of heat (or the temperature field) in a given body over time. Detailed knowledge of the temperature field is very important in thermal conduction through materials. The equation have…
Aadil Shaikh
updated on 18 Sep 2020
Abstract :
The heat conduction equation is a partial differential equation that describes the distribution of heat (or the temperature field) in a given body over time. Detailed knowledge of the temperature field is very important in thermal conduction through materials. The equation have been solved using finite difference method, using this discretized equations and boundary conditions a matlab program is created, where both steady and unsteady states of this equation are solved using iterative solvers like Jacobi, Gauss seidel and Successive over relaxation methods.
Study has been conducted to understand the Computational time taken to solve each of these solvers and comparison is done.
Study on the effect of time step on the stability of the Transient state of the heat conduction equation of both Implicit and explicit methods is done and understanding how and why an unstable solution forms, how CFL condition is developed using Von neumann analysis and how solution behaves using it.
I . Objectives :-
II. 2D Heat Conduction (Governing equation) : ∂T∂t=α(∂2T∂x2)+(∂2T∂y2)
where,
T : Temperature
t : time
α = Thermal expansion coefficient
II. A) Solving the equation for Steady state using Finite difference method :
Equation for Steady state : (∂2T∂x2)+(∂2T∂y2)=0
Now, using central difference scheme, eqn becomes,
Tni+1,j−2Tni,j+Tni−1,jΔx2+Tni,j+1−2Tni,j+Tni,j−1Δy2=0
on simplification, we get,
Tni,j=1k⋅[Tni+1,j+Tni−1,jΔx2+Tni,j+1+Tni,j−1Δy2] --(1)
where, k=2⋅(Δx2+Δy2Δx2⋅Δy2)
II. B) Solving the equation for Unsteady (Transient) state using Finite difference method :
Equation for Transient state : ∂T∂t+α(∂2T∂x2+∂2T∂y2)=0
For ease, lets say -
Tni+1,j=R
Tni−1,j=L
Tni,j+1=T
Tni,j−1=B
Tni,j=P
using first order forward difference in time derivative and central difference in x,y derivative, we get,
Tn+1P=TnP+α⋅Δt[TnR−2TnP+TnLΔx2+TnT−2TnP+TnBΔy2] `
On Further Simplification,
Tn+1P=TnP(1−2k1−2k2)+k1TnL+k1TnR+k2TnB+k2TnT --(2)
where, k1=α⋅ΔtΔx2 & k2=α⋅ΔtΔy2
Similarly for,
Implicit Scheme :
From the transient state equation, solving using FDM, we get,
Tn+1Pâ‹…(1+2k1+2k2)=TnP+k1(Tn+1L+Tn+1R)+k2(Tn+1T+Tn+1B) -- (3)
II. C) Point Iterative Methods :
These equations obtained are solved using iterative methods such as Jacobi, Gauss-Seideland S.O.R, in matlab.
III. Assumptions & Boundary Condition for the problem :
1. Assume that the domain is a unit square.
2. Assume nx = ny [Number of points along the x direction is equal to the number of points along the y direction]
3. Boundary conditions for steady and transient case
1. Left:400K
2. Top:600K
3. Right:800K
4. Bottom:900K
4. Tolerance = 1e-4 (for all solvers and schemes)
IV. Matlab Program :
IV A.) Main Program :
% Program to solve a 2D Heat Conduction equation
% dT/dt = alpha*(dT^2/dx^2 + dT^2/dy^2
% alpha = Thermal conductivity
% rf = relaxation factor (SOR method)
% dx = dy = grid space (domain = unit square)
% nx = ny [Number of points along the x direction is equal to the number of points along the y direction]
% Boundary conditions for steady and transient case (both schemes)
%
% 1. Left:400K
% 2. Top:600K
% 3. Right:800K
% 4. Bottom:900K
%
% Code by AADIL SHAIKH
% DATE : 7/29/2019
close all
clear all
clc
disp('1. Steady state solver')
disp('2. Explicit Scheme - Transient solver')
disp('3. Implicit Scheme - Transient solver')
% Choose a solver from the above 3 displayed solvers .
Solver = input('Choose a solver from above : ');
% After choosing solvers , choose the Iterative method for which the
% solution is needed .
% 1. Jacobi method
% 2. Gauss Seidel method
% 3. Successive over relaxation method
if Solver == 1
[x,y,T] = Steady_state ;
elseif Solver == 2
[x,y,T] = Explicit_transient ;
elseif Solver == 3
[x,y,T] = Implicit_transient ;
end
This is the Main program which basically calls anyone of the three solvers, according to the users choice.
Namely,
Steady state , Unsteady - Explicit scheme & Unsteady state - Implicit scheme .
IV. B) Steady state solver : Iterative methods - Jacobi, Gauss Seidel , S.O.R
function [x,y,T] = Steady_state
%Domain inputs
nx = 40;
ny = 40;
rf = 1.5 ; % Relaxation factor
x = linspace(0,1,nx);
y = linspace(0,1,ny);
dx = x(2)-x(1);
dy = y(2)-y(1);
k = (2*((dx^2)+(dy^2)))/((dx^2)*(dy^2));
% assigining bc
T = ones(nx,ny);
T(:,1) = 400;
T(1,:) = 600;
T(:,end) = 800;
T(end,:) = 900;
Told = T;
disp('1. Jacobi method')
disp('2 Gauss Seidel method')
disp('3. S.O.R method')
iterative_solver = input('Choose which Iterative method to solve with : ');
error = 9e9;
tol = 1e-4;
%jacobi method
tic
iter_ctr = 1;
if iterative_solver ==1
while (error > tol)
for i = 2:nx-1
for j = 2:ny-1
H = (Told(i+1,j)+Told(i-1,j))/(dx^2);
V = (Told(i,j+1)+Told(i,j-1))/dy^2;
T(i,j) = (H + V)/k;
end
end
error = max(max(abs(Told-T)));
Told = T;
iter_ctr = iter_ctr + 1;
end
Simulation_time = toc;
figure(1)
colormap(jet)
contourf(x,y,T,':','showText','on')
set(gca, 'YDir','reverse')
xlabel('x axis')
ylabel('y axis')
title({['steady state - Jacobi'];['Iteration number : ',num2str(iter_ctr)];['Simulation time : ',num2str(Simulation_time)]})
colorbar
% pause(0.0001)
saveas(1,'ss_jacobi','png')
end
%Gauss Seidel method
tic
iter_ctr = 1;
if iterative_solver == 2
while (error > tol)
for i = 2:nx-1
for j = 2:ny-1
H = (Told(i+1,j)+T(i-1,j))/(dx^2);
V = (Told(i,j+1)+T(i,j-1))/dy^2;
T(i,j) = (H + V)/k;
end
end
error = max(max(abs(Told-T)));
Told = T;
iter_ctr = iter_ctr + 1;
end
Simulation_time = toc;
figure(2)
colormap(jet)
contourf(x,y,T,':','showText','on')
set(gca, 'YDir','reverse')
xlabel('x axis')
ylabel('y axis')
title({['steady state - Gauss Seidel'];['Iteration number : ',num2str(iter_ctr)];['Simulation time : ',num2str(Simulation_time)]})
colorbar
% pause(0.0001)
saveas(2,'ss_gs','png')
end
% Successive Over Relaxation method
tic
iter_ctr = 1;
if iterative_solver == 3
while (error > tol)
for i = 2:nx-1
for j = 2:ny-1
H = (Told(i+1,j)+T(i-1,j))/(dx^2);
V = (Told(i,j+1)+T(i,j-1))/dy^2;
T(i,j) = Told(i,j)*(1-rf) + rf*((H + V)/k);
end
end
error = max(max(abs(Told-T)));
Told = T;
iter_ctr = iter_ctr + 1;
end
Simulation_time = toc;
figure(3)
colormap(jet)
contourf(x,y,T,':','showText','on')
set(gca, 'YDir','reverse')
xlabel('x axis')
ylabel('y axis')
title({['Steady state - Successive Over Relaxation'];['Iteration number : ',num2str(iter_ctr)];['Simulation time : ',num2str(Simulation_time)]})
colorbar
% pause(0.0001)
saveas(3,'ss_sor','png')
end
end
Results :
IV. B-1) SOR :
IV. C) Transient state solver - Explicit Scheme : Iterative methods - Jacobi, Gauss seidel, S.O.R
function [x,y,T] = Explicit_transient
%Domain inputs
nx = 40;
ny = 40;
x = linspace(0,1,nx);
y = linspace(0,1,ny);
dx = x(2)-x(1);
dy = y(2)-y(1);
dt = 0.0001;
alpha = 1.4;
k1 = alpha*dt/(dx^2);
k2 = alpha*dt/(dy^2);
nt = 400;
rf = 1.5 ;
CFL_Num = alpha*dt/(dx^2);
% assigining bc
T = ones(nx,ny);
T(:,1) = 400;
T(1,:) = 600;
T(:,end) = 800;
T(end,:) = 900;
Told = T;
Tprev_dt = T;
disp('1. Jacobi method')
disp('2. Gauss Seidel method')
disp('3. S.O.R method')
iterative_solver = input('Choose which Iterative method to solve with : ');
error = 9e9;
tol = 1e-4;
%jacobi method
tic
if iterative_solver == 1
for k = 1:nt
for i = 2:nx-1
for j = 2:ny-1
Term1 = (1 -2*k1 - 2*k2);
Term2 = k1;
Term3 = k2;
H = (Told(i+1,j)+Told(i-1,j));
V = (Told(i,j+1)+Told(i,j-1));
T(i,j) = (Told(i,j)*Term1) + (Term2*H) + (Term3*V);
end
end
Told = T;
end
Simulation_time = toc;
figure(1)
colormap(jet)
contourf(x,y,T,':','showText','on')
set(gca, 'YDir','reverse')
xlabel('x axis')
ylabel('y axis')
title({['Explicit - Transient solver using Jacobi '];['Simulation time : ',num2str(Simulation_time)]})
colorbar
saveas(1,'EP_jacobi','png')
end
% Gauss Seidel method
tic
if iterative_solver == 2
for k = 1:nt
for i = 2:nx-1
for j = 2:ny-1
Term1 = (1 -2*k1 - 2*k2);
Term2 = k1;
Term3 = k2;
H = (Told(i+1,j)+T(i-1,j));
V = (Told(i,j+1)+T(i,j-1));
T(i,j) = (Told(i,j)*Term1) + (Term2*H) + (Term3*V);
end
end
Told = T;
end
Simulation_time = toc;
figure(2)
colormap(jet)
contourf(x,y,T,':','showText','on')
set(gca, 'YDir','reverse')
xlabel('x axis')
ylabel('y axis')
title({['Explicit - Transient solver using Gauss Seidel '];['Simulation time : ',num2str(Simulation_time)]})
colorbar
saveas(2,'EP_GS','png')
end
% S.O.R method
tic
if iterative_solver == 3
for k = 1:nt
for i = 2:nx-1
for j = 2:ny-1
Term1 = (1 -2*k1 - 2*k2);
Term2 = k1;
Term3 = k2;
H = (Told(i+1,j)+T(i-1,j));
V = (Told(i,j+1)+T(i,j-1));
T(i,j) = Told(i,j)*(1-rf) + rf*((Told(i,j)*Term1) + (Term2*H) + (Term3*V));
end
end
Told = T;
end
Simulation_time = toc;
figure(3)
colormap(jet)
contourf(x,y,T,':','showText','on')
set(gca, 'YDir','reverse')
xlabel('x axis')
ylabel('y axis')
title({['Explicit - Transient solver using Successive Over Relaxation '];['Simulation time : ',num2str(Simulation_time)]})
colorbar
saveas(3,'EP_SOR','png')
end
end
Results :
Transient State - Explicit scheme : Jacobi (nt = 400)
Transient State - Explicit scheme : Gauss Seidel (nt = 400)
Transient State - Explicit scheme : Successive Over Relaxation (nt = 400)
IV. D) Transient state solver - Implicit Scheme : Iterative methods - Jacobi, Gauss seidel, S.O.R
function [x,y,T] = Implicit_transient ;
%Domain inputs
nx = 40;
ny = 40;
x = linspace(0,1,nx);
y = linspace(0,1,ny);
dx = x(2)-x(1);
dy = y(2)-y(1);
dt = 0.001;
alpha = 1.4;
k1 = alpha*dt/(dx^2);
k2 = alpha*dt/(dy^2);
CFL_Num = alpha*dt/(dx^2)
nt = 400;
rf = 1.5 ; % relaxation factor
% assigining bc
T = ones(nx,ny);
T(:,1) = 400;
T(1,:) = 600;
T(:,end) = 800;
T(end,:) = 900;
% creating a copy of u
%uold = u ;
Told = T;
Tprev_dt = T;
disp('1. Jacobi method')
disp('2 Gauss Seidel method')
disp('3. S.O.R method')
iterative_solver = input('Choose which method to solve with : ');
error = 9e9;
tol = 1e-4;
%jacobi method
tic
jacobi_iter = 1;
if iterative_solver ==1
for k = 1:nt
error = 9e9;
while(error > tol)
for i = 2:nx-1
for j = 2:ny-1
Term1 = (1 +2*k1 + 2*k2)^-1;
Term2 = k1*Term1;
Term3 = k2*Term1;
H = (Told(i+1,j)+Told(i-1,j));
V = (Told(i,j+1)+Told(i,j-1));
T(i,j) = (Tprev_dt(i,j)*Term1) + (Term2*H) + (Term3*V);
end
end
error = (max(abs(T-Told)));
error = max(error);
Told = T;
jacobi_iter = jacobi_iter + 1;
end
Tprev_dt = T;
end
Simulation_time = toc;
figure(1)
colormap(jet)
contourf(x,y,T,':','showText','on')
set(gca, 'YDir','reverse')
xlabel('x axis')
ylabel('y axis')
title({['Implicit - Transient solver using Jacobi '];['Iteration number : ',num2str(jacobi_iter)];['Simulation time : ',num2str(Simulation_time)]})
colorbar
saveas(1,'im_jacobi','png')
end
% Gauss Seidel method
tic
gs_iter = 1;
if iterative_solver == 2
for k = 1:nt
error = 9e9;
while(error > tol)
for i = 2:nx-1
for j = 2:ny-1
Term1 = (1 +2*k1 + 2*k2)^-1;
Term2 = k1*Term1;
Term3 = k2*Term1;
H = (Told(i+1,j)+T(i-1,j));
V = (Told(i,j+1)+T(i,j-1));
T(i,j) = (Tprev_dt(i,j)*Term1) + (Term2*H) + (Term3*V);
end
end
error = (max(abs(Told-T)));
error = max(error);
Told = T;
gs_iter = gs_iter + 1;
end
Tprev_dt = T;
end
Simulation_time = toc;
figure(2)
colormap(jet)
contourf(x,y,T,':','showText','on')
set(gca, 'YDir','reverse')
xlabel('x axis')
ylabel('y axis')
title({['Implicit - Transient solver using Gauss Seidel '];['Iteration number : ',num2str(gs_iter)];['Simulation time : ',num2str(Simulation_time)]})
colorbar
saveas(2,'im_gs','png')
end
% Successive over relaxation method
tic
sor_iter = 1;
if iterative_solver == 3
for k = 1:nt
error = 9e9;
while(error > tol)
for i = 2:nx-1
for j = 2:ny-1
Term1 = (1 +2*k1 + 2*k2)^-1;
Term2 = k1*Term1;
Term3 = k2*Term1;
H = (Told(i+1,j)+T(i-1,j));
V = (Told(i,j+1)+T(i,j-1));
T(i,j) = Told(i,j)*(1 - rf) + rf*((Tprev_dt(i,j)*Term1) + (Term2*H) + (Term3*V));
end
end
error = (max(abs(Told-T)));
error = max(error);
Told = T;
sor_iter = sor_iter + 1;
end
Tprev_dt = T;
end
Simulation_time = toc;
figure(3)
colormap(jet)
contourf(x,y,T,':','showText','on')
set(gca, 'YDir','reverse')
xlabel('x axis')
ylabel('y axis')
title({['Implicit - Transient solver using S.O.R '];['Iteration number : ',num2str(sor_iter)];['Simulation time : ',num2str(Simulation_time)]})
colorbar
saveas(3,'im_sor','png')
end
end
Results :
v) Comparing the Fastest Steady state simulation vs the Fastest Transient state simulation
V-1 ) Steady state results :
V-2) Unsteady state Results :
Explicit scheme :
Implicit Scheme :
V-3 ) Conclusion for Fastest Steady state simulation vs Transient state :
Results In a tabular form
VI ) Stability Analysis in the Unsteady Problem
A solution can go unstable if there are errors in it . hence by studying those errors we can understand what makes it go unstable & hence its stability criteria
The numerical solution for such an equation is influenced by two sources of error.
1. Discretization error - difference between exact analytical solution of the pde and exact solution of the corresponding difference equation . ( the truncation error) plus any errors introduced by numerical treatment of boundacy conditions.
2. Round off error : Computer rounding off repetitive numbers of calculation.
From equation
Tn+1P=TnP+α⋅Δt[TnR−2TnP+TnLΔx2+TnT−2TnP+TnBΔy2]
using a discrete Fourier decomposition , where range of x and y is defined seperately for each direction . Defining the amplification matrix G as in one dimensional case - we move forward, obtaining :
α⋅(1dx2+1dy2)⋅dt≤12
This stability condition is sufficient and analogous to normal condition.
but when dx = dy , it puts a severe requirement on the time step , it is reduced further by a factor of 2 compared with one dimensional case, we get,
α⋅dtdx2≤14 or dt≤dx24⋅α
where, dx = dy : no. grid points in x,y direction
This equation gives the stability requirement for the solution of finite difference equation above to be stable. .
Clearly for the value dx the value of dt must be small enough to satisfy the condition.
As long as this condition is met, error will not grow with subsequent steps and numerical solution will proceed in a stable manner otherwise the error will grow larger and cause the solution to blow up .
This analysis is called Von Neumann stability method.
From using the Von neumann stability analysis we can determine Courant-Friedrichs-Levy condition for the stability of an explicit solution of a PDE.
Thus that condition from the above analysis is :
C≤0.25 , (C/CFL number/ courant number)
If in explicit scheme, CFL number is more than 0.25 the solution will blow up and become unstable.
However Implicit solvers are unconditionally stable, which means the they can tolerate CFL numbers more larger than CFL condition. whereas the explicit solvers are conditionally stable and can never tolerate values more than CFL condition.
VI-1 ) Observing Stability analysis of the above program :
A) Explicit solver:
The changing cfl number and time steps are mentioned in the plots itself and as we can see the cfl number is under 0.25 for nt = 400 iterations . The results are stable and approaching the steady state.
Thermal diffusivity used is 1.4 for all conditions.
For just a little increase over the cfl , we see that th jacobi has become unstable. it tried to solve a we can see from the initial plot shows the temperature 500 but failed further and blew up. however gauss seidel and SOR managed to solve.
For a little more increase in the CFL number , jacobi has become fully unstable, however Gauss seidel method was successful in achieving the result , however the SOR updated from Gauss seidel became some what unstable and blew up .
An increase in approximately 8 times the cfl condition totally blew up all the solvers for explicit. and became totally unstable that it couldnt produce it in the plot.
B ) Implicit solver :
Since implicit solvers are unconditionally stable, increasing the cfl number did not affect the stability of the solution . Experiments with really high courant number was done but it still did not become unstable.
VII ) References :
keywords - NUMERICAL-ANALYSIS, MATLAB, MATLAB-BASICS, FINITE DIFFERENCE, 2D HEAT CONDUCTION
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
Flow over a Throttle body - Using CONVERGE CFD
I. Introduction: In this Project, A Steady & Transient state simulation is done of a Flow through an Elbow joint consisting of a throttle valve. The steady state case is solved with the Throttle valve fully open until convergence is reached. While the Transient case is ran with the throttle valve rotating i.e…
18 Sep 2020 08:29 PM IST
Literature review – RANS Derivation and analysis
Introduction: The Reynolds-averaged Navier–Stokes equations (or RANS equations) are time-averaged equations of motion for fluid flow. The idea behind the equations is Reynolds decomposition, whereby an instantaneous quantity is decomposed into its time-averaged and fluctuating quantities,…
18 Sep 2020 08:28 PM IST
C.H.T Analysis on a Graphic card using ANSYS FLUENT
I. Introduction : In this project, A steady state conjugate heat transfer analysis on a Graphic card model is done. Graphic card has become an everyday used object and a very importat part of any computer system, laptops etc. This product is mass produced daily in millions and has made computers exceptionally efficient.…
18 Sep 2020 08:23 PM IST
Aerodynamics : Flow around the Ahmed Body using ANSYS FLUENT
I. Introduction : Automotive aerodynamics comprises of the study of aerodynamics of road vehicles. Its main goals are reducing drag, minimizing noise emission, improving fuel economy, preventing undesired lift forces and minimising other causes of aerodynamic instability at high speeds. Also, in order to maintain…
18 Sep 2020 08:21 PM IST
Related Courses
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.