STEADY AND UNSTEADY 2D HEAT CONDUCTION (MATLab)
AIM:
To solve the 2d heat conduction problem steady and unsteady state analysis using Jacobian, Siedel and SOR methods.
Boundary Conditions:
nx = 10;
ny = nx;
T(:,1) = 400;
T(:,ny) = 800;
T(1,:) = 600;
T(nx,:) = 900;
error = 9e9;
tolerance = 1e-4;
dt = 30 ;
Derivation:
Heat conduction equation
`delT/dt + alphanabla^2T` = 0
`delT/dt + alpha(del^2T/delx^2 + del^2T/dely^2+ del^2T/delz^2) = 0`
STEADY STATE ANLYSIS:
where `delT/dt = 0`for steady state condition
the equation is
`alpha(del^2T/delx^2 +del^2T/dely^2) = 0`
apply CDS scheme because it is 2nd order derivative.
TRANSIENT STATE ANLYSIS:
`alpha(del^2T/delx^2 +del^2T/dely^2) = delT/delt`
Jacobain steadystate:
% Steady State Jacobian
clear
close all
clc
nx = 10;
ny = nx;
x = linspace(0,1,nx);
dx = x(2) - x(1);
y = linspace(0,1,ny);
dy = y(2) - y(1);
T = 298*ones(nx,ny); % temperature 25c 273+25=298
T(:,1) = 400;
T(:,ny) = 800;
T(1,:) = 600;
T(nx,:) = 900;
Told = T;
method = 1;
error = 9e9;
tolerance = 1e-4;
jacobi_iteration = 1;
tic
while(error>tolerance)
for i=2:nx-1
for j = 2:ny-1
if method == 1
H_jacobian = 0.25*(Told(i-1,j)+Told(i+1,j));
V_jacobian = 0.25*(Told(i,j-1)+Told(i,j+1));
T(i,j)=(H_jacobian)+(V_jacobian);
end
end
error_n = max(abs(Told-T));
error = max(error_n);
Told = T;
jacob_t =toc;
contourf(x,y,T)
colormap(jet)
xlabel('x axis')
ylabel('y axis')
colorbar
jacobi_iteration = jacobi_iteration+1;
title_text = sprintf('Iteration Number = %d, time=%d s', jacobi_iteration,jacob_t);
title(title_text)
pause(0.03)
end
end
Here, Jacobian method for Steady state analysis it gives totally 1161 iterations at 192 sec by taking Temperature = 25c.
Steady State Siedel:
% Steady State siedel
clear
close all
clc
nx = 10;
ny = nx;
x = linspace(0,1,nx);
dx = x(2) - x(1);
y = linspace(0,1,ny);
dy = y(2) - y(1);
T = 298*ones(nx,ny); % temperature 25c 273+25=298
T(:,1) = 400;
T(:,ny) = 800;
T(1,:) = 600;
T(nx,:) = 900;
Told = T;
method = 2;
error = 9e9;
tolerance = 1e-4;
siedel_iteration= 1;
tic
while(error>tolerance)
for i=2:nx-1
for j = 2:ny-1
if method == 2
H_siedel = 0.25*(T(i-1,j)+T(i+1,j));
V_siedel = 0.25*(T(i,j-1)+T(i,j+1));
T(i,j)=(H_siedel)+(V_siedel);
end
end
error_n = max(abs(Told-T));
error = max(error_n);
Told = T;
siedel_t = toc;
contourf(x,y,T)
colormap(jet)
xlabel('x axis')
ylabel('y axis')
colorbar
siedel_iteration = siedel_iteration+1;
title_text = sprintf('Iteration Number = %d, time=%d s', siedel_iteration, siedel_t);
title(title_text)
pause(0.03)
end
end
Here, siedel method for Steady state analysis it gives totally 809 iterations at 124 sec by taking Temperature at 25c
Steady State SOR:
% Steady State SOR
clear
close all
clc
nx = 10;
ny = nx;
x = linspace(0,1,nx);
dx = x(2) - x(1);
y = linspace(0,1,ny);
dy = y(2) - y(1);
T = 298*ones(nx,ny);
T(:,1) = 400;
T(:,ny) = 800;
T(1,:) = 600;
T(nx,:) = 900;
Told = T;
omega = 2/(1+sin(pi*dx));
method = 3;
error = 9e9;
tolerance = 1e-4;
SOR_iteration = 1;
tic
while(error>tolerance)
for i=2:nx-1
for j = 2:ny-1
if method == 3
H_SOR = 0.25*((T(i-1,j)*omega)+Told(i-1,j)*(1-omega)+Told(i+1,j));
V_SOR = 0.25*((T(i,j-1)*omega)+Told(i,j-1)*(1-omega)+Told(i,j+1));
T(i,j)=(H_SOR)+(V_SOR);
end
end
error_n = max(abs(Told-T));
error = max(error_n);
Told = T;
SOR_t = toc;
contourf(x,y,T)
colormap(jet)
xlabel('x axis')
ylabel('y axis')
colorbar
SOR_iteration=SOR_iteration+1;
title_text = sprintf('Iteration Number = %d, time = %d s', SOR_iteration,SOR_t);
title(title_text)
pause(0.03)
end
end
Here, SOR method for Steady state analysis it gives totally 609 iterations at 97 sec by taking Temperature = 25c
Transient Implicit jacobian:
% Transient jacobian method
clear
close all
clc
nx = 10;
ny = nx;
x = linspace(0,1,nx);
dx = x(2) - x(1);
y = linspace(0,1,ny);
dy = y(2) - y(1);
T = 298*ones(nx,ny);
T(:,1) = 400;
T(:,ny) = 800;
T(1,:) = 600;
T(nx,:) = 900;
dt = 30 ;
Told = T;
k1 = 1e-4*(dt/dx^2);
k2 = 1e-4*(dt/dy^2);
method = 1;
error = 9e9;
tolerance = 1e-4;
jacobi_iteration = 1;
tic
while(error>tolerance)
for i=2:nx-1
for j = 2:ny-1
if method == 1
H_jacobian = (Told(i-1,j)+Told(i+1,j));
V_jacobian = (Told(i,j-1)+Told(i,j+1));
term1 = 1/(1+2*k1+2*k2);
term2 = k1*term1;
term3 = k2*term1;
T(i,j)=(Told(i,j)*term1)+(H_jacobian*term2)+(V_jacobian*term3);
end
end
error_n = max(abs(T-Told));
error = max(error_n);
Told = T;
jacob_t = toc;
contourf(x,y,T)
colormap(jet)
xlabel('x axis')
ylabel('y axis')
colorbar
jacobi_iteration = jacobi_iteration+1;
title_text = sprintf('Iteration Number = %d, time = %d s', jacobi_iteration,jacob_t);
title(title_text)
pause(0.03)
end
end
Here, Jacobian method for Transient state implicit analysis it gives totally 2601 iterations at 496.3 sec by taking dt =30 and alpha is 1e-4.
Transient Implicit siedel:
% Transient Gauss siedel method
clear
close all
clc
nx = 10;
ny = nx;
x = linspace(0,1,nx);
dx = x(2) - x(1);
y = linspace(0,1,ny);
dy = y(2) - y(1);
T = 298*ones(nx,ny);
T(:,1) = 400;
T(:,ny) = 800;
T(1,:) = 600;
T(nx,:) = 900;
dt = 30;
Told = T;
Tprev = T;
k1 = 1e-4*(dt/dx^2);
k2 = 1e-4*(dt/dy^2);
method = 2;
error = 9e9;
tolerance = 1e-4;
siedel= 1;
tic
while(error>tolerance)
for i=2:nx-1
for j = 2:ny-1
if method == 2
H_siedel = (T(i-1,j)+Told(i+1,j));
V_siedel = (T(i,j-1)+Told(i,j+1));
term1 = 1/(1+2*k1+2*k2);
term2 = k1*term1;
term3 = k2*term1;
T(i,j)=(Told(i,j)*term1)+(H_siedel*term2)+(V_siedel*term3);
end
end
error_n = max(abs(T-Told));
error = max(error_n);
Told = T;
siedel_t = toc;
contourf(x,y,T)
colormap(jet)
xlabel('x axis')
ylabel('y axis')
colorbar
siedel = siedel+1;
title_text = sprintf('Iteration Number = %d, time = %d s', siedel,siedel_t);
title(title_text)
pause(0.03)
end
end
Here, Siedel method for Transient state implicit analysis it gives totally 2289 iterations at 418.6 sec by taking dt =30 and alpha is 1e-4.
Transient Implicit SOR:
% Transient SOR method
clear
close all
clc
nx = 10;
ny = nx;
x = linspace(0,1,nx);
dx = x(2) - x(1);
y = linspace(0,1,ny);
dy = y(2) - y(1);
T = 298*ones(nx,ny);
T(:,1) = 400;
T(:,ny) = 800;
T(1,:) = 600;
T(nx,:) = 900;
dt = 30;
Told = T;
Tprev = T;
k1 = 1e-4*(dt/dx^2);
k2 = 1e-4*(dt/dy^2);
omega = 2/(1+sin(pi*dx));
method = 3;
error = 9e9;
tolerance = 1e-4;
SOR = 1;
tic
while(error>tolerance)
for i=2:nx-1
for j = 2:ny-1
if method == 3
H_SOR = (T(i-1,j)*omega)+Told(i-1,j)*(1-omega)+Told(i+1,j);
V_SOR = (T(i,j-1)*omega)+Told(i,j-1)*(1-omega)+Told(i,j+1);
term1 = 1/(1+2*k1+2*k2);
term2 = k1*term1;
term3 = k2*term1;
T(i,j)=(Told(i,j)*term1)+(H_SOR*term2)+(V_SOR*term3);
end
end
error_n = max(abs(T-Told));
error = max(error_n);
Told = T;
SOR_t = toc;
contourf(x,y,T)
colormap(jet)
xlabel('x axis')
ylabel('y axis')
colorbar
SOR=SOR+1;
title_text = sprintf('Iteration Number = %d, time = %d s', SOR,SOR_t);
title(title_text)
pause(0.03)
end
end
Here, Jacobian method for Transient state implicit analysis it gives totally 2129 iterations at 405.3 sec by taking dt =30 and alpha is 1e-4.
Transient explicit Jacobian:
clear
close all
clc
nx = 10;
ny = nx;
x = linspace(0,1,nx);
dx = x(2) - x(1);
y = linspace(0,1,ny);
dy = y(2) - y(1);
T = 298*ones(nx,ny);
T(:,1) = 400;
T(:,ny) = 800;
T(1,:) = 600;
T(nx,:) = 900;
dt = 30 ;
Told = T;
k1 = 1e-4*(dt/dx^2);
k2 = 1e-4*(dt/dy^2);
method = 1;
error = 9e9;
tolerance = 1e-4;
jacobi_iteration = 1;
tic
while(error>tolerance)
for i=2:nx-1
for j = 2:ny-1
if method == 1
H_jacobian = (Told(i-1,j)+Told(i+1,j));
V_jacobian = (Told(i,j-1)+Told(i,j+1));
term1 = (1-2*k1-2*k2);
term2 = k1*H_jacobian;
term3 = k2*V_jacobian;
T(i,j)=(Told(i,j)*term1)+term2+term3 ;
end
end
error_n = max(abs(T-Told));
error = max(error_n);
Told = T;
jacob_t = toc;
contourf(x,y,T)
colormap(jet)
xlabel('x axis')
ylabel('y axis')
colorbar
jacobi_iteration = jacobi_iteration+1;
title_text = sprintf('Iteration Number = %d, time = %d s', jacobi_iteration,jacob_t);
title(title_text)
pause(0.03)
end
end
Here, Transient state explicit analysis for jacobian method it gives totally 1209 iterations at 213 sec by taking dt =30 and alpha is 1e-4. As it is Time marching so the function vary with respect to time.
Transient explicit seidel:
clear
close all
clc
nx = 10;
ny = nx;
x = linspace(0,1,nx);
dx = x(2) - x(1);
y = linspace(0,1,ny);
dy = y(2) - y(1);
T = 298*ones(nx,ny);
T(:,1) = 400;
T(:,ny) = 800;
T(1,:) = 600;
T(nx,:) = 900;
dt = 30;
Told = T;
Tprev = T;
k1 = 1e-4*(dt/dx^2);
k2 = 1e-4*(dt/dy^2);
method = 1;
error = 9e9;
tolerance = 1e-4;
tic
siedel_iteration = 1;
while(error>tolerance)
for i=2:nx-1
for j = 2:ny-1
if method == 1
H_siedel = (T(i-1,j)+Told(i+1,j));
V_siedel = (T(i,j-1)+Told(i,j+1));
term1 = (1-2*k1-2*k2);
term2 = k1*H_siedel;
term3 = k2*V_siedel;
T(i,j)=(Told(i,j)*term1)+term2+term3 ;
end
end
error_n = max(abs(T-Told));
error = max(error_n);
Told = T;
siedel_t = toc;
contourf(x,y,T)
colormap(jet)
xlabel('x axis')
ylabel('y axis')
colorbar
siedel_iteration = siedel_iteration+1;
title_text = sprintf('Iteration Number = %d, time = %d s', siedel_iteration,siedel_t);
title(title_text)
pause(0.03)
end
end
Here, Transient state explicit siedel analysis for gauss siedel it gives totally 849 iterations at 134.8 sec by taking dt =30 and alpha is 1e-4. As it is Time marching so the function vary with respect to time.
Transient explicit SOR:
% Transient SOR method
clear
close all
clc
nx = 10;
ny = nx;
x = linspace(0,1,nx);
dx = x(2) - x(1);
y = linspace(0,1,ny);
dy = y(2) - y(1);
T = 298*ones(nx,ny);
T(:,1) = 400;
T(:,ny) = 800;
T(1,:) = 600;
T(nx,:) = 900;
dt = 30;
Told = T;
k1 = 1e-4*(dt/dx^2);
k2 = 1e-4*(dt/dy^2);
omega = 2/(1+sin(pi*dx));
method = 3;
error = 9e9;
tolerance = 1e-4;
SOR = 1;
tic
while(error>tolerance)
for i=2:nx-1
for j = 2:ny-1
if method == 3
H_SOR = (T(i-1,j)*omega)+Told(i-1,j)*(1-omega)+Told(i+1,j);
V_SOR = (T(i,j-1)*omega)+Told(i,j-1)*(1-omega)+Told(i,j+1);
term1 =(1-2*k1-2*k2);
term2 = k1*H_SOR;
term3 = k2*V_SOR;
T(i,j)=(Told(i,j)*term1)+term2+term3;
end
end
error_n = max(abs(T-Told));
error = max(error_n);
Told = T;
SOR_t = toc;
contourf(x,y,T)
colormap(jet)
xlabel('x axis')
ylabel('y axis')
colorbar
SOR=SOR+1;
title_text = sprintf('Iteration Number = %d, time = %d s', SOR,SOR_t);
title(title_text)
pause(0.03)
end
end
Here, Transient state explicit analysis for SOR it gives totally 657 iterations at 102.17 sec by taking dt =15 and alpha is 1e-4. As it is Time marching so the function vary with respect to time.
Explanation:
In, Steady state analysis compare to all the methods (jacobian,siedel,SOR). SOR gives the results fastly compared to all the methods and the time taken to solve is less in SOR method.
In numerical linear algebra all the three methods are used to solve the iterative algoritm method for determining the solutions of diagonally dominat system of linear equations.the main difference is in jacobian method the process is iterated untill it converges. the values obtained from the previous steps. In siedel method always applies the latest updated values. In sor method results in faster convergence than the other two methods.
Transient state is the process of variables are change and not yet reached steady state The time taken to change from steady state to another steady state it is called transient time. it can be done both by explicit and implicit solver
Steady state is a process which defines the behaviour of the system and the state that is established after a certain time. it is done using implicit solver.
In, Transient Implicit and Explicit method explicit menthod is preferable because the execution time is faster than the implicit method.
Explicit method calculates the future time from the current time of system status.
Implicit method calculates the future time from involving the currnt and future time system status.
so, explicit method execution time is lower than the implicit method.
Steady Vs UnSteady:
STEADY STATE SUCCESSIVE OVER RELAXATION:
Here in steady state simulation for given boundary conditions comaparing jacobian gauss siedel and SOR methods SOR is the fastest way of convergence. Iteration number = 609, time taken to converge 97 sec.
TRANSIENT STATE SUCCESSIVE OVER RELAXATION:(IMPLICIT)
Here in Transient state simulation (Implicit) for given boundary conditions comaparing jacobian gauss siedel and SOR methods SOR is the fastest way of convergence. Iteration number = 2129, time taken to converge 405.3 sec.
TRANSIENT STATE SUCCESSIVE OVER RELAXATION:(EXPLICIT)
Here in Transient state simulation (Explicit) for given boundary conditions comaparing jacobian gauss siedel and SOR methods SOR is the fastest way of convergence. Iteration number = 657, time taken to converge 102 sec.
1. Steady state is faster than the transient state. This is because of the mathematical simplification of the problem and there is no numerical diffusion due to absence of thermal diffusivity and it is stable.
2. Tansient explicit gives faster convergence than the Trancient Implicit solver because in Trancient Explicit the future time is taken from the current time system and in Implicit method it takes from both the present and future time in a system so, explicit gives the better convergence.
Steady state < Transient Explicit < Transient Implicit
|
METHOD |
ITERATION |
TIME |
|
STEADY SOR |
609 |
97.43 sec |
|
TRANSIENT IMPLICIT SOR |
2129 |
405.3 sec |
|
TRANSIENT EXPLICIT SOR |
657 |
102.17 sec |
Stability Analysis:
CFL condition determines the conditions which is necessary for converging in partial differntial equations numerically.
stability of 2D heat conduction CFL = `alpha*(dt/dx^2)`
alpha = 1e-4 (Thermal Diffusivity)
dt = time step
dx = grid points
Transient Explicit:
For nx = 10 and dt = 55 in transient explicit method it becomes unstable with the CFL of 0.44 the CFL number depends on the gridsize and the time step for the given nx and dt values it becomes unstable.
Transient Implicit:
In Implicit method it does not becomes unstable for larger values of dt and the CFL number does not effect the stability. In Implicit methods time accuracy decreases with increase in time step. Here, dt = 100 nx = 10