neuralop.layers.spectral_projection.spectral_projection_divergence_free

neuralop.layers.spectral_projection.spectral_projection_divergence_free(u, domain_size, constraint_modes)[source]

Apply spectral projection layer to make a velocity field divergence-free.

Parameters:
utorch.Tensor

Input velocity field [batch, 2, height, width] where the last two dimensions represent the 2D velocity components (u_x, u_y)

domain_sizefloat or tuple of float

Physical domain size. If float, assumes square domain with same size for height and width. If tuple, should be (height_size, width_size) for non-square domains.

constraint_modestuple

Number of modes to use for constraint resolution (height_modes, width_modes). If larger than input dimensions, they are truncated to the input dimensions.

Returns:
torch.Tensor

Divergence-free projected velocity field with [batch, 2, height, width] shape. The output maintains the same shape as the input while satisfying ∇·u = 0.

Notes

Mathematical formulation: Helmholtz-Hodge projection in spectral domain: û_proj = û - (k·û)/|k|² * k. Enforces ∇·u = 0 by removing the irrotational component. Periodicity: Velocity fields are assumed periodic. For non-periodic fields, extend via Fourier continuation (neuralop.layers.fourier_continuation), project, then truncate.

References

The method is based on the spectral projection approach described in:

[1] Towards Enforcing Hard Physics Constraints in Operator Learning Frameworks V. Duruisseaux, M. Liu-Schiaffini, J. Berner, and A. Anandkumar ICML 2024 AI for Science Workshop https://openreview.net/pdf?id=Zvxm14Rd1F

[2] Enforcing physical constraints in CNNs through differentiable PDE layer. C. M. Jiang, K. Kashinath, P. Prabhat, and P. Marcus ICLR 2020 Workshop on Integration of Deep Neural Models and Differential Equations, 2020. https://openreview.net/pdf?id=q2noHUqMkK