16. Time integration¶
16.1. Numerical schemes¶
The options for time integration can be modified in the XML section time/integration_method/
.
The time integration of the momentum equations is based on the following discretization scheme:
Various degrees of accuracy can be obtained, depending on the chosen parameters. The most common combinations of parameters are listed in the following table:
Name | Order | @ddtd |
@ddta |
@ddtb |
@feab1 |
@feab2 |
---|---|---|---|---|---|---|
forward Euler | 1 | "1.0" |
"1.0" |
"0.0" |
"1.0" |
"0.0" |
Adams-Bashforth | 2 | "1.0" |
"1.0" |
"0.0" |
"1.5" |
"-0.5" |
Other combinations can be derived with different accuracy and stability properties. For consistency the parameters must satisfy the following conditions:
@feab1
+@feab2
is equal to 1,@ddtd
-@ddta
-@ddtb
is equal to 0.
16.2. Manual and automatic time step control¶
The initial time step size is set in time/@dt
.
ComFLOW provided several mechanisms for manually or automatically adjusting the time step size, which are described below.
If necessary, all time step control can be disabled by setting the option time/@fixed
to "true"
, which tells ComFLOW to always use the specified initial time step size.
16.2.1. CFL condition for flow¶
The size of the time step can be controlled automatically in order to satisfy numerical stability restrictions without using unnecessarily small time steps.
The numerical methods used in ComFLOW require that the time step satisfies (at least) the following CFL condition (here simplified to the 1-D case):
where \(\Delta t\) is the time step size, \(\Delta x\) is the local grid spacing and \(u\) is the magnitude of the local velocity. In words this conditions states that the fluid must not propagate more than 1 grid cell per time step. Notes:
- The above condition is based on linear theory. Because the flow equations of ComFLOW are non-linear, a safety margin should be applied. It is recommended to stay at least 10 to 20 percent below the theoretical maximum.
- Some combinations of numerical schemes require stricter CFL conditions (see also Section 8.1)
- Stability restrictions also apply to the discretization of diffusion, which becomes most notable in strongly viscous flow.
During the simulation ComFLOW keeps track of the CFL numbers and can automatically adjust the time step if the requested CFL conditions are no longer satisfied. The automatic time step adjustment for the CFL flow condition can be enabled or disabled by setting time/cfl_flow/@enable
to true or false. The maximum CFL number is specified in time/cfl_flow/@max
and the minimum CFL number is specified in time/cfl_flow/@min
. When the CFL number supersedes the requested maximum, the time step size is immediately multiplied by a power of time/@dtfact
, which typically is set to "0.5"
. If the CFL number stays below the minimum threshold for at least 10 time steps, the time step size is divided (once) by time/@dtfact
.
It is possible to specify manual maximum time step size time/@dtmax
. This setting takes priority over all other settings.
By default this attribute is set to "Inf"
, which means the maximum time step size is determined fully automatically.
16.2.2. CFL condition for waves¶
For accurate simulation of waves it is recommended to also satisfy a CFL condition in terms of the wave velocity. This means that waves do not propagate more than one cell length per time step. The settings for this condition can be supplied in the section time/cfl_wave/
and follow the same notation as for the CFL condition for flow.
16.3. Example¶
As an example consider the following setup for a wave simulation, in which the Adams-Bashforth method is used for time integration. The time step size is fully controlled by the CFL conditions for flow and waves. The flow CFL number is bounded between 0.25 and 0.75 and the wave CFL number is bounded between 0.75 and 0.95.
<time tmax="6.0" dt="0.0025" dtmax="Inf" dtfact=".5" fixed="false">
<integration_method feab1="1.5" feab2="-.5"/>
<cfl_flow enable="true" min=".25" max=".75"/>
<cfl_wave enable="true" min="0.75" max="0.95"/>
</time>