Project

Steady State simulation vs Unsteady state analysis

Objective:

to compare the steady state fastest simulation and transient state fastest simulation time from both implicit and explicit methods

SOR method (steady) and Guass implicit(transient) as obtained from results in previous problem

Solution:

consider,

no. of grid points in x-y direction is 10

time step = 1e-2 s

total time = 2s

no. of time steps= total time/time step

initial temperature = 100K

error =9e9

relaxation factor(alpha) = 1.25

constant(beta) = 0.25

given conditions,

tolerance =1e-4

boundary temperature condition

T_left = 400

T_right = 800

T_top = 600

T_bottom + 900

for steady state

SOR method

T=Told*(1-alpha)+alpha*(T_guass)

for transient state

guass implicit method

k1=beta*dt/(dx^2)

k2=beta*dt/(dy^2)

K=1+2k1+2k2

T=(T_initial+k1(T_left+T_right)+k2(T_top+T_bottom))/k

%Steady state vs unsteady state 
clear all 
close all
clc

%given conditions
% nx=ny i.e n is number of points
%x = y
nx=10;
ny=10;

%domain is unit square along x and y direction
x = linspace(0,1,nx);
y = linspace(0,1,ny);
dx= 1/(nx-1);
dy=1/(ny-1);

%time step dt and total time be 2s
dt=1e-2;
nt= 2/dt;

% let the initial temperature be 100k
T=100*ones(nx,ny);

%boundary conditions for steady case
T(:,1) = 400; %for left
T(:,nx)= 800; %for right
T(1,:)= 600; %for top
T(ny,:) = 900; %for bottom

%tolerance and error
error = 9e9;
absolute_error = 1e-4;

%steady explicit methods
T_old =T;
T_initial =T;

%constant
beta=0.25;

%RELAXATION FACTOR
alpha = 1.25;

%steady state
K=2*(dx^2+dy^2)/((dx^2)*(dy^2));

%unsteady state i.e transient 
k1=(beta*dt/(dx^2));
k2=(beta*dt/(dy^2));
k=1+(2*k1)+(2*k2);

%steady state analysis
%successive over relaxation methods
tic;
sor_iter=1;
while(error>absolute_error)
  for i=2:nx-1
    for j=2:ny-1
        k1=(T(i-1,j)+T_old(i+1,j))/(dx^2);
        k2=(T_old(i,j+1)+T(i,j-1))/(dy^2);
        T_gauss(i,j)=(k1+k2)/k;
        T(i,j)=T_old(i,j)*(1-alpha)+alpha*(T_gauss(i,j));
      end
    end
      error = max(max(abs(T-T_old)));  
  T_old=T;
  sor_iter =sor_iter+1;
toc
simulation_steady_sor=toc;
end

%transient(unsteady) implicit
%guass siedal methods

tic
guass_iter=1;
for s=1:nt
    while(error>absolute_error)
    for i=2:nx-1
      for j=2:ny-1
      T_left = T(i-1,j);
      T_right = T_old(i+1,j);
      T_top = T_old(i,j+1);
      T_bottom = T(i,j-1);
      T(i,j) = (T_initial(i,j)+k1*(T_left+T_right)+k2*(T_top+T_bottom)/k);
      end
    end
    error = max(max(abs(T-T_old)));
    T_old=T;
    guass_iter = guass_iter+1;
    
    end
  end  
      toc
    transient_implicit_guass = toc;
  
%plotting bar graph for comparison
%s=categorical({'steady sor','transient implicit guass'});
s = [1 2];
barlabels = ['steady sor','transient implicit gauss'];
simulation_time = [simulation_steady_sor, transient_implicit_guass];
figure(1)
bar(s,simulation_time,0.3,'b')
set(gca, 'XTickLabel', barlabels);
xlabel('method');
ylabel('simulation time');
title('method vs simulation');
legend('simulation time');

Result:

Conclusion:

from the figure, it can be observed that successive over relaxation method for steady state takes longer time than guass implicit method for transient state

simulation time, steady SOR = 3.5828 s

transient guass implicit = 4.2346s

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.