Project

Transient Analysis

TRANSIENT STATE ANALYSIS

The 2D heat conduction for the transient state is given by

`(delT)/(delt)- alpha((del^2T)/(delx^2)+(del^2T)/(dely^2))=0`

discretizing the temporal terms by forward differencing

`(delT)/(delt)=(T^(n+1)i,j-T^ni,j)/(Deltat)`

discretizing the spatial terms by central differencing

`(del^2T)/(delx^2)= (Ti-1,j-2Ti,j+Ti+1,j)/(Deltax^2)`

`(del^2T)/(delx^2)= (Ti-1,j-2Ti,j+Ti+1,j)/(Deltay^2)`

substituting the values for ease of computation ,we get

`Ti,j=Tp; Tl=Ti-1,j; Tr=Ti+1,j; Tb=Ti,j+1; Tt=Ti,j+1`

`Tp^(n+1)= (Tp^n +k1(Tl+Tr)^(n+1)+k2(Tt+Tb)^(n+1))/(1+2k1+2k2)`

where

`k1=(alphaDeltat)/(Deltax^2) ; k2=(alphaDeltat)/(Deltay^2)`

The above equation is in implicit form.

The explicit form is given by

`Tp^(n+1)= (Tp^n +k1(Tl+Tr)^(n)+k2(Tt+Tb)^(n))/(1+2k1+2k2)`

The code for the implicit scheme is as follows

MAIN CODE
% implicit scheme

clear all
close all
clc
%initial conditions
L=1;
nx=10;
ny=nx;
dt=0.01;
alpha=1.4;
nt=1000;
% grid spacing along x and y axes
x=linspace(0,L,nx);
dx=L/(nx-1);
y=linspace(0,L,ny);
dy=L/(ny-1);
error=7e7;
tolerance=1e-4;
lambda=1.5;
% BCs
T=ones(nx,ny);
T(:,1)=400;
T(end,:)=600;
T(:,end)=800;
T(1,:)=900;
% temperature at corners by refining edges
T(1,1)=(900+400)/2;
T(1,end)=(900+800)/2;
T(end,1)=(600+400)/2;
T(end,end)=(600+800)/2;
% temperature distribution using tje Jacobi iterative scheme
k1=alpha*dt/(dx^2);
k2=alpha*dt/(dy^2);
%method selection
for method=[1 2 3];  
    
    if method==1
        jacobi_trans_imp(T,x,y,nx,ny,tolerance,k1,k2,nt);
    else if method==2
            gs_trans_imp(T,x,y,nx,ny,tolerance,k1,k2,nt);
        else if method==3
                sor_trans_imp(T,x,y,nx,ny,tolerance,k1,k2,nt,lambda);
            end
        end
    end

JACOBI FUNCTION CODE

function out= jacobi_trans_imp(T,x,y,nx,ny,tolerance,k1,k2,nt)

T_old=T;
T_prev_dt=T_old;
 term_1=(1+2*k1+2*k2)^(-1);
 term_2=k1*term_1;
 term_3=k2*term_1;
 
tic
jac_iter=1;
%time loop
for k=1:nt
    error=7e7;
    %convergence loop
  while(error>tolerance)
      %nodal loop
      for i=2:nx-1
          for j=2:ny-1
              H=(T_old(i-1,j)+T_old(i+1,j));
              V=(T_old(i,j-1)+T_old(i,j+1));
              T(i,j)=((term_1*(T_prev_dt(i,j)))+(term_2*H)+(term_3*V));
          end
      end
      error=max(max(abs(T_old-T)));
      T_old=T;
      jac_iter=jac_iter+1;
       
  end
T_prev_dt=T;
end
T_jacobi=toc;
figure(1)
[X,Y]=meshgrid(x,y);
contourf(x,y,T,'showtext','on')
colormap(jet)
colorbar
title_name=sprintf('no of iterations for transient implicit 2D heat conduction eqn is :%d Convergence time : %f sec',jac_iter,T_jacobi);
title(title_name)
xlabel('x-axis')
ylabel('y-axis')
saveas(gca,'jacobi_trans_imp.jpg')
out=figure(1)
end

GAUSS SEIDEL FUNCTION CODE

function out= gs_trans_imp(T,x,y,nx,ny,tolerance,k1,k2,nt)
 
T_old=T;
T_prev_dt=T_old;
term_1=(1+2*k1+2*k2)^(-1);
term_2=k1*term_1;
term_3=k2*term_1;
gs_iter=1;
tic

%time loop
for k=1:nt
   error=7e7;
  %convergence loop
  while(error>tolerance)
      %nodal loop
      for i=2:nx-1
          for j=2:ny-1
              H=(T(i-1,j)+T(i+1,j));
              V=(T(i,j-1)+T(i,j+1));
              T(i,j)=((T_prev_dt(i,j)*term_1)+(H*term_2)+(V*term_3));
          end
      end
      error=max(max(abs(T_old-T)));
      T_old=T;
      gs_iter=gs_iter+1;
       
  end
 T_prev_dt=T_old;
