Skip to content

Ensure we handled the rotational and divergent parts correctly #16

Closed

Description

@jbphyswx

Helmholtz Decomposition. see https://doi.org/10.1029/2022GL097713.

We need to ensure we have both the 3rd order SF for energy cascade and those Lindborg 2015 transformations from https://doi.org/10.1017/jfm.2014.685 set up and on offer correclty.

Activity

  1. self-assigned this
    on May 30, 2026
  2. jbphyswx commented on Sep 6, 2026

    @jbphyswx
    OwnerAuthor

    Answered, and the answer was no — the decomposition was wrong. It is now fixed, and the fix is gated.

    The defect. helmholtz_decompose_2d multiplied the cumulative integral by r:

    D_rot = D_TT[k] + bin_mids[k] * I[k]
    D_div = D_LL[k] - bin_mids[k] * I[k]

    Deriving the 2-D relations (D_TT = D_LL + r dD_LL/dr solenoidal, D_LL = D_TT + r dD_TT/dr irrotational) and splitting D_LL = A + (B + rB′), D_TT = (A + rA′) + B gives I(r) = ∫₀^r [D_TT − D_LL]/s ds = A − B, hence

    D_rot(r) = D_TT(r) + I(r)        D_div(r) = D_LL(r) − I(r)
    

    with no r multiplying I.

    Falsified numerically. On a purely rotational field (D_LL = r^(2/3), D_TT = (5/3) r^(2/3), so D_div ≡ 0 exactly), 40 log bins over r ∈ [1e-3, 1]:

    shipped corrected
    max|D_div| (must be 0) 0.329 0.0106
    max|D_rot + D_div − (D_LL + D_TT)| 4.4e-16 2.2e-16

    i.e. a 33 % spurious divergent signal on a field with no divergent component.

    The decisive test is unit invariance. Rescaling r by 1000 — the same physical field in millimetres rather than metres — moved the shipped max|D_div| from 0.329 to 856, a 2600× change from a change of unit. The corrected form is invariant.

    Why it survived. The ±r·I terms cancel in D_rot + D_div, so the energy-conservation check passes to 4e-16 with the bug present — and that was the only physics-level assertion in the suite. The unit test then pinned the error by re-deriving the same wrong expression and checking the code agreed with it. A conservation identity the defect preserves is not a gate.

    Also fixed in the same function: the integral's lower limit was silently the first bin midpoint rather than 0. The omitted segment is not small — for D_LL ∝ r^(2/3) it equals D_LL(r₁).

    Now gated in test/test_known_truth.jl: the solenoidal case, the mirror irrotational case, and the unit-invariance assertion. Verified discriminating by re-injecting the factor of r — the gate reports 0.329 against its 0.047 threshold and the millimetre run reaches 859, while the energy-conservation assertion still passes.

    Lindborg 2015 transformations (the issue's second half) are also implemented: helmholtz_spectra transforms the rotational and divergent components to E_rot(k) and E_div(k) with the dimension-appropriate kernel. Because D_rot + D_div = D_LL + D_TT exactly and the transform is linear, the two spectra sum to the trace's spectrum — asserted at rtol = 1e-10.

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