Repository navigation
Accelerate SEMIANA response with finite-window recurrence - #48
Merged
Merged
Conversation
Replace the serial cached Numba SEMIANA hot path with an algebraically equivalent finite-window recurrence while retaining the legacy implementation as an internal reference. Add low-level and full-flow parity tests, scaling benchmarks, trajectory validation through 10,000 migration steps, and reusable component timing instrumentation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR accelerates the Numba SEMIANA response used by the free-flow solver by replacing the repeated finite-window convolution summation with an algebraically equivalent recursive finite-window formulation.
The optimization preserves the existing:
jtolltruncationTOLL=1e-4The new recurrence is not an infinite-IIR approximation. It explicitly subtracts the contribution leaving the finite
jtollwindow.The public Numba path now uses the recursive response only for the validated configuration:
paral=0numba_parallel=Falsenumba_fastmath=FalseOther execution modes retain the legacy implementation.
The previous cached Numba SEMIANA response is preserved as an internal reference for validation and benchmarking.
Main changes
Numerical validation
Direct finite-window parity
The recursive kernels were compared station-by-station against the legacy cached finite convolution for:
jtoll = 2,3, intermediate values, near-N,N, andN+1Complete flowfield parity was also checked for:
At
N=2500, direct NumPy-reference versus recursive Numba response gave:5.40e-162.66e-167.02e-111e-12denominator floorResonance flags matched in all tested cases.
Long-term trajectory validation
A 10,000-step A/B comparison was run using:
Both runs:
Final values:
NsThe final two-point
Nsdifference was investigated separately.At the shared cutoff event at step 9,996, the existing strict first-hit neck-cutoff rule saw candidate
i0=1249on opposite sides of the cutoff threshold:4.79e-5abovedslim36.02e-5belowdslim3This caused:
(1250, 1275)(1249, 1276)and therefore remove 28 versus 30 points.
This was confirmed to be threshold sensitivity in the existing cutoff rule, not a SEMIANA indexing error.
Small floating-point trajectory drift begins before the first cutoff; nonlinear evolution, resampling, and discrete cutoff decisions subsequently amplify that drift.
No claim of bitwise-identical long-term trajectories is made.
Performance
Fixed-size SEMIANA benchmark
Median SEMIANA-response speedup increased strongly with centreline size:
This reflects the reduction from repeated finite-window summation toward approximately linear work per response.
10,000-step evolving simulation
These timings are machine-specific and are included as indicative performance measurements.
Public selector validation
After switching the public Numba default, a 500-step wiring comparison was run between:
Both runs ended with:
Ns=1000This confirms the public serial Numba path routes to the recursive implementation.
Tests
pytest -q: passedgit diff --check: passedNo scientific parameters, geometry rules, cutoff rules, tolerances, or model defaults were changed.