You are on page 1of 8

School of Mechanical, Aerospace & Civil Engineering

4th Year Advanced Modelling & Simulation


CFD Problem Solutions Unsteady Flows
Question 1.
(a). Using explicit Euler time dierencing, we approximate the time derivative as
du
dt

u
(n+1)
u
(n)
t
and evaluate the right hand side of the equation at time level n.
Hence we obtain
u
(n+1)
u
(n)
t
= F
(n)
or u
(n+1)
= u
(n)
+ tF
(n)
Performing a Taylor series expansion for u
(n+1)
about time t, we obtain
u
(n+1)
= u(t + t) = u(t) + tu

(t) +
(t)
2
2!
u

(t) + O(t
3
)
= u(t) + tF(u(t)) +
(t)
2
2!
u

(t) + O(t
3
)
= u
(n)
+ tF
(n)
+ O(t
2
)
For a single time step the truncation error of the forward Euler scheme is thus of
order t
2
. However, the number of time steps required for a given simulation will
be proportional to 1/t, and hence the total error will be proportional to t. The
approximation is thus rst order.
(b). We now approximate the problem by a form
u
(n+1)
u
(n)
t
= aF
(n)
+ bF
(n1)
Re-writing this, we obtain
u
(n+1)
= u
(n)
+ t
_
aF
(n)
+ bF
(n1)
_
Expanding u
(n+1)
and F
(n1)
as Taylor series expansions, we obtain
u
(n+1)
= u(t + t) = u(t) + tu

(t) +
(t)
2
2!
u

(t) + O(t
3
)
= u
(n)
+ tF
(n)
+
(t)
2
2!
F

F
(n)
+ O(t
3
)
F
(n1)
= F
(n)
t
dF
dt
+
(t)
2
2!
d
2
F
dt
2
+ O(t
3
)
= F
(n)
tF

F
(n)
+ O(t
2
)
since u

= F(u) and hence u

= dF/dt = (dF/du)(du/dt) = F

F.
1
We thus have
t
_
aF
(n)
+ bF
(n1)
_
= (a + b)tF
(n)
b(t)
2
F

F
(n)
+ O(t
3
)
Comparing with the expansion for u
(n+1)
, in order to match the terms of order t
and (t)
2
, we thus need
a + b = 1 b = 1/2
Hence a = 3/2 and b = 1/2.
With these values the truncation error of the approximation for a single timestep is
proportional to (t)
3
, so the overall error over a xed time interval is proportional
to (t)
2
and the scheme is second order.
Question 2.
(a). Considering the wave equation, using central dierencing in space and the Lax time
discretization method, we approximate

(n+1)
i

_

(n)
i+1
+
(n)
i1
_
/2
t
and

x


(n)
i+1

(n)
i1
2x
The discretized equation can thus be written

(n+1)
i
=
_

(n)
i+1
+
(n)
i1
_
/2 +
V t
2x
_

(n)
i+1

(n)
i1
_
= 0.5(1 +V t/x)
(n)
i+1
+ 0.5(1 V t/x)
(n)
i1
(1)
(b). Applying Von-Neumann stability analysis, we examine a wave term of the form

(n)
j
=
n
exp(ikjx). Substituting this into the discretized equation gives (after
canceling the common factor
n
exp(ikjx)):
= 0.5(1 +V t/x) exp(ikx) + 0.5(1 V t/x) exp(ikx)
= 0.5(exp(ikx) + exp(ikx)) + 0.5(V t/x)(exp(ikx) exp(ikx))
= cos(kx) + i(V t/x) sin(kx)
Hence the magnitude of is given by
||
2
= cos
2
(kx) + (V t/x)
2
sin
2
(kx) = 1 (1 (V t/x)
2
) sin
2
(kx)
Hence we have || < 1, corresponding to a stable solution, for |V |t/x < 1.
Alternatively, one could note that for all the coecients on the right hand side of
equation (1) to be positive we would require |V |t/x < 1.
2
Question 3.
(a). Using the explicit forward Euler method and central dierences in space, the wave
equation is discretized as

(n+1)
i

(n)
i
t
= V
(
(n)
i+1

(n)
i1
)
2x
or

(n+1)
i
=
(n)
i
+
V t
2x
_

(n)
i+1

(n)
i1
_
As an indication of instability, we note that the coecient associated with
(n)
i1
is
always negative, whatever time step is taken.
Formally, we can apply Von-Neumann stability analysis by substituting in an ex-
pression for
(n)
j
of the form
n
exp(ikjx), resulting in
= 1 +
V t
2x
(exp(ikx) + exp(ikx))
= 1 +i
V t
x
sin(kx)
Hence
||
2
= 1 + (V t/x)
2
The magnitude of is thus always greater than unity, and the scheme is uncondi-
tionally unstable.
(b). Using the Lax method to discretize the time derivative, the discretized equation
becomes

