Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Theory exercise

Assume constant velocity u from left to right. Convection equation in 1d


is:
∂c ∂c
+u =0 (1)
∂t ∂x
Taylor series:

X 1 ∂f
f (x0 + ∆x) = ∆xn (2)
n! ∂x x=x0
n=0

Lets use notation ci+1 = c(xi+1 ) = c(xi + ∆x).

Central difference (CD2)


The 2nd order central difference is calculated as:
∂c ci+1 − ci−1
= (3)
∂x i,num 2∆x
Expand both terms in the numerator as Taylor series with respect
to point xi :

1 ∂c 1 ∂2c 2 1 ∂3c
ci+1 ≈ ci + ∆x + ∆x + ∆x3 + O(∆x4 ) (4)
1! ∂x i 2! ∂x2 i 3! ∂x3 i
1 ∂c 1 ∂2c 2 1 ∂3c
ci−1 ≈ ci − ∆x + ∆x − ∆x3 + O(∆x4 ) (5)
1! ∂x i 2! ∂x2 i 3! ∂x3 i
Use these to form the numerical derivative:
∂c 1  ∂c 1 ∂2c 2 1 ∂3c
≈ + ci + ∆x + ∆x + ∆x3
∂x i,num 2∆x ∂x i 2 ∂x2 i 6 ∂x3 i
∂c 1 ∂2c 2 1 ∂3c 3 4

− ci + ∆x − ∆x + ∆x + O(∆x )
∂x i 2 ∂x2 i 6 ∂x3 i
1  ∂c 3
2∂ c 
3 4
= 2 ∆x + ∆x + O(∆x )
2∆x ∂x i 6 ∂x3 i
∂c 3
1∂ c
= + ∆x2 + O(∆x3 )
∂x i 6 ∂x3 i
(6)

We note that the discretization error is second order in ∆x. In addi-


tion, the leading error term depends on the third derivative of c which
indicates that the error is dispersive.

1
Upwind difference (UD)
The first order upwind difference is calculated as:
∂c ci − ci−1
= (7)
∂x i,num ∆x
Note that the discretization would change if u would be in the opposite
direction.
Using the Taylor expansion calculated earlier we obtain:

∂c 1  ∂c 1 ∂2c 2 1 ∂3c 3 4

≈ ci − ci + ∆x − ∆x + ∆x + O(∆x )
∂x i,num ∆x ∂x i 2 ∂x2 i 6 ∂x3 i
1  ∂c 1 ∂2c 2 3

= ∆x − ∆x + O(∆x )
∆x ∂x i 2 ∂x2 i
∂c 2
1∂ c
= − ∆x + O(∆x2 )
∂x i 2 ∂x2 i
(8)

The discretization error is first order in ∆x. This time the leading er-
ror term is diffusive as the term is proportional to the second derivative
of c.

2
Simulation exercise
For all the following simulations, the temporal discretization scheme is
set to Euler, and the time step is chosen so that Co = 0.08.

Part A
Figure 1 shows a comparison of transported scalar profiles with differ-
ent discretization schemes and the analytical solution after one pass-by
time with a coarse mesh resolution (N = 32). upwind scheme demon-
strates its diffusive characteristics, significantly smoothing the profile
and decreasing the maximum of the Gaussian. The error of the linear
scheme has a dispersive nature and thus causes numerical oscillations
to lag behind the solution. Parameters for other schemes were chosen
such that: 1) they do not produce negative values; 2) the resulting Gaus-
sian shape is as close as possible to the analytical solution. With the flux
limiter case (Gamma 0.1 or limitedLinear 0.1), there are no oscillations
and the diffusion is limited to an extent, which makes this scheme a
better alternative for both. blended 0.5 scheme results in a profile sim-
ilar in shape to the one of upwind, but with a peak value a little closer
to linear.

1.0 analytical
linear
upwind
0.8 blended 0.5
limitedLinear 0.1
Gamma 0.1
0.6
0.4
T(x),

0.2
0.0
0.2
0 /2 3 /2 2
x, m

Figure 1: A comparison of transported scalar profiles with different discretiza-


tion schemes and the analytical solution after one pass-by time with a coarse
mesh resolution (N = 32).

3
Part B
Figure 2 shows a comparison of transported scalar profiles with a fine
mesh resolution (Ncells = 64) after one pass-by time. The error became
significantly smaller after the mesh refinement. The effect is strongest
for the linear scheme since it has a pure second-order truncation error
term. Flux-limiting schemes also demonstrate a large improvement.

1.0 analytical
linear
upwind
0.8 blended 0.5
limitedLinear 0.1
Gamma 0.1
0.6
T(x),

0.4

0.2

0.0
0 /2 3 /2 2
x, m

Figure 2: A comparison of transported scalar profiles with different discretiza-


tion schemes and the analytical solution after one pass-by time with a fine
mesh resolution (N = 64).

Answers to questions
• What is the effect of the variation of the selected scheme parame-
ter? What do you think the parameter values 0.0 and 1.0 represent?
For blended X scheme, the parameter X is a linear scaling factor
between upwind (X = 0) and linear (X = 0). For flux limiting
schemes, the parameter, according to simulations, also affects the
diffusion vs dispersion ratio of the solution, with larger values of
the parameter corresponding to a more diffusive solution.

• What do you think will happen to the solution at time t −→ ∞ with


upwind and linear schemes?
With the upwind scheme the solution will eventually fully diffuse,

4
leaving uniform T = const along the domain. With the linear
scheme, oscillations will amplify themselves, but eventually due
to temporal discretization error (I used 1st order Euler scheme)
they will also diffuse.

• How did results change when you refine the mesh? Which scheme
upwind or linear is more sensitive to the mesh refinement and why?
Mesh refinement reduces the errors of all tested schemes. linear
scheme is more sensitive to the mesh refinement since it is a second-
order scheme and thus the error is proportional to a square of the
cell size. So, the 2x decrease in the mesh size leads to a 4x reduc-
tion in the error.

• How did you choose a time step for simulations? What do you think
is the effect of lowering or increasing it?
The time step is chosen based on dimensionless Courant number
Co = U∆x ∆t
= 0.08 < 1.0. The increase of the time step will lead to
the destabilization of the solution and the increase in the tempo-
ral discretization error, which is diffusive. Lowering the timestep
reduces the temporal discretization error. In this exercise, a first-
order Euler temporal discretization scheme is used, hence the tem-
poral discretization error will linearly decrease with the reduction
of the time step.

You might also like