Skip to content

Implement NonnegativeLeastSquares.jl enhanced Energy Transfers from Third-Order Structure Functions #18

Closed

Description

@jbphyswx

An Improved Methodology to Estimate Cross-Scale Kinetic Energy Transfers from Third-Order Structure Functions Using Regularized Least Squares https://doi.org/10.1175/JTECH-D-25-0025.1 indicates that we should be able to use this method of optimized energy transfer calculations.

See also Third-order structure functions for isotropic turbulence with bidirectional energy transfer https://doi.org/10.1017/jfm.2019.651, and Direct observational evidence of an oceanic dual kinetic energy cascade and its seasonality https://doi.org/10.1126/sciadv.abq2566

PS, it also uses the Hankel transformation stuff that we never ported here, check what's going on and get that built in here too

Activity

  1. jbphyswx commented on Jun 5, 2026

    @jbphyswx
    OwnerAuthor

    Implement Dimension-Aware Transforms Between Structure Functions and Spectra

    Description
    Our package calculates Structure Functions (SFs) of all orders, but lacks the ability to invert them into Isotropic Power Spectra ($E(k)$). Because our data spans different dimensions (1D tracks, 2D surfaces, 3D volumes), we cannot use a standard 1D FFT for all inversions. When multi-dimensional fields are averaged into 1D isotropic spectra, the geometry of the required transform changes.

    Theoretical Basis

    1. The 2nd-Order SF is the Bridge: By the Wiener-Khinchin theorem, only the 2nd-order structure function ($S_2(r)$) can be directly transformed into the kinetic energy power spectrum ($E(k)$).
    2. The 3rd-Order SF is the Flux: The 3rd-order structure function ($S_3(r)$) represents spectral energy transfer (e.g., Kolmogorov's 4/5ths law). It cannot be inverted into a standard power spectrum.

    Dimensionality Constraints & Required Basis Functions
    To accurately convert an isotropic spectrum $E(k_r)$ back to a physical $S_2(r)$ (and vice versa), the integration basis function must match the dimension the data was azimuthally or spherically averaged from:

    • 1D Data (Straight-line tracks): No angular averaging.
      • Transform: Standard 1D FFT / Discrete Cosine Transform.
      • Basis Function: Cosine wave ($\cos(kr)$).
    • 2D Data (Ocean/Atmosphere surfaces): Averaged over circular rings.
      • Transform: Discrete Hankel Transform.
      • Basis Function: Bessel function of the first kind, order zero ($J_0(kr)$).
    • 3D Data (Volume fields): Averaged over spherical shells.
      • Transform: Spherical Bessel Transform.
      • Basis Function: Sinc function ($\frac{\sin(kr)}{kr}$).

    Implementation Checklist

    • Implement 1D Cosine inversion for $S_2(r) \leftrightarrow E(k_{1D})$
    • Implement 2D Hankel inversion (Bessel $J_0$) for isotropic surface fields.
    • Implement 3D Spherical Bessel inversion (Sinc) for isotropic volume fields.
    • Add explicit errors if a user attempts an $E(k)$ inversion on $S_n$ where $n \neq 2$.
    • (Optional) Add a dedicated method to extract the turbulent dissipation rate ($\epsilon$) directly from $S_3(r)$.

    This actually I think can used the generalized Hankel Transform for any dimensions, but the rest of the package needs to be updated to accept any dimension data.

  2. self-assigned this
    on Jun 5, 2026
  3. jbphyswx commented on Jun 6, 2026

    @jbphyswx
    OwnerAuthor
  4. jbphyswx commented on Sep 6, 2026

    @jbphyswx
    OwnerAuthor

    The transform half is implemented; the NNLS estimator is not, and is what remains here.

    Done, following the dimension↔kernel table in the comments above:

    data angular average kernel
    1-D tracks none cos(kr)
    2-D surfaces circular rings J₀(kr)
    3-D volumes spherical shells sin(kr)/(kr)

    isotropic_spectrum(result, wavenumbers, Val(D)), verified pointwise against a closed form (a Gaussian correlation has an analytic spectral density in every dimension): agreement to 6.6e-05, 2.3e-09, 9.9e-14 in 1-D/2-D/3-D. Bessels.jl is a zero-dependency weakdep, needed only for the 2-D kernel since the other two are elementary.

    Two corrections to the spec in this issue, both of which would otherwise have been silent errors:

    1. "S₂" is ambiguous, and the ambiguity is a factor of 2. This package has three second-order quantities: S2SF is the trace ⟨‖δu‖²⟩, L2SF is ⟨δu_L²⟩, T2SF is ⟨δu_T²⟩. Only the trace maps to the KE spectrum by the plain Wiener–Khinchin route — measured in 2-D, mean(D_LL / trace) = 0.497. So handing L2SF to a routine documented as "S₂ → E(k)" would silently return about half the kinetic-energy spectrum. assert_invertible now accepts only the trace and refuses L2SF/T2SF naming the isotropy relation needed to convert.
    2. No variance argument. The k ≠ 0 spectrum follows from D(r) alone: since FT[D](k) = 2C(0)·N·δ_{k,0} − 2·FT[C](k), the constant lives entirely at k = 0. Verified to 2.3e-16 against a directly computed spectrum, and adding a constant offset of 137 to the field leaves D unchanged to 4.6e-14 and the recovered spectrum unchanged to 1.3e-12. Only the k = 0 mode is lost, and no variance argument would recover it. (That argument is required for the covariance in Covariance Matrix from Structure Fucntion #21 — same blindness, opposite consequence.)

    Also implemented, and worth noting since it was not in the original scope: the Helmholtz route. D_rot/D_div transform to E_rot(k)/E_div(k) with the same kernels — the canonical oceanographic SF→KE pipeline, and the reason the package carries a Helmholtz decomposition at all. It was unreachable until the factor-of-r defect in #16 was fixed.

    "Only S₂ may be inverted" is enforced: orders other than two are refused as fluxes rather than spectra.

    Remaining here: the NNLS-regularised energy transfers. That needs NonnegativeLeastSquares.jl and a regularisation choice which is a research decision rather than an implementation one, so it is deliberately its own deliverable on top of the transforms above.

  5. jbphyswx commented on Nov 11, 2026

    @jbphyswx
    OwnerAuthor

    Should be closed by #39, reopen if anything was missed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions