Strouhal
A fluid solver for Apple silicon: D3Q19 lattice-Boltzmann in Metal, a command line of validation runs, and a live SwiftUI app. Any result can be “hardened” into an uncertainty with a stated validation domain — and the tool refuses to print a calibrated error bar where none can be defended.
$ swift build -c releaseSwift · Metal · SwiftUI · Swift Package Manager · Lattice Boltzmann
v0.8.0 · Apache-2.0 · macOS 15+ on Apple silicon · build from source
- 1,445
- MLUPS at 256³, FP16 storage, base M5
- 0.16%
- cylinder drag error vs Schäfer–Turek
- 10
- physics checks against analytic or published data
Solver
A D3Q19 lattice with TRT or SRT collision, FP32 arithmetic, and FP32 or FP16 storage. It streams in place with the AA pattern, uses halfway bounce-back with moving walls, and applies Guo forcing. FP32 runs at about 785 MLUPS — roughly 80% of peak memory bandwidth.
FP16 storage pairs with SRT by design: TRT's antisymmetric mode subtracts two half-precision values, and at FP16 that made the lid-driven-cavity error five times worse.
Determinism as a contract
Safe math mode, no atomics, and reductions always taken in the same order. Runs repeat bit for bit, confirmed by identical SHA-256 digests of the state at both precisions. A single value injected in each of the 18 directions lands exactly at cell + T·cᵢ, with nothing leaking.
Hardening a number
The tool re-runs a case at several resolutions plus once at half the Mach number, then combines U = k·√(u_num² + u_stat² + u_Ma² + u_domain²) with k = 2, and writes a report in ASME V&V 20 terms.
The domain term was added after it turned out to dominate: a periodic box overestimated sphere drag by 36.8%. Correcting for it moved C_D from 1.3591 ± 0.0621, which missed the reference, to 1.0714 ± 0.0916, which covers it.
case (built-in or STL) ──▶ voxelize ──▶ Metal kernels
│
▼
ladder ── resolution rungs · half-Mach anchor · domain
│ settle until the quantity stops moving
▼
uncertainty ── U = k·√(u_num² + u_stat² + u_Ma² + u_dom²)
│
├──▶ inside validated domain ──▶ report with bar
└──▶ outside ──▶ components only, no calibrated barcase (built-in or STL) ──▶ voxelize ──▶ Metal kernels
│
▼
ladder ── resolution rungs · half-Mach anchor · domain
│ settle until the quantity stops moving
▼
uncertainty ── U = k·√(u_num² + u_stat² + u_Ma² + u_dom²)
│
├──▶ inside validated domain ──▶ report with bar
└──▶ outside ──▶ components only, no calibrated barWhat it refuses to report
No Grid Convergence Index, because the observed order is only a diagnostic. No calibrated error bar for imported shapes without validation data. The pipe case showed curved walls converging at first order (0.96); when the sphere's resolution ladder came out at order 0.13, the tool flagged it instead of printing a tidy number.