(n+1)
i
(
(n)
i+1
+
(n)
i1
)/2
t
= V
(
(n)
i+1

(n)
i1
)
2x
or

(n+1)
i
=
_

(n)
i+1
+
(n)
i1
_
/2 +
V t
2x
_

(n)
i+1

(n)
i1
_
= 0.5(1 +V t/x)
(n)
i+1
+ 0.5(1 V t/x)
(n)
i1
We can perform Von-Neumann stability analysis on this, by examining a wave term
of the form
(n)
j
=
n
exp(ikjx). Substituting this into the discretized equation
gives (after canceling the common factor
n
exp(ikjx)):
= 0.5(1 +V t/x) exp(ikx) + 0.5(1 V t/x) exp(ikx)
= 0.5(exp(ikx) + exp(ikx)) + 0.5(V t/x)(exp(ikx) exp(ikx))
= cos(kx) + i(V t/x) sin(kx)
Hence the magnitude of is given by
||
2
= cos
2
(kx) + (V t/x)
2
sin
2
(kx) = 1 (1 (V t/x)
2
) sin
2
(kx)
Hence for || < 1, corresponding to a stable solution, we need |V |t/x < 1, so
the maximum allowable time step is given by t < x/|V |.
3
From the expansions for
(n+1)
i
,
(n)
i+1
and
(n)
i1
, we obtain

(n+1)
i
=
(n)
i
+ t

t
+
(t)
2
2!

t
2
+

(n)
i+1
=
(n)
i
+ x

x
+
(x)
2
2!

x
2
+

(n)
i1
=
(n)
i
x

x
+
(x)
2
2!

x
2
+
The Lax approximation thus can be written as

(n+1)
i
(
(n)
i+1
+
(n)
i1
)/2
t
=

t
+
t
2!

t
2

(x)
2
(2!)t

x
2
+
From this we can see that the scheme introduces a second spatial derivative error
term. It has thus eectively added a term of the form
(x)
2
(2!)t

x
2
to the right hand side of the equation, which is diusive in nature, with a numerical
viscosity of (x)
2
/((2!)t).
Question 4.
The partial dierential equation

t
= D

x
2
is approximated by

(n+1)
i

(n)
i
t
= D
_

(n)
i+1
+
(n)
i1
2
(n)
i
_
(x)
2
This can be written as

(n+1)
i
=
(n)
i
+
Dt
(x)
2
_

(n)
i+1
+
(n)
i1
2
(n)
i
_
A Von-Neumann stabilty analysis can be carried out by examining the evolution of a term
of the form
(n)
j
=
n
exp(ikjx). Substituting this into the discretized equation leads to
= 1 +
Dt
(x)
2
(exp(ikx) + exp(ikx) 2)
= 1 +
2Dt
(x)
2
(cos(kx) 1)
For || < 1 we thus need

1 +
2Dt
(x)
2
(cos(kx) 1)

< 1
Since cos(kx) < 1, then the worst case occurs when cos(kx) = 1, so we thus need to
ensure that
1 +
2Dt
(x)
2
(2) > 1 or 4
Dt
(x)
2
< 2
4
The stabilty constraint is thus
t <
(x)
2
2D
Question 5.
(a). Considering the unsteady problem
T
t
= F
(i) Expanding T as a Taylor series expansion about time t we get
T(t + t) = T(t) + t
_
T
t
_
t
+
(t)
2
2!
_

2
T
t
2
_
t
+ O((t)
3
)
= T(t) + t F(t) + O((t)
2
)
Hence we have
T
(n+1)
= T
(n)
+ tF
(n)
+ O((t)
2
)
The truncation error in the above equation is proportional to (t)
2
, but for
a given time interval the number of time steps taken will be proportional to
1/(t), so the total error will be proportional to t and the scheme is rst
order.
(ii) To examine the Crank-Nicolson scheme, we take Taylor series expansions about
time t + t/2:
T(t + t) = T(t + t/2) +
t
2
_
T
t
_
t+t/2
+
(t)
2
8
_

2
T
t
2
_
t+t/2
+ O((t)
3
)
T(t) = T(t + t/2)
t
2
_
T
t
_
t+t/2
+
(t)
2
8
_

2
T
t
2
_
t+t/2
+ O((t)
3
)
Subtracting gives
T(t + t) = T(t) + t
_
T
t
_
t+t/2
+ O(t
3
)
= T(t) + tF
(n+1/2)
+ O((t)
3
)
Since the central dierence approximation F
(n+1/2)
(F
(n+1)
+F
(n)
)/2 is sec-
ond order, the truncation error in the Crank Nicolson approximation is propor-
tional to (t)
3
and so for a given time interval the total error is proportional
to (t)
2
and the scheme is second order.
(b). We now consider the problem
T
t
=

