Skip to content

Promote flux and tau_from_cmap from beta to simulations - #1177

Draft
ma-sadeghi wants to merge 4 commits into
devfrom
feature/1023-move-tau-from-cmap
Draft

Promote flux and tau_from_cmap from beta to simulations#1177
ma-sadeghi wants to merge 4 commits into
devfrom
feature/1023-move-tau-from-cmap

Conversation

@ma-sadeghi

Copy link
Copy Markdown
Member

Closes #1023.

Moves flux and tau_from_cmap from porespy.beta._dns_tools into porespy.simulations._dns_tools, alongside tortuosity_fd. Pure rename — no code changes — plus the import plumbing in simulations/__init__.py and beta/__init__.py and the test imports.

On the edge-case bug I asked about in the issue thread: I went looking for it and couldn't reproduce one. I swept several hundred combinations of ndim ∈ {2, 3}, varied shapes (cubic, anisotropic, long-thin, short-fat down to L=2), porosities 0.4–0.85, multiple seeds, all axes, plus targeted constructions (single-column channels, partially-blocked inlet faces, multiple disjoint percolating clusters, last-layer solids that exercise the _fix_gradient_outlet path). In every case tau_from_cmap(im_conc, im, axis) agreed with tortuosity_fd(im, axis).tortuosity at solver-noise level (worst rel-diff ~1.4e-5, typically 1e-6 or tighter). The boundary fix at the outlet is approximate but safe under tortuosity_fd's outputs because solid voxels and Dirichlet-zero outlet voxels both have c=0, which kills the only term that could disagree.

Three new tests are added to capture the cases I checked manually so future readers can re-audit: low-porosity 2D blobs, an inlet face with a solid half, and an anisotropic 3D shape across all three axes.

Heads-up for #1170 if it lands second: it imports from porespy.beta import flux; that path is gone and needs to become from porespy.simulations import flux.

Moves `flux` and `tau_from_cmap` out of `porespy.beta` into
`porespy.simulations`, alongside `tortuosity_fd`, since they're the
intended companion utilities. No code changes — pure rename + import
plumbing. Test suite updated to import from the new path. Three new
edge-case tests (low-porosity 2D, partially blocked inlet, anisotropic
shape) confirm `tau_from_cmap` agrees with `tortuosity_fd` to
solver-noise level. Closes #1023.
@codecov

codecov Bot commented Apr 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.0%. Comparing base (a2ffcc5) to head (4b7b2e5).
⚠️ Report is 28 commits behind head on dev.

Additional details and impacted files
@@           Coverage Diff           @@
##             dev   #1177     +/-   ##
=======================================
+ Coverage   70.8%   71.0%   +0.1%     
=======================================
  Files         45      46      +1     
  Lines       6533    6578     +45     
=======================================
+ Hits        4627    4672     +45     
  Misses      1906    1906             
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ma-sadeghi
ma-sadeghi requested a review from jgostick April 28, 2026 13:21
@jgostick

jgostick commented May 5, 2026

Copy link
Copy Markdown
Member

@ma-sadeghi I had to reduce the rtol on your 3 tests to 1e-3 from 1e-4 and 1e-5. Maybe you can rerun your checks?

@jgostick
jgostick marked this pull request as draft May 5, 2026 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add function for converting concentration map to tortuosity

2 participants