Project

MID TERM PROJECT - Steady state vs Unsteady state analysis

REPORT:

AIM:

To compare the fastest steady state simulation and the fastest transient simulation and also to write a detailed report of the results.

TRANSIENT CASE:

In the transient case the program is solved by two methods,

  • Explicit method
  • Implicit method

The explicit method is solved directly since all the values are known.

In the implicit method all the values are not known, So the iterative techniques are used namely,

  • Jacobi method
  • Gauss seidal method
  • SOR method

Output of Explicit method:

OUTPUT FOR IMPLICIT METHOD:

JACOBI METHOD:

GAUSS SIEDAL METHOD:

SOR METHOD:

COMPARING THE ITERATIVE METHODS IN IMPLICIT TRANSIENT CASE:

From the two bar graph it is clearly indicated that the SOR iterative method is the fastest simulation method in implicit form, Which has the less no.of,iterations and simulation time compared with the other iterative methods.

COMPARING THE OUTPUTS OF EXPLICIT AND IMPLICIT METHODS:

Since SOR method is the fastest simulation method in implicit form it is taken for the comparision with the explicit form.

From the above two bar graphs it is clearly indicated that the explicit method is the fastest simulation method compared with the implicit method, Because it has less no.of.iterations and simulation time.

STEADY STATE:

In the steady state method there is no need to use the iterative methods since all the values are known.

OUTPUT FOR THE STEADY STATE METHOD:

COMPARING STEADY STATE AND TRANSIENT STATE:

From the above bar graphs its clearly indicated that the transeint simulation is considered to be the fastest. As shown in the above graph the explicit method is fastest method with less iteration and less simulation time.

IMPLICIT METHOD > STEADT STATE > EXPLICIT METHOD

Below the codes are given for further refferences

MATLAB CODE FOR EXPLICIT METHOD (TRANSIENT CASE):

clear all
close all
clc

L = 1;
nx = 30;
ny = nx;

x = linspace(0,L,nx);
y = linspace(0,L,ny);

dx = x(2) - x(1);
dy = y(2) - y(1);


tol = 1e-4;
alpha = 1.4;
dt =1/5000;  

T_L = 400;
T_T = 600;
T_R = 800;
T_B = 900;
T = ones(nx,ny);

T(2:ny-1,1) = T_L;
T(2:ny-1,nx) = T_R;
T(1,2:nx-1) = T_T;
T(nx,2:ny-1) = T_B;

T(1,1) = (T_T + T_L)/2;
T(nx,ny) = (T_R + T_B)/2;
T(1,ny) = (T_T + T_R)/2;
T(nx,1) = (T_B + T_L)/2;

k1 = (alpha*dt)/(dx^2);
k2 = (alpha*dt)/(dy^2);
nt = 800
; 
cfl = alpha*(1/(dx^2) + 1/(dy^2))*(dt);  

[X,Y] = meshgrid(x,y);
told = T;

  

    tic;
         for g = 1:nt
      
            for i = 2:nx-1
                for j = 2:ny-1
                    term1 = told(i,j);
                    term2 = k1*(told(i+1,j) - 2*told(i,j) + told(i-1,j));
                    term3 = k2*(told(i,j+1) - 2*told(i,j) + told(i,j-1));
                    T(i,j) = (term1 + term2 + term3);
                end
                end
                told = T;
            end
            
  
 f = toc;
 
 figure(1)
 [M,N] = contourf(X,Y,T);  
 clabel(M,N)
 colormap(jet)
 colorbar
 title_text = sprintf('No.of iterations = %d \t time taken = %fs',nt,f);
 title(title_text)
 xlabel('x axis')
 ylabel('y axix')
 set(gca,'ydir','reverse')
 

MATLAB CODE FOR IMPLICIT METHOD (TRANSEINT CASE):

clear all
close all  
clc
       


L = 1;
nx = 30;
ny = nx;

x = linspace(0,L,nx);
y = linspace(0,L,ny);

dx = x(2) - x(1);
dy = y(2) - y(1);


tol = 1e-4;
alpha = 1.4;
  

