← all repositories
tum-pbs/PhiFlow

When your fluid sim needs to learn backprop

PhiFlow wraps PDE solvers in automatic differentiation so physics and neural networks can train together.

★1.9k stars Python Other AI
PhiFlow
Not currently ranked — collecting fresh signals.
star history

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.

Frequently asked

What is tum-pbs/PhiFlow?
PhiFlow wraps PDE solvers in automatic differentiation so physics and neural networks can train together.
Is PhiFlow open source?
Yes — tum-pbs/PhiFlow is open source, released under the MIT license.
What language is PhiFlow written in?
tum-pbs/PhiFlow is primarily written in Python.
How popular is PhiFlow?
tum-pbs/PhiFlow has 1.9k stars on GitHub.
Where can I find PhiFlow?
tum-pbs/PhiFlow is on GitHub at https://github.com/tum-pbs/PhiFlow.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.