You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Ensure we handled the rotational and divergent parts correctly #16
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.
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.
Activity
jbphyswx commentedon Sep 6, 2026
Answered, and the answer was no — the decomposition was wrong. It is now fixed, and the fix is gated.
The defect.
helmholtz_decompose_2dmultiplied the cumulative integral byr:Deriving the 2-D relations (
D_TT = D_LL + r dD_LL/drsolenoidal,D_LL = D_TT + r dD_TT/drirrotational) and splittingD_LL = A + (B + rB′),D_TT = (A + rA′) + BgivesI(r) = ∫₀^r [D_TT − D_LL]/s ds = A − B, hencewith no
rmultiplyingI.Falsified numerically. On a purely rotational field (
D_LL = r^(2/3),D_TT = (5/3) r^(2/3), soD_div ≡ 0exactly), 40 log bins overr ∈ [1e-3, 1]:max|D_div|(must be 0)max|D_rot + D_div − (D_LL + D_TT)|i.e. a 33 % spurious divergent signal on a field with no divergent component.
The decisive test is unit invariance. Rescaling
rby 1000 — the same physical field in millimetres rather than metres — moved the shippedmax|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·Iterms cancel inD_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 equalsD_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 ofr— 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_spectratransforms the rotational and divergent components toE_rot(k)andE_div(k)with the dimension-appropriate kernel. BecauseD_rot + D_div = D_LL + D_TTexactly and the transform is linear, the two spectra sum to the trace's spectrum — asserted atrtol = 1e-10.