In this report, we will be studying the effects of the grid points in the first order convection equation describing one dimensional velocity distribution.


`frac{delu}{delt} = c*frac{delu}{delx}`



clear all
close all

c = 1;                   %convective coefficient
dt = 0.01;               
l = 1;                   %length of domain
n = 160;                 %grid points
x = linspace(0,l,n);     %discretisation of space
dx = x(2)-x(1);          
time = 0.4; 

%dt*tstep = time; 
tstep = time/dt;

%xstart = 0.1
% xend = 0.2
ct = 1;
for i = 1:n
    if x(i) >= 0.1 && x(i)<=0.3
        ustart(ct) = i;
    ct = ct+1;

%initial vel = 1
u = ones(1,n);
u(ustart(1:end)) = 2;

uold = u;

%plotting initial velocity
plot (x,u,'linewidth',3,'color','b')
grid on
title(sprintf('1D-convection n n = %d',n))
xlabel('space - x','FontWeight','b')
ylabel('velocity - u','FontWeight','b')
hold on

%time marching
for r = 1:tstep
%space marching   
for i = 2 : n

    u(i) = uold(i) - ((c*dt/dx)*(uold(i) - uold(i-1)));

%update velocity field
    uold = u;


% plotting the final profile




1. n=20


we can see that as the grid points are less there is a steep wave instead of a square wave to be formed. Also, there is a huge loss in the maximum value when time marching.


2. n=40


When we increase the grid points to 40, we can see the difference in the initial and final plots clearly.


3. n=80


If we increase the grids to 80, we are achieving the maximum velocity and we cannot even notice the velocity drop due to truncation losses.


4. n=160



When the number of grid points has been changed to 160, we can see that the initial velocity square wave is well clear but the final profile looks destructive. This is due to the instability which is described by Von Neumenn and the analysis is termed as Von neumenn stability analysis. That states the instability occurance when the number of grid points has been increased beyond the saturation level.

Projects by Yokesh R

Yokesh R · 2020-02-04 11:48:17

Hello Read more

Yokesh R · 2020-01-21 11:46:05

Hello Read more

Mixing tee project
Yokesh R · 2019-08-22 06:06:22

Case-1:       CASE-2:           CASE-3:         Read more

MAIN CODE: clear all close all clc A=[5 1 2 ; -3 9 4; 1 2 -7]; B=[10 ;-14; 33]; u = [0 1 2; 0 0 4; 0 0 0]; l = [0 0 0; -3 0 0; 1 2 0]; di = [5 0 0; 0 9 0; 0 0 -7]; mag = [0.25,0.5,0.75,1,1.5,2]; for i = 1 : length(mag) d = di*mag(i); Read more

DESCRIPTION: In this code, we are going to solve the two dimesnional convection equation defining a temperture distribution. The equation can be solved by 2 methods. 1. Implicit method 2. Explicit method In explicit method, we will be solving the equation sequencial Read more

DESCRIPTION: Using the central and skewed scheme methods initially, we have to develop the Taylor table, which should be converted into a matrix and solved for the constants. These constants help in solving the second order differential equation. Finally, the error res Read more

DESCRIPTION: In this code, we are going to compare the results of the 1D convection distribution equation describing the velocity for a range of time-step values. As a result, we will be getting the plots on the final velocity profile on time marching and computational Read more

DESCRIPTION:      In this code, we are going to discretize the function for the first-order derivative using first, second and fourth order approximation techniques and studying the error bounced by every method by a bar chart.   CODE: clear all Read more

DESCRIPTION:      Here in this code, we are using a range of dx terms for discretizing the first order derivative and studying the results of the dx vs error plot  CODE: clear all close all clc x = pi/3; dx = linspace(pi/4,pi/4000,30); %y Read more

STOICHIOMETRIC COMBUSTION   DESCRIPTION:   Stoichiometric combustion defines the ideal combustion that needs to take place for a given chemical equation. This is actually the general form of equation for alkanes. The general form might differ for e Read more


The End