Skip to main content

Toolbox for batch and 1D reactive transport modeling in porous media aimed on easiness of use for the user without computational background

Project description

PyPI version GitHub issues GitHub forks GitHub stars GitHub license Twitter DOI

PorousMediaLab

The toolbox for batch and 1D reactive transport modelling in porous media aimed at the easiness of use for the user without computational background.

What's New in v2.2.0

Robustness and maintainability improvements with expanded test coverage:

  • Input validation across the solver: division-by-zero guards and a CFL stability warning catch unstable grids early
  • Behavior-preserving refactor of the core ODE/PDE solver and class contracts (boundary conditions, flux estimators, acid-base updates)
  • Removed unused code (sensitivity.py stubs, dead element.py, legacy Python 2 compatibility)
  • Test suite expanded to 389 tests, including mathematical-correctness integration tests

What's New in v2.1.1

Correctness and packaging hardening for solver setup and release artifacts:

  • Validates time and spatial grids to prevent silently shifted dt and dx
  • Fixes ODE derivative ordering, Batch solver dispatch, flux estimators, and calibration depth comparisons
  • Removes obsolete binary build artifacts and legacy upload scripts from the source distribution

What's New in v2.1.0

2.4x overall performance improvement with optimized rate reconstruction:

  • Vectorized reconstruct_rates() method - 45x faster
  • Enabled numexpr multi-threading for parallel rate expression evaluation
  • Pre-allocated arrays in hot loops to reduce memory overhead

What's New in v2.0.0

6-60x faster reaction integration with the new vectorized ODE solver:

  • Reactions are now solved using a vectorized approach that processes all spatial points simultaneously
  • Uses scipy.integrate.solve_ivp with LSODA method (auto-detects stiffness)
  • Backward compatible: use ode_method='scipy_sequential' for the old behavior
Spatial Points Species Speedup
50 2 13x
100 3 23x
500 5 62x

How to use

Have a look at "examples" folder.

Installation using pip

  • Install Python version 3.10 or higher (click);
  • To install the toolbox run pip install porousmedialab
  • In terminal run jupyter notebook;
  • You will see the folders in your home folder. You can navigate in any folder and create a new notebook with your model.

Development installation using Poetry

  • Install Python version 3.10 or higher (click);
  • Install Poetry (click);
  • Clone this repository: git clone https://github.com/biogeochemistry/PorousMediaLab
  • Navigate to the project folder: cd PorousMediaLab
  • Install dependencies: poetry install
  • Run tests: poetry run pytest
  • Activate the virtual environment: poetry shell

Development Commands (Makefile)

The project includes a Makefile for common tasks:

make install       # Install dependencies
make test          # Run test suite
make benchmark     # Run performance optimization benchmark
make benchmark-ode # Run ODE solver benchmark
make build         # Build package
make publish       # Publish to PyPI
make release       # Build and publish
make clean         # Clean build artifacts

Manual installation

  • Install Python version 3.10 or higher (click);
  • Download and unzip or clone (using git) this repository (PorousMediaLab);
  • Open terminal and go to the PorousMediaLab folder using cd command. If you have problems with the terminal, check this guide;
  • Install dependencies: pip install numpy numexpr scipy matplotlib seaborn h5py scikit-learn
  • In terminal run command jupyter notebook;
  • You will see the folders of the PorousMediaLab project; you can go in "examples" folder and play with them.

Testing

To run the test suite:

pip install pytest pytest-cov
pytest tests/ -v

For coverage report:

pytest tests/ --cov=porousmedialab --cov-report=term-missing

Citation

Igor Markelov (2020). Modelling Biogeochemical Cycles Across Scales: From Whole-Lake Phosphorus Dynamics to Microbial Reaction Systems. UWSpace. http://hdl.handle.net/10012/15513

Contribution

I am looking for contributors specifically for incorporation of:

  • sensitivity tests
  • unsaturated flow
  • thermodynamic calculations
  • your crazy ideas and needs

If you wish to contribute in this open source project, please, create pull request or contact me via email: is.markelov@gmail.com.

Acknowledgements

This project was funded by

MIT License

Copyright (c) 2019 Igor Markelov

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

porousmedialab-3.0.0.tar.gz (39.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

porousmedialab-3.0.0-py3-none-any.whl (42.0 kB view details)

Uploaded Python 3

File details

Details for the file porousmedialab-3.0.0.tar.gz.

File metadata

  • Download URL: porousmedialab-3.0.0.tar.gz
  • Upload date:
  • Size: 39.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.13.0 Darwin/25.5.0

File hashes

Hashes for porousmedialab-3.0.0.tar.gz
Algorithm Hash digest
SHA256 391b81c4f00cb6ee575fe60032447fb93e71381f8dbecb5c4c55e34d535ea99d
MD5 896955d196c0356cd25510f31ab8f0da
BLAKE2b-256 4613d5dd1539416380bd72a64aaadbfda8715a3756788fdbc2381b5c763d0ccf

See more details on using hashes here.

File details

Details for the file porousmedialab-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: porousmedialab-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 42.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.13.0 Darwin/25.5.0

File hashes

Hashes for porousmedialab-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 969b3319c8339a44c08c42f1f7c3950d3e7f3048b60cd4a308d30376160bbb67
MD5 82ef465b7faa5703b52f6f5b54f92175
BLAKE2b-256 b6cbdcc4ffdf6df100314675f78bab8978bab71f2e9a9dd3c6765c566afc959f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page