Improve physical geometry, fluid solvers, audio, and profiling

This commit is contained in:
max
2026-10-30 18:57:56 +01:00
parent bf8621ad39
commit eb2b6366c2
130 changed files with 14649 additions and 862 deletions

110
docs/ACOUSTIC_BENCHMARK.md Normal file
View File

@@ -0,0 +1,110 @@
# Acoustic pulse benchmark
Run from the repository root:
```powershell
cmake --build --preset windows --target fluidsim_acoustic_benchmark
.\out\build\windows-gcc\fluidsim_acoustic_benchmark.exe out/acoustics
ctest --preset windows -R 'acoustic_benchmark|fluid_validation' --output-on-failure
```
`summary.csv` contains 408 cases. Each case also has a pressure/velocity probe
trace in CSV. No engine configuration or production solver behavior is changed.
## Cases and measurement
- A continuous 4 m pipe and an equivalent pair of directly connected 2 m pipes.
- Equal-area characteristic and legacy zero-storage three-way junctions, and an unequal-area characteristic junction (an idealized T/Y, without angles).
- Two-port and three-port finite-volume fittings, with 50, 500, and 5000 cc storage
and discharge coefficients 1.0 and 0.7. Opening area equals branch pipe area;
discharge variation represents restriction, not resolved entry geometry.
- Rusanov, HLLE, HLLC, and limited MUSCL-Hancock/HLLC; 40, 80, and 160 cells per 2 m; nominal Courant
settings 0.4 and 0.8. Solver CFL protection remains active. The requested
timestep uses reference sound speed plus a small wave-speed margin.
All pipes have area 0.001 m² and initially rest at 101325 Pa, 300 K. A 100 Pa
Gaussian pressure pulse, centered 0.6 m from the inlet with width parameter
0.12 m, is initialized as a right-going linear acoustic wave. Explicit pipe
damping and thermal relaxation are disabled.
The upstream probe is near x=1.4 m, and downstream probes are near x=2.6 m
(0.6 m into each outlet branch). Probe positions use containing cell centers.
The 9 ms integration ends before far-end reflections return to the probes.
For every probe, characteristics are `p± = (p' ± rho*c*u)/2`.
Acoustic pulse energy is the integral of `area * p±² / (rho*c)` over time.
Transmitted energy sums all outlet branches. Ratios divide by incident energy
at the upstream probe, so incident-path attenuation before that probe is excluded.
`transmission_over_straight` and `reflection_over_straight` divide the measured
ratios by transmission through the continuous pipe at matching mesh, scheme,
and timestep. This approximately removes shared propagation attenuation. Junction
filtering can change spectra, so this correction is not a complete de-embedding
of frequency-dependent pipe loss.
The ideal equal-area lossless three-way junction has reflected energy 1/9 and
total transmitted energy 8/9. Straight-pipe ideals are 0 and 1. Finite-volume
fittings have no constant analytic coefficient in this benchmark: their storage
and nozzle models introduce frequency and amplitude dependence.
`unaccounted_ratio` is acoustic energy missing from the measured outgoing pulse,
not a total conserved-energy error. It includes numerical attenuation, interface
loss, and any energy still stored or delayed beyond the measurement window.
It must not automatically be interpreted as physical dissipation.
Mass and total-energy drift, limited fluxes, positivity repairs, and substeps are
reported separately. Cases with limiting or outgoing acoustic energy above 1.05
times incident are flagged; they are not accepted as physical loss measurements.
The test fails for nonfinite results, positivity repairs, conservation drift
above 100 ppm, straight-pipe reflection above 0.0001, split-pipe mismatch, or a
failure of straight-pipe transmission to improve with mesh refinement at 0.4.
Flagged volume cases are retained as diagnostics rather than silently discarded.
## Initial findings
For Rusanov at nominal Courant 0.4:
| Cells per 2 m | Straight transmission | Three-way transmission / straight |
| --- | --- | --- |
| 40 | 0.6783 | 0.2215 |
| 80 | 0.7172 | 0.2219 |
| 160 | 0.7707 | 0.2222 |
The split pipe matches the continuous pipe. Straight-pipe attenuation decreases
with refinement, identifying spatial numerical diffusion as a contributor.
The legacy zero-storage junction's corrected transmission remains near 2/9 instead of
the ideal 8/9, indicating a separate interface problem that refinement does not
remove. Total mass and energy conservation alone does not establish correct
acoustic scattering.
The original three solvers flagged five coarse, high-timestep 50 cc three-port volume cases for flux
limiting or acoustic amplification. These show sensitivity to component storage
and explicit exchange timesteps; a pipe CFL limit alone does not validate that
coupling. A component timestep study should precede acoustic calibration of those
cases. Other cases passing robustness checks are not thereby physically validated.
These are small-signal, zero-mean-flow results for one pulse bandwidth. They do
not establish the dominant loss at every engine operating point. The single-450
and current V8 use storage volumes, so a zero-storage junction fix alone will not
address their sound. The next production-model investigation should address
pipe diffusion and finite-volume coupling stability; retain the zero-storage
scattering result as a separate junction regression target. Frequency sweeps,
phase comparison, mean-flow cases, and measured fitting data remain follow-up work.
## Production listening candidate
`muscl` is now a fourth selectable solver in the desktop, CLI, and capture tool.
Its straight-pipe energy transmission at Courant 0.4 is 0.7834, 0.8637, and
0.9446 for 40, 80, and 160 cells per 2 m, versus Rusanov's 0.6783, 0.7172,
and 0.7707. The benchmark also checks at least 0.05 improvement over Rusanov at
matching mesh/timestep. Split-pipe equivalence still passes without relaxed
thresholds. Adding MUSCL and the new characteristic/unequal-area comparisons brings the sweep to 408 cases, with seven flagged
small-volume cases; the component-coupling timestep issue is still open.
The new reconstruction applies to uniform pipe sections and matching direct
connections. Fittings, component boundaries, and profile transitions retain
first-order coupling. Production evaluation is opt-in (`--solver muscl` or F3);
Rusanov remains the startup default. Auto gain defaults off for listening.
The new characteristic solver corrects the legacy scattering error. Its corrected
transmission is about 8/9 for equal branches; unequal-area checks and transmitted
500/1000 Hz gain/phase checks are now included. See [junction solver details](JUNCTION_SOLVER.md).