latticebmjax
About
'latticebmjax' is a Python package designed for hardware-accelerated simulation of fluid flows using the Lattice Boltzmann Method (LBM) with JAX as the computational backend. It is capable of:
- Solving 2D incompressible flows using the D2Q9 BGK-LBM scheme
- Applying Zou-He and bounce-back boundary conditions
- Running on CPU with JIT compilation via JAX
- Validating results against the Ghia et al. (1982) benchmark data
- Plotting velocity fields, streamlines and centreline profiles
- Benchmarking JIT vs non-JIT performance across multiple solvers
Features
- D2Q9 lattice with BGK single-relaxation-time collision operator
- Zou-He velocity boundary condition for the moving lid
- Bounce-back no-slip boundary conditions for stationary walls
- JIT-compiled time loop via
jax.jitfor high performance - Lid-driven cavity solver validated against Ghia et al. (1982)
- Poiseuille solver validated against the analytical parabolic profile
- Centreline velocity profiles compared to benchmark data (Re=100, 400, 1000)
Examples
- 'jit_benchmark.py' — JIT vs no-JIT performance comparison across all solvers
- 'lid_cavity.py' — lid-driven cavity with live plotting and Ghia comparison
- 'poiseuille.py' — Poiseuille channel flow with analytical validation
Installation
Dependencies
Ensure you have the required dependencies installed, which are listed in requirements.txt. You can install them using:
pip install -r requirements.txt
User installation
Clone the repository and install locally:
git clone https://github.com/veracfernanda/latticebmjax.git
cd latticebmjax
pip install -e .
To install the library, you can use the 'pip' command:
pip install latticebmjax
Folder structure
latticebmjax
├─── README.md
├─── LICENSE
├─── pyproject.toml
├─── requirements.txt
├─── benchmarks
│ ├─── convergence.py
│ └─── ghia_data.py
├─── examples
│ ├─── poiseuille.py
│ ├─── jit_benchmark.py
│ └─── lid_cavity.py
├─── latticebmjax
│ ├─── __init__.py
│ ├─── collision.py
│ ├─── equilibrium.py
│ ├─── lattice.py
│ └─── streaming.py
├─── solvers
│ ├─── __init__.py
│ ├─── base_solver.py
│ ├─── boundary.py
│ ├─── lid_cavity.py
│ └─── poiseuille.py
├─── testcase_data
│ ├─── ghia_re100.csv
│ ├─── ghia_re400.csv
│ └─── ghia_re1000.csv
└─── tests
├─── test_collision.py
├─── test_lid_cavity.py
└─── test_streaming.py
Examples
Some usage examples of the library can be found in the examples folder
License
This software is distributed under the MIT License and further information about the license can be found in the LICENSE file
Third-party libraries
The library currently uses the following third-party libraries:
- jax — JIT compilation and GPU acceleration
- numpy — array utilities and CSV loading
- matplotlib — velocity field and centreline plots
- pandas — benchmark data loading
- pytest — unit and integration testing
Contributing
The project is in the early development phase. Upon completion and delivery, contributions will be welcome! Please fork the repository and submit a pull request for any improvements or bug fixes.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file latticebmjax-1.0.1.tar.gz.
File metadata
- Download URL: latticebmjax-1.0.1.tar.gz
- Upload date:
- Size: 20.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2078ebab9c97f2e6f711eb9c06fcedc9d3664956b41e29fc7ae763f327d5c3b3
|
|
| MD5 |
e4931b054d7b8ccbcd85915f799e417f
|
|
| BLAKE2b-256 |
bf831a9a8d21a42bd3fd23ad67901ef7567c920993faf07b76dca26d8f89af59
|
File details
Details for the file latticebmjax-1.0.1-py3-none-any.whl.
File metadata
- Download URL: latticebmjax-1.0.1-py3-none-any.whl
- Upload date:
- Size: 15.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bdfee0ea95daa411845d9d37a2ca281bf894121a9b72d7a83a78c6e2969774a0
|
|
| MD5 |
2b7dcc9dff8d7eab41071cfccc41f6b4
|
|
| BLAKE2b-256 |
7a53fa9e48e46097aa07fab4899953544ae2242d9730972c66533545284fa83b
|