Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Homework Set 1
Name
Chan Min Xhao
Chin Mun Xue
Foong XiPeng
Matric Number
125190
125192
125194
School
Aerospace Engineering
Date of Submission
26th of September 2017
Page | 1
EME 451 Computational Fluid Dynamics CFD
Homework Set 1
𝑢𝑡 = 𝑎𝑢 (1)
The problem requires us to find the solution to the ordinary differential equation (ODE), Equation (1)
which has the initial condition, u(0) = 1 at t = 2. The equation has the exact solution shown below as
in Equation (2).
𝑢 = 𝑢0 𝑒 𝑎𝑡 (2)
There are 2 numerical methods: Taylor series and Runge-Kutta used in order to solve the given ODE.
Manipulating Variable p
Figure 1 shows the graph of u against t with manipulating variable p. The p is set to 0.9 (<1), 1 (=1)
and 1.1 (>1). It is clearly shown that when p is equal to 1 (=1), the solution of the numerical method
approaches that of the analytical method.
When p is equal to 0.9 (<1) or 1.1 (>1), the solution of the numerical method deviates from that of the
analytical method. For the former, there is a sudden surge or spike while the latter takes a very long
time to get close to the curve of analytical solution.
Page | 2
EME 451 Computational Fluid Dynamics CFD
Homework Set 1
Manipulating Variable a
Figure 2 shows the graph of u against t with manipulating variable a. The a is set to 2 (>0), 1/2 (>0)
and -1/2 (<0). It is clearly shown that only when a is equal to 2 (>0), the solution of the numerical
method approaches that of the analytical method.
When a is equal to 1/2 (>0), the solution of the numerical method approaches the solution of the
analytical method extremely slowly. When a is equal to -1/2 (<0), the solution of the numerical
method approaches the x- axis (y=0) but will never equal to 0. It has deviated from the actual solution.
Page | 3
EME 451 Computational Fluid Dynamics CFD
Homework Set 1
Manipulating Variable Δt
Figure 2 shows the graph of u against t with manipulating variable Δt. The Δt is set to 1, 0.01 and
0.001. It is clearly shown with a smaller time step, the curve of numerical solutions is closer to that of
analytical solution.
In conclusion, the smaller the time step, the more accurate the numerical solutions. However, it should
be mentioned that a smaller time step will result in a longer computation time.
Page | 4
EME 451 Computational Fluid Dynamics CFD
Homework Set 1
𝛥𝑡 (4)
𝑢∗ = 𝑢𝑛 (1 + 𝛼 )
2
Comparison of Numerical Methods with Exact Solution and Verification of Order of Accuracy
The table below lists the amount of numerical work required for both first order and second order
methods to achieve 1% and 0.01% accuracy, represented in number of intervals required and their
corresponding time step. The calculated results for verifying the order of accuracy are listed as well.
The difference in the number of intervals between the first order and second order methods is
astounding. Even at 1% accuracy, the first order method requires at least 794 intervals between 0 and
2, compared to a merely 32 by the second order method. This means it takes almost 25 times as much
interval for the first order method to achieve 1% accuracy compared to the second order method.
Moving up to 0.01% accuracy, the difference is even ginormous. Now the first order method requires
almost 80,000 intervals to reach within 0.01% range of the actual solution, whereas the second order
method needs just 326 intervals. This time, the first order method takes about 245 times as much
intervals as the second order method.
2 (6)
𝑇𝑖𝑚𝑒 𝑆𝑡𝑒𝑝, ∆𝑡 =
𝑁𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝐼𝑛𝑡𝑒𝑟𝑣𝑎𝑙𝑠, 𝑁
To verify the order of accuracy of the numerical methods, calculations are performed for both
methods at the two accuracies using the error value (not percentage) and the time step:
For both cases, the calculated order of accuracy is close to their actual values (first order ≈ 1, second
order ≈ 2). Therefore, it can be safely verified that the numerical methods used in this analysis are
indeed first and second order methods. One thing worth mentioning is that as the accuracy is
improved, the calculated value approaches closer to the actual value.
Page | 5
EME 451 Computational Fluid Dynamics CFD
Homework Set 1
MATLAB Codes
1. Verifying the Correct Choices for Variables p and a, plus the Effects of Δt on Accuracy
clc;clear all;close all; legend({'p=0.9','p=1','p=1.1','Analytical'},'location','northwest')
title('Manipulating variable p')
%Given conditions xlabel('time,t');ylabel('u')
t0 = 0; hold off
u0 = 1;
tEnd=2; %Manipulating variable 'a'
delta_t = 0.01; figure(2)
changing_a = [2 1/2 -1/2]; hold on
changing_delta_t = [1 0.1 0.01];
changing_p = [0.9 1 1.1]; for j = 1:3
a = 2; for i = 1:N_a
p = 1; U_a(i+1) = U_a(i)+delta_t*changing_a(j)*U_a(i)^p;
end
%Initializing solutions plot(T,U_a,plotstyle{j})
N = (tEnd-t0)/delta_t; end
N_p = (tEnd-t0)/delta_t;
N_a = (tEnd-t0)/delta_t; plot(T,U_True,'r')
N_t = (tEnd-t0)./changing_delta_t; legend({'a=2','a=1/2','a=-1/2','Analytical'},'location','northwest')
T = t0:delta_t:tEnd; title('Manipulating variable a')
U_1(1) = u0; xlabel('time,t');ylabel('u')
U_2(1) = u0; hold off
U_p(1) = u0;
U_a(1) = u0; %Manipulating variable 'delta t'
U_t(1) = u0; figure(3)
plotstyle = {'-k','-b','-g'}; hold on
U_True=u0*exp(a*T);
for j = 1:3
%Solving using Euler's explicit method changing_T = t0:changing_delta_t(j):tEnd;
%Manipulating variable 'p' for i = 1:N_t(j)
figure(1) U_t(i+1) = U_t(i)+changing_delta_t(j)*a*U_t(i)^p;
hold on end
plot(changing_T,U_t,plotstyle{j})
for j = 1:3 end
for i = 1:N_p
U_p(i+1) = U_p(i)+delta_t*a*U_p(i)^changing_p(j); plot(T,U_True,'r')
end legend({'delta t = 1','delta t = 0.01','delta t =
plot(T,U_p,plotstyle{j}) 0.001','Analytical'},'location','northwest')
end title('Manipulating variable delta t')
xlabel('time,t');ylabel('u')
plot(T,U_True,'r') hold off
Page | 6
EME 451 Computational Fluid Dynamics CFD
Homework Set 1
Page | 7