diffSPH - Differentiable Smoothed Particle Hydrodynamics for Adjoint Optimization and Machine Learning
A fully differentiable SPH framework in PyTorch, spanning incompressible to compressible schemes, built so that gradients flow through the solver.
diffSPH is a fully differentiable Smoothed Particle Hydrodynamics solver written in PyTorch with GPU acceleration. It is designed around differentiation from the ground up, so gradients propagate through the entire simulation rather than around it — which is what makes inverse problems, parameter estimation and learned closure models tractable.
Published in the Journal of Computational Physics (Winchenbach & Thuerey, 2026) and available on GitHub. A companion dataset, diffSPH16K, provides compressible and incompressible problems at a consistent 16K-particle resolution for training neural surrogates.
Schemes and features
Simulation schemes
- δ-SPH and δ⁺-SPH for weakly compressible simulations
- IISPH and DFSPH for incompressible simulations
- CompSPH, CRKSPH, PESPH and the classic Monaghan scheme for compressible simulations
Boundary and domain handling
- mDBC boundary conditions for rigid bodies
- Inlets and outlets with buffer zones
- Periodic BCs using minimum image conventions
- Neumann and Dirichlet BCs
Numerics
- grad-H, kernel renormalization and CRK correction schemes
- δ⁺ and implicit particle shifting
- Monaghan and Owen schemes for adaptive particle support radii
- Balsara, Morris, Rosswog, and Cullen-Dehnen artificial viscosity switches
- Sub-particle-scale turbulence modelling
- Most common SPH kernel functions (Wendland, B-Spline, Poly6)
Infrastructure
- Differentiable generation of initial conditions using SDFs
- Hierarchical and compact hashing based neighbor searching
- Verlet lists for neighborhood searches
What differentiability buys you
Because the solver is differentiable end to end, it supports inverse problems, loss-based physics, parameter estimation, shape optimization and closure modelling directly, rather than requiring a separate adjoint implementation to be written and maintained alongside the forward solver.