Metadata-Version: 2.4
Name: poromics
Version: 0.0.8
Summary: A tool for rapid estimation of transport properties of 3D images of porous materials
Author-email: Amin Sadeghi <amin.sadeghi@live.com>
Maintainer-email: Amin Sadeghi <amin.sadeghi@live.com>
License: MIT License
        
        Copyright (c) 2025, Amin Sadeghi
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Requires-Python: <3.13,>=3.10
Requires-Dist: ipykernel>=6.29.5
Requires-Dist: ipython>=8.34.0
Requires-Dist: ipywidgets>=8.1.8
Requires-Dist: juliacall>=0.9.24
Requires-Dist: juliapkg>=0.1.16
Requires-Dist: loguru>=0.7.3
Requires-Dist: numba>=0.59.0
Requires-Dist: numpy>=2.1.3
Requires-Dist: porespy>=2.4.2
Requires-Dist: pydantic-settings
Requires-Dist: pydantic~=2.0
Requires-Dist: rich>=13.9.4
Requires-Dist: taichi>=1.7.4
Requires-Dist: tqdm>=4.67.1
Requires-Dist: typer
Description-Content-Type: text/markdown

# Poromics

Poromics estimates transport properties of 3D porous material images. It is GPU-accelerated and designed to be fast and easy to use.

**Supported properties:**

- **Tortuosity / effective diffusivity** — via Julia-based FD solver (`tortuosity_fd`) or Taichi-based LBM D3Q7 BGK solver (`tortuosity_lbm`)
- **Absolute permeability** — via Taichi-based LBM D3Q19 MRT solver (`permeability_lbm`)

## Installation

The Julia-based FD solver depends on [Tortuosity.jl](https://github.com/ma-sadeghi/Tortuosity.jl/), which is installed automatically. The LBM solvers use [Taichi](https://www.taichi-lang.org/) with automatic GPU detection.

> [!NOTE]
> We highly recommend using `uv` instead of `pip` to install `poromics` (or any other Python package!) as it's extremely faster. It has lots of useful features, but for all practical purposes, it is a drop-in replacement for `pip`.

### Uv

Install [`uv`](https://docs.astral.sh/uv/getting-started/installation/), and then run the following command in a terminal/command prompt:

```shell
uv pip install poromics
```

### Pip

If you prefer to use `pip`, run the following command in a terminal/command prompt:

```shell
pip install poromics
```

## Basic Usage

> [!NOTE]
> The first time you call `tortuosity_fd`, it will take a few minutes to install Julia and the required packages. This is a one-time setup. The LBM solvers (`tortuosity_lbm`, `permeability_lbm`) use Taichi and do not require Julia.

### Tortuosity (Julia FD solver)

```python
import porespy as ps
import poromics

im = ps.generators.blobs(shape=[100, 100, 100], porosity=0.6)
result = poromics.tortuosity_fd(im, axis=0, rtol=1e-5, gpu=True)
print(result.tau, result.D_eff)
```

### Tortuosity (LBM solver)

```python
result = poromics.tortuosity_lbm(im, axis=0, D=1e-9, voxel_size=1e-6)
print(result.tau, result.D_eff)
```

### Permeability (LBM solver)

```python
result = poromics.permeability_lbm(im, axis=0, nu=1e-6, voxel_size=1e-6)
print(result.k)
```

### Result objects

`TortuosityResult` attributes: `im`, `axis`, `porosity`, `tau`, `D_eff`, `c`, `formation_factor`, `D`.

`PermeabilityResult` attributes: `im`, `axis`, `porosity`, `k`, `u_darcy`, `u_pore`, `velocity`, `pressure`.

### Simulation solvers

For more control, use the solver classes directly:

```python
from poromics.simulation import TransientDiffusion, TransientFlow

solver = TransientDiffusion(im, axis=0, D=1e-9, voxel_size=1e-6)
solver.run(n_steps=100_000, tol=1e-2)
print(solver.concentration.shape, solver.converged)
```

## CLI

> [!WARNING]
> The CLI is still in development and not yet functional.

```bash
poromics --help
```

## Acknowledgments

The LBM solvers are based on [taichi_LBM3D](https://github.com/yjhp1016/taichi_LBM3D) by Yi-Jie Huang.

## Roadmap

- [x] Diffusional tortuosity
    - [x] Julia FD solver ([Tortuosity.jl](https://github.com/ma-sadeghi/Tortuosity.jl/))
    - [x] Taichi LBM D3Q7 BGK solver
- [ ] Transient tortuosity
    - [ ] Julia FD solver ([Tortuosity.jl](https://github.com/ma-sadeghi/Tortuosity.jl/))
- [x] Permeability
    - [x] Taichi LBM D3Q19 MRT solver
- [ ] [Electrode tortuosity](https://doi.org/10.1038/s41524-020-00386-4)
- [x] Julia/Taichi coexistence via subprocess isolation
- [ ] Add command-line interface (CLI) for easy usage
- [ ] Add support for [sysimage](https://julialang.github.io/PackageCompiler.jl/dev/sysimages.html) creation upon installation for faster startup