T_L = 400;
T_T = 600;
T_R = 800;
T_B = 900;
T = ones(nx,ny);

T(2:ny-1,1) = T_L;
T(2:ny-1,nx) = T_R;
T(1,2:nx-1) = T_T;
T(nx,2:ny-1) = T_B;

T(1,1) = (T_T + T_L)/2;
T(nx,ny) = (T_R + T_B)/2;
T(1,ny) = (T_T + T_R)/2;
T(nx,1) = (T_B + T_L)/2;
dt = 1/5000;
cfl = alpha*(1/(dx^2) + 1/(dy^2))*(dt);  
k1 = (alpha*dt)/(dx^2);
k2 = (alpha*dt)/(dy^2);
nt = 800;


[X,Y] = meshgrid(x,y);   
told = T;
t_prev = told;

 iterative_solver =  1:3;
 for iterative_solver = 1
    tic;
    if iterative_solver == 1
        jacobi_iter = 1;
         for g = 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) = (t_prev(i,j)*term1) + (H*term2) + (V*term3);
                    
                end
            end
            error = max(max(abs(told - T))); 
            told = T;
            jacobi_iter = jacobi_iter + 1;  
        end
        t_prev = T;
         end
    end  
    
     f = toc;
 
 figure(1)
 [M,N] = contourf(X,Y,T);
 clabel(M,N)
 colormap(jet)
 colorbar
 title_text = sprintf('No.of.iterations(Jacobi) = %d  Simulation time = %fs',jacobi_iter,f); 
 title(title_text)
 xlabel('x axis')
 ylabel('y axix')
 set(gca,'ydir','reverse')

 end
 
 
 L = 1;
nx = 30;
ny = nx;

x = linspace(0,L,nx);
y = linspace(0,L,ny);

dx = x(2) - x(1);
dy = y(2) - y(1);  


tol = 1e-4;
alpha = 1.4;
dt = 1/5000;  

T_L = 400;
T_T = 600;
T_R = 800;
T_B = 900;
T = ones(nx,ny);

T(2:ny-1,1) = T_L;
T(2:ny-1,nx) = T_R;
T(1,2:nx-1) = T_T;
T(nx,2:ny-1) = T_B;

T(1,1) = (T_T + T_L)/2;
T(nx,ny) = (T_R + T_B)/2;
T(1,ny) = (T_T + T_R)/2;
T(nx,1) = (T_B + T_L)/2;

cfl = alpha*(1/(dx^2) + 1/(dy^2))*(dt);  
k1 = (alpha*dt)/(dx^2);
k2 = (alpha*dt)/(dy^2);
nt = 800;

    for iterative_solver = 2
  tic;   
    if iterative_solver == 2
         gs_iter = 1;
         for g = 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 = T(i-1,j) + told(i+1,j);
                    V = T(i,j-1) + told(i,j+1);
                    T(i,j) = (t_prev(i,j)*term1) + (H*term2) + (V*term3);
                    
                end
            end
            error = max(max(abs(told - T))); 
            told = T;
            gs_iter = gs_iter +  1;
        end
        t_prev = T;
         end
    end  
 
 f2 = toc;
 
 figure(2)
 [M,N] = contourf(X,Y,T);
 clabel(M,N)
 colormap(jet)
 colorbar
 title_text = sprintf('No,of,iterations(gs) = %d  Simulation time = %fs',gs_iter,f2); 
 title(title_text)
 xlabel('x axis')
 ylabel('y axix')
 set(gca,'ydir','reverse')


    end

 L = 1;
nx = 30;
ny = nx;

x = linspace(0,L,nx);
y = linspace(0,L,ny);

dx = x(2) - x(1);
dy = y(2) - y(1);


tol = 1e-4;
alpha = 1.4;
omega = 1.5;      
dt = 1/5000;  
  
T_L = 400;
T_T = 600;
T_R = 800;
T_B = 900;
T = ones(nx,ny);

T(2:ny-1,1) = T_L;
T(2:ny-1,nx) = T_R;
T(1,2:nx-1) = T_T;
T(nx,2:ny-1) = T_B;

