Development of Thermal Feature in XLB - #167
Merged
Merged
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
hsalehipour
approved these changes
Sep 12, 2026
hsalehipour
left a comment
Collaborator
There was a problem hiding this comment.
Looks great! thank you
Author
|
I have read the CLA Document and I hereby sign the CLA |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contributing Guidelines
Description
Adds thermal (scalar) transport and buoyancy-driven (Boussinesq) flow to XLB, along with a set of tutorial notebooks that teach the library step by step, from a basic isothermal flow through fully two-way coupled thermal-flow simulations.
Core library (
xlb/): everything tested in JAXThermalStepper,ScalarDirichletBC,ScalarNeumannBC,ScalarOutflowBC,LinearEquilibrium,ScalarSource, and anomega_from_diffusivityhelper.D2Q5(cheap stencil for scalar transport) andD3Q7.ForcedCollisionandExactDifferenceForcenow accept a force vector supplied at call time (not just construction time), which is what lets a temperature-dependent Boussinesq buoyancy force be injected into the flow's collision step every time step without breaking JAX's JIT caching.Examples (
examples/thermal/):heat_conduction_2d.py), one-way coupled thermal lid-driven cavity, and a 3D flow-past-sphere thermal case.Tutorials (
examples/tutorials/):01_lid_driven_cavity_2d— velocity set (D2Q9), boundary conditions, convergence detection, validated against the classic Ghia, Ghia & Shin (1982) benchmark02_heat_conduction— scalar solver (D2Q5), Dirichlet/Neumann BCs, no flow03_flow_past_cylinder_2d— external unsteady flow, momentum transfer, Strouhal number04_pass_scalar_transp_cavity_2d— one-way thermal-flow coupling, Péclet/Nusselt numbers05_flow_past_square_thermal_2d— cold obstacle in warm external flow06_buoyant_cavity— two-way coupling, Boussinesq force, differentially-heated vertical cavity07_rayleighbenard— two-way coupling, bottom-heated Rayleigh–Bénard convection, validated against a Nusselt-number/Rayleigh-number scaling law01_lid_driven_cavity_2d's benchmark comparison uses JSON reference data underexamples/cfd/data/cavity-ghia/(converted from tabulated PDF data via a companion tool, extract-ghia) forRein {1000, 2500, 5000, 7500, 10000, 12500, 20000, 25000, 30000}; an unsupportedReis handled gracefully rather than failing.examples/tutorials/README.mdand the top-levelREADME.mdupdated to list all seven tutorials and point new users there.Tests (
tests/):Type of change
How Has This Been Tested?
New unit tests added under
tests/thermal/(JAX backends) andtests/equilibrium/for the new operators.All seven tutorial notebooks run end-to-end on the JAX backend (CPU); outputs and figures were inspected manually for physical plausibility (e.g. lid-driven-cavity velocity profiles against Ghia et al., Rayleigh–Bénard convection rolls and Nusselt number against the expected scaling law).
JAX pytest tests pass
Linting and Code Formatting
Make sure the code follows the project's linting and formatting standards. This project uses Ruff for linting.
To run Ruff, execute the following command from the root of the repository:
ruff check .