Search arXivSearch

arXiv · 2407.16032

WaterLily.jl: A differentiable and backend-agnostic Julia solver for incompressible viscous flow around dynamic bodies

Abstract

Integrating computational fluid dynamics (CFD) solvers into optimization and machine-learning frameworks is hampered by the rigidity of classic computational languages and the slow performance of more flexible high-level languages. In this work, we introduce WaterLily.jl: an open-source incompressible viscous flow solver written in the Julia language. An immersed boundary method is used to enforce the effect of solid boundaries on flow past complex geometries with arbitrary motions. The small code base is multidimensional, multiplatform and backend-agnostic, ie. it supports serial and multithreaded CPU execution, and GPUs of different vendors. Additionally, the pure-Julia implementation allows the solver to be fully differentiable using automatic differentiation. The computational cost per time step and grid point remains constant with increasing grid size on CPU backends, and we measure up to two orders of magnitude speed-up on a supercomputer GPU compared to serial CPU execution. This leads to comparable performance with low-level CFD solvers written in C and Fortran on research-scale problems, opening up exciting possible future applications on the cutting edge of machine-learning research.

Explore related subjects

Keep this discovery

Explore connections, maps & timelines

BibTeXRIS

Gabriel D. Weymouth, Bernat Font. 2025-07-21. WaterLily.jl: A differentiable and backend-agnostic Julia solver for incompressible viscous flow around dynamic bodies. https://doi.org/10.1016/j.cpc.2025.109748

Cite the original work for its findings. Save a collection to share your selection of sources.

KEEP EXPLORING

Related papers

Kolmogorov scale in turbulence of surface gravity waves

In this paper, we study the analogue of the Kolmogorov scale in surface gravity wave turbulence, characterized by the cutoff wavenumber $k_c$ at which the power-law inertial range transitions into the dissipation range. We perform numerical simulations of the primitive dynamical equations with a broad-scale dissipation of magnitude $γ_0 k^2$ in spectral space to establish the relation between $k_c$ and $γ_0$. Our results show a scaling $k_c\simγ_0^β$, where $β$ depends on the slope $α$ of the power-law spectrum. We find that $β(α)$ agrees more closely with the prediction obtained by balancing the nonlinear and dissipation terms in the dynamical equations than with that based on the kinetic equation. This observation reveals that non-resonant triad interactions play a more significant role than resonant quartet interactions in the formation of $k_c$.

physics.flu-dyn

Structural identifiability and stress reconstruction from incomplete optical maps with velocimetry

Reconstructing the stress field of a planar viscoelastic flow from optical measurements loses its direct evidence wherever optical coverage is interrupted, and no improvement in optical precision restores an observation that was never made. We characterize what a second, velocity channel adds, and what neither channel can supply. Two calibrated optical components determine the local deviatoric stress pointwise, while velocity constrains spatial stress variation through momentum balance, so the two channels are complementary rather than redundant. The isotropic part of the stress is unobservable to both: the divergence of an isotropic field is a pure gradient, which the Leray projection annihilates, so every representable isotropic mode lies in the joint null space. That accounts for the null space exactly when the optical field is complete, and bounds it from below otherwise, since finite incomplete sampling and aperture zeros can remove further directions. We verify the count directly on three discretizations. In paired synthetic tests with finite measurement apertures, spatially correlated noise and optical stripe dropout, adding velocity reduces the mean whole-domain deviatoric error from 50.40% to 27.82% at 3% reference noise, and the improvement survives shared gaps, inverse-grid refinement at fixed physical sampling, and a constitutively generated stress field. The improvement does not rest on how the regularization parameter is chosen: it holds under both the expected-norm discrepancy rule and generalized cross-validation, and we report each selection with its position in the search interval, which is where the two rules differ.

physics.flu-dyn

A unified multirate lattice Boltzmann framework for thermosolutal dendritic solidification

Thermosolutal dendritic solidification involves interface evolution, solute diffusion, heat transfer, and melt flow over markedly different time scales. In lattice Boltzmann simulations, a single numerical time interval may place different transport processes in unfavorable relaxation ranges, while asynchronous updates require consistent transfer of phase-change contributions. To address these issues, a unified multirate multiple-relaxation-time lattice Boltzmann method is developed for thermal, solutal, and thermosolutal dendritic solidification. The coupled fields share a common moment-space framework but evolve at different update rates. The concentration and temperature source terms are separated into transport-related and phase-change contributions, and each resolved phase increment is used to immediately transfer the corresponding solutal and latent-heat contributions. The method reproduces characteristic dendritic morphologies and tip-velocity trends under pure diffusion and forced convection, with weak sensitivity to the tested update factors. Directional solidification over Lewis numbers \(Le=1\)--\(1000\) captures the transition from nearly planar to cellular and strongly branched growth, including vertically aligned dendrites and solute-rich interdendritic channels for saline water, in qualitative agreement with experiments. Source-coupling ablation shows that delayed coarse-step transfer produces increasingly strong local source pulses and eventual loss of numerical stability as time-scale separation increases, whereas phase-step instantaneous transfer remains stable over the tested conditions. These results demonstrate the applicability of the proposed framework to dendritic solidification with strongly separated transport time scales. The source code is publicly available in the \emph{DendriteLBM} repository.

physics.flu-dyn