All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Objective : To observe the effect of time step size on the solution of 1D linear equation. It is in sequence with the previous report : here Parameters changed : To observe the different time steps of same solution and understand the time it takes to simulate that solution, we create a function…
Aadil Shaikh
updated on 22 Jan 2020
Objective : To observe the effect of time step size on the solution of 1D linear equation. It is in sequence with the previous report : here
Parameters changed : To observe the different time steps of same solution and understand the time it takes to simulate that solution, we create a function that accepts time step as an arguement , and provide that arguement in the main code where it plots with those arguements in the same plot . And the use of tic toc command to calculate the time taken for each of the solution with its respective time step . (plotted in bar)
Program :
function [nx,uold] = time_steps(dt)
%% Specifying parameters
L = 1; % domain length
n = 80;
nx = linspace(0,L,n); % Number of steps in grid
T = 0.4 ;
c = 1; % velocity
dx = nx(2)-nx(1); % width of space
nt = T/dt; % number of steps in time
u = zeros(1,n); % preallocating space
%% define start and end points for square vave
for i = 1:n
if ((0.1<=nx(i))&&(nx(i)<=0.3))
u(i) = 2;
else
u(i) = 1;
end
end
uold = u;
%%
for k = 1:nt
%space loop
for i = 2:n
u(i) = uold(i) - (c*dt/dx)*(uold(i)-uold(i-1));
end
%update old velocities
uold = u;
end
end
Main program :
%% 1-D Linear eqn model by time marching method of (Finite difference Method )
% This code accepts time step as an arguement and solves the problem for a
% number of time steps.
%Code by Aadil Shaikh
clear all
close all
clc
%% using tic toc command to call function in the x and y values of plot to be from the function ,at the time steps (1e-1,1e-2,1e-3,1e-4) serially
% tic toc calculates the time of each time step
tic
[nx1,uold1] = time_steps(1e-1);
toc
t1 = toc;
tic
[nx2,uold2]= time_steps(1e-2);
toc
t2 =toc;
tic
[nx3,uold3] = time_steps(1e-3);
toc
t3 =toc;
tic
[nx4,uold4] = time_steps(1e-4);
toc
t4 =toc;
%% plotting the velocities and comparing the effect for different time steps
figure(1)
hold all
loglog(nx1,uold1,'g','linewidth',1)
loglog(nx2,uold2,'-o','linewidth',.5)
loglog(nx3,uold3,'-s','linewidth',.5)
loglog(nx4,uold4,'b','linewidth',.5)
axis([0 1.2 0.8 2.2])
title({['1-D Linear Convection at C = 1 & n = 80' ];['time = 0.4 sec ']})
legend('1e-1','le-2','1e-3','1e-4')
xlabel('Grid Co-ordinate (x) \rightarrow')
ylabel('Velocity (u) \rightarrow')
%% plotting Simulation time as function of time step
total_time_of_simulation = [t1 t2 t3 t4];
h = categorical({'1e-1','1e-2','1e-3','1e-4'});
figure(2)
bar(h,total_time_of_simulation,'g')
xlabel('Time step')
ylabel('Simulation time')
title('Simulation time')
Plots :
Comparison for different time steps :
Explanation of the behaviour of plot(solution comparison)
Comparison of simulation time :
Simulation time output :
Conclusion :
References :
https://en.wikipedia.org/wiki/Courant%E2%80%93Friedrichs%E2%80%93Lewy_condition
---------------------------------------THE END -----------------------------------------
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...
Flow over a Throttle body - Using CONVERGE CFD
I. Introduction: In this Project, A Steady & Transient state simulation is done of a Flow through an Elbow joint consisting of a throttle valve. The steady state case is solved with the Throttle valve fully open until convergence is reached. While the Transient case is ran with the throttle valve rotating i.e…
18 Sep 2020 08:29 PM IST
Literature review – RANS Derivation and analysis
Introduction: The Reynolds-averaged Navier–Stokes equations (or RANS equations) are time-averaged equations of motion for fluid flow. The idea behind the equations is Reynolds decomposition, whereby an instantaneous quantity is decomposed into its time-averaged and fluctuating quantities,…
18 Sep 2020 08:28 PM IST
C.H.T Analysis on a Graphic card using ANSYS FLUENT
I. Introduction : In this project, A steady state conjugate heat transfer analysis on a Graphic card model is done. Graphic card has become an everyday used object and a very importat part of any computer system, laptops etc. This product is mass produced daily in millions and has made computers exceptionally efficient.…
18 Sep 2020 08:23 PM IST
Aerodynamics : Flow around the Ahmed Body using ANSYS FLUENT
I. Introduction : Automotive aerodynamics comprises of the study of aerodynamics of road vehicles. Its main goals are reducing drag, minimizing noise emission, improving fuel economy, preventing undesired lift forces and minimising other causes of aerodynamic instability at high speeds. Also, in order to maintain…
18 Sep 2020 08:21 PM IST
Related Courses
0 Hours of Content
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.