solve_flow

solve_flow(
    im,
    direction='x',
    n_steps=15000,
    nu=1.0 / 6.0,
    log_every=500,
    verbose=True,
    sparse=False,
    tol=0.001,
)

Run a pressure-driven single-phase LBM simulation to steady state.

Parameters

Name Type Description Default
im (np.ndarray, shape(nx, ny, nz)) Binary image of the pore space. 1 (or True) = pore, 0 (or False) = solid. This matches the PoreSpy convention. required
direction (x, y, z) Axis along which the pressure gradient is applied. Default 'x'. 'x'
n_steps int Number of LBM time steps to run. Default 15000. 15000
nu float Kinematic viscosity in lattice units. Default 1/6. 1.0 / 6.0
log_every int Print a progress line every this many steps. Default 500. 500
verbose bool Print progress to stdout. Default True. True
sparse bool If True, use Taichi sparse (pointer-backed) storage for the distribution fields. Only pore cells are allocated, which can significantly reduce memory on images with high solid fractions. Default False (dense storage). False
tol float or None Convergence tolerance. The simulation stops early when the relative change in the total velocity magnitude between log intervals falls below this value: delta\|v\| / \|v\| < tol. Set to None to always run the full n_steps. Default 1e-3. 0.001

Returns

Name Type Description
result FlowResult Result object containing solid, rho, velocity, direction, and nu as numpy arrays/values. Pass directly to compute_permeability() or compute_hydraulic_conductance(), or call result.export_to_vtk(prefix) to save a VTR file.

Notes

Taichi must be initialized by the caller before invoking this function:

import taichi as ti
ti.init(arch=ti.cpu)