Project

Effects of Grid Point on One Dimensional Linear Convection Equation..

Aim:

To find the numerical solution to the one-dimensional Linear Convection equation at varying Grid Points.

Program Code :

The following code is used to differentiate the output of the 1D Linear convection equation. the changes in the output can be noticed clearly according to the number of nodes.

CODE

close all
clear all
clc

%input_parameters

L = 1 ;
n = 160 ;
c = 1 ;
nt = 40 ;
dt = 0.01 ;
x = linspace(0,L,n)


% formula for grid spacing
dx = x(2) - x(1) ;

% x_start = 0.1;
% x_stop = 0.3;


n_start = 18 ;
n_stop = 49 ;
u= ones(1,n)
u(n_start:n_stop)= 2;
uold = u;
u_initial = u ;


% time loop

for k = 1:nt

for i = 2:n
u(i) = uold(i) - (c*(dt/dx)) * (uold(i) - uold(i-1))

end
uold = u ;

plot(x,u_initial,'r')
hold on
plot(x,u,'g')
axis([0 1 0 2])
pause(0.4)

end

@ n=20

The soluton of the eqaution of 1D can be observed from the below image. Since the no of grid points is low, the profile decreases drastically which is evident from the graph. The amplitude of the velocity decreases from 2m/s to 1.7m/s approx.

@ n=40

As the no of grid points are slightly greater than the previous case . We observe the same trend here but the final velocity will be greater than the former case. It is around 1.9m/s

@n = 80

The trend somewhat decreases here. The graph is moother and the square wave is not much distorted. The initial and final velocities are appoximately equal.

@n= 160

when the grid points is 160, the graph becomes full of ripples and there is a disturbamce in the profile .

CONCLUSION:

Hence we come to know that when the number the grid points is increased the graph becomes smoother and there is no change in velocity . However at some point stage the graph becomes distorted and the results are not accurate. Yet this assignment tells us about the change in profile according to time ie ; Linear Convection

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.