Skip to content

Add BET simulation to beta module - #1132

Open
jgostick wants to merge 11 commits into
devfrom
BET
Open

Add BET simulation to beta module#1132
jgostick wants to merge 11 commits into
devfrom
BET

Conversation

@jgostick

Copy link
Copy Markdown
Member

No description provided.

@ma-sadeghi ma-sadeghi changed the title Adding BET Simulation to beta Add BET simulation to beta module Dec 5, 2025
SebVaron and others added 11 commits April 28, 2026 03:23
The 'Adsorption v2.py' script is superseded by the proper
_physisorption module, and the .mp4 was an animation artifact
that should not be tracked in the repo.
Major refactor of the BET-style physisorption simulation:

- Lift kelvin_cohan and harkins_jura helpers to module level so they
  are not redefined on every call.
- Fix the unit inconsistency between the Kelvin-Cohan term (computed
  in metres) and the film-thickness sweep (in nm) by converting the
  capillary radius to nm before adding the film thickness. Without
  this fix, the Kelvin correction was numerically swamped by the
  thickness, effectively turning the simulation into a thickness sweep
  with no capillary condensation.
- Add voxel_size, T, gamma, vm, and harkins_jura parameters so the
  function works for fluids other than N2 at 77 K.
- Use the full float-valued EDT for the thickness sweep instead of an
  integer cast, giving a finer isotherm.
- Filter the thickness sweep to keep only steps where Harkins-Jura
  returns p in (0, 1); pressures outside that range are unphysical
  and would crash the algorithm at p=0 or p>=1.
- Mask new-voxel updates with the void mask to keep solid voxels at
  zero in im_ads and im_des.
- Add a NumPy-style docstring with units and Cohan / Harkins-Jura
  references.
- Drop the unused fill_closed_pores import.
The full visual demo (animation, hysteresis loop, parameter sweep)
lives in the educational notebook. The __main__ block is just a
quick sanity check now.
Without this, the function was unreachable as porespy.beta.physisorption
even though the module file existed.
Cover the public physisorption API with 2D and 3D fixtures, and
unit-test the Kelvin-Cohan and Harkins-Jura helpers directly to
guard against future regressions in the underlying physics.
Users (and downstream visualisations) often want to filter the
filling-thickness map at a specific step or annotate isotherm plots
with the corresponding film thickness, both of which need the
thickness sweep used internally. Surfacing them avoids forcing
callers to recover them via Harkins-Jura inversion.
A short, high-signal walk through running physisorption on a 2D blobs
image: hysteresis loop, filling-thickness map, snapshots along the
adsorption branch, and a comparison between N2 at 77 K and Ar at 87 K
showing the parameterisation in action.
@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 70.4%. Comparing base (c352d60) to head (035ece6).

Additional details and impacted files
@@          Coverage Diff          @@
##             dev   #1132   +/-   ##
=====================================
  Coverage   70.4%   70.4%           
=====================================
  Files         45      45           
  Lines       6460    6460           
=====================================
  Hits        4554    4554           
  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 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

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.

3 participants