Project

Effects of Time-step on One Dimensional Linear Convection Equation..

AIM:
To solve the 1D linear convection equation and to study its characteristics in different time steps with respect to velocity..

EQUATION:

∂u /∂t + c*(∂u/∂x) = 0

Above is the Navier Stokes equation..

Time step has been set as t=0.4s and time steps will be t/dt

Length varies from 0 to 1m and velocity is 1m/s and 2m/s at points x=0.1 and x=0.3

VELOCITY PROFILE:

Unlike previous challenges where the grid point was contant, here it is changing and hence we use the below formula to fix the initial profile.

n_start = (x_start/dx) +1

n_stop = (x_stop/dx) +1

We use the Forward Difference Scheme for time derivative and Backward Difference Scheme for Space Derivative.

MATLAB CODE:

Linear_convection_Challenge2_main_code,

clear all

close all

clc

[x1,u1] = time_step(1e-1)

[x2,u2]= time_step(1e-2)

[x3,u3]= time_step(1e-3)

[x4,u4]= time_step(1e-4)

% Effect of time step on velocity

figure(1)

plot(x1,u1,'r')

hold on

plot(x2,u2,'g')

hold on

plot(x3,u3,'b')

hold on

plot(x4,u4,'y')

xlabel('Length in m')

ylabel('Velocity in m/s')

title('Effect of Timestep on Velocity')

legend('1e-1','1e-2','1e-3','1e-4');

axis ([0 1 0 2])

FUNCTION CODE:

function[x,u] = time_step(dt)

L = 1;

n = 80 ;

c = 1 ;

t = 0.4;

nt = t/dt ;

x = linspace(0,L,n);

dx = L /(n-1) ;

x_start = 0.1;

x_stop = 0.3;

n_start = (x_start/dx)+1 ;

n_stop =(x_stop/dx)+1 ;

u= ones(1,n)

u(n_start:n_stop) = 2;

uold = u;

u_initial = u;

for k = 1:nt

for i = 2:n

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

end

uold = u ;

end

end

PLOT:

CONCLUSION AND EXPLANATION OF PLOT :

We use the time marching procedure here with the gradual increase time step recording each one in the plot accordingly. The plot above conveys that solution is not stable for the first time step. The second time is close to accuracy but it is not accurate to the shape of the initial profile.Courant–Friedrichs–Lewy plays an important role here in determining a stability of a profile. Its definition is that length between its mesh points or grid points should not be greater than the Overall length to be in stable in nature. The more the grid points, the more stability occurs. In time step 1e-1, solution is diffused and this is Artificial Diffusion in 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.