Project

Effect of time step on numerical solution

Objective : To understand the imporatance of time step in numerical solution for 1D linear Convection Equation.

Terms to be understand :

Convection : The flow that combines diffusion and the advection is called convection.

Advection : Bulk transfer of mass,momentum,heat of the molecules due to flow of field.

Diffusion : Diffusion mainly due to momentum of the molecules , from high to low concentration

region of property.

Courant Number (CFL Criteria):

CFL = `frac{c*Deltat}{Deltax}`.

Used to understand the stability of model.

`Deltat` = time step.

`Deltax` = grid size.

CFL < 1 , condition for the model to be stable for explicit time marching problems.

As here grid size is static , and velocity(c) is constant (1m/s) , so CFL resitricted to time step.

As CFL `alpha` time step , CFL increases as time step increases errors get approach to be bounded.

General Equation using discretization and taylor series :

This scheme is First order upwind scheme

`frac{delphi}{delt} = -c*frac{delphi}{delx} + c*frac{Deltax}{2}*(1-lambda)*frac{del^2phi}{delx^2}+O([Deltax^2])`

As leading term of truncation error here is even power derivative , so dissipation occurs...

Can observe that in results below , as over time loss in momentum (velocity decreases)...

As by defination , dissipation means loss of quanitity over time...

here `lambda` is courant number.

  1. If `lambda` < 1 , then local truncation error is positive and has a Numerical Diffusion effect.
  2. If `lambda` > 1 , the local truncation error is negative and has a amplyfying effect and is a cause of instability.
  3. If `lambda` = 1 , then lcoal truncation error is Zero , No Numerical Diffusion.

NOTE :

CFL Criteria is used for explicit method , no matters how much is courant number while doing implicit method.

Discretization can be solved by using Three methods ...,

  • Implicit method.
  • Explicit method.
  • Crank Nichalson method(Implicit + Explicit method).

Stability criterias :

  • CFL Number.

Explanation of code :

  • Considered required inputs for required data calculations , with constant grid size , 4 time steps , Length of domain as 1m.
  • Calculated velocity data using function defination , for all 4 time steps.
  • Plotted the initial and final velocity profiles in a single graph , and labeled using commands.
  • Shown simulation time for time-steps using 'tic-toc' command using bar graph.

Code snippet :

close all ; clear all ;clc 
n = 80;
dt = [1e-4,1e-3,1e-2,1e-1];
t = 0.4;
nt = t./dt;
t1 = ones(1,4);
x = linspace(0,1,80);
dx = x(2) - x(1);
u = ones(1,n);
A = logical(x>=0.1 & x<=0.3);
index = find(A==1);
n_start = index(1);
n_end = index(end);
u(n_start:n_end) = 2;
plot(x,u)
hold on
for p = 1:length(dt)
[u1,a] = linear_convection_func2(dt(p),nt(p),length(x),u,dx);
plot(x,u1)
if dt(p) == 1e-3
    text(x(36),u1(36),strcat('dt=',num2str(dt(p))));
else
    text(x(50),u1(50),strcat('dt=',num2str(dt(p))));
end
axis([0 1 0 2])
t1(p) = a;
end
legend('initial','1e-4','1e-3','1e-2','1e-1')
figure(2)
X = categorical({'1e-4','1e-3','1e-2','1e-1'});
X = reordercats(X,{'1e-4','1e-3','1e-2','1e-1'});
bar(X,t1(1,:))
title('simulation time for ',num2str(80))
xlabel('\delta t')
ylabel('simulation time')


Function snippet :

function [z,a] = linear_convection_func2(dt,nt,k,u,dx)
  v = u;
  L = 1;
  c = 1;
  tic
   %time loop
      for i = 1:nt
   % space loop
         for j = 2:k
           z(j) = v(1,j) - ((c*dt)/dx)*(v(1,j) - v(1,j-1));  
         end
         z(1) = 1;
         v = z;
      end
      a = toc;
end

Results :

Generally , time-step consideration depends on the discretization model we considered.

Here by increasing the time step , stability and rate of convergence increases.

But for 'dt = 0.1' , solution blasted , as it undergoes under instability .(CFL > 1).

For explicit time marching problems , (CFL < 1).

By this graph , as time step increases simulation time decreases , as the number of iterations decreases.

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.