Covariance Kernels#

class drdmannturb.Covariance(ndim=2, **kwargs)[source]#

Generic Covariance kernel metaclass. In particular, every subclass involves the computation of \(G(\boldsymbol{k})\) where

\[G(\boldsymbol{k}) G^*(\boldsymbol{k})=\Phi(\boldsymbol{k}, \tau(\boldsymbol{k}))\]

for different choices of the spectral tensor \(\Phi(\boldsymbol{k})\).

Subclasses only require one field ndim, which specifies the number of dimensions in which the generated kernels operate, respectively. For now, all fields and kernels operate in 3D, though functionality for 2D may be added readily. Finally, if a generic evaluation function is desired for a subclass, it may be set with eval_func in the constructor, as well as any associated arguments.

class drdmannturb.VonKarmanCovariance(ndim: int, length_scale: float, E0: float, **kwargs)[source]#

Von Karman covariance kernel. Evaluates the \(G(\boldsymbol{k})\) which satisfies \(G(\boldsymbol{k}) G^*(\boldsymbol{k})=\Phi(\boldsymbol{k})\) where

\[\Phi_{i j}^{\mathrm{VK}}(\boldsymbol{k})=\frac{E(k)}{4 \pi k^2}\left(\delta_{i j}-\frac{k_i k_j}{k^2}\right)\]

which utilizes the energy spectrum function

\[E(k)=c_0^2 \varepsilon^{2 / 3} k^{-5 / 3}\left(\frac{k L}{\left(1+(k L)^2\right)^{1 / 2}}\right)^{17 / 3},\]

where \(\varepsilon\) is the viscous dissipation of the turbulent kinetic energy, \(L\) is the length scale parameter and \(c_0^2 \approx 1.7\) is an empirical constant.

Parameters:
  • ndim (int) – Number of dimensions over which to apply the covariance kernel.

  • length_scale (float) – Length scale non-dimensionalizing constant.

  • E0 (float) – Energy spectrum.

Raises:

ValueError – ndim must be 3 for Von Karman covariance.

precompute_Spectrum(Frequencies: ndarray) ndarray[source]#

Evaluation method which pre-computes the square-root of the associated spectral tensor in the frequency domain.

Parameters:

Frequencies (np.ndarray) – Frequency domain in 3D over which to compute the square-root of the spectral tensor.

Returns:

np.ndarray – Square-root of the spectral tensor evaluated in the frequency domain; note that these are complex values.

Return type:

ndarray

class drdmannturb.MannCovariance(ndim: int = 3, length_scale: float = 1.0, E0: float = 1.0, Gamma: float = 1.0, **kwargs)[source]#

Mann covariance kernel implementation. Evaluates the \(G(\boldsymbol{k})\) which satisfies \(G(\boldsymbol{k}) G^*(\boldsymbol{k})=\Phi(\boldsymbol{k}, \tau(\boldsymbol{k}))\) where

\[\tau^{\mathrm{IEC}}(k)=\frac{T B^{-1}(k L)^{-\frac{2}{3}}}{\sqrt{{ }_2 F_1\left(1 / 3,17 / 6 ; 4 / 3 ;-(k L)^{-2}\right)}}\]
and the full spectral tensor can be found in the following reference:
  1. Mann, “The spatial structure of neutral atmospheric surface layer turbulence,” Journal of fluid mechanics 273, 141-168 (1994)

Parameters:
  • ndim (int, optional) – Number of dimensions for kernel to operate over, by default 3

  • length_scale (float, optional) – Length scale non-dimensionalizing constant, by default 1.0

  • E0 (float, optional) – Energy spectrum, by default 1.0

  • Gamma (float, optional) – Time scale, by default 1.0

Raises:

ValueError – ndim must be 3 for Mann covariance.

precompute_Spectrum(Frequencies: ndarray) ndarray[source]#

Evaluation method which pre-computes the square-root of the associated spectral tensor in the frequency domain.

Parameters:

Frequencies (np.ndarray) – Frequency domain in 3D over which to compute the square-root of the spectral tensor.

Returns:

np.ndarray – Square-root of the spectral tensor evaluated in the frequency domain; note that these are complex values.

Return type:

ndarray

class drdmannturb.NNCovariance(ndim: int, length_scale: float, E0: float, Gamma: float, ops: OnePointSpectra, h_ref: float)[source]#

Neural Network covariance kernel. Like other covariance kernel implementations, this evaluates the \(G(\boldsymbol{k})\) which satisfies \(G(\boldsymbol{k}) G^*(\boldsymbol{k})=\Phi(\boldsymbol{k}, \tau(\boldsymbol{k}))\) where the spectral tensor is defined through the eddy lifetime function learned by the neural network as well as the fitted spectra. Here,

\[\tau(\boldsymbol{k})=\frac{T|\boldsymbol{a}|^{\nu-\frac{2}{3}}}{\left(1+|\boldsymbol{a}|^2\right)^{\nu / 2}}, \quad \boldsymbol{a}=\boldsymbol{a}(\boldsymbol{k})\]

satisfies

\begin{align} \Phi(\boldsymbol{k}, \tau) & =\left\langle\widehat{\mathbf{u}}(\boldsymbol{k}) \widehat{\mathbf{u}}^*(\boldsymbol{k})\right\rangle \\ & =\mathbf{D}_\tau(\boldsymbol{k}) \boldsymbol{G}_0\left(\boldsymbol{k}_0\right)\left\langle\widehat{\boldsymbol{\xi}}\left(\boldsymbol{k}_0\right) \widehat{\boldsymbol{\xi}}^*\left(\boldsymbol{k}_0\right)\right\rangle \boldsymbol{G}_0^*\left(\boldsymbol{k}_0\right) \mathbf{D}_\tau^*(\boldsymbol{k}) \\ & =\mathbf{D}_\tau(\boldsymbol{k}) \boldsymbol{G}_0\left(\boldsymbol{k}_0\right) \boldsymbol{G}_0^*\left(\boldsymbol{k}_0\right) \mathbf{D}_\tau^*(\boldsymbol{k}) \\ & =\mathbf{D}_\tau(\boldsymbol{k}) \Phi^{\mathrm{VK}}\left(\boldsymbol{k}_0\right) \mathbf{D}_\tau^*(\boldsymbol{k}) . \end{align}

For more detailed definitions of individual terms, refer to section III B (specifically pages 4 and 5) of the original DRD paper.

Parameters:
  • ndim (int, optional) – Number of dimensions for kernel to operate over.

  • length_scale (float, optional) – Length scale non-dimensionalizing constant.

  • E0 (float, optional) – Energy spectrum.

  • Gamma (float, optional) – Time scale.

  • ops (OnePointSpectra) – Pre-trained OnePointSpectra object with a neural network representing the eddy lifetime function and containing the non-dimensionalizing scales, which are also learned by the DRD model.

  • h_ref (float) – Reference height (this is not a parameter learned by the DRD model).

Raises:

ValueError – ndim must be 3 for NN covariance.

precompute_Spectrum(Frequencies: ndarray) ndarray[source]#

Evaluation method which pre-computes the square-root of the associated spectrum tensor in the complex domain.

Parameters:

Frequencies (np.ndarray) – Frequency domain in 3D over which to compute the square-root of the spectral tensor.

Returns:

np.ndarray – Square-root of the spectral tensor evaluated in the frequency domain; note that these are complex values.

Return type:

ndarray