discrete_spectral_operators#

Module: fridom.framework.grid.cartesian.discrete_spectral_operators

Functions

k_hat(kx, dx, sign[, use_discrete])

Spectral operator for the forward finite difference.

k_hat_squared(kx, dx[, use_discrete])

Spectral operator of forward - backward finite difference.

one_hat(kx, dx, sign[, use_discrete])

Spectral operator for the forward linear interpolation.

one_hat_squared(kx, dx[, use_discrete])

Discrete spectral operator of forward - backward linear interpolation.

set_nyquist_to_zero(z)

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:

\[\overline{u}^{x\pm} = \frac{u(x \pm \Delta x) + u(x)}{2}\]

where \(\pm\) denotes the forward (+) or backward (-) linear interpolation. A fourier transform yields the discrete spectral operator:

\[\overline{u}^{x\pm} \rightarrow \frac{e^{\pm ik_x \Delta x} + 1}{2}u = \hat{1}_x^\pm u\]

Hence, the discrete spectral operator one_hat is given by:

\[\hat{1}_x^\pm = \frac{e^{\pm ik_x \Delta x} + 1}{2}\]

In the continuous case, e.g. \(\Delta x \rightarrow 0\), the limit yields

\[\lim_{\Delta x \rightarrow 0} \hat{1}_x^\pm = 1\]

When applying a forward and consecutive backward linear interpolation, ( or vice versa), the discrete spectral operator one_hat_squared is given by:

\[\hat{1}_x^2 = \hat{1}_x^+ \hat{1}_x^- = \frac{1 + \cos(k_x \Delta x)}{2}\]

Differentiation operators#

The finite difference operator is defined as:

\[\delta_x^\pm u = \pm \frac{u(x \pm \Delta x) - u(x)}{\Delta x}\]

where \(\pm\) denotes the forward (+) or backward (-) finite difference. A fourier transform yields the discrete spectral operator:

\[\delta_x^\pm u \rightarrow \pm \frac{e^{\pm ik_x \Delta x} - 1}{\Delta x}u = i \hat{k}_x^\pm u\]

Hence, the discrete spectral operator k_hat is given by:

\[\hat{k}_x^\pm = \mp i \frac{e^{\pm ik_x \Delta x} - 1}{\Delta x}\]

For the continuous case, e.g. \(\Delta x \rightarrow 0\), the limit yields

\[\lim_{\Delta x \rightarrow 0} \hat{k}_x^\pm = k_x\]

When applying a forward and consecutive backward finite difference, (or vice versa), the discrete spectral operator k_hat_squared is given by:

\[\hat{k}_x^2 = \hat{k}_x^+ \hat{k}_x^- = 2 \frac{1 - \cos(k_x \Delta x)}{\Delta x^2}\]
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: VectorField) VectorField[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.