PyBaMM-GEM 0.1.0__tar.gz → 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. pybamm_gem-0.2.1/.github/workflows/ci.yml +53 -0
  2. pybamm_gem-0.2.1/.github/workflows/release.yml +103 -0
  3. pybamm_gem-0.2.1/.gitignore +9 -0
  4. pybamm_gem-0.2.1/CHANGELOG.md +18 -0
  5. pybamm_gem-0.1.0/LICENSE → pybamm_gem-0.2.1/LICENSE.txt +29 -28
  6. pybamm_gem-0.2.1/LICENSES-bundled.txt +37 -0
  7. pybamm_gem-0.2.1/PKG-INFO +78 -0
  8. pybamm_gem-0.2.1/README.md +61 -0
  9. pybamm_gem-0.2.1/examples/higher_dimensional_models.ipynb +622 -0
  10. pybamm_gem-0.2.1/pyproject.toml +43 -0
  11. pybamm_gem-0.2.1/src/pybamm_gem/__init__.py +18 -0
  12. pybamm_gem-0.2.1/src/pybamm_gem/_registry.py +96 -0
  13. pybamm_gem-0.2.1/src/pybamm_gem/dfn_2d/CITATION.bib +28 -0
  14. pybamm_gem-0.2.1/src/pybamm_gem/dfn_2d/README.md +42 -0
  15. pybamm_gem-0.2.1/src/pybamm_gem/dfn_2d/__init__.py +3 -0
  16. pybamm_gem-0.2.1/src/pybamm_gem/dfn_2d/examples/run_dfn_2d.py +29 -0
  17. pybamm_gem-0.2.1/src/pybamm_gem/dfn_2d/model.py +248 -0
  18. pybamm_gem-0.2.1/src/pybamm_gem/dfn_2d/model.toml +21 -0
  19. pybamm_gem-0.2.1/src/pybamm_gem/dfn_2d/tests/test_dfn_2d.py +21 -0
  20. pybamm_gem-0.2.1/src/pybamm_gem/dfn_3d/CITATION.bib +28 -0
  21. pybamm_gem-0.2.1/src/pybamm_gem/dfn_3d/README.md +43 -0
  22. pybamm_gem-0.2.1/src/pybamm_gem/dfn_3d/__init__.py +3 -0
  23. pybamm_gem-0.2.1/src/pybamm_gem/dfn_3d/examples/run_dfn_3d.py +29 -0
  24. pybamm_gem-0.2.1/src/pybamm_gem/dfn_3d/model.py +14 -0
  25. pybamm_gem-0.2.1/src/pybamm_gem/dfn_3d/model.toml +21 -0
  26. pybamm_gem-0.2.1/src/pybamm_gem/dfn_3d/tests/test_dfn_3d.py +21 -0
  27. pybamm_gem-0.2.1/src/pybamm_gem/lithium_ion/__init__.py +6 -0
  28. pybamm_gem-0.2.1/src/pybamm_gem/spm_2d/CITATION.bib +17 -0
  29. pybamm_gem-0.2.1/src/pybamm_gem/spm_2d/README.md +40 -0
  30. pybamm_gem-0.2.1/src/pybamm_gem/spm_2d/__init__.py +3 -0
  31. pybamm_gem-0.2.1/src/pybamm_gem/spm_2d/examples/run_spm_2d.py +24 -0
  32. pybamm_gem-0.2.1/src/pybamm_gem/spm_2d/model.py +309 -0
  33. pybamm_gem-0.2.1/src/pybamm_gem/spm_2d/model.toml +21 -0
  34. pybamm_gem-0.2.1/src/pybamm_gem/spm_2d/tests/test_spm_2d.py +35 -0
  35. pybamm_gem-0.2.1/src/pybamm_gem/spm_3d/CITATION.bib +17 -0
  36. pybamm_gem-0.2.1/src/pybamm_gem/spm_3d/README.md +39 -0
  37. pybamm_gem-0.2.1/src/pybamm_gem/spm_3d/__init__.py +3 -0
  38. pybamm_gem-0.2.1/src/pybamm_gem/spm_3d/examples/run_spm_3d.py +35 -0
  39. pybamm_gem-0.2.1/src/pybamm_gem/spm_3d/model.py +79 -0
  40. pybamm_gem-0.2.1/src/pybamm_gem/spm_3d/model.toml +21 -0
  41. pybamm_gem-0.2.1/src/pybamm_gem/spm_3d/tests/test_spm_3d.py +18 -0
  42. pybamm_gem-0.2.1/tests/test_registry.py +72 -0
  43. pybamm_gem-0.1.0/.git_archival.txt +0 -4
  44. pybamm_gem-0.1.0/.gitattributes.txt +0 -1
  45. pybamm_gem-0.1.0/.gitignore +0 -129
  46. pybamm_gem-0.1.0/.pre-commit-config.yaml +0 -65
  47. pybamm_gem-0.1.0/.readthedocs.yml +0 -28
  48. pybamm_gem-0.1.0/CITATION.cff +0 -25
  49. pybamm_gem-0.1.0/CODE_OF_CONDUCT.md +0 -45
  50. pybamm_gem-0.1.0/CONTRIBUTING.md +0 -150
  51. pybamm_gem-0.1.0/LICENSES-bundled.txt +0 -10
  52. pybamm_gem-0.1.0/PKG-INFO +0 -175
  53. pybamm_gem-0.1.0/README.md +0 -127
  54. pybamm_gem-0.1.0/docs/_static/.gitkeep +0 -0
  55. pybamm_gem-0.1.0/docs/architecture.md +0 -42
  56. pybamm_gem-0.1.0/docs/conf.py +0 -191
  57. pybamm_gem-0.1.0/docs/design_principles.md +0 -101
  58. pybamm_gem-0.1.0/docs/index.md +0 -17
  59. pybamm_gem-0.1.0/docs/refs.bib +0 -0
  60. pybamm_gem-0.1.0/examples/01_parameter_set_registration_demo.ipynb +0 -259
  61. pybamm_gem-0.1.0/noxfile.py +0 -70
  62. pybamm_gem-0.1.0/pyproject.toml +0 -139
  63. pybamm_gem-0.1.0/src/pybamm_gem/__init__.py +0 -77
  64. pybamm_gem-0.1.0/src/pybamm_gem/_version.py +0 -24
  65. pybamm_gem-0.1.0/src/pybamm_gem/entry_point.py +0 -154
  66. pybamm_gem-0.1.0/src/pybamm_gem/models/input/ExampleReservoir.py +0 -200
  67. pybamm_gem-0.1.0/src/pybamm_gem/models/input/ExampleSPM.py +0 -215
  68. pybamm_gem-0.1.0/src/pybamm_gem/parameters/input/ExampleChen2020.py +0 -371
  69. pybamm_gem-0.1.0/src/pybamm_gem/parameters/input/Imperial2026.py +0 -352
  70. pybamm_gem-0.1.0/src/pybamm_gem/py.typed +0 -0
  71. pybamm_gem-0.1.0/tests/generated_project_tests/test_entry_points.py +0 -46
  72. pybamm_gem-0.1.0/tests/user_tests/test_package.py +0 -5
@@ -0,0 +1,53 @@
1
+ # Runs the tests on every push and pull request, and every Monday, against the latest
2
+ # PyBaMM release. A failing scheduled run opens ONE issue (or adds a comment to the open
3
+ # one). It never changes any code.
4
+ name: CI
5
+
6
+ on:
7
+ push:
8
+ pull_request:
9
+ schedule:
10
+ - cron: "17 6 * * 1"
11
+ workflow_dispatch:
12
+
13
+ permissions:
14
+ contents: read
15
+ issues: write
16
+
17
+ jobs:
18
+ release:
19
+ name: PyBaMM release
20
+ runs-on: ubuntu-latest
21
+ steps:
22
+ - uses: actions/checkout@v4
23
+ - uses: actions/setup-python@v5
24
+ with:
25
+ python-version: "3.12"
26
+ - name: Install
27
+ run: |
28
+ pip install --upgrade pip
29
+ pip install -e ".[dev]"
30
+ - name: Lint
31
+ run: ruff check src tests
32
+ - name: Test
33
+ run: pytest
34
+
35
+ report:
36
+ name: Report a failure
37
+ needs: [release]
38
+ if: ${{ always() && github.event_name == 'schedule' && needs.release.result == 'failure' }}
39
+ runs-on: ubuntu-latest
40
+ steps:
41
+ - name: Open an issue, or comment on the open one
42
+ env:
43
+ GH_TOKEN: ${{ github.token }}
44
+ REPO: ${{ github.repository }}
45
+ RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
46
+ run: |
47
+ TITLE="Weekly check failed"
48
+ NUMBER=$(gh issue list --repo "$REPO" --state open --search "$TITLE in:title" --json number --jq '.[0].number')
49
+ if [ -z "$NUMBER" ]; then
50
+ gh issue create --repo "$REPO" --title "$TITLE" --body "The weekly check failed. See $RUN_URL"
51
+ else
52
+ gh issue comment "$NUMBER" --repo "$REPO" --body "Failed again. See $RUN_URL"
53
+ fi
@@ -0,0 +1,103 @@
1
+ # Publishes PyBaMM-GEM when a GitHub release is published (tag "v" + the version in pyproject.toml).
2
+ # 1. Build the package and run its tests.
3
+ # 2. Upload to TestPyPI, install it from there and run the tests again.
4
+ # 3. Upload to PyPI. This step waits until a maintainer approves it (GitHub environment "pypi").
5
+ # No tokens are stored anywhere: PyPI and TestPyPI trust this workflow ("trusted publishing").
6
+ # Running it by hand (Actions -> Release -> Run workflow) only does steps 1 and 2, as a test.
7
+ name: Release
8
+
9
+ on:
10
+ release:
11
+ types: [published]
12
+ workflow_dispatch:
13
+
14
+ permissions:
15
+ contents: read
16
+
17
+ jobs:
18
+ build:
19
+ name: Build and test
20
+ runs-on: ubuntu-latest
21
+ steps:
22
+ - uses: actions/checkout@v4
23
+ - uses: actions/setup-python@v5
24
+ with:
25
+ python-version: "3.12"
26
+ - name: Check that the release tag matches the version
27
+ if: github.event_name == 'release'
28
+ run: |
29
+ VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
30
+ if [ "v$VERSION" != "$GITHUB_REF_NAME" ]; then
31
+ echo "The tag is $GITHUB_REF_NAME but pyproject.toml says version $VERSION"
32
+ exit 1
33
+ fi
34
+ - name: Build
35
+ run: |
36
+ pip install build twine
37
+ python -m build
38
+ twine check dist/*
39
+ - name: Test the built package
40
+ run: |
41
+ pip install dist/*.whl pytest
42
+ cd /tmp
43
+ pytest --import-mode=importlib --pyargs pybamm_gem
44
+ - uses: actions/upload-artifact@v4
45
+ with:
46
+ name: dist
47
+ path: dist/
48
+
49
+ testpypi:
50
+ name: Upload to TestPyPI
51
+ needs: build
52
+ runs-on: ubuntu-latest
53
+ environment: testpypi
54
+ permissions:
55
+ id-token: write
56
+ steps:
57
+ - uses: actions/download-artifact@v4
58
+ with:
59
+ name: dist
60
+ path: dist/
61
+ - uses: pypa/gh-action-pypi-publish@release/v1
62
+ with:
63
+ repository-url: https://test.pypi.org/legacy/
64
+ skip-existing: true
65
+
66
+ check-testpypi:
67
+ name: Install from TestPyPI and test
68
+ needs: testpypi
69
+ runs-on: ubuntu-latest
70
+ steps:
71
+ - uses: actions/checkout@v4
72
+ - uses: actions/setup-python@v5
73
+ with:
74
+ python-version: "3.12"
75
+ - name: Install and test
76
+ run: |
77
+ VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
78
+ pip install "pybamm[cite]>=26.9" pytest
79
+ # A new upload can take a few minutes to appear on TestPyPI
80
+ for attempt in 1 2 3 4 5 6 7 8 9 10; do
81
+ if pip install --no-deps --index-url https://test.pypi.org/simple/ "pybamm-gem==$VERSION"; then
82
+ break
83
+ fi
84
+ sleep 30
85
+ done
86
+ cd /tmp
87
+ python -c "import pybamm_gem; print(pybamm_gem.__version__, pybamm_gem.list_models())"
88
+ pytest --import-mode=importlib --pyargs pybamm_gem
89
+
90
+ pypi:
91
+ name: Upload to PyPI (needs approval)
92
+ needs: check-testpypi
93
+ if: github.event_name == 'release'
94
+ runs-on: ubuntu-latest
95
+ environment: pypi
96
+ permissions:
97
+ id-token: write
98
+ steps:
99
+ - uses: actions/download-artifact@v4
100
+ with:
101
+ name: dist
102
+ path: dist/
103
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,9 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ build/
5
+ dist/
6
+ .venv*/
7
+ .pytest_cache/
8
+ .ruff_cache/
9
+ .ipynb_checkpoints/
@@ -0,0 +1,18 @@
1
+ # Changelog
2
+
3
+ ## 0.2.1
4
+
5
+ - `pybamm_gem` now has the same commands as the PyBaMM model zoo: `require()` is new, and
6
+ `info()`, `load()`, `require()` and `register_citation()` accept the class name (for example
7
+ `"BasicSPM2D"`) as well as the slug (`"spm_2d"`).
8
+ - `info()` fields can be read as `info.title` as well as `info["title"]`.
9
+
10
+ ## 0.2.0
11
+
12
+ - Rebuilt in the PyBaMM model-zoo layout: one folder per model, each with a `model.toml`
13
+ manifest, `CITATION.bib`, `README.md`, tests and an example.
14
+ - Models: `spm_2d` (`BasicSPM2D`), `spm_3d` (`BasicSPM3D`), `dfn_2d` (`DFN2D`) and `dfn_3d` (`DFN3D`).
15
+ - Registry: `pybamm_gem.list_models()`, `pybamm_gem.info()` and `pybamm_gem.load()`.
16
+ - Example notebook: `examples/higher_dimensional_models.ipynb`.
17
+ - Needs PyBaMM 26.9 or newer.
18
+ - The previous code is kept on the branch `legacy-2026-11`.
@@ -1,28 +1,29 @@
1
- BSD 3-Clause License
2
-
3
- Copyright (c) 2026, Mohammed Asheruddin (Asher)
4
-
5
- Redistribution and use in source and binary forms, with or without
6
- modification, are permitted provided that the following conditions are met:
7
-
8
- 1. Redistributions of source code must retain the above copyright notice, this
9
- list of conditions and the following disclaimer.
10
-
11
- 2. Redistributions in binary form must reproduce the above copyright notice,
12
- this list of conditions and the following disclaimer in the documentation
13
- and/or other materials provided with the distribution.
14
-
15
- 3. Neither the name of the copyright holder nor the names of its
16
- contributors may be used to endorse or promote products derived from
17
- this software without specific prior written permission.
18
-
19
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, Imperial College London
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ 3. Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,37 @@
1
+ PyBaMM-GEM contains code adapted from PyBaMM (https://github.com/pybamm-team/PyBaMM):
2
+
3
+ - src/pybamm_gem/spm_2d/model.py, adapted from pybamm/models/full_battery_models/lithium_ion/basic_spm.py
4
+ - src/pybamm_gem/dfn_2d/model.py, the electrolyte and electrode submodel methods, adapted from
5
+ pybamm/models/submodels/electrolyte_conductivity/full_conductivity.py,
6
+ pybamm/models/submodels/electrolyte_diffusion/full_diffusion.py and
7
+ pybamm/models/submodels/electrode/ohm/full_ohm.py
8
+
9
+ PyBaMM is distributed under the following licence:
10
+
11
+ Copyright (c) 2018, the PyBaMM team.
12
+ All rights reserved.
13
+
14
+ Redistribution and use in source and binary forms, with or without
15
+ modification, are permitted provided that the following conditions are met:
16
+
17
+ * Redistributions of source code must retain the above copyright notice, this
18
+ list of conditions and the following disclaimer.
19
+
20
+ * Redistributions in binary form must reproduce the above copyright notice,
21
+ this list of conditions and the following disclaimer in the documentation
22
+ and/or other materials provided with the distribution.
23
+
24
+ * Neither the name of the copyright holder nor the names of its
25
+ contributors may be used to endorse or promote products derived from
26
+ this software without specific prior written permission.
27
+
28
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
31
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
32
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
34
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
35
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
36
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,78 @@
1
+ Metadata-Version: 2.5
2
+ Name: PyBaMM-GEM
3
+ Version: 0.2.1
4
+ Summary: Spatially resolved (2D and 3D) battery models for PyBaMM
5
+ Author: Mohammed Asheruddin N
6
+ License-Expression: BSD-3-Clause
7
+ License-File: LICENSE.txt
8
+ License-File: LICENSES-bundled.txt
9
+ Keywords: battery,electrochemistry,lithium-ion,modelling,pybamm,simulation
10
+ Requires-Python: >=3.10
11
+ Requires-Dist: pybamm[cite]>=26.9
12
+ Requires-Dist: tomli>=2.0.1; python_version < '3.11'
13
+ Provides-Extra: dev
14
+ Requires-Dist: pytest; extra == 'dev'
15
+ Requires-Dist: ruff; extra == 'dev'
16
+ Description-Content-Type: text/markdown
17
+
18
+ # PyBaMM-GEM
19
+
20
+ Spatially resolved (2D and 3D) battery models built on [PyBaMM](https://pybamm.org), laid out
21
+ like the PyBaMM model zoo: one folder per model, each with a `model.toml` manifest, a
22
+ `CITATION.bib`, a README, tests and an example.
23
+
24
+ ## Models
25
+
26
+ | Slug | Class | What it is |
27
+ |---|---|---|
28
+ | `spm_2d` | `BasicSPM2D` | Single Particle Model with a pair of particles at every height z |
29
+ | `spm_3d` | `BasicSPM3D` | The same, over a y-z grid of points |
30
+ | `dfn_2d` | `DFN2D` | Doyle-Fuller-Newman model resolved in x and z |
31
+ | `dfn_3d` | `DFN3D` | The same, resolved in x, y and z |
32
+
33
+ ## Installation
34
+
35
+ ```
36
+ pip install git+https://github.com/ImperialCollegeLondon/PyBaMM-GEM
37
+ ```
38
+
39
+ PyBaMM 26.9 or newer is needed.
40
+
41
+ ## Usage
42
+
43
+ ```python
44
+ import pybamm
45
+ import pybamm_gem as gem
46
+
47
+ print(gem.list_models())
48
+ model = gem.load("spm_2d")()
49
+ simulation = pybamm.Simulation(model)
50
+ solution = simulation.solve([0, 3000])
51
+ print(solution["Voltage [V]"](1500))
52
+ ```
53
+
54
+ The classes are also available directly, for example `gem.lithium_ion.BasicSPM2D` or
55
+ `gem.lithium_ion.DFN2D`.
56
+
57
+ The commands are the same as in the PyBaMM model zoo (`pybamm_model_zoo`): `list_models()`,
58
+ `info()`, `load()`, `require()` and `register_citation()`. `info()`, `load()`, `require()` and
59
+ `register_citation()` take either the slug (`"spm_2d"`) or the class name (`"BasicSPM2D"`);
60
+ `list_models()` returns the slugs. With `pybamm-model-zoo` installed, the GEM models are also
61
+ listed by `pybamm_model_zoo.list_models()`.
62
+
63
+ The notebook `examples/higher_dimensional_models.ipynb` runs all four models, compares them with
64
+ the stock PyBaMM models and shows a temperature that changes with height.
65
+
66
+ ## Licence
67
+
68
+ BSD 3-Clause, see `LICENSE.txt`. Copyright (c) 2026, Imperial College London.
69
+ Some of the model code is adapted from PyBaMM; see `LICENSES-bundled.txt`.
70
+
71
+ ## Releasing a new version
72
+
73
+ 1. In a pull request, raise `version` in `pyproject.toml` (for example `0.2.1`) and add a
74
+ `CHANGELOG.md` entry. Merge it.
75
+ 2. On GitHub, go to Releases, then "Draft a new release". Create the tag `v0.2.1` (a "v" and
76
+ the version), add a title and notes, and publish.
77
+ 3. The Release workflow builds and tests the package, uploads it to TestPyPI and tests it again.
78
+ It then waits for a maintainer to approve the upload to PyPI (GitHub sends an email).
@@ -0,0 +1,61 @@
1
+ # PyBaMM-GEM
2
+
3
+ Spatially resolved (2D and 3D) battery models built on [PyBaMM](https://pybamm.org), laid out
4
+ like the PyBaMM model zoo: one folder per model, each with a `model.toml` manifest, a
5
+ `CITATION.bib`, a README, tests and an example.
6
+
7
+ ## Models
8
+
9
+ | Slug | Class | What it is |
10
+ |---|---|---|
11
+ | `spm_2d` | `BasicSPM2D` | Single Particle Model with a pair of particles at every height z |
12
+ | `spm_3d` | `BasicSPM3D` | The same, over a y-z grid of points |
13
+ | `dfn_2d` | `DFN2D` | Doyle-Fuller-Newman model resolved in x and z |
14
+ | `dfn_3d` | `DFN3D` | The same, resolved in x, y and z |
15
+
16
+ ## Installation
17
+
18
+ ```
19
+ pip install git+https://github.com/ImperialCollegeLondon/PyBaMM-GEM
20
+ ```
21
+
22
+ PyBaMM 26.9 or newer is needed.
23
+
24
+ ## Usage
25
+
26
+ ```python
27
+ import pybamm
28
+ import pybamm_gem as gem
29
+
30
+ print(gem.list_models())
31
+ model = gem.load("spm_2d")()
32
+ simulation = pybamm.Simulation(model)
33
+ solution = simulation.solve([0, 3000])
34
+ print(solution["Voltage [V]"](1500))
35
+ ```
36
+
37
+ The classes are also available directly, for example `gem.lithium_ion.BasicSPM2D` or
38
+ `gem.lithium_ion.DFN2D`.
39
+
40
+ The commands are the same as in the PyBaMM model zoo (`pybamm_model_zoo`): `list_models()`,
41
+ `info()`, `load()`, `require()` and `register_citation()`. `info()`, `load()`, `require()` and
42
+ `register_citation()` take either the slug (`"spm_2d"`) or the class name (`"BasicSPM2D"`);
43
+ `list_models()` returns the slugs. With `pybamm-model-zoo` installed, the GEM models are also
44
+ listed by `pybamm_model_zoo.list_models()`.
45
+
46
+ The notebook `examples/higher_dimensional_models.ipynb` runs all four models, compares them with
47
+ the stock PyBaMM models and shows a temperature that changes with height.
48
+
49
+ ## Licence
50
+
51
+ BSD 3-Clause, see `LICENSE.txt`. Copyright (c) 2026, Imperial College London.
52
+ Some of the model code is adapted from PyBaMM; see `LICENSES-bundled.txt`.
53
+
54
+ ## Releasing a new version
55
+
56
+ 1. In a pull request, raise `version` in `pyproject.toml` (for example `0.2.1`) and add a
57
+ `CHANGELOG.md` entry. Merge it.
58
+ 2. On GitHub, go to Releases, then "Draft a new release". Create the tag `v0.2.1` (a "v" and
59
+ the version), add a title and notes, and publish.
60
+ 3. The Release workflow builds and tests the package, uploads it to TestPyPI and tests it again.
61
+ It then waits for a maintainer to approve the upload to PyPI (GitHub sends an email).