end
T_gs=toc;
figure(2)
[X,Y]=meshgrid(x,y);
contourf(x,y,T,'showtext','on')
colormap(jet)
colorbar
title_name=sprintf('no of iterations for transient implicit 2D heat conduction eqn is : %d Convergence time : %f sec',gs_iter,T_gs);
title(title_name)
xlabel('x-axis')
ylabel('y-axis')
saveas(gca,'gs_trans_imp.jpg')
out=figure(2)
end

SOR FUNCTION CODE

function out= sor_trans_imp(T,x,y,nx,ny,tolerance,k1,k2,nt,lambda)
T_old=T;
T_prev_dt=T_old;
lambda=1.5;
term_1=(1+2*k1+2*k2)^(-1);
term_2=k1*term_1;
term_3=k2*term_1;
sor_iter=1;
tic
%time loop
for k=1:nt
    error=7e7;

  %convergence loop
  while(error>tolerance)
      %nodal loop
      for i=2:nx-1
          for j=2:ny-1
              H=(T(i-1,j)+T(i+1,j));
              V=(T(i,j-1)+T(i,j+1));
              T(i,j)=lambda*((T_prev_dt(i,j)*term_1)+(H*term_2)+(V*term_3))+((1-lambda)*T_old(i,j));
          end
      end
      error=max(max(abs(T_old-T)));
      T_old=T;
      sor_iter=sor_iter+1;
  end
     T_prev_dt=T_old;
end
T_sor=toc;
figure(3)
[X,Y]=meshgrid(x,y);
contourf(x,y,T,'showtext','on')
colormap(jet)
colorbar
title_name=sprintf('no of iterations for transient implicit 2D heat conduction eqn is :%d Convergence time : %f sec',sor_iter,T_sor);
title(title_name)
xlabel('x-axis')
ylabel('y-axis')
saveas(gca,'sor_trans_imp.jpg')
out=figure(3)
end

The following are the plots obtained

2) JACOBI IMPLICIT ITERATION SCHEME

2)GAUSS SEIDEL IMPLICIT ITERATION SCHEME

3) SUCCESSIVE OVER RELAXATION IMPLICIT ITERATION SCHEME

The code for the explicit iteration scheme is as follows

%trans explicit 
clear all
close all
clc
%initial conditions
L=1;
nx=10;
ny=nx;
dt=0.001;
alpha=1.4;
nt=1000;
error=7e7;
tolerance=1e-4;
% grid spacing along x and y axes
x=linspace(0,L,nx);
dx=L/(nx-1);
y=linspace(0,L,ny);
dy=L/(ny-1);
% BCs
T=ones(nx,ny);
T(:,1)=400;
T(end,:)=600;
T(:,end)=800;
T(1,:)=900;
% temperature at corners by refining edges
T(1,1)=(900+400)/2;
T(1,end)=(900+800)/2;
T(end,1)=(600+400)/2;
T(end,end)=(600+800)/2;
% temperature distribution 
k1=alpha*dt/(dx^2);
k2=alpha*dt/(dy^2);
T_old=T;
method=1;
tic;
if method==1;
iter_count=1
       for k=1:nt
         for i=2:nx-1
     for   j=2:ny-1
        term_1=T_old(i,j);
        term_2=k1*(T_old(i-1,j)-2*T_old(i,j)+T_old(i+1,j));
        term_3=k2*(T_old(i,j-1)-2*T_old(i,j)+T_old(i,j+1));
      
        T(i,j)=term_1+term_2+term_3;
     end
         end
    
     T_old=T;
    iter_count=iter_count+1;
        end
    end
    iter_time=toc;
    figure(1)
    contourf(x,y,T,'showtext','on');
    colormap(jet)
    colorbar
    xlabel('x-axis')
    ylabel('y-axis')
    title_text=sprintf('Explicit method -No of iterations=%d \n Convergence time =%f sec',iter_count,iter_time);
    title(title_text)
   

The plot obtained looks like this

1) TRANSIENT EXPLICIT ITERATION SCHEME

INFERENCE:

  • For both transient and steady state methods, SOR yields the fastest results when compared to the other two iteration schemes.
  • Due to the lack of the time derivative, the steady state method results in faster convergence time as opposed to the Transient state method.
  • The explicit scheme is faster when compared to the implicit scheme as the time taken to reach convergence and number of iterations is almost 3 and a half times lesser than the implicit scheme, for the same number of timsteps and grid points.
  • But in the case of the explicit scheme, when the dt value exceeds 0.001(0.01,0.1 etc) the solution becomes unstable and fails to reach a steady state.
  • On the contrary, the Implicit scheme has a stable solution for all values of dt above and below 0.001 .
  • Although the explicit scheme results in faster convergence time , it does not prove to be versatile as in the case of the implicit scheme wherein a steady state can be achieved for a myriad of dt values.
Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.