Project

Behaviour Of Velocity Profile in Linear Convection equation for varying Grid points

The objective of this challenge is to solve a linear convection equation and to determine its behaviour for final velocity profile by varying the grid points

Here, my initial velocity profile is fixed to 2m/s between 0.1 - 0.3 in my domain.

LINEAR CONVECTION EQUATION:

`(∂u)/(∂t)+c⋅(∂u)/(∂x)=0`

We can say that the linear convection equation is a snippet from the Navier stokes equation.

The output of the equation is a straight line. But for our observation, we limit it to 0.4s to see how it behaves. So the number of time steps becomes 0.4/dt

Here my domain x varies from 0 - 1m for grid points(n=20,40,80,160)

To perform the simulation in Matlab we need to discretize it.

To discretize this equation in space and time we will use the Forward Difference scheme for time derivative and Backward Difference scheme for space derivative.

`(u^(n+1) - u^n) / (Deltat) + C [(u _i - u_(i-1))/( Deltax)] = 0`

`(u^(n+1) ) = u^n - C (Deltat) /( Deltax) [(u _i - u_(i-1))/( Deltax)]`

FIXING THE INITIAL VELOCITY PROFILE:

It is clear that we want a profile of velocity 2m/s at 0.1 -0.3 m.

Since the x is divided into n number of grid points, we need to locate the grid point number where the x is 0.1 - 0.3. If we do so, we can fix its velocity to 2m/s.

The index at which the grid points(n) of x varies from 0.1-0.3 is identified and the Velocity is set to 2 at those grids points.

Here we have a varying grid point so, the function

n_start = (x_start/dx) + 1;
n_stop = (x_stop/dx) + 1;

is introduced. This could identify the index of x that's varying from 0.1 - 0.3 for any number of grid points.

FINAL VELOCITY PROFILE:

The final velocity is obtained by the Forward Difference scheme for time derivative and Backward Difference scheme for space derivative in the linear convection equation with number of time steps as 40. For the number of Grid points the velocity profile is calculated.

MAIN CODE FOR VARYING GRID POINTS:

clear all
close all
clc


%linear convection problem
L = 1;
c = 1;
dt = 1e-02;
n = [20]; %Subject to change as 40 80 160

x = linspace(0,1,n);
dx = x(2) - x(1);

%Length at which velocity should step
x_start = 0.1;
x_stop = 0.3;

%Assigning Index value for my step to start and stop
n_start = (x_start/dx) + 1;
n_stop = (x_stop/dx) + 1;

% u=2 at x= 0.1 to 0.3.
u = ones(1, n);
u(n_start:n_stop) = 2;

    uold = u;
    u_orginal= u;
    
    nt = 40;  %nt=t/dt t=0.4 0.4/0.01
    for k = 1:nt   %Time marching solution
      for  i = 2:n %Space marching solution
        
         
        u(i) = uold(i) - (c*(dt/dx)*(uold(i)-uold(i-1)));
      
    end
    
    uold = u;
   %Velocity profile for every time step
   figure(2)
   plot(x,u,'b');
   hold on
   plot(x,u_orginal,'r')
   xlabel('Length');
   ylabel('Velocity');
   axis([0 1 0 3])
   pause(0.4)
   legend('Final velocity profile','Initial velocity profile');
   title('Effect of Velocity Profile for n=20');
   grid on
   
  
    
    end

    
        
   %Final profile of the velocity 
   figure(2)
   plot(x,u,'b');
   hold on
   plot(x,u_orginal,'r')
   xlabel('Length');
   ylabel('Velocity');
   axis([0 1 0 3])
   pause(0.4)
   legend('Final velocity profile','Initial velocity profile');
   title('Effect of Velocity Profile for n=20');
   grid on
   
   

OBTAINED RESULTS:

For n = 20

Effect on every time step vs final time step

For n = 40

For n = 80

For n = 160

CONCLUSIONS:

  • We could conclude that the smaller number of grid points makes the solution stable and a large number of grid points blows up the solution as in n = 160 for a domain like this.
  • We could notice a diffusion taking place in all grid points except for n = 160. This is called artificial Diffusion.
  • For n = 80, we could see that the final profile is almost same as the initial profile. Here there is no diffusion taking place.
  • At n = 160 the solution looks unphysical because of the node points are so close to each other.
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.