You are on page 1of 2

Fundamentals of Numerical Thermo-Fluid Dynamics 322.

061
Examples for home preparation

Exercise 4: Explicit time-stepping schemes

To be presented on April 21, 2021

4.1 Compute the streamline of a steady vortex:


 
y3
~x˙ = ~u(~x) ≡ (1)
−x

starting from the seeding point ~x = (1, 1)T (at time t = 0). Use the following methods

(a) Explicit Euler: ~xk+1 = ~xk + ∆t~u(~xk )


(b) Third-order Runge-Kutta
(c) Fourth-order Runge-Kutta

with the time-step ∆t = 0.1. Compute the difference in the final position at t =
2π between R-K 3 and R-K 4. Can one use this difference as an estimate of the
discretization error of R-K 3 or R-K 4?
Hint: You can find a list of Runge-Kutta methods and a template script in TUWEL.

4.2 Consider the motion of a frictionless pendulum

− gl sin θ
   
ω̇
= f~ ≡ (2)
θ̇ ω

starting from the initial angle θ = π/2 and zero angular velocity ω = 0 at t0 = 0.
Assume l = 2, g = 1. Let us define a state vector y = (ω, θ)T .

(a) Compute the trajectory of the pendulum in the phase diagram θ − ω using the
second-order Adams-Bashforth method:
∆t
yk+1 = yk + (3fk − fk−1 )
2
Use the explicit Euler scheme for the first time step. What ∆t do you need to
obtain a converged result?

1
Exercise 4 322.061: Fundamentals of Numerical Thermo-Fluid Dynamics

(b) Compute the change of the mechanical energy


1
E = ω 2 l2 + gl(1 − cos θ)
2
after approximately one swing of the pendulum. Can you use this quantity to
check the accuracy of the discretization?
Hint: A suitable termination time is around t = 7π
2
.

4.3 We want to solve the advection of passive scalar by time dependent velocity


 ∂t u = − sin(2πt)∂x u , on Ω = [−1/2, 1]

 (x−0.5)2
u(t = 0, x) = e− 0.04

(3)


 u(t, x = 0) = u(t, x = 1)

∂x u(t, x = 0) = ∂x u(t, x = 1)

in one spatial dimension on a grid with uniform spacing ∆x. Semi-discretization with
second order central differences in space leads to an initial value problem

∂t~u = − sin(2πt)A~u (4)

where A is the matrix form of the discrete first derivative.


Compute the solution at t = 1.25 in MatLab, using the predictor-corrector scheme

u~0 = u~n − ∆t sin(2πtn )Au~n (5)


~ 1 
n ~n n+1 ~0

u n+1 ~n
= u − ∆tA sin(2πt )u + sin(2πt )u (6)
2
with ∆x = 0.01, ∆t = 0.005. Compare the result with the exact analytical solution
and to the result of the first-order implicit Euler scheme.
Hint: You can find a template function in TUWEL.

You might also like