Table of Contents
Fetching ...

Physics-Constrained Flow Matching: Sampling Generative Models with Hard Constraints

Utkarsh Utkarsh, Pengfei Cai, Alan Edelman, Rafael Gomez-Bombarelli, Christopher Vincent Rackauckas

TL;DR

Physics-Constrained Flow Matching (PCFM) introduces a zero-shot, post-hoc framework for enforcing arbitrary nonlinear hard constraints in pretrained flow-based PDE solvers. By interleaving forward shooting, tangent-space projections, an optimal-transport-based reverse update, and a relaxed constraint correction, PCFM preserves alignment with the learned flow while ensuring $h(u_1)=0$ at the final sample. The method supports global and local constraints, including mass conservation and complex boundary conditions, without retraining the underlying model, and demonstrates state-of-the-art fidelity across linear and nonlinear PDEs, including shocks. Practically, PCFM delivers exact constraint satisfaction with modest runtime overhead through a batched differentiable solver and can enrich generative modeling in scientific computing and related domains.

Abstract

Deep generative models have recently been applied to physical systems governed by partial differential equations (PDEs), offering scalable simulation and uncertainty-aware inference. However, enforcing physical constraints, such as conservation laws (linear and nonlinear) and physical consistencies, remains challenging. Existing methods often rely on soft penalties or architectural biases that fail to guarantee hard constraints. In this work, we propose Physics-Constrained Flow Matching (PCFM), a zero-shot inference framework that enforces arbitrary nonlinear constraints in pretrained flow-based generative models. PCFM continuously guides the sampling process through physics-based corrections applied to intermediate solution states, while remaining aligned with the learned flow and satisfying physical constraints. Empirically, PCFM outperforms both unconstrained and constrained baselines on a range of PDEs, including those with shocks, discontinuities, and sharp features, while ensuring exact constraint satisfaction at the final solution. Our method provides a flexible framework for enforcing hard constraints in both scientific and general-purpose generative models, especially in applications where constraint satisfaction is essential.

Physics-Constrained Flow Matching: Sampling Generative Models with Hard Constraints

TL;DR

Physics-Constrained Flow Matching (PCFM) introduces a zero-shot, post-hoc framework for enforcing arbitrary nonlinear hard constraints in pretrained flow-based PDE solvers. By interleaving forward shooting, tangent-space projections, an optimal-transport-based reverse update, and a relaxed constraint correction, PCFM preserves alignment with the learned flow while ensuring at the final sample. The method supports global and local constraints, including mass conservation and complex boundary conditions, without retraining the underlying model, and demonstrates state-of-the-art fidelity across linear and nonlinear PDEs, including shocks. Practically, PCFM delivers exact constraint satisfaction with modest runtime overhead through a batched differentiable solver and can enrich generative modeling in scientific computing and related domains.

Abstract

Deep generative models have recently been applied to physical systems governed by partial differential equations (PDEs), offering scalable simulation and uncertainty-aware inference. However, enforcing physical constraints, such as conservation laws (linear and nonlinear) and physical consistencies, remains challenging. Existing methods often rely on soft penalties or architectural biases that fail to guarantee hard constraints. In this work, we propose Physics-Constrained Flow Matching (PCFM), a zero-shot inference framework that enforces arbitrary nonlinear constraints in pretrained flow-based generative models. PCFM continuously guides the sampling process through physics-based corrections applied to intermediate solution states, while remaining aligned with the learned flow and satisfying physical constraints. Empirically, PCFM outperforms both unconstrained and constrained baselines on a range of PDEs, including those with shocks, discontinuities, and sharp features, while ensuring exact constraint satisfaction at the final solution. Our method provides a flexible framework for enforcing hard constraints in both scientific and general-purpose generative models, especially in applications where constraint satisfaction is essential.

Paper Structure

This paper contains 76 sections, 3 theorems, 57 equations, 9 figures, 8 tables, 1 algorithm.

Key Result

Proposition 3.1

Let $v_\theta(u, \tau)$ be a pre-trained marginal velocity field learned via deterministic flow matching, with pushforward map $\phi_\tau$ such that $u_1 = \phi_1(u_0)$, for samples $u_0 \sim \pi_0$ and $u_1 \sim \pi_1$. Suppose $v_\theta(u, \tau)$ is Lipschitz continuous in both $u$ and $\tau$. The where $p$ is the order of the integrator. Moreover, defining the OT displacement interpolant $\bar{

Figures (9)

  • Figure 1: Evolution of generated solutions for the Burgers equation using vanilla Flow Matching (bottom) and our Physics-Constrained Flow Matching (top). Burgers' equation exhibits sharp shock fronts (top left in the figure), which standard FFM fails to capture accurately, resulting in overly smoothed or smeared solutions. In contrast, PCFM efficiently incorporates physical constraints during sampling, enabling accurate shock resolution and physically consistent final outputs.
  • Figure 2: Comparison of mean $\pm$ 1 std. of mass residuals across samples. generated solutions and mass conservation errors for the Reaction-Diffusion problem with IC fixed. By enforcing both IC and nonlinear mass conservation constraints, PCFM improves quality of generated solutions while satisfying both constraints exactly.
  • Figure 3: Comparison of mean generated solutions and mass conservation errors for the Burger's problem with IC fixed. By enforcing nonlinear conservation constraints via PCFM, our method captures the Burgers' shock phenomenon, ensures global mass conservation in the generated solution, while improving solution quality. Shaded bands show $\pm$ 1 std. of mass residuals across samples.
  • Figure 4: Increasing the number of constraints (constraint collocation points) can improve solution fidelity while maintaining strong satisfaction of other constraints (IC and global mass conservation), demonstrating the ability of PCFM to handle chaining of multiple constraints.
  • Figure 5: Solution profiles for the Inviscid Burgers equation with fixed BC. We plot the various constraint guidance methods and compare the mean solution profile and standard deviation. While PCFM yields slightly worse MMSE and SMSE and better FPD, it ensures global mass conservation and maintains low constraint errors for both Dirichlet and Neumann BCs over time.
  • ...and 4 more figures

Theorems & Definitions (4)

  • Proposition 3.1: Reversibility under OT Displacement Interpolant
  • Theorem A.1: Exact Constraint Enforcement
  • proof
  • Proposition E.1: Tangent-Space Projection in Hilbert Spaces