All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Objective: Write a MATLAB Code and to solve 1D linear equation Given Data: Length( L ) = 1m Convective Coeffieient( C ) = 1 Time step( dt ) = 0.01 Grid point( n ) = [20,40,80,160]…
Nikith M
updated on 08 Dec 2019
Objective: Write a MATLAB Code and to solve 1D linear equation
Given Data:
Length( L ) = 1m
Convective Coeffieient( C ) = 1
Time step( dt ) = 0.01
Grid point( n ) = [20,40,80,160]
Total simulation time( t ) = 0.4 seconds
intial velocity profile is 2 ms between 0.1 and 0.3 and 1 ms everywhere.
Matlab Code:
clear all
close all
clc
% Input Parameters
L = 1; % Length
c = 1; % Convective coefficient
n = [20,40,80,160]; % Grid points
t = 0.4; % Total time
dt = 0.01; % Time step
x_start = 0.1; % Start point of square wave
x_old = 0.3; % End point of square wave
nt = t/dt; % Number of time steps (nt)
% Loop
for i = 1:4
x = linspace(0,L,n(i));
dx = L/(n(i)-1);
u = ones(1,n(i));
n_start(i) = round((x_start/dx)+1);
n_end(i) = round((x_old/dx)+1);
u(:,n_start(i):n_end(i)) = 2 % Defining start and end nodes where velocity is 2m/s
uold=u;
u_initial=u;
for k = 1:nt
for j = 2:n(i)
u(j) = uold(j) - (c*(dt/dx)*(uold(j)-uold(j-1)))
end
uold=u;
% Plotting
figure(i)
plot(x,u_initial,'color','b')
hold on
plot(x,u,'color','g')
xlabel('Length')
xlabel('Velocity')
grid on
title('Velocity profile for various time steps')
axis([0 1.5 0 2.5])
end
end
Plots
Figure 1, n=20
In this plot where n=20, we can see that there is a drastic decrease in the velocity profile
the amplitude of the velocity profile keeps decreasing with length
the minimum velocity is approximately is 1.6 to 1.7ms
Figure 2, n=40
In this plot where n=40, we can see that there is a significant decrease in the velocity profile
the amplitude of the velocity profile keeps decreasing with length
the minimum velocity is approximately is between 1.7 to 1.8ms
Figure 3, n=80
In this plot where n=80, we can see that there is a gradual decrease in the velocity profile, The change in the velocity profile with respect to length is not a major change. Hence we can tell that the amplitude is almost constant.
the min and max velocity very very close 2ms
Figure 4, n=160
In Figure 4, there is a disturbance in the velocity profile. We can see that there is a blow-up and it noticed that ripples are formed in the plot making it unstable.
Conclusion
From the above figures 1,2,3 & 4, we can tell that with the increase in grid spacing may lead to ripples. But at n=80 the optimum results are achieved and then decreases.
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
Steady Vs Unsteady (Mid Term)
Objective: To solve steady and unsteady 2D heat conduction equation using different iterative techniques for implicit and explicit methods in MATLAB. Introduction: Assumptions: - The domain is a square domain - Number of points along the 'x-direction' is equal to the number of points along the 'y-direction'…
28 Jan 2020 03:33 AM IST
1D Linear Convection (Grid points)
Objective: Write a MATLAB Code and to solve 1D linear equation Given Data: Length( L ) = 1m Convective Coeffieient( C ) = 1 Time step( dt ) = 0.01 Grid point( n ) = [20,40,80,160]…
08 Dec 2019 01:56 AM IST
Linear Convection Effect of Time steps on Solution
Objective: To write a MATLAB program that solves a 1D Linear equation for various time-steps. Given Data: Length( L ) = 1m Convective Coeffieient( C ) = 1 Time step( dt ) = (1e-1,1e-2,1e-3,1e-4)…
05 Dec 2019 11:56 PM IST
Discretization basics Numerical derivative vs. exact derivative
Objective: Write a program that compares the first, second and fourth-order approximations of the first derivative against the analytical/exact derivative. Given Function : f(x)=sin(x)x3 First derivative of the function is f'(x)=x3cos(x)−sin(x)⋅3x2x6 The function is computed at x=π3 First-order…
05 Dec 2019 11:56 PM IST
Related Courses
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.