All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Objective:- Effect of time step size on the solution Write a function that accepts time step as an argument and solves the same problem. You will compare the effect of time step on the numerical solution. 1. Set n = 80 2. Time steps to use = 1e-4, 1e-3, 1e-2, and 1e-1 Expected output 1. In a single graph compare the numerical…
Mohammad Saifuddin
updated on 30 Sep 2019
Objective:-
Effect of time step size on the solution
Write a function that accepts time step as an argument and solves the same problem. You will compare the effect of time step on the numerical solution.
1. Set n = 80
2. Time steps to use = 1e-4, 1e-3, 1e-2, and 1e-1
Expected output
1. In a single graph compare the numerical solution at t = 0.4 seconds
2. Plot the simulation time as a function of the time step
Software used:- MATLAB
Solution:-
Matlab code
clear all
close all
clc
% using tic & toc command to calculate the simulation time at different
% value of dt
tic
[u0,x0] = solution_dt(1e-1) % calling the function and finding the solution at dt=1e-1
toc
simulation_time1 = toc
tic
[u1,x1] = solution_dt(1e-2) % calling the function and finding the solution at dt=1e-2
toc
simulation_time2 = toc
tic
[u2,x2] = solution_dt(1e-3) % calling the function and finding the solution at dt=1e-3
toc
simulation_time3 = toc
tic
[u3,x3] = solution_dt(1e-4) % calling the function and finding the solution at dt=1e-4
toc
simulation_time4 = toc
% plotting the graph to compare the numerical solution at t = 0.4 seconds,
% at different values of dt
figure(1)
plot(x0,u0,'b','linewidth',2)
hold on
plot(x1,u1,'r','linewidth',2)
hold on
plot(x2,u2,'bla','linewidth',3)
hold on
plot(x3,u3,'y','linewidth',2)
legend('Profile at dt=1e-1','Profile at dt=1e-2','Profile at dt=1e-3','Profile at dt=1e-4','location','southeast')
xlabel('x')
ylabel('velocity')
title('Effect of time step size on the solution')
axis([0 1 0 2.5])
grid on
% plotting the bar graph for simulation time as a function of time step (dt)
figure(2)
c = categorical({'dt=1e-1','dt=1e-2','dt=1e-3','dt=1e-4'})
simulation_time = [simulation_time1 simulation_time2 simulation_time3 simulation_time4]
bar(c,simulation_time)
legend('Simulation time','location','best')
xlabel('time steps')
ylabel('Simulation time')
title('Simulation time as a function of the time step')
Function for linear convection
function [u,x] = solution_dt(dt)
L = 1; % Domain lenght in meter
n = 80; % no. of grid points
c = 1; %linear convection velocity
x = linspace(0,L,n);% mesh
dx = x(2) - x(1);
time = 0.4; % total time in seconds
nt = time/dt; % total no. of time steps
%start point for square wave
x_start = 0.1;
n_start = round((x_start/dx) + 1); % finding the integer value of the node for x_start
%stop point for square wave
x_stop = 0.3;
n_stop = round((x_stop/dx) + 1); % finding the integer value of the node for x_stop
u = ones(L,n);
u(:,n_start:n_stop) = 2;
uold = u;
%time loop
for k = 1:nt
% space loop
for i = 2:n
u(i) = uold(i) - (c*(dt/dx))*(uold(i) - uold(i-1)); % solving linear convection equation
end
%update old velocities
uold = u;
end
end
Report:
Figure(1)
Conclusion:- Large value of dt gives totaly inaccurate solution. With the decreas in time step (dt), The velocity profile moves closer to the initial velocity profile in its shape and paek value but by further decreasing the time step the solution deviates from the original solution.
figure(2)
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...
External Aerodynamics of a Mercedes Truck After Performing Surface Wrapping in STAR-CCM+
Surface Wrapping Surface wrapping is a method of extracting the desired surface with the desired volume of interest to perform CFD analysis. Surface wrapping does not incorporate all the minor details of the inside of the geometry, it only takes the outer detail of the geometry. When the CAD file contains a lot…
16 Feb 2020 02:12 PM IST
External flow Analysis of Ahmed body and Comparing the Numerical and Experimental data in STAR-CCM+.
Objective: Create the Ahmed Body slant for both 250 and 350 Run Steady-state implicit coupled flow simulation Use the turbulence models K-OmegsSST and k-epsilon Validate the velocity profile along the Ahmed body at different points with the experimental data. Calculate the cd and cl using the different turbulence.…
16 Feb 2020 01:45 PM IST
External flow analysis of NACA 0012 airfoil for different values of angle of attack in STAR - CCM+
NACA The NACA airfoils are airfoil shapes for aircraft wings developed by the National Advisory Committee for Aeronautics (NACA). The shape of the NACA airfoils is described using a series of digits following the word "NACA". The parameters in the numerical code can be entered into equations to precisely generate the cross-section…
29 Jan 2020 04:34 AM IST
Transient state analysis of Rayleigh Taylor instability in ANSYS FLUENT.
Objective Discuss some practical CFD models that have been based on the mathematical analysis of Rayleigh Taylor waves. And explain how these mathematical models have been adapted for CFD calculations. Perform the Rayleigh Taylor instability simulation for 3 different mesh sizes with the base mesh being 0.5 mm. Compare…
15 Jan 2020 09:52 AM 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.