Você está na página 1de 6

School of Mechanical Aerospace and Civil Engineering

Explicit vs. Implicit Treatments


We consider the generic time-dependent problem

= f (t, (t))
t

Unsteady Problems

Integrating with respect to time, over one time step, gives

Introduction to CFD

Finite volume methods


Pressure-velocity coupling
Solving sets of linear equations
Unsteady problems
Turbulence and other physical modelling
Body-fitted coordinate systems

t+t

(n+1) = (n) +

f (t, (t)) dt

(3)

f (t, (t)) dt

(4)

or

Contents:

Finite difference methods

t+t

dt =
t

T. J. Craft
George Begg Building, C41

Numerical solution of equations

(2)

t+t
t

where the superscript (n) denotes a quantity evaluated at time t, and (n + 1) at time t + t.
Reading:
J. Ferziger, M. Peric, Computational Methods for Fluid
Dynamics
H.K. Versteeg, W. Malalasekara, An Introduction to Computational Fluid Dynamics: The Finite Volume Method
S.V. Patankar, Numerical Heat Transfer and Fluid Flow
Notes: http://cfd.mace.manchester.ac.uk/tmcfd
- People - T. Craft - Online Teaching Material

The problem is then how to approximate the integral on the right hand side.
If we approximate the integral using the value of f at the initial time, t, then we obtain
(n+1) = (n) + f (t, (n) )t

(5)

This is a fully explicit method. Once we have values at time step n, equation (5) can be
applied in a simple explicit fashion to obtain the value of at time step n + 1.
- p. 3

Overview

If the integral is approximated using the value of the integrand at the final time, t + t, then
we have
(n+1) = (n) + f (t + t, (n+1) )t
(6)

In considering the discretization of fluid flow problems so far we have considered only
steady-state situations.
This has meant we have only discretized spatial derivatives.

This is a fully implicit method. It cannot be solved in a simple pointwise fashion, since values
of (n+1) appear on both the left and right hand sides. In a general case it will thus often
require an iterative solution procedure to obtain (n+1) .

In this lecture we consider how to handle unsteady flow problems, and any additional
complications this might introduce.
The Navier-Stokes momentum equations (for incompressible flow) now become

(Ui Uj )
Ui
1 P

Ui

+
=
+
t
xj
xi
xj
xj

Another alternative is to approximate the integral using a weighted average of the initial and
final values of f .
(1)

When considering how to discretize the time derivatives, we need to recognise a major
difference between space and time coordinates.

In the case of an equally weighted average the integral is evaluated using the trapezium rule:
(n+1) = (n) +

Most real fluid flow problems are (at least to some extent) elliptic in nature meaning that
any forcing introduced has an effect in all directions.
However, the time dependence is purely parabolic any forcing affects only the future,
never the past.