2
T
x
2
5
(i) Using central dierences for the diusion terms and the explicit Euler scheme
results in
T
(n+1)
i
= T
(n)
i
+
t
(x)
2
_
T
(n)
i+1
+ T
(n)
i1
2T
(n)
i
_
Since x = 1 in this case, after rearranging we get
T
(n+1)
i
= t(T
(n)
i+1
+ T
(n)
i1
) + (1 2t)T
(n)
i
Thus
T
(1)
2
= t(T
(0)
3
+T
(0)
1
) +(12t)T
(0)
2
= t(1+0) +(12t) = 1t
Hence T
(1)
2
becomes negative if the time step is taken greater than 1/.
(ii) Using the Crank-Nicolson scheme gives
T
(n+1)
i
= T
(n)
i
+
t
2(x)
2
_
T
(n+1)
i+1
+ T
(n+1)
i1
2T
(n+1)
i
+ T
(n)
i+1
+ T
(n)
i1
2T
(n)
i
_
Again, since x = 1, this simplies to
T
(n+1)
i
(1+t) = (t/2)(T
(n+1)
i+1
+T
(n+1)
i1
)+(t/2)(T
(n)
i+1
+T
(n)
i1
)+(1t)T
(n)
i
We now get, for the three interior nodes (using the b.c.s T
(1)
0
= 0 and T
(1)
4
= 1),
T
(1)
1
(1 + t) = (t/2)T
(1)
2
+ (t/2)
T
(1)
2
(1 + t) = (t/2)(T
(1)
3
+ T
(1)
1
) + t/2 + 1 (t)
= (t/2)(T
(1)
3
+ T
(1)
1
) + 1 (t/2)
T
(1)
3
(1 + t) = (t/2)(T
(1)
2
+ 1) + t + (1 t) = (t/2)T
(1)
2
+ 1 + t/2
Adding the rst and third equations gives
T
(1)
1
+ T
(1)
3
= (tT
(1)
2
+ (1 + t))/(1 + t)
Substituting this into the second equation then leads to
T
(1)
2
(1 + t)
2
= (t)
2
/2T
(1)
2
+ (t/2)(1 + t) + (1 t/2)(1 + t)
Rearranging results in
T
(1)
2
= (1 + t)/(1 + 2t + (t)
2
/2)
which will always be positive, since all terms in numerator and denominator
are positive.
6
Question 6.
(a). For the rst order explicit scheme we approximate the time derivative as
T
t

T
(n+1)
i
T
(n)
i
t
and evaluate all other terms at time level n.
The discretized equation thus becomes
T
(n+1)
i
T
(n)
i
t
=
_
(T
(n)
i+1
T
(n)
i
)/x (T
(n)
i
T
(n)
i1
)/x
x
_
or, on rearranging,
T
(n+1)
i
= T
(n)
i
+
t
(x)
2
_
T
(n)
i+1
+ T
(n)
i1
2T
(n)
i
_
(b). With the spike shown, we have T
(0)
k
= 1 and T
(0)
k1
= T
(0)
k+1
= 0.
Hence the above discretized equation gives
T
(1)
k1
= 0 +
t
(x)
2
(1 + 0 0) =
t
(x)
2
T
(1)
k+1
= 0 +
t
(x)
2
(0 + 1 0) =
t
(x)
2
T
(1)
k
= 1 +
t
(x)
2
(0 + 0 2) = 1
2t
(x)
2
(c). For t/(x)
2
= 1/4 we get T
(1)
k1
= T
(1)
k+1
= 1/4 and T
(1)
k
= 1/2. The solution at
time t + t thus looks something like:
0
T
x
k k-1 k+1
1
For t/(x)
2
= 1 we get T
(1)
k1
= T
(1)
k+1
= 1
and T
(1)
k
= 1. The solution at time t + t
thus looks something like:
0
T
x
k k-1 k+1
1
Clearly the second case is physically not possible.
(d). If the Lax method is used to approximate the time derivative, the discretized equa-
tion becomes
T
(n+1)
i
= (1/2)
_
T
(n)
i+1
+ T
(n)
i1
_
+
t
(x)
2
_
T
(n)
i+1
+ T
(n)
i1
2T
(n)
i
_
7
(e). Hence for the 3 points we obtain
T
(1)
k1
= 1/2 +
t
(x)
2
(1 + 0 0) = 1/2 +
t
(x)
2
T
(1)
k+1
= 1/2 +
t
(x)
2
(0 + 1 0) = 1/2 +
t
(x)
2
T
(1)
k
= 0 +
t
(x)
2
(0 + 0 2) =
2t
(x)
2
The computed temperature prole at t + t thus
looks something like the sketch, which is clearly
unphysical.
0
T
x
k k-1 k+1
1
8

You might also like