Warning
This repository is archived and no longer maintained. The IDAKLU solver now lives in the PyBaMM monorepo: https://github.com/pybamm-team/PyBaMM
Please file issues and contributions there. This repo is kept read-only for historical reference.
Standalone repository for the C/C++ solvers used in PyBaMM
From PyPI:
pip install pybammsolvers And from conda-forge (>=v0.7.0 only):
conda install pybammsolvers
# or mamba install pybammsolversThe following solvers are available:
- PyBaMM's IDAKLU solver
For testing new solvers and unsupported architectures, local builds are possible.
The build backend is scikit-build-core;
build-time dependencies (scikit-build-core, pybind11, cmake, ninja) are
resolved automatically via PEP 517 isolation when running pip install.
Nox can be used to do a quick build:
pip install nox
noxThis will setup an environment and attempt to build the library.
Mac dependencies can be installed using brew
brew install libomp
brew reinstall gcc
git submodule update --init --recursive
python install_KLU_Sundials.py
pip install .Linux installs may vary based on the distribution, however, the basic build can be performed with the following commands:
sudo apt-get install libopenblas-dev gcc gfortran make g++ build-essential
git submodule update --init --recursive
python install_KLU_Sundials.py
pip install .If SUNDIALS and SuiteSparse are installed somewhere other than ./.idaklu,
pass paths through pip's --config-settings:
pip install . \
--config-settings=cmake.define.SUNDIALS_ROOT=/path/to/sundials \
--config-settings=cmake.define.SuiteSparse_ROOT=/path/to/suitesparsepip install -e .[dev] installs in editable mode with auto-rebuild on import:
edits to C++ sources trigger a rebuild the next time pybammsolvers is
imported. To force a rebuild manually (e.g. when auto-rebuild is bypassed in
CI):
nox -s dev-rebuildThe project includes comprehensive test suites:
Test pybammsolvers functionality in isolation:
nox -s unit # Run all unit tests
nox -s integration # Run all integration testsVerify compatibility with PyBaMM:
nox -s pybamm-tests # Clone/update PyBaMM and run all tests
nox -s pybamm-tests -- --unit-only # Run only unit tests
nox -s pybamm-tests -- --integration-only # Run only integration tests
nox -s pybamm-tests -- --no-update # Skip git pull (use current version)
nox -s pybamm-tests -- --pybamm-dir ./custom/path # Use existing PyBaMM clone
nox -s pybamm-tests -- --branch main # Use specific branch/tagThe integration tests ensure that changes to pybammsolvers don't break PyBaMM functionality.
Test for performance regressions against released PyBaMM:
nox -s benchmarks