Lattice Boltzmann¶
The voids.lbm sub-package provides package-facing LBM namespaces for
direct-image single-phase flow. The current Stokes-limit implementation wraps
the optional XLB adapter owned by voids.lbm.singlephase.xlb.
For the binary image convention, lattice pressure relation, convergence metric, permeability conversion, and guidance on tuning LBM runs for a new sample, see Map-Based Single-Phase Solvers.
XLB Backend¶
voids.lbm.singlephase.xlb
¶
Direct-image single-phase XLB adapters for binary segmented volumes.
XLBConvergenceWarning
¶
XLBOptions
dataclass
¶
Numerical controls for the direct-image XLB solver.
Attributes:
| Name | Type | Description |
|---|---|---|
formulation |
str
|
Either |
backend |
str
|
XLB compute backend. The current |
precision_policy |
str
|
XLB precision policy name, for example |
collision_model |
str
|
XLB collision operator label passed to the stepper. |
streaming_scheme |
str
|
XLB streaming scheme label passed to the stepper. |
lattice_viscosity |
float
|
Kinematic viscosity in lattice units. |
pressure_inlet_lattice, pressure_outlet_lattice |
Optional inlet and outlet lattice pressures. If both are provided they define the pressure BC directly. |
|
pressure_drop_lattice |
float | None
|
Optional lattice pressure drop. When set without explicit inlet/outlet
pressures, it is applied relative to |
reference_density_lattice |
float
|
Reference lattice density used to construct a baseline outlet pressure
when only |
rho_inlet, rho_outlet |
Legacy density-based BC inputs retained for backward compatibility.
They are converted internally to lattice pressure using
|
|
inlet_outlet_buffer_cells |
int
|
Number of fluid reservoir layers inserted ahead of and behind the sample. |
max_steps, min_steps, check_interval, steady_rtol |
Iteration and convergence controls for the steady-state solve. |
Notes
The current voids adapter uses XLB's JAX backend only. This keeps the
dependency path compatible with CPU-only macOS and Linux environments.
The currently exposed XLB operator is the incompressible Navier-Stokes
lattice-Boltzmann stepper. Setting formulation="steady_stokes_limit"
does not switch to a different PDE solver; it selects conservative forcing
and convergence defaults so the converged solution can be interpreted in the
steady creeping-flow limit.
In this isothermal LBM setting, lattice pressure satisfies
p_lu = c_s^2 rho. The preferred public inputs are therefore the lattice
pressure fields pressure_inlet_lattice / pressure_outlet_lattice or
the pressure drop pressure_drop_lattice. The legacy fields rho_inlet
and rho_outlet remain supported for backward compatibility and are
converted internally to pressure.
Source code in src/voids/lbm/singlephase/xlb.py
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 | |
steady_stokes_defaults
classmethod
¶
Return a conservative preset for the steady creeping-flow limit.
Notes
XLB does not currently expose a separate Stokes-only stepper in the
installed package used by voids. This preset therefore still uses the
incompressible Navier-Stokes LBM operator, but with a smaller lattice
pressure drop and tighter steady-state controls so the converged solution is
interpreted in the low-Reynolds, low-Mach limit.
The buffer and convergence controls are intentionally stricter than the
generic :class:XLBOptions defaults. They were selected from same-ROI
DRP-317 sensitivity runs as a conservative direct-image permeability
preset, not as a fit to experimental permeability.
Source code in src/voids/lbm/singlephase/xlb.py
XLBDirectSimulationResult
dataclass
¶
Store direct-image LBM outputs from an XLB run.
Attributes:
| Name | Type | Description |
|---|---|---|
lattice_pressure_inlet, lattice_pressure_outlet, lattice_pressure_drop |
Resolved inlet, outlet, and differential pressure in lattice units. |
|
lattice_density_inlet, lattice_density_outlet |
Equivalent lattice densities associated with the pressure BCs through
|
|
permeability |
float
|
Apparent permeability mapped back to physical units. |
max_mach_lattice, reynolds_voxel_max |
Low-inertia diagnostics useful when interpreting a run as a creeping-flow reference. |
Source code in src/voids/lbm/singlephase/xlb.py
solve_binary_volume_with_xlb
¶
Solve a binary segmented volume directly with XLB and estimate permeability.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
phases
|
ndarray
|
Binary segmented volume with |
required |
voxel_size
|
float
|
Physical voxel size used when mapping lattice permeability back to physical units. |
required |
flow_axis
|
str | None
|
Requested flow axis. When omitted, the canonical sample axis inferred by
:func: |
None
|
options
|
XLBOptions | None
|
XLB numerical controls. This low-level interface expects lattice-unit
pressure inputs through |
None
|
Returns:
| Type | Description |
|---|---|
XLBDirectSimulationResult
|
Direct-image XLB solution summary and permeability diagnostics. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the input volume, flow axis, or XLB numerical controls are invalid. |
RuntimeError
|
If the run completes with a non-physical permeability estimate. |
Warns:
| Type | Description |
|---|---|
XLBConvergenceWarning
|
If |
Notes
The current adapter uses XLB's incompressible Navier-Stokes lattice
Boltzmann stepper with BGK-style collision and pressure / bounce-back
boundary conditions. If options.formulation == "steady_stokes_limit",
the same stepper is still used; the solution is simply driven more gently
and interpreted in the low-Reynolds, low-Mach steady limit.
The inlet and outlet conditions are pressure boundary conditions. The public
API accepts lattice pressure values or a lattice pressure drop, which are
converted internally to the density values expected by the isothermal LBM
boundary operator through p_lu = c_s^2 rho.
The permeability conversion is based on lattice units:
K_phys = nu_lu * U_lu * L_lu * dx_phys**2 / dp_lu
where U_lu is the superficial sample velocity, nu_lu is the lattice
kinematic viscosity, L_lu is the voxel count along the flow axis, and
dp_lu = p_in,lu - p_out,lu.
This keeps the solve focused on permeability, which is the transport quantity comparable to the PNM solve without requiring a full physical pressure-unit calibration of the lattice simulation.
Source code in src/voids/lbm/singlephase/xlb.py
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 | |
Stokes-Limit XLB Backend¶
voids.lbm.singlephase.stokes
¶
XLBConvergenceWarning
¶
XLBDirectSimulationResult
dataclass
¶
Store direct-image LBM outputs from an XLB run.
Attributes:
| Name | Type | Description |
|---|---|---|
lattice_pressure_inlet, lattice_pressure_outlet, lattice_pressure_drop |
Resolved inlet, outlet, and differential pressure in lattice units. |
|
lattice_density_inlet, lattice_density_outlet |
Equivalent lattice densities associated with the pressure BCs through
|
|
permeability |
float
|
Apparent permeability mapped back to physical units. |
max_mach_lattice, reynolds_voxel_max |
Low-inertia diagnostics useful when interpreting a run as a creeping-flow reference. |
Source code in src/voids/lbm/singlephase/xlb.py
XLBOptions
dataclass
¶
Numerical controls for the direct-image XLB solver.
Attributes:
| Name | Type | Description |
|---|---|---|
formulation |
str
|
Either |
backend |
str
|
XLB compute backend. The current |
precision_policy |
str
|
XLB precision policy name, for example |
collision_model |
str
|
XLB collision operator label passed to the stepper. |
streaming_scheme |
str
|
XLB streaming scheme label passed to the stepper. |
lattice_viscosity |
float
|
Kinematic viscosity in lattice units. |
pressure_inlet_lattice, pressure_outlet_lattice |
Optional inlet and outlet lattice pressures. If both are provided they define the pressure BC directly. |
|
pressure_drop_lattice |
float | None
|
Optional lattice pressure drop. When set without explicit inlet/outlet
pressures, it is applied relative to |
reference_density_lattice |
float
|
Reference lattice density used to construct a baseline outlet pressure
when only |
rho_inlet, rho_outlet |
Legacy density-based BC inputs retained for backward compatibility.
They are converted internally to lattice pressure using
|
|
inlet_outlet_buffer_cells |
int
|
Number of fluid reservoir layers inserted ahead of and behind the sample. |
max_steps, min_steps, check_interval, steady_rtol |
Iteration and convergence controls for the steady-state solve. |
Notes
The current voids adapter uses XLB's JAX backend only. This keeps the
dependency path compatible with CPU-only macOS and Linux environments.
The currently exposed XLB operator is the incompressible Navier-Stokes
lattice-Boltzmann stepper. Setting formulation="steady_stokes_limit"
does not switch to a different PDE solver; it selects conservative forcing
and convergence defaults so the converged solution can be interpreted in the
steady creeping-flow limit.
In this isothermal LBM setting, lattice pressure satisfies
p_lu = c_s^2 rho. The preferred public inputs are therefore the lattice
pressure fields pressure_inlet_lattice / pressure_outlet_lattice or
the pressure drop pressure_drop_lattice. The legacy fields rho_inlet
and rho_outlet remain supported for backward compatibility and are
converted internally to pressure.
Source code in src/voids/lbm/singlephase/xlb.py
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 | |
steady_stokes_defaults
classmethod
¶
Return a conservative preset for the steady creeping-flow limit.
Notes
XLB does not currently expose a separate Stokes-only stepper in the
installed package used by voids. This preset therefore still uses the
incompressible Navier-Stokes LBM operator, but with a smaller lattice
pressure drop and tighter steady-state controls so the converged solution is
interpreted in the low-Reynolds, low-Mach limit.
The buffer and convergence controls are intentionally stricter than the
generic :class:XLBOptions defaults. They were selected from same-ROI
DRP-317 sensitivity runs as a conservative direct-image permeability
preset, not as a fit to experimental permeability.
Source code in src/voids/lbm/singlephase/xlb.py
steady_stokes_options
¶
Return XLB options configured for the steady Stokes-limit formulation.
solve_binary_volume_stokes
¶
Solve Stokes-limit flow on a binary image using the XLB backend.
This is the package-facing LBM namespace for direct-image single-phase
solves. Benchmark utilities consume this lower-level adapter for
verification workflows. The input follows the current XLB adapter
convention: void=1 and solid=0.