Although we have described the discretisation of temporal derivatives in Sections
2.4.3 and 2.4.4, we need to consider how to treat the spatial derivatives in a
transient problem. If we denote all the spatial terms as where is any
spatial operator, e.g. Laplacian, then we can express a transient PDE in integral
form as
(2.30)
Using the Euler implicit method of Equation 2.21, the first term can be
expressed as
(2.31)
The second term can be expressed as
(2.32)
where represents the spatial discretisation of . The time integral can be
discretised in three ways:
Euler implicit
uses implicit discretisation of the spatial terms, thereby taking
current values .
(2.33)
It is first order accurate in time, guarantees boundedness and is
unconditionally stable.
Explicit
uses explicit discretisation of the spatial terms, thereby taking old
values .
(2.34)
It is first order accurate in time and is unstable if the Courant number
is greater than 1. The Courant number is defined as
(2.35)
where is a characteristic velocity, e.g. velocity of a wave front, velocity
of flow.
Crank Nicholson
uses the trapezoid rule to discretise the spatial terms,
thereby taking a mean of current values and old values .
(2.36)
It is second order accurate in time, is unconditionally stable but does not
guarantee boundedness.
At present the treatment of the temporal discretisation is controlled by the
implementation of the spatial derivatives in the PDE we wish to solve. For
example, let us say we wish to solve a transient diffusion equation
(2.37)
An Euler implicit implementation of this would read
solve(fvm::ddt(phi) == kappa*fvm::laplacian(phi))
where we use the fvm class to discretise the Laplacian term implicitly. An explicit
implementation would read
solve(fvm::ddt(phi) == kappa*fvc::laplacian(phi))
where we now use the fvc class to discretise the Laplacian term explicitly. The
Crank Nicholson scheme can be implemented by the mean of implicit and explicit
terms: