项目 / pybamm-team/PyBaMM
Fast and flexible physics-based battery models in Python
本站整理,非 GitHub 官方 description。
官方快照(gh_history.db,2026-11-25):总榜 未进 Top50 · 日榜 未进 Top50 · 周榜未满 7 天基线(官方不生成) · 月榜暂无官方口径;下方四卡为站内趋势聚合(周卡按上榜次数,非官方 7 日增量窗)。
以下三段按该项目自己的 GitHub README 章节摘录(可合理截断并标明);README 没有对应章节的留空,不编造。
可运行 pip install pybamm。
除默认的恒流放电示例外,也可用 `Experiment` 描述充放电与静置步骤并重复仿真。模型物理、参数、几何、网格、空间离散方法和积分求解器均可调整。新用户可下载[入门指南](https://github.com/pybamm-team/PyBaMM/tree/main/docs/source/examples/notebooks/getting_started/),或在 Google Colab 中打开。也可用 conda 安装 `pybamm-base` 或带额外依赖的 `pybamm`;社区与合作方模型另见 [model zoo](https://docs.pybamm.org/en/latest/source/model_zoo/index.html)。可选求解器包括基于 JAX 的求解器。
来自 GitHub 仓库 README / 主页介绍正文,原样摘录,共 10,289 字节。

#
<div align="center">
[](http://numfocus.org)
[](https://github.com/pybamm-team/PyBaMM/actions/workflows/run_periodic_tests.yml)
[](https://docs.pybamm.org/en/latest/?badge=latest)
[](https://codecov.io/gh/pybamm-team/PyBaMM)
[](https://colab.research.google.com/github/pybamm-team/PyBaMM/blob/main/)
[](https://doi.org/10.5334/jors.309)
[](https://github.com/pybamm-team/PyBaMM/releases)
[](https://github.com/astral-sh/ruff)
[](https://scorecard.dev/viewer/?uri=github.com/pybamm-team/PyBaMM)
</div>
# PyBaMM
PyBaMM (Python Battery Mathematical Modelling) is an open-source battery simulation package
written in Python. Our mission is to accelerate battery modelling research by
providing open-source tools for multi-institutional, interdisciplinary collaboration.
Broadly, PyBaMM consists of
(i) a framework for writing and solving systems
of differential equations,
(ii) a library of battery models and parameters, and
(iii) specialized tools for simulating battery-specific experiments and visualizing the results.
Together, these enable flexible model definitions and fast battery simulations, allowing users to
explore the effect of different battery designs and modeling assumptions under a variety of operating scenarios.
[//]: # (numfocus-fiscal-sponsor-attribution)
PyBaMM uses an [open governance model](https://pybamm.org/governance/)
and is fiscally sponsored by [NumFOCUS](https://numfocus.org/). Consider making
a [tax-deductible donation](https://numfocus.org/donate-for-pybamm) to help the project
pay for developer time, professional services, travel, workshops, and a variety of other needs.
<div align="center">
<a href="https://numfocus.org/project/pybamm">
<img height="60px"
src="https://raw.githubusercontent.com/numfocus/templates/master/images/numfocus-logo.png"
align="center">
</a>
</div>
<br>
## 💻 Using PyBaMM
The easiest way to use PyBaMM is to run a 1C constant-current discharge with a model of your choice with all the default settings:
```python
import pybamm
model = pybamm.lithium_ion.DFN() # Doyle-Fuller-Newman model
sim = pybamm.Simulation(model)
sim.solve([0, 3600]) # solve for 1 hour
sim.plot()
```
or simulate an experiment such as a constant-current discharge followed by a constant-current-constant-voltage charge:
```python
import pybamm
experiment = pybamm.Experiment(
[
(
"Discharge at C/10 for 10 hours or until 3.3 V",
"Rest for 1 hour",
"Charge at 1 A until 4.1 V",
"Hold at 4.1 V until 50 mA",
"Rest for 1 hour",
)
]
* 3,
)
model = pybamm.lithium_ion.DFN()
sim = pybamm.Simulation(model, experiment=experiment)
sim.solve()
sim.plot()
```
However, much greater customisation is available. It is possible to change the physics, parameter values, geometry, submesh type, number of submesh points, methods for spatial discretisation and solver for integration (see DFN [script](https://github.com/pybamm-team/PyBaMM/blob/main/examples/scripts/DFN.py) or [notebook](https://github.com/pybamm-team/PyBaMM/blob/main/docs/source/examples/notebooks/models/DFN.ipynb)).
For new users we recommend the [Getting Started](https://github.com/pybamm-team/PyBaMM/tree/main/docs/source/examples/notebooks/getting_started/) guides. These are intended to be very simple step-by-step guides to show the basic functionality of PyBaMM, and can either be downloaded and used locally, or used online through [Google Colab](https://colab.research.google.com/github/pybamm-team/PyBaMM/blob/main/).
Further details can be found in a number of [detailed examples](https://github.com/pybamm-team/PyBaMM/tree/main/examples), hosted here on
github. In addition, there is a [full API documentation](https://docs.pybamm.org/en/latest/source/api/index.html),
hosted on [Read The Docs](https://readthedocs.org/).
Additional supporting material can be found
[here](https://github.com/pybamm-team/pybamm-supporting-material/).
Note that the examples on the `main` branch are tested on the latest commit. If you are using an older version of PyBaMM from pip, you can switch to the corresponding release tag on GitHub to see the version of the examples that is compatible with that release.
## Versioning
PyBaMM uses [CalVer](https://calver.org/). Version numbers take the form `YY.MM.N.P`, where `YY.MM` is the year and month of the release, `N` is the feature release within that month (`0` for the first), and `P` is the patch level (`0` for the feature release itself). For example, `27.1.0.1` is the first patch of the first feature release in January 2027.
Releases ship when there's something worth releasing, not on a fixed schedule. Any release may contain breaking changes; when it does, they appear under a `## Breaking changes` section at the top of [`CHANGELOG.md`](CHANGELOG.md). Public APIs that are removed or renamed ship a `DeprecationWarning` for at least two prior feature releases first, where technically possible.
See [`RELEASE.md`](RELEASE.md) for the full release policy, including how we define "public API" and what counts as a breaking change.
## 🚀 Installing PyBaMM
PyBaMM is available on GNU/Linux, MacOS and Windows.
We strongly recommend to install PyBaMM within a python virtual environment, in order not to alter any distribution python files.
For instructions on how to create a virtual environment for PyBaMM, see [the documentation](https://docs.pybamm.org/en/latest/source/user_guide/installation/index.html#user-install-label).
### Using pip
[](https://pypi.org/project/pybamm/)
[](https://pypi.org/project/pybamm/)
```bash
pip install pybamm
```
### Using conda
PyBaMM is available as a conda package through the conda-forge channel.
> [!NOTE]
> PyBaMM versions between 24.11.2 and 25.6 (not including these boundary versions) are not available on conda-forge.
[](https://anaconda.org/conda-forge/pybamm-base)
[](https://anaconda.org/conda-forge/pybamm-base)
[](https://anaconda.org/conda-forge/pybamm)
[](https://anaconda.org/conda-forge/pybamm)
```bash
# for no extra dependencies
conda install -c conda-forge pybamm-base
# for all extra dependencies except jax
conda install -c conda-forge pybamm
# optionally install jax >=0.7.0, <0.9.0
conda install -c conda-forge "jax>=0.7.0,<0.9.0"
```
### Optional solvers
The following solvers are optionally available:
- [jax](https://jax.readthedocs.io/en/latest/notebooks/quickstart.html)-based solver, see [the documentation](https://docs.pybamm.org/en/latest/source/user_guide/installation/index.html#optional-jaxsolver).
### Model zoo
Community- and partner-contributed models are distributed separately, in the [model zoo](https://docs.pybamm.org/en/latest/source/model_zoo/index.html):
```bash
pip install pybamm-model-zoo
```
## 📖 Citing PyBaMM
If you use PyBaMM in your work, please cite our paper
> Sulzer, V., Marquis, S. G., Timms, R., Robinson, M., & Chapman, S. J. (2021). Python Battery Mathematical Modelling (PyBaMM). _Journal of Open Research Software, 9(1)_.
You can use the BibTeX
```
@article{Sulzer2021,
title = {{Python Battery Mathematical Modelling (PyBaMM)}},
author = {Sulzer, Valentin and Marquis, Scott G. and Timms, Robert and Robinson, Martin and Chapman, S. Jon},
doi = {10.5334/jors.309},
journal = {Journal of Open Research Software},
publisher = {Software Sustainability Institute},
volume = {9},
number = {1},
pages = {14},
year = {2021}
}
```
We would be grateful if you could also cite the relevant papers. These will change depending on what models and solvers you use. To find out which papers you should cite, add the line
```python
pybamm.print_citations()
```
to the end of your script. This will print BibTeX information to the terminal; passing a filename to `print_citations` will print the BibTeX information to the specified file instead. A list of all citations can also be found in the [citations file](https://github.com/pybamm-team/PyBaMM/blob/main/packages/pybamm/src/pybamm/CITATIONS.bib). In particular, PyBaMM relies heavily on [CasADi](https://web.casadi.org/publications/).
See [CONTRIBUTING.md](https://github.com/pybamm-team/PyBaMM/blob/main/CONTRIBUTING.md#citations) for information on how to add your own citations when you contribute.
## 🛠️ Contributing to PyBaMM
If you'd like to help us develop PyBaMM by adding new methods, writing documentation, or fixing embarrassing bugs, please have a look at these [guidelines](https://github.com/pybamm-team/PyBaMM/blob/main/CONTRIBUTING.md) first.
## 📫 Get in touch
For any questions, comments, suggestions or bug reports, please visit:
- Our [Contact Page](https://pybamm.org/community/)
- Our [Discussion Forum](https://pybamm.discourse.group/)
## 📃 License
PyBaMM is fully open source. For more information about its license, see [LICENSE](https://github.com/pybamm-team/PyBaMM/blob/main/LICENSE.txt).