discrete_spectral_operators#
Module: fridom.framework.grid.cartesian.discrete_spectral_operators
Functions
|
Spectral operator for the forward finite difference. |
|
Spectral operator of forward - backward finite difference. |
|
Spectral operator for the forward linear interpolation. |
|
Discrete spectral operator of forward - backward linear interpolation. |
Set the nyquist frequency to zero in the spectral domain. |
Operators for spectral analysis of discrete Cartesian grids.
Averaging operators#
The linear interpolation operator on a field \(u\) is defined as:
where \(\pm\) denotes the forward (+) or backward (-) linear interpolation. A fourier transform yields the discrete spectral operator:
Hence, the discrete spectral operator one_hat is given by:
In the continuous case, e.g. \(\Delta x \rightarrow 0\), the limit yields
When applying a forward and consecutive backward linear interpolation, ( or vice versa), the discrete spectral operator one_hat_squared is given by:
Differentiation operators#
The finite difference operator is defined as:
where \(\pm\) denotes the forward (+) or backward (-) finite difference. A fourier transform yields the discrete spectral operator:
Hence, the discrete spectral operator k_hat is given by:
For the continuous case, e.g. \(\Delta x \rightarrow 0\), the limit yields
When applying a forward and consecutive backward finite difference, (or vice versa), the discrete spectral operator k_hat_squared is given by:
- fridom.framework.grid.cartesian.discrete_spectral_operators.one_hat(kx: ndarray, dx: float, sign: int, use_discrete: bool = True) ndarray[source]#
Spectral operator for the forward linear interpolation.
Description#
Computes the spectral operator \(\hat{1}_x^\pm\) that arises from the discrete forward (+1) or backward (-1) linear interpolation:
\[\hat{1}_x^\pm = \frac{e^{\pm ik_x \Delta x} + 1}{2}\]Parameters#
- kxndarray
The wavenumber
- dxfloat
The grid spacing
- signint
The sign of the operator (+1 for forward, -1 for backward)
- use_discretebool (default: True)
If True, the discrete operator is returned. Otherwise, the continuous operator is returned which is 1 for forward and backward interpolation.
Returns#
- ndarray
The spectral operator.
- fridom.framework.grid.cartesian.discrete_spectral_operators.one_hat_squared(kx: ndarray, dx: float, use_discrete: bool = True) ndarray[source]#
Discrete spectral operator of forward - backward linear interpolation.
Description#
Computes the spectral operator \(\hat{1}_x^2\) that arises from the discrete forward - backward linear interpolation:
\[\hat{1}_x^2 = \hat{1}_x^+ \hat{1}_x^- = \frac{1 + \cos(k_x \Delta x)}{2}\]Parameters#
- kxndarray
The wavenumber
- dxfloat
The grid spacing
- use_discretebool
If True, the discrete operator is returned. Otherwise, the continuous operator is returned which is always 1.
Returns#
- ndarray
The spectral operator.
- fridom.framework.grid.cartesian.discrete_spectral_operators.k_hat(kx: ndarray, dx: float, sign: int, use_discrete: bool = True) ndarray[source]#
Spectral operator for the forward finite difference.
Description#
Computes the spectral operator \(\hat{k}_x^\pm\) that arises from the discrete forward (+1) or backward (-1) finite difference.
\[\hat{k}_x^\pm = \mp i \frac{e^{\pm ik_x \Delta x} - 1}{\Delta x}\]Parameters#
- kxndarray
The wavenumber
- dxfloat
The grid spacing
- signint
The sign of the operator (+1 for forward, -1 for backward)
- use_discretebool
If True, the discrete operator is returned. Otherwise, the continuous operator is returned which is always kx.
Returns#
- ndarray
The spectral operator.
- fridom.framework.grid.cartesian.discrete_spectral_operators.k_hat_squared(kx: ndarray, dx: float, use_discrete: bool = True) ndarray[source]#
Spectral operator of forward - backward finite difference.
Description#
Computes the spectral operator \(\hat{k}_x^2\) that arises from forward - backward finite difference:
\[\hat{k}_x^2 = \hat{k}_x^+ \hat{k}_x^- = 2 \frac{1 - \cos(k_x \Delta x)}{\Delta x^2}\]Parameters#
- kxndarray
The wavenumber
- dxfloat
The grid spacing
- use_discretebool
If True, the discrete operator is returned. Otherwise, the continuous operator is returned which is always kx**2.
Returns#
- ndarray
The spectral operator.
- fridom.framework.grid.cartesian.discrete_spectral_operators.set_nyquist_to_zero(z: StateBase) StateBase[source]#
Set the nyquist frequency to zero in the spectral domain.
Parameters#
- zState
The state which nyquist frequency should be set to zero.
Returns#
- State
The state with the nyquist frequency set to zero.