r/CUDA • u/Obvious-Ask-9099 • 3h ago
Replacing float32/float64 with exact integer and rational arithmetic in open-channel hydraulics and shallow-water solvers (verified in Lean 4)
Hi everyone, Over millions of time steps in river and open-channel flow simulations, standard float32/float64 arithmetic often introduces small volume drift, subtractive cancellation in shallow trapezoidal beds, and slight discrepancies between CPU and parallel GPU runs. I have been developing an integer-first hydrodynamics and scientific computing framework (UNIQUANT) that replaces floating-point updates with exact integer and rational arithmetic, and I formally verified 40 of its core modules in Lean 4 (0 sorry):
- Backlog-free donor-limited volume ledgers: Proportional outflow apportionment so cell inventories never overdraw and blocked zero-flow channels leave no unphysical backlog.
- Cancellation-free trapezoidal channel geometry: Algebraic depth inversion h = 2A / (b + sqrt(b^2 + 4mA)), exact hydrostatic pressure moment identities (I1'(h) = A(h)), and cut-cell ramp integrals.
- Tridiagonal M-matrix integer solvers: Strictly row-dominant integer solvers with dyadic grid refinement invariance (K to 2K), tie-to-even rounding to prevent solver oscillation, and certified L_infinity error bounds.
- Coupled sediment and momentum conservation: Exact two-phase suspended/bed sediment mass conservation, equilibrium Rusanov fluxes, and 128/256-bit multi-limb arithmetic for bit-exact CPU/CUDA execution.
The reference code (including Elbe hydraulic core headers and Python implementations) and Lean 4 proofs are open source here:
Primary repo & code: https://github.com/joesen88/Uniquant23 (DOI: 10.5281/zenodo.24570873)
Lean 4 formalization: https://github.com/joesen88/UNIQUANT-Formal (DOI: 10.5281/zenodo.24629562)
Would love to hear feedback from anyone working on shallow-water solvers, well-balanced schemes, or deterministic CFD!