t
f (t, (n) ) + f (t + t, (n+1)
2

(7)

Again, this is an implicit scheme, and will typically require an iterative procedure to obtain
(n+1) .

To reflect this, solution methods tend to advance in time in a marching manner.


Initial values are provided at time t = 0 and the solution method proceeds by advancing in
time in a step-by-step manner.
- p. 2

- p. 4

Accuracy of Temporal Schemes

Stability of Temporal Schemes

By expanding as a Taylor series expansion about time t we can examine the accuracy of
the fully explicit scheme:
(t + t) = (t) + t

(t)2
+
2!

2
t2

= (t) + t f (t, (t)) + O((t)2 )

Another important issue with temporal discretization schemes is that of stability.


Explicit schemes in particular are prone to instabilities if too large a time step is employed.

+ O((t) )

To see why this should be, consider a 1-D spatial,


time dependent problem, dominated by
convective effects.

Zone of
Influence

Hence we have
(n+1) = (n) + tf (t, (n) ) + O((t)2 )

(8)

From this we can see that equation (5) shows a truncation error proportional to (t)2 over a
single time step.

The flow conditions at some point xi influence an


increasingly wide region of the flow as time
progresses.

xi

Equally, we can identify a region of the flow that


has an influence on conditions at the point xi at
any time t.

However, the number of time steps that must be performed for a given simulated time is
proportional to 1/t.

Zone of
dependence

Hence the total error associated with use of the scheme is proportional to t, and the
scheme is referred to as first order accurate.

xi

In a fully explicit scheme, since the value of at time t(n) is determined purely from its
values at time t(n1) , we need to ensure that the spatial stencil does contain all the relevant
flow information at time t(n1) .

The fully implicit scheme of equation (6) can also be shown to be first order accurate.

- p. 5

The trapezium approximation of equation (7) can be shown to be second order accurate,
since

t
(t)2 /4 2
(t + t) = (t + t/2) +
+
+ O((t)3 )
(9)
2
t t+t/2
2!
t2 t+t/2

(t)2 /4 2
t
+
+ O((t)3 ) (10)
(t) = (t + t/2)
2
t t+t/2
2!
t2 t+t/2
Hence
(n+1)

(n)

(n+1/2)

(n+1/2)

t
(t)2 /4
+
f (t + t/2, (n+1/2) ) +
2
2!

2
t2

t
(t)2 /4
f (t + t/2, (n+1/2) ) +

2
2!

2
t2

+ O((t) ) (11)

t+t/2

- p. 7

For example, if a 3-point spatial stencil was


employed, then for the problem shown in the
figure this would cover the zone of dependence
at time t t, so the scheme could be expected
to be stable.

t- t
t-2 t

If, however, a time step of 2t were taken, not all the relevant flow information at time
t 2t would be included in the discretization, and the scheme would likely be unstable.
Hence stability often imposes a limit on the time step that can be used in a calculation.

+ O((t) ) (12)

t+t/2

An examination of the stability of different schemes will be covered in the following sections
when applying them to unsteady convection/diffusion problems.

Combining these expansions gives


(n+1) (n) = t f (t + t/2, (n+1/2) ) + O((t)3 )

(13)

The truncation error over a single time step is thus proportional to (t)3 , so over a fixed time
integration the scheme is second order.
- p. 6

- p. 8

Time Stepping for Steady Problems

Stability Analysis
As indicated earlier, the stability of a temporal discretization is often an important issue,
particularly with explicit schemes.

In some cases the solution to a steady flow problem is obtained by introducing a time
derivative term and solving the unsteady problem, marching the solution to a steady state.
In such cases the accuracy of the time discretization is not crucial (since the time derivative
will be zero at the end of the calculation), and one typically wants to take rather large time
steps.

Broadly, we interpret a stable scheme to be one that leads to a bounded solution if the
original differential equation would have done so.
A method that is frequently used to explore stability issues is the Von-Neumann stability
analysis.

The stability of the scheme is therefore particularly important in these cases, since the
time-step size that can be applied may well be limited by this, rather than by accuracy
considerations.

If one assumes there are no forcing terms, then the discretized equation for can be written
in the form
(18)
(n+1) = A (n)

In a solution procedure such as the above, the time-stepping is effectively playing a similar
role to under-relaxation, which was considered earlier in the context of solving steady-state
problems in a segregated fashion.

If we further assume that the eigenvectors of A form a basis, then can be written in terms
of these:
X (n)
(n) =
k ak
(19)
k

where ak are the eigenvectors of A and

(n)
k

the associated coefficients.

The difference between solutions for at successive time steps (using some appropriate
norm) is then

X (n+1)
(n)
k
ak ||
||(n+1) (n) || = ||
k
(20)
k

- p. 9

The Explicit Euler Scheme


For simplicity we consider the time dependent convection/diffusion problem for some
variable :

+
(Uj ) =

t
xj
xj
xj

(14)

The explicit Euler method is obtained by moving all terms except /t to the right hand
side and applying the fully explicit formulation examined earlier:

=
(Uj ) +

f (t, (t))
(15)
t
xj
xj
xj
If we consider the 1-D problem with constant velocity U and diffusivity then the differential
equation becomes

2
(16)
= U
+ 2
t
x
x
Using central differences to approximate spatial derivatives then leads to
13
1
0
2
0
(n)
(n)
(n)
(n)
(n)
i+1 2i + i1
i+1 i1
(n+1)
(n)
A5
A+ @
i
= i + t 4U @
2x
(x)2
(n+1)

Given initial conditions the calculation can then proceed, evaluating i


pointwise manner.

- p. 11

Using the discretized equation to relate this difference to that at the previous timestep leads
to
X
X (n) (n1)
(n)
(n1)
||(n+1) (n) || = ||A((n) (n1) )|| = ||A
(k k
)ak || = ||
k (k k
)ak ||
k

(21)

where k is the eigenvalue corresponding to eigenvector ak


Hence the difference between the solutions at successive timesteps gets smaller
(corresponding to a stable solution) if all the eigenvalues of the matrix A are less than unity.
For the simplified problem being considered, on a uniform grid, the eigenvectors can be
expressed as combinations of Fourier modes with sines and cosines.
Hence to analyse stability we consider as being represented by a combination of Fourier
modes of the form
X
(n)
j =
kn exp(ikjx)
(22)
k

where i =
(17)

1, the index j denotes the spatial position and superscript (n) the time level.

We then examine whether the (complex) coefficient k associated with the Fourier mode k is
less than or greater than unity in magnitude.

in a simple
- p. 10

- p. 12

Substituting the form n exp(ikjx) into the discretized equation (17) leads to

exp(ikx) 2 + exp(ikx)
exp(ikx) exp(ikx)
+ t
n+1 = n 1 U t
2x
(x)2
(23)

or

Another way of examining stability and boundedness is to write the discretized equation as

2t
U t
U t
t
t
(n+1)
(n)
(n)
(n)

i1
= 1
+

+
+
(30)
i
i
i+1
(x)2
(x)2
2x
(x)2
2x
Suppose that represents some scalar quantity that cannot physically be negative.

t
U t
[exp(ikx) exp(ikx)] +
[exp(ikx) + exp(ikx) 2]
=1
2x
(x)2
2t
U t
sin(kx) +
=1i
[cos(kx) 1]
x
(x)2

(24)

(25)

(n)

(n)

(n)

If any of the coefficients associated with i , i+1 or i1 take a negative value then it is
possible that

(n+1)
i

could become negative, leading to an unbounded solution.

To ensure all coefficients are positive requires


The magnitude of (or rather 2 ) is thus given by
2 =

2t
1+
[cos(kx) 1]
(x)2

U t
sin(kx)
x

2t
>0
(x)2

or

t
< 1/2
(x)2

and

t
U t

>0
(x)2
2x

U x
<2

or

(26)

The first of these conditions is the same as found by the Von-Neumann analysis.

Two limiting cases can be considered:

The second is that the cell Peclet number (met in earlier lectures) should be less than 2.
Note that this is the condition found earlier to be sufficient for the centred convection scheme
to be bounded.

When there is no diffusion.


When there is no convection.

The restriction t/(x)2 < 1/2 can impose a rather serious constraint on the time step for
practical calculations. If the grid spacing is halved, for example, the time step has to be
reduced by a factor of four.
- p. 13

- p. 15

Upwinding Convection Terms

In the absence of diffusion, we have


2 = 1 +

U t
sin(kx)
x

(27)

so || is always greater than unity and the scheme is unconditionally unstable!


In the absence of convection we have

2
2t
[cos(kx)

1]
2 = 1 +
(x)2

or

(28)

t
14
(x)2

(n+1)

2t
U t

(x)2
x

(n)

t (n)

+
(x)2 i+1

t
U t
+
(x)2
x

(n)

i1

(32)

To ensure the coefficients remain positive, we now need

The maximum value of 2 thus occurs when cos(kx) = 1, when we have


2

If we retain the explicit Euler time discretization, but now use the first order upwind scheme
to discretize the convective terms, the discretized equation for the above unsteady
convection/diffusion problem (assuming U > 0) becomes
1
0
1
0
(n)
(n)
(n)
(n)
(n)
i i1
i+1 2i + i1
(n+1)
(n)
A
A + t @
(31)
= i U t @
i
x
(x)2

(29)

2t
U t

>0
(x)2
x

or

t <

1
(2)/(x)2 + U/x

For the case of negligible diffusion this limit becomes


Thus || < 1 provided that t/(x)2 < 1/2, and the scheme is conditionally stable.

U t
<1
x

or

t <

x
U

The quantity U t/x is known as the Courant Number, and represents the ratio of the time
step to the time required for a disturbance to be convected across the cell.
- p. 14

- p. 16

The Von-Neumann analysis can also be applied to this case, leading to the same limit on t.
Thus, for a purely convective flow, the introduction of upwinding for the convective flux leads
to conditional stability of the explicit Euler method. Stability is achieved provided the Courant
number is less than unity.
Note that this condition implies that t should be sufficiently small so that a fluid element
cannot travel more than one grid cell length in each time step.
It is worth noting that the exact stability conditions obtained above relate to the rather
simplified problem currently considered. In real fluid flow problems the precise criteria may
be different, although the limits found above are generally good guidelines.

The Implicit Euler Scheme


One of the drawbacks of explicit schemes is that the restriction on the time step, to ensure
stability, can often result in very small time steps having to be used.
This is a particular problem in flows where the time scales are fairly large, or where time
stepping is used to march to a steady state solution (and an accurate resolution of the
transient stage is not required).
If the convection and diffusion terms (and other sources) are evaluated at the new time level
n + 1, we arrive at the implicit Euler method.
For the unsteady convection/diffusion problem, with a central difference approximation for
convective fluxes, the discretized equation now becomes
0
1
1
0
(n+1)
(n+1)
(n+1)
(n+1)
(n+1)
i+1 2i
+ i1
i+1 i1
(n+1)
(n)
@
A
A
@
+ t
(33)
= i U t
i
2x
(x)2
or, on rearranging:

(n)

1
2

U
U
(n+1)
(n+1)
(n+1)
i
i+1
i1 = i
+
+
+

2
2
2
t
(x)
2x
(x)
2x
(x)
t

(34)

- p. 17

Unsteady Convection/Diffusion Example

Note that this results in a similar tri-diagonal system to that met in the equivalent steady
problem, but with an additional (positive) term in the diagonal element and the additional
(n)
source term i /t.

- p. 19

Since the introduction of the time discretization does not alter the sign of the coefficients, the
solution is unconditionally stable (although as in the steady case, the use of central
differencing for convection can lead to oscillations if the cell Peclet number is too large).

The 1-D unsteady convection/diffusion problem


T
2T
T
+U
= 2
t
x
x

Von-Neumann analysis can again be used to confirm the stability of the scheme.

on the interval 0 < x < 1 with U = 0.2 and = 0.2.

One drawback of the scheme is that one has to solve a large coupled system of equations at
each time step (using one of the matrix solution techniques examined in an earlier lecture).

Initial conditions are


(
1 for 0.3 < x < 0.7
T =
0 otherwise

Since there will typically be a large number of time steps, employing an efficient solver is
crucial.
An advantage of the scheme is that if marching to a steady state solution, very large time
steps can be used in a stable fashion.

Boundary conditions are


T /x = 0 at x = 0 and x = 1.

However, if a time accurate solution is required, accuracy considerations may still lead to a
rather small time step because of the first order truncation error.

Central spatial differencing.


Computed profiles of T shown at
t = 0.0, 0.18, 0.36, 0.54 and 0.72.

- p. 18

- p. 20

The Crank-Nicolson Scheme

Unsteady Convection/Diffusion Example

When considering generic temporal discretizations we noted that approximating the time
integral between t and t + t via the trapezium rule resulted in a second order scheme.

Considering the same problem as in the earlier example.


Both time schemes applied with central differencing for spatial derivatives.

Such a scheme applied to partial differential equations is known as the Crank-Nicolson


Scheme.
For the unsteady convection/diffusion problem, with central differencing for convective terms,
we now get
0
1
0
1
(n+1)
(n+1)
(n+1)
(n+1)
(n+1)
+ i1
U t @ i+1 i1 A t @ i+1 2i
(n+1)
(n)
A
= i
+
i
2
2x
2
(x)2
0
1
0
1
(n)
(n)
(n)
(n)
(n)
U t @ i+1 i1 A t @ i+1 2i + i1 A
+

(35)
2
2x
2
(x)2

or

+
t
(x)2

Crank-Nicolson

U
U

(n+1)
(n+1)

i1
+
+
i+1
4x
2(x)2
4x
2(x)2

U
1
U

(n)
(n)
(n)
=
i +
i+1 +
i1

+
+
2
2
2
t
(x)
4x
2(x)
4x
2(x)

(n+1)

Implicit Euler

(36)

The scheme is again implicit, so requires a matrix system solution at each time step.
- p. 21

Von-Neumann analysis shows the scheme to be unconditionally stable, although in practice


it can produce oscillations or become unstable for rather large time steps.
However, the second order accuracy means that larger time steps can usually be taken than
with the first order schemes, whilst retaining acceptable temporal accuracy.

- p. 23

Other Time Discretization Schemes


The schemes presented above are not the only ones available in many CFD codes, although
they are some of the more widely-used ones.
They do also illustrate many of the considerations regarding accuracy and stability that
should be borne in mind when choosing which scheme to use for a particular problem.
Higher order schemes can be constructed by employing a larger time stencil for example
by evaluating terms at time levels n + 1, n and n 1.
In some cases additional stability can be gained from including influences from more than
two time levels.
However, the requirement to store more time levels does increase the overall storage (and
hence memory) requirements.
As seen earlier, in most general purpose finite volume schemes the underlying
approximations are second order, so there may be little point in employing a temporal
discretization of higher order than this. However, for some applications or purposes it may
be appropriate.

- p. 22

- p. 24

Você também pode gostar