Crank-Nicolson time scheme
Properties
- Implicit
- Second order in time (when the off-centring coefficient is 1, after startup)
- Transient
- Off-centring often required for stability on complex flows
- Boundedness not guaranteed
Discretisation
Consider a generic transport equation for a scalar :
Crank-Nicolson evaluates terms at the mid-point of the time step. OpenFOAM achieves this by
splitting each contribution into an implicit part that enters the linear system
(fvm:: terms) and an explicit part that is carried forward from previous time
levels. For the temporal derivative alone, the scheme stores an auxiliary field
on the mesh registry.
On a static mesh, with uniform time step and off-centring coefficient , the temporal rate after startup is represented as:
The field is updated each time step from the previous time levels:
When the scheme is fully centred; when it reduces to the Euler implicit scheme.
Implicit and explicit contributions
When fvm::ddt(phi) is used, the temporal term contributes to the linear system for
as:
| Contribution | Discrete form |
|---|---|
| Implicit (matrix diagonal) | |
| Explicit (source) |
where is the cell volume. The corresponding explicit evaluation from fvc::ddt(phi)
is the difference between these two parts.
The implicit weighting of off-centred terms is related to the off-centring coefficient by:
On the first time step the scheme uses the Euler implicit coefficient to avoid start-up problems; from the second step onward the formulation applies.
Usage
The scheme is specified using:
ddtSchemes
{
default CrankNicolson <coeff>
ddt(phi) CrankNicolson <coeff>;
}
The mandatory <coeff> is the off-centring coefficient in the range :
- 0: equivalent to Euler implicit
- 1: fully centred Crank-Nicolson
- Values such as 0.9 are commonly used as a compromise between accuracy and robustness
The coefficient may also be specified as a Function1 to ramp from Euler to
Crank-Nicolson over an initial period, for example:
ddtSchemes
{
default CrankNicolson
ocCoeff
{
type scale;
scale linearRamp;
duration 0.01;
value 0.9;
};
}
Compared with the backward scheme, Crank-Nicolson requires only the current and old-time field values (not old-old-time values in the matrix assembly), but is generally less robust. The backward scheme provides formal second-order accuracy with stronger stability characteristics.
Further information
Source code
Reference
- Crank and Nicolson 11