fluidsim.base.time_stepping.finite_diff

Time stepping (fluidsim.base.time_stepping.finite_diff)

Provides:

class fluidsim.base.time_stepping.finite_diff.TimeSteppingFiniteDiffCrankNicolson(sim)[source]

Bases: TimeSteppingBase

Time stepping class for finite-difference solvers.

static _complete_params_with_default(params)[source]

This static method is used to complete the params container.

one_time_step_computation()[source]

One time step

_time_step_RK2()[source]

Advance in time the variables with the Runge-Kutta 2 method.

Notes

The Runge-Kutta 2 method computes an approximation of the solution after a time increment \(dt\). We denote the initial time \(t = 0\).

For the finite difference schemes, We consider an equation of the form

\[\p_t S = L S + N(S),\]

The linear term can be treated with an implicit method while the nonlinear term have to be treated with an explicit method (see for example Explicit and implicit methods).

  • Approximation 1:

    For the first step where the nonlinear term is approximated as \(N(S) \simeq N(S_0)\), we obtain

    \[\left( 1 - \frac{dt}{4} L \right) S_{A1dt/2} \simeq \left( 1 + \frac{dt}{4} L \right) S_0 + N(S_0)dt/2\]

    Once the right-hand side has been computed, a linear equation has to be solved. It is not efficient to invert the matrix \(1 + \frac{dt}{2} L\) so other methods have to be used, as the Thomas algorithm, or algorithms based on the LU or the QR decompositions.

  • Approximation 2:

    The nonlinear term is then approximated as \(N(S) \simeq N(S_{A1dt/2})\), which gives

    \[\left( 1 - \frac{dt}{2} L \right) S_{A2dt} \simeq \left( 1 + \frac{dt}{2} L \right) S_0 + N(S_{A1dt/2})dt\]
invert_to_get_solution(A, b)[source]

Solve the linear system \(Ax = b\).

Classes

TimeSteppingFiniteDiffCrankNicolson(sim)

Time stepping class for finite-difference solvers.