When your fluid sim needs to learn backprop
PhiFlow wraps PDE solvers in automatic differentiation so physics and neural networks can train together.

What it does PhiFlow is a Python simulation toolkit for PDEs—mostly fluids—that plugs into NumPy, PyTorch, JAX, or TensorFlow. The pitch is simple: write your physics once, run it on CPU or GPU, and backpropagate through the entire simulation because the framework leverages each backend’s autograd.
The interesting bit The same code runs a 2D NumPy sim and a 3D GPU sim without rewriting. That’s less magic than it sounds—it’s a vectorized, backend-agnostic abstraction layer—but it means you can prototype on your laptop and scale to a cluster without touching the PDE formulation. The built-in web UI (Dash-based) also lets you poke at live simulations or training runs in a browser.
Key highlights
- Supports grids, meshes, and particle methods (SPH, FLIP) with built-in PDE operations
- End-to-end differentiability through PyTorch, JAX, or TensorFlow autodiff
- Backend-agnostic code: dimensionality and hardware are swappable config, not rewrite
- Automated sparse matrix generation for linear solves
- Optional custom CUDA operators for GPU performance
Caveats
- Requires installing your chosen ML framework separately; “pip install phiflow” alone won’t give you GPU or autodiff
- Custom CUDA operators need manual compilation for “optimal” performance
- Python 3.6+ supported, though 3.6 itself is well past end-of-life
Verdict Worth a look if you’re doing physics-informed ML, inverse problems, or optimal control with fluids. Pure CFD practitioners who don’t need gradients may find the ML-framework dependency overhead unnecessary.