Data Types and Eddy Lifetime Functions#

DRDMannTurb uses several enumerations to set information regarding the type of spectra data being used, the eddy lifetime model to use, and the power spectra law (there is currently only one implemented: the RDT power spectra). The following is an exhaustive list of their labels and values, with individual discussion further below.

Data Types#

The type of spectral tensor is determined by the DataType enum, which determines one of the following models:

  1. DataType.KAIMAL, which is the Kaimal spectra.

  2. DataType.VK, which is the von Karman spectra model.

  3. DataType.CUSTOM, usually used for data that is processed from real-world data. The spectra values are to be provided as the spectra_values field, or else to be loaded from a provided spectra_file. The result is that the provided data are matched on the wavevector domain.

  4. DataType.AUTO, which generates a filtered version of provided spectra data. The filtering is based on differential evolution to perform a non-linear fit onto functions of the following form:

\begin{align} & \frac{k_1 F_{11}\left(k_1 z\right)}{u_*^2}=J_1(f):=\frac{a_1 f}{(1+b_1 f)^{c_1}} \\ & \frac{k_1 F_{22}\left(k_1 z\right)}{u_*^2}=J_2(f):=\frac{a_2 f}{(1+b_2 f)^{c_2}} \\ & \frac{k_1 F_{33}\left(k_1 z\right)}{u_*^2}=J_3(f):=\frac{a_3 f}{1+ b_3 f^{ c_3}} \\ & -\frac{k_1 F_{13}\left(k_1 z\right)}{u_*^2}=J_4(f):=\frac{a_4 f}{(1+ b_4 f)^{c_4}}, \end{align}

with \(F_{12}=F_{23}=0\). Here, \(f = (2\pi)^{-1} k_1 z\). In the above, the \(a_i, b_i, c_i\) are free parameters which are optimized by differential evolution. The result is a spectra model that is similar in form to the Kaimal spectra and which filters/smooths the spectra data from the real world and eases fitting by DRD models. This option is highly suggested in cases where spectra data have large deviations.

Note

The one-point spectra for \(F_{13}\) are NOT to be pre-multiplied with a negative, this data generator automatically performs this step both when using DataType.CUSTOM and DataType.AUTO.

enum drdmannturb.DataType(value)#

An enumeration.

Valid values are as follows:

KAIMAL = <DataType.KAIMAL: 1>#
CUSTOM = <DataType.CUSTOM: 2>#
AUTO = <DataType.AUTO: 3>#
VK = <DataType.VK: 4>#

Power Spectra#

enum drdmannturb.PowerSpectraType(value)#

An enumeration.

Valid values are as follows:

RDT = <PowerSpectraType.RDT: 1>#

The power spectra law definition is given here.

Eddy Lifetime Function#

The type of eddy lifetime function \(\tau\) to use, its form, and whether or not to learn this function is determined by EddyLifetimeType. The following models are provided, with more discussions of each in the next section:

  1. EddyLifetimeType.CONST which simply returns \(\tau = 1\).

  2. EddyLifetimeType.TWOTHIRD which returns \(\tau = (kL)^{-2/3}\).

  3. EddyLifetimeType.MANN, which is the Mann function determined by

    \[\tau^{\mathrm{Mann}}(k)=\frac{(k L)^{-\frac{2}{3}}}{\sqrt{{ }_2 F_1\left(1 / 3,17 / 6 ; 4 / 3 ;-(k L)^{-2}\right)}}\]

    Note

    This is a CPU-bound function since the hypergeometric function has no readily use-able CUDA implementation, which considerably impacts performance. Consider using an approximation to this function.

  4. EddyLifetimeType.MANN_APPROX, which performs a linear regression on a single evaluation of the Mann eddy lifetime function in log-log space. This results in a GPU function of the form \(\tau \approx \exp (\alpha \boldsymbol{k} + \beta)\).

  5. EddyLifetimeType.TAUNET, which performs a simple neural-network based fit of the eddy lifetime function. This has the component of learning

    \[\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}).\]

    The architecture here is identical to the one used in the original DRD paper: 2 layers of 10 neurons each, connected by a RELU function. Setting learn_nu=True means the neural network will also attempt to learn the \(\nu\) value.

  6. EddyLifetimeType.CUSTOMMLP which is an expanded API of the TAUNET: the number of layers, widths of each layer, and activation functions between each layer can be specified. The learn_nu variable serves the same function as for TAUNET.

enum drdmannturb.EddyLifetimeType(value)#

An enumeration.

Valid values are as follows:

TWOTHIRD = <EddyLifetimeType.TWOTHIRD: 1>#
CUSTOMMLP = <EddyLifetimeType.CUSTOMMLP: 2>#
TAUNET = <EddyLifetimeType.TAUNET: 3>#
MANN = <EddyLifetimeType.MANN: 4>#
MANN_APPROX = <EddyLifetimeType.MANN_APPROX: 5>#
CONST = <EddyLifetimeType.CONST: 6>#

Mann Eddy Lifetime Function and VK Energy Spectrum#

The associated eddy lifetime functions are as follows:

drdmannturb.common.MannEddyLifetime(kL: Tensor | ndarray) Tensor[source]#

Implementation of the full Mann eddy lifetime function, of the form

\[\tau^{\mathrm{IEC}}(k)=\frac{(k L)^{-\frac{2}{3}}}{\sqrt{{ }_2 F_1\left(1 / 3,17 / 6 ; 4 / 3 ;-(k L)^{-2}\right)}}\]

This function can execute with input data that are either in Torch or numpy. However,

Warning

This function depends on SciPy for evaluating the hypergeometric function, meaning a GPU tensor will be returned to the CPU for a single evaluation and then converted back to a GPU tensor. This incurs a substantial loss of performance.

Parameters:

kL (Union[torch.Tensor, np.ndarray]) – Scaled wave number

Returns:

torch.Tensor – Evaluated Mann eddy lifetime function.

Return type:

Tensor

drdmannturb.common.Mann_linear_exponential_approx(kL: Tensor, coefficient: Tensor, intercept: Tensor) Tensor[source]#

A surrogate for the term involving the hypergeometric function

\[\frac{x^{-\frac{2}{3}}}{\sqrt{{ }_2 F_1\left(1 / 3,17 / 6 ; 4 / 3 ;-x^{-2}\right)}}\]

via an exponential function, which is a reasonable approximation since the resulting \(\tau\) is nearly linear on a log-log plot. The resulting approximation is the function

\[\exp \left( \alpha kL + \beta \right)\]

where \(\alpha, \beta\) are obtained from a linear regression on the hypergeometric function on the domain of interest. In particular, using this function requires that a linear regression has already been performed on the basis of the above function depending on the hypergeometric function, which is an operation performed once on the CPU. The rest of this subroutine is on the GPU and unlike the full hypergeometric approximation, will not incur any slow-down of the rest of the spectra fitting.

Parameters:
  • kL (torch.Tensor) – _description_

  • coefficient (torch.Tensor) – The linear coefficient \(\alpha\) obtained from the linear regression.

  • intercept (torch.Tensor) – The intercept term \(\beta\) from the linear regression.

Returns:

torch.Tensor – Exponential approximation to the Mann eddy lifetime function output.

Return type:

Tensor

drdmannturb.common.VKEnergySpectrum()#

Von Karman energy spectrum without scaling:

\[\widetilde{E}(\boldsymbol{k}) = \left(\frac{k L}{\left(1+(k L)^2\right)^{1 / 2}}\right)^{17 / 3}.\]
Parameters:

kL (torch.Tensor) – Scaled wave number domain.

Returns:

torch.Tensor – Result of the evaluation