T(1,1) = (T_T + T_L)/2;
T(nx,ny) = (T_R + T_B)/2;
T(1,ny) = (T_T + T_R)/2;
T(nx,1) = (T_B + T_L)/2;

cfl = alpha*(1/(dx^2) + 1/(dy^2))*(dt);  
k1 = (alpha*dt)/(dx^2);
k2 = (alpha*dt)/(dy^2);
nt = 800;
for iterative_solver = 3 
    omega = 1.4;
    tic;   
    if iterative_solver == 3
        sor_iter = 1;
         for g = 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 = T(i-1,j) + told(i+1,j);
                    V = T(i,j-1) + told(i,j+1);
                    T(i,j) = ((1-omega)*told(i,j)) + omega*((t_prev(i,j)*term1) + (H*term2) + (V*term3));
                    
                end
            end
            error = max(max(abs(told - T))); 
            told = T;
            sor_iter = sor_iter + 1;  
        end
        t_prev = T;  
         end
    end    
 
 f3 = toc;
 
 figure(3)
 [M,N] = contourf(X,Y,T);
 clabel(M,N)
 colormap(jet)
 colorbar
 title_text = sprintf('No.of.iterations(sor) = %d   Simulation time = %fs',sor_iter,f3); 
 title(title_text)
 xlabel('x axis')
 ylabel('y axix')
set(gca,'ydir','reverse')

end
 

MATLAB CODE FOT STEADY STATE CASE:

clear all
close all
clc 

L = 1;
nx = 30;
ny = nx;

x = linspace(0,L,nx);
y = linspace(0,L,ny);

dx = x(2) - x(1);
dy = y(2) - y(1);

error = 9e9;
tol = 1e-4;
alpha = 1.4;

T_L = 400;
T_T = 600;
T_R = 800;
T_B = 900;
T = ones(nx,ny);

T(2:ny-1,1) = T_L;
T(2:ny-1,nx) = T_R;
T(1,2:nx-1) = T_T;
T(nx,2:ny-1) = T_B;

T(1,1) = (T_T + T_L)/2;
T(nx,ny) = (T_R + T_B)/2;
T(1,ny) = (T_T + T_R)/2;
T(nx,1) = (T_B + T_L)/2;

[X,Y] = meshgrid(x,y)
told = T;
t_prev = told;

   
  
    tic;
           k = 1;
           while(error>tol) 
             
     
            for i = 2:nx-1
                for j = 2:ny-1
                    T(i,j) = (0.25*((told(i-1,j) + told(i+1,j) + told(i,j-1) + told(i,j+1))));
                    
                end
            end
            error = max(max(abs(told - T)));  
            told = T; 
            k= k+1;
        end
 f = toc;
 
 figure(1)
 [M,N] = contourf(X,Y,T);
 clabel(M,N)
 colormap(jet)
 colorbar
 title_text = sprintf('No.of iterations = %d \t Simulation Time = %fs',k,f);
 title(title_text)
 xlabel('x axis')
 ylabel('y axix')
 set(gca,'ydir','reverse')

 
 
 

CONCLUSION:

In the staedy state simulation there is no need time criteria, A sthere is no time marching achieved. When there is no time marching achieved, the temperature gradient remains the same throughout the simulation. Also, the number of grid points are the same nx = ny.

In the transient simulation, there is the time marching criteria which can be detected by the presence of a term that denotes time in the equation. Due to which the temperature gradient will keep changing according to the time. There are two ways to process the unsteady state, One is the explicit method and the other one is implicit method which takes longer and more no. of.iterations than the explicit method.

The no.of.Time steps used in the explicit and implcit was 800

i.e, nt = 800

and dt = 1/5000

In which the explicit is considered to the fastest among the other method, But in the explicit method it should satisfy the CFL number which should be less than 0.5. When the CFL number is more than 0.5 the solution goes unstable.

However we know that implicit method is unconditionally stable with the CFL number being high.But the disadvantage is that it takes more time and iterations compared with the explicit method.

As a result the transient simulation (Explicit form) is considered to be fastest than the steady state simulation.

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.