Project

Week 4 - Linear Convection

Governing Equation:

`(du)/(dt)+c((du)/(dx))`

we use forward differce scheem for time derivative and use backward difference scheem for time space

matlab code for linear convection

clear allclose allclc% inputs for the linear convectionl=1;n=160;c=1;dt=0.01;%calculationx=linspace(0,l,n);dx=x(2)-x(1);% dx=l/(n-1)% define start and end time% x_start=0.1;% x_end=0.3;% n_start=f(x_start);% n_end=f(x_end);n_start=3;n_end=7;% intialize arrys and boundary conditionu=0.1*ones(1,n);u(n_start:n_end)=2% BCu(1)=0.1;uold=u;u_intial=u;nt=100;% time loopfor k=1:nt       for i=2:n    u(i)=uold(i)-(c*dt/dx)*(uold(i)-uold(i-1))   end      % update u valve    uold=u;    plot(x,u_intial,'r')    hold on    plot(x,u,'b')    grid on    pause(0.4);    axis([0 1 0 2])    xlabel('x axis')    ylabel('velocity')end

Result:

iteration=20, time=0.4

Iteration=40, time=0.4

Iteration=80, time=0.4

Iteration=160,time=0.4

the above plots represents velocity profiles at different grid points ie. 20 40 80 160 . It can be observed that as the value of grid increases the curves obtained have similar peaks as that of the original profile.and the plot grid 160 is unstable which one is >1

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.