All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Aim: To solve a heat conduction equation of a 2D plate surrounded by constant temperature by the Finite Difference Method. Here we will consider both the Steady-state and Transient state(Unsteady) case and compare which iterative method gives better results with fewer number iteration. Also, we will understand the effect…
Himanshu Chavan
updated on 02 Jul 2021
Aim: To solve a heat conduction equation of a 2D plate surrounded by constant temperature by the Finite Difference Method. Here we will consider both the Steady-state and Transient state(Unsteady) case and compare which iterative method gives better results with fewer number iteration. Also, we will understand the effect of CFL numbers in the case of transient cases.
Assumptions:
1. Absolute error criteria is 1e-4
2. Consider an equal number of grid points or nodes along the X-axis and Y-axis
3. No internal heat generation
4. Boundary conditions are as follows
Governing Equation:∂2T∂x2+∂2T∂y2+∂2T∂z2+qk=ρcpk∂T∂t
Here.
q= Rate of Heat Generation
k= Thermal Conductivity
ρ= Density
cp=Specific heat capacity at constant pressure
ρcp=volumetric heat capacity
Considering 2D case and no heat generation constant pressure
∂2T∂x2+∂2T∂y2=1α∂T∂t
∂Tdt=α[∂2T∂x2+∂2T∂y2]
Numerical Discretization:
1. Steady-State Case:
In the case of steady-state, the time derivative term of temperature becomes zero. So the governing equation becomes :
∂2T∂x2+∂2T∂y2=0
Now Discretizing each of the terma by finite difference method we get,
∂2T∂x2=Tni,j+1+2Tni,j+Tni,j−1(Δx)2
∂2T∂y2=Tni+1,j+2Tni,j+Tni−1,j(Δy)2
After rearranging the terms we get,
Ti,j=Ti+1,j+Ti−1,j+Ti,j+1+Ti,j−14
This simultaneous set of eqaution can be solved using the followiing iterative method:
Here the subscript old refers to the value in the previous iteration and the subscripts T, B R and L refders to Top, Bottom,Right and Left respectively.
2. Transient State Case:
In the case of the transient case the time derivative term of temperature is considered. So the governing equation becomes:
α(∂2T∂x2+∂2T∂y2)=∂T∂t
Here,
α=kρcp=1.4m2s(considered arbitarily)
Now Discretizing each of the terms by finite difference method we get,
∂T∂t=Tn+1l−TnlΔt
Now we get two cases, Explicit and Implicit based on the discretization of the remaining two terms.
Considering the previous time step will give rise to explicit terms and considering the same time step will give rise to the implicit case.
Explicit Case:
∂2T∂x2=Tni,j+1+2Tni,j+Tni,j−1(Δx)2
∂2T∂y2=Tni+1,j+2Tni,j+Tni−1,j(Δy)2
After calculation consider Δx=Δy and k1=k2
Tp=Tpold[1−4k]+k(TTold+TBold+TLold+TRold)
Implicit Case:
∂2T∂x2=Tn+1i,j+1+2Tn+1i,j+Tn+1i,j−1Δx2
∂2t∂y2=Tn+1i+1,j+2Tn+1i,j+Tn+1i−1,j(Δy)2
Now just like the staeadt state equations this set of implicit case can be solved by the following iterative methods.
Here TPprev= values of Tpin the previous time step
User-Defined Functions:
1. linear_eqn_solver_jacobi
function linear_eqn_solver_jacobi(T,Told,Tprev,nx,ny,nt,x,y,k1,k2,tol,type)
%%Transient Implicit (Jacobi)
if type == 11
tic;
iteration = 1;
for k= 1:nt %time loop
error=9e9;
while(error > tol) % Convergence loop
for i= 2:nx-1 % Space loop
for j= 2:ny-1
term1 = (1+(2*k1)+(2*k2))^-1;
V = Told(i-1,j) + Told(i+1,j);
H = Told(i,j-1) + Told(i,j+1);
T(i,j) = (Tprev(i,j)*term1) + (k1*term1*H) + (k2*term1*V);
end
end % end of space loop
error = max(max(abs(Told-T)));
Told =T;
iteration = iteration +1;
end % end of convergence loop
Tprev =T;
end % end of time loop
time = toc;
f1=figure(1)
contourf(x,y,T,'--','ShowText', 'on')
colorbar
colormap('jet')
text=sprintf("2D Transient Heat Conduction-Implicite-Jacobi No. of iteration %f Time of simulation %f Sec",iteration,time);
title(text)
set(gca,'YDIR','reverse')
%Steady State (Jacobi)
elseif type== 21
iteration =1;
tic;
error=9e9;
while (error> tol) %Convergence loop
for i= 2:nx-1 %Space Loop
for j=2:ny-1
term1 = Told(i,j-1) +Told(i,j+1);
term2 = Told(i-1,j) + Told(i+1,j);
T(i,j) = (1/4)*(term1+term2);
end
end % End of space loop
error=max(max(abs(Told-T)));
Told=T;
iteration =iteration+1;
end % End of convergence loop
time=toc;
f1=figure(1)
contourf(x,y,T,'--','ShowText','on')
colorbar
colormap('jet')
text = sprintf("2D Steady State Heat Conduction - Jacobi No. of iteration %f Time of Simulation %f Sec",iteration,time);
title(text)
set(gca,'YDIR','reverse')
end
end
2.linear_eqn_solver_Gs
function linear_eqn_solver_Gs(T,Told,Tprev,nx,ny,nt,x,y,k1,k2,tol,type)
%Transient Implicit(Gauss seidal)
if type == 12
iteration = 1;
tic;
for k=1:nt %Time loop
error = 9e9;
while(error > tol) % convergence loop
for i=2:nx-1 %Space Loop
for j=2:ny-1
term1 = (1+(2*k1)+(2*k2))^-1;
V = T(i-1,j) + Told(i+1,j);
H = T(i,j-1)+ Told(i,j+1);
T(i,j) = (Tprev(i,j)*term1)+(k1*term1*H)+(k2*term1*V);
end
end %end of space loop
error =max(max(abs(Told-T)));
Told=T;
iteration = iteration+1;
end % End of convergence loop
Tprev= T;
end% Enf of time loop
time= toc;
f2 = figure(2)
contourf(x,y,T,'--','ShowText','on')
colorbar
colormap('jet')
text =sprintf("2D Transient Heat Conduction - Implicit - GS NO. of iteration %f Time of simulation %f Sec", iteration, time);
title(text)
set(gca,'YDIR','reverse')
%%Steady State Gauss Seidal
elseif type ==22
iteration =1;
error= 9e9;
tic;
while(error > tol ) %convergence loop
for i=2:nx-1 % Space loop
for j=2:ny-1
term1 = T(i,j-1) + Told(i,j+1);
term2 = T(i-1,j) + Told(i+1,j);
T(i,j) = (1/4)*(term1 +term2);
end
end %end of space loop
error = max(max(abs(Told-T)));
Told =T;
iteration =iteration+1;
end % End of convergence loop
time = toc;
f2= figure(2)
contourf(x,y,T,'--','ShowText','on')
colormap('jet')
text = sprintf("2D ASteady State Heat Conduction - GS No. of iterations %f Time of Simulation %f Sec", iteration,time);
title(text)
set(gca,'YDIR','reverse')
end
end
3.linear_eqn_solver_SOR
function [iteration] = linear_eqn_solver_SOR(T,Told,Tprev,x,y,nx,ny,nt,k1,k2,tol,type)
%%% Transient Implicit (SOR)
w=1.1;
if type == 13
iteration =1;
tic;
for k =1:nt %time loop
error=9e9;
while(error > tol) %convergence loop
for i=2:nx-1 %space loop
for j= 2:ny-1
term1 = (1+(2*k1)+(2*k2))^-1;
V = T(i-1,j) + Told(i+1,j); % Ttop(updated) + Tbottom
H = T(i,j-1) + Told(i,j+1); %Tleft(updated) + Tright
T_GS(i,j) = (Tprev(i,j)*term1) + (k1*term1*H) + (k2*term1*V);
T(i,j) = ((1-w)*Told(i,j)) + (w*T_GS(i,j));
end
end % end of space loop
error = max(max(abs(Told-T)));
Told=T;
iteration = iteration+1;
end %end of convergence loop
Tprev= T;
end % end of time loop
time = toc;
f3 = figure(3)
contourf(x,y,T,'--','ShowText','on')
colorbar
colormap('jet')
text =sprintf("2D Transient Heat Conduction - Implicit - SOR NO. of iteration %f Time of simulation %f Sec", iteration, time);
title(text)
set(gca,'YDIR','reverse')
%%% Steady State SOR
elseif type == 23
iteration = 1;
error=9e9;
tic;
while(error > tol) %convergence loop
for i=2:nx-1 % Space loop
for j=2:ny-1
term1 = T(i,j-1) + Told(i,j+1);
term2 = T(i-1,j) + Told(i+1,j);
T_GS(i,j) = (1/4)*(term1 + term2);
T(i,j) = ((1-w)*Told(i,j)) + (w*T_GS(i,j));
end
end %end of space loop
error= max(max(abs(Told-T)));
Told=T;
iteration= iteration+1;
end % end of convergence loop
time=toc;
f3 = figure(3)
contourf(x,y,T,'--','ShowText','on')
colorbar
colormap('jet')
text =sprintf("2D Steady State Heat Conduction -SOR NO. of iteration %f Time of simulation %f Sec", iteration, time);
title(text)
set(gca,'YDIR','reverse')
end
end
4. linear_eqn_solver_exlpicit
function linear_eqn_solver_explicit(T,Told,nx,ny,nt,x,y,k1,k2)
%%Transient Explicit
iteration= 1;
tic;
for k=1:nt %time loop
for i=2:nx-1 %time loop
for j=2:ny-1
term1=(1+(2*k1)+(2*k2))^-1;
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) + (k1*H) + (k2*V);
end
end % end if space loop
error = max(max(abs(Told-T)));
Told =T;
iteration=iteration+1;
end %end of time loop
time =toc;
f4=figure(4)
contourf(x,y, T,'--','ShowText','on')
colorbar
colormap('jet')
text=sprintf("2D Transient Heat Conduction- Explicit- No. of iterations %f Time of Simulation %f Sec",iteration,time);
title(text)
set(gca,'YDIR','reverse')
end
MAIN CODE:
clear all
close all
clc
% Inputs
L=1;
nx=11;
x=linspace(0,L,nx);
dx=x(2)-x(1);
W=1;
ny=nx;
y=linspace(0,W,ny);
dy=y(2)-y(1);
prompt = 'type='; %transient case =1 and Steady State =2
type= input(prompt);
if type ==1
prompt = 'CFL=';
CFL = input(prompt); % Fails for Explicit if CFL >0.5
% CFL CFLx+CFLy = alpha*dt/dx^2 + alpha*dt/dy^2=2*alpha*dt/dx^2
else
CFL =0;
end
alpha =1.4;
% Finding dt & nt
dt = CFL*dx^2/(2*alpha);
time=.03*60; % mins
nt = time/dt;
% Error Limit Inputs
error=9e9;
tol=1e-4;
%Boundary Conditions
T=300*ones(nx,ny);
T(:,1) = 400; % left
T(:,end) = 800;% right
T(1,:) = 600; %top
T(end,:) = 900;%bottom
T(1,1) = (400+600)/2;
T(end,end) = (800+900)/2;
T(end,1) = (400+900)/2;
T(1,end) = (600+800)/2;
Told=T;
Tprev=T;
k1=(alpha*dt/(dx^2));
k2=(alpha*dt/(dy^2));
% Calling the Solvers
if type ==1 % Transient case
linear_eqn_solver_jacobi(T,Told,Tprev,nx,ny,nt,x,y,k1,k2,tol,11);
linear_eqn_solver_Gs(T,Told,Tprev,nx,ny,nt,x,y,k1,k2,tol,12);
linear_eqn_solver_SOR(T,Told,Tprev,x,y,nx,ny,nt,k1,k2,tol,13);
linear_eqn_solver_explicit(T,Told,nx,ny,nt,x,y,k1,k2); % Transient Explicit
elseif type ==2 % Steady State Case
linear_eqn_solver_jacobi(T,Told,Tprev,nx,ny,nt,x,y,k1,k2,tol,21);
linear_eqn_solver_Gs(T,Told,Tprev,nx,ny,nt,x,y,k1,k2,tol,22);
linear_eqn_solver_SOR(T,Told,Tprev,x,y,nx,ny,nt,k1,k2,tol,23);
end
Algorithm:
The main difference between these solvers is that the discretized equations are solved by different iterative methods like Jacobi, Gauss-seidel, or Successive overrelaxation methods.
OUTPUT:
1.Transient-State Analysis:
EXPLICIT
2.STEADY-STATE.
Discussion of Results:
1. In the case of both implicit Transient and Steady-state SOR converges faster than others. SOR>GS>Jacobi. This can will be understood by the iteration number and simulation time.
2. Between Implicit and Explicit methods of Transient, there is a limitation of explicit methods on the CFL number. The solutions blow up for CFL greater than 0.5
3. Between the fastest method of the steady-state and transient that is SOR, steady-state converges faster than transient.
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...
Simulation Of A 1D Super-sonic Nozzle Using Macormack Method
AIM: To simulate the isentropic flow through a Quasi 1D subsonic - supersinic nozzle by deriving both the conservation and non-conservation forms of the governing equations and solve them by implementing Macormacks's technique using MATLAB. Objective: Determine the steady-state temperature distribution for the flow field…
19 Oct 2021 11:02 AM IST
Project 1 : CFD Meshing for Tesla Cyber Truck
ADVANCED CFD MESHING OF THE TESLA CYBER TRUCK l. OBJECTIVE 1. Geometry Clean-up of the model 2. Generation of surface mesh on the model. 3. Analyze and correct the quality of the mesh. 4. Setting…
08 Oct 2021 10:34 PM IST
Week 4 Challenge : CFD Meshing for BMW car
ADVANCED CFD MESHING OF THE BMW M6 MODEL USING ANSA l. OBJECTIVE 1. Detailed geometry clean-up of the BMW M6 Model. 2. Generation of a surface mesh on the model. 3. Analyze and correct the quality of the mesh. 4. Setting up a wind…
29 Sep 2021 10:51 PM IST
Related Courses
0 Hours of Content
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.