Finite difference method
- class tedeous.finite_diffs.First_order_scheme(term: list, nvars: int, axes_scheme_type: str)[source]
Bases:
objectClass for numerical scheme construction. Central o(h^2) difference scheme is used for ‘central’ points, forward (‘f’) and backward (‘b’) o(h) schemes are used for boundary points. ‘central’, and combination ‘f’,’b’ are corresponding to points_type. Args:
- static finite_diff_shift(diff: list, axis: int, mode: str) list[source]
1st order points shift for the corresponding finite difference mode.
- Parameters:
diff – values of finite differences.
axis – axis.
mode – the finite difference mode (i.e., forward, backward, central).
- Returns:
list with shifted points.
- Return type:
diff_list
- scheme_build() list[source]
Building first order (in terms of accuracy) finite-difference stencil.
Start from list of zeros where them numbers equal nvars. After that we move value in that axis which corresponding toterm. [0,0]->[[1,0],[-1,0]] it means that term was [0] (d/dx) and mode (scheme_type) is ‘central’.
- Returns:
numerical scheme.
- sign_order(h: float = 0.5) list[source]
Determines the sign of the derivative for the corresponding transformation from Finite_diffs.scheme_build().
From transformations above, we always start from +1 (1) Every +1 changes to ->[+1,-1] when order of differential rises [0,0] (+1) ->([1,0]-[-1,0]) ([+1,-1]) Every -1 changes to [-1,+1] [[1,0],[-1,0]] ([+1,-1])->[[1,1],[1,-1],[-1,1],[-1,-1]] ([+1,-1,-1,+1])
- Parameters:
h – discretizing parameter in finite difference method (i.e., grid resolution for scheme).
- Returns:
list, with signs for corresponding points.
- class tedeous.finite_diffs.Second_order_scheme(term: list, nvars: int, axes_scheme_type: str)[source]
Bases:
objectCrank–Nicolson method. This realization only for boundary points.
- class tedeous.finite_diffs.Finite_diffs(term: list, nvars: int, axes_scheme_type: str)[source]
Bases:
objectClass for numerical scheme choosing.
- scheme_choose(scheme_label: str, h: float = 0.5)[source]
Method for numerical scheme choosing via realized above.
- Parameters:
scheme_label – ‘2’- for second order scheme (only boundaries points), ‘1’ - for first order scheme.
h – discretizing parameter in finite difference method (i.e., grid resolution for scheme).
- Returns:
list where list[0] is numerical scheme and list[1] is signs.