Project

Solving 1D Linear Convection Equation for Different Grid Poins

REPORT:

AIM:

To solve the 1D Linear convection equation.

1D Linear Convection Equation:

`frac{delu }{delt} + cfrac{delu}{delx} = 0`

where,

`frac{delu}{delt} =`Time derivative

`frac{delu}{delx}` = Convective term

'u' is a quantity that is transported in a constant velocity.The constant velocity makes the equation linear in nature contrary to NS equation which is non-linear.The physical behaviour of the above equation is that the initial profile at u(x,t=0)u0(x) is getting transported depending upon the magnitude of constant velocity c.If the constant velocity 'c' is +ve then initial profile will be transported rightward and if -ve ,it will transport leftward

To compute this numerically, a space-time discretization is used.In particular the "forward difference in time, backward difference in space" numerical scheme is used. Thia is a finite difference scheme,which takes the form:

`frac{underset(i)(u^(n+1)) - underset(i)(u^(n))}{Deltat}` + c.`frac{underset(i)(u^(n)) - underset(i-1)(u^(n))}{Deltax}` = 0

Transposing the above discretization equation,we can solve the next time step and it is called as Time marching.

`underset(i)(u^(n+1)) - underset(i)(u^(n)) - frac{c.Deltat}{Deltax} .(underset(i)(u^(n+1)) - underset(i-1)(u^(n)))`

GIVEN:

1. Assume that the domain length is L = 1m

2. The initial velocity profile is a step function. It is equal to 2m/s between x= 0.1 and 0.3 and 1m/s everywhere else

3. Use first-order forward differencing for the time derivative

4. Use first-order backward/rearward differencing for the space term.

5. Time step and number of grid points should be variables in your calculation

6. Constant Velocity, C = 1

7. Set time step = 0.01

MAIN CODE:

clear all
close all
clc

n = [20,40,80,160];

for i = 1:length(n)
    
 
[x,u,u_initial] = linear(n(i));

end

FUNCTION CODE:

 function [x,u,u_initial] = linear(n)
    
L = 1;
C = 1;
t = 0.5;
dt = 0.01;
x_start = 0.1;
x_end = 0.3;
nt = t/dt;

 x = linspace(0,L,n);
 dx = L/(n-1);
 u = ones(1,n);
  k=1;

 for p = 1:n
     
 if (x(p) >= 0.1) && (x(p) <= 0.3)
     a(k) = p;
     k = k+1;
      
 end
 
 end
 
 nstart = a(1);
 nend=a(end);
 
 u(nstart:nend) = 2;
 

uold = u;
 u_initial = u;

 
 for j = 1:nt
    for l = 2:n
    u(l) = uold(l) - (C*dt/dx)*(uold(l) - uold(l-1));    
    end   
    uold = u;
figure(n)
plot(x,u, 'r');
    hold on
    plot(x,u_initial,'b')
    grid on
    xlabel('length of domain')
    ylabel('velocity')
    title({'1 D Linear convection',['no.of grid points =' ,num2str(n)]},'fontsize',16)
    legend('final velocity','initial velocity')
    axis ([0 1 0 2.5])
    pause(0.03)
 
   end
end

 

OUTPUT:

For grid point = 20

For grid point = 40

For grid points = 80

For grid points = 160

CONCLUSION:

  • For grid points(n) = 20, initial velocity profile is not square, it looks like trapezium and it travels towards rightward.The amplitude is continuosly decreasing and the final shape of velocity profile looks like sin wave and the length of the wave also increased.
  • For grid points(n)= 40, initial velocity profile is not perfect square in shape and amplitude wave is graudually decreasing.
  • For grid points(n) = 80, shape of wave is not disorting as it moves rightwards and amplitude of wave remains constant hence, it can be said that wave is moving with constant velocity.
  • For grid points(n) = 160, initial velocity profile is perfect square but as we moves rightward. It is oscilating continuosly about line of constant velocity of 1m/s this creating sharp leading and trailing edges.It may occur because of ignored diffusion terms in numerical calculation,they are called as 'artificial diffusion'.
  • From the above 4 graphs, It can be said that as the no.of,grid point increases the waves travels with decreasing amplitude first and then it travels with constant velocity and after optimum no.of.grid points and extra no.of.grid points causes distortion in waveforms due to ignored terms during numerical calculations.
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.