Skip to content

Commit

Permalink
Merge branch 'develop' into issue3051-BPX-diffusivity-activation-ener…
Browse files Browse the repository at this point in the history
…gies
  • Loading branch information
darryl-ad authored Sep 19, 2023
2 parents c943216 + a270b08 commit dc3c6ed
Show file tree
Hide file tree
Showing 79 changed files with 5,372 additions and 2,288 deletions.
21 changes: 21 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,27 @@
"ideas",
"bug"
]
},
{
"login": "bobonice",
"name": "bobonice",
"avatar_url": "https://avatars.githubusercontent.com/u/22030806?v=4",
"profile": "https://github.com/bobonice",
"contributions": [
"bug",
"code"
]
},
{
"login": "kratman",
"name": "Eric G. Kratz",
"avatar_url": "https://avatars.githubusercontent.com/u/10170302?v=4",
"profile": "https://github.com/kratman",
"contributions": [
"doc",
"infra",
"bug"
]
}
],
"contributorsPerLine": 7,
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/lychee_url_checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
--accept 200,429
--exclude-path ./CHANGELOG.md
--exclude-path ./scripts/update_version.py
--exclude-path docs/conf.py
'./**/*.rst'
'./**/*.md'
'./**/*.py'
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ci:

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.0.284"
rev: "v0.0.288"
hooks:
- id: ruff
args: [--fix, --ignore=E741, --exclude=__init__.py]
Expand All @@ -17,7 +17,7 @@ repos:
args: ["--fix","--ignore=E501,E402"]

- repo: https://github.com/adamchainz/blacken-docs
rev: "1.15.0"
rev: "1.16.0"
hooks:
- id: blacken-docs
additional_dependencies: [black==22.12.0]
Expand Down
14 changes: 9 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
# [Unreleased](https://github.com/pybamm-team/PyBaMM/)

## Features

- The parameter "Ambient temperature [K]" can now be given as a function of position `(y,z)` and time `t`. The "edge" and "current collector" heat transfer coefficient parameters can also depend on `(y,z)` ([#3257](https://github.com/pybamm-team/PyBaMM/pull/3257))
- Spherical and cylindrical shell domains can now be solved with any boundary conditions ([#3237](https://github.com/pybamm-team/PyBaMM/pull/3237))
- Processed variables now get the spatial variables automatically, allowing plotting of more generic models ([#3234](https://github.com/pybamm-team/PyBaMM/pull/3234))
- Numpy functions now work with PyBaMM symbols (e.g. `np.exp(pybamm.Symbol("a"))` returns `pybamm.Exp(pybamm.Symbol("a"))`). This means that parameter functions can be specified using numpy functions instead of pybamm functions. Additionally, combining numpy arrays with pybamm objects now works (the numpy array is converted to a pybamm array) ([#3205](https://github.com/pybamm-team/PyBaMM/pull/3205))
- Implement the MSMR model ([#3116](https://github.com/pybamm-team/PyBaMM/pull/3116))

## Bug fixes

- Fixed bug causing incorrect activation energies using `create_from_bpx()` ([#3242](https://github.com/pybamm-team/PyBaMM/pull/3242))
- Fixed a bug that caused incorrect results of “{Domain} electrode thickness change [m]” due to the absence of dimension for the variable `electrode_thickness_change`([#3329](https://github.com/pybamm-team/PyBaMM/pull/3329)).
- Fixed a bug that occured in `check_ys_are_not_too_large` when trying to reference `y-slice` where the referenced variable was not a `pybamm.StateVector` ([#3313](https://github.com/pybamm-team/PyBaMM/pull/3313)
- Fixed a bug with `_Heaviside._evaluate_for_shape` which meant some expressions involving heaviside function and subtractions did not work ([#3306](https://github.com/pybamm-team/PyBaMM/pull/3306))
- The `OneDimensionalX` thermal model has been updated to account for edge/tab cooling and account for the current collector volumetric heat capacity. It now gives the correct behaviour compared with a lumped model with the correct total heat transfer coefficient and surface area for cooling. ([#3042](https://github.com/pybamm-team/PyBaMM/pull/3042))
- Fixed a bug where the "basic" lithium-ion models gave incorrect results when using nonlinear particle diffusivity ([#3207](https://github.com/pybamm-team/PyBaMM/pull/3207))
- Particle size distributions now work with SPMe and NewmanTobias models ([#3207](https://github.com/pybamm-team/PyBaMM/pull/3207))
- Fix to simulate c_rate steps with drive cycles ([#3186](https://github.com/pybamm-team/PyBaMM/pull/3186))
- Parameters in `Prada2013` have been updated to better match those given in the paper, which is a 2.3 Ah cell, instead of the mix-and-match with the 1.1 Ah cell from Lain2019.
- Error generated when invalid parameter values are passed. ([#3132](https://github.com/pybamm-team/PyBaMM/pull/3132))
- Thevenin() model is now constructed with standard variables: `Time [s], Time [min], Time [h]` ([#3143](https://github.com/pybamm-team/PyBaMM/pull/3143))
- Always save last cycle in experiment, to fix issues with `starting_solution` and `last_state` ([#3177](https://github.com/pybamm-team/PyBaMM/pull/3177))
- Fix simulations with `starting_solution` to work with `start_time` experiments ([#3177](https://github.com/pybamm-team/PyBaMM/pull/3177))
- Fix SEI Example Notebook ([#3166](https://github.com/pybamm-team/PyBaMM/pull/3166))
- Thevenin() model is now constructed with standard variables: `Time [s]`, `Time [min]`, `Time [h]` ([#3143](https://github.com/pybamm-team/PyBaMM/pull/3143))
- Error generated when invalid parameter values are passed ([#3132](https://github.com/pybamm-team/PyBaMM/pull/3132))
- Parameters in `Prada2013` have been updated to better match those given in the paper, which is a 2.3 Ah cell, instead of the mix-and-match with the 1.1 Ah cell from Lain2019 ([#3096](https://github.com/pybamm-team/PyBaMM/pull/3096))



## Breaking changes

Expand Down
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
[![code style](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-61-orange.svg)](#-contributors)
[![All Contributors](https://img.shields.io/badge/all_contributors-63-orange.svg)](#-contributors)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

</div>
Expand Down Expand Up @@ -54,6 +54,7 @@ The easiest way to use PyBaMM is to run a 1C constant-current discharge with a m

```python3
import pybamm

model = pybamm.lithium_ion.DFN() # Doyle-Fuller-Newman model
sim = pybamm.Simulation(model)
sim.solve([0, 3600]) # solve for 1 hour
Expand All @@ -64,13 +65,16 @@ or simulate an experiment such as a constant-current discharge followed by a con

```python3
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")
(
"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,
)
Expand Down Expand Up @@ -259,6 +263,8 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<td align="center" valign="top" width="14.28%"><a href="https://batterycontrolgroup.engin.umich.edu/"><img src="https://avatars.githubusercontent.com/u/633873?v=4?s=100" width="100px;" alt="Jason Siegel"/><br /><sub><b>Jason Siegel</b></sub></a><br /><a href="https://github.com/pybamm-team/PyBaMM/commits?author=js1tr3" title="Code">💻</a> <a href="#ideas-js1tr3" title="Ideas, Planning, & Feedback">🤔</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/tommaull"><img src="https://avatars.githubusercontent.com/u/101814207?v=4?s=100" width="100px;" alt="Tom Maull"/><br /><sub><b>Tom Maull</b></sub></a><br /><a href="https://github.com/pybamm-team/PyBaMM/commits?author=tommaull" title="Code">💻</a> <a href="https://github.com/pybamm-team/PyBaMM/commits?author=tommaull" title="Tests">⚠️</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/ejfdickinson"><img src="https://avatars.githubusercontent.com/u/116663050?v=4?s=100" width="100px;" alt="ejfdickinson"/><br /><sub><b>ejfdickinson</b></sub></a><br /><a href="#ideas-ejfdickinson" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/pybamm-team/PyBaMM/issues?q=author%3Aejfdickinson" title="Bug reports">🐛</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/bobonice"><img src="https://avatars.githubusercontent.com/u/22030806?v=4?s=100" width="100px;" alt="bobonice"/><br /><sub><b>bobonice</b></sub></a><br /><a href="https://github.com/pybamm-team/PyBaMM/issues?q=author%3Abobonice" title="Bug reports">🐛</a> <a href="https://github.com/pybamm-team/PyBaMM/commits?author=bobonice" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/kratman"><img src="https://avatars.githubusercontent.com/u/10170302?v=4?s=100" width="100px;" alt="Eric G. Kratz"/><br /><sub><b>Eric G. Kratz</b></sub></a><br /><a href="https://github.com/pybamm-team/PyBaMM/commits?author=kratman" title="Documentation">📖</a> <a href="#infra-kratman" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="https://github.com/pybamm-team/PyBaMM/issues?q=author%3Akratman" title="Bug reports">🐛</a></td>
</tr>
</tbody>
</table>
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ Note that benchmark functions _must_ start with the prefix `time_`, for instance

```python3
def time_solve_SPM_ScipySolver(self):
solver = pb.ScipySolver()
solver.solve(self.model, [0, 3600])
solver = pb.ScipySolver()
solver.solve(self.model, [0, 3600])
```

In the case where some setup is necessary, but should not be timed, a `setup` function
Expand All @@ -76,7 +76,7 @@ class TimeSPM:
model = pb.lithium_ion.SPM()
geometry = model.default_geometry

# ...
# ...

self.model = model

Expand Down
46 changes: 42 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,14 +303,52 @@
# a conflict with the sphinx-docsearch extension for Algolia search

nbsphinx_requirejs_path = ""

# For notebook downloads (23.5 onwards), we get the version from the environment
# variable READTHEDOCS_VERSION and set it accordingly.

# If the version is set to "latest", then we are on the develop branch, and we
# point to the notebook in the develop blob
# If we are on "stable", we point to the notebook in the relevant release tree
# for the PyBaMM version
# On a PR build, we use READTHEDOCS_GIT_COMMIT_HASH which will always point to changes
# made to a notebook, if any.
# On local builds, the version is not set, so we use "latest".

if (os.environ.get("READTHEDOCS_VERSION") == "latest") or (
os.environ.get("READTHEDOCS_VERSION") is None
):
notebooks_version = "develop"
append_to_url = f"blob/{notebooks_version}"

if os.environ.get("READTHEDOCS_VERSION") == "stable":
notebooks_version = version
append_to_url = f"tree/v{notebooks_version}"

if os.environ.get("READTHEDOCS_VERSION_TYPE") == "external":
notebooks_version = os.environ.get("READTHEDOCS_GIT_COMMIT_HASH")
append_to_url = f"blob/{notebooks_version}"

github_download_url = f"https://github.com/pybamm-team/PyBaMM/{append_to_url}"
google_colab_url = github_download_url.replace("github.com", "githubtocolab.com")

html_context.update(
{
"notebooks_version": notebooks_version,
"github_download_url": github_download_url,
"google_colab_url": google_colab_url,
}
)

nbsphinx_prolog = r"""
{% set github_docname =
'github/pybamm-team/pybamm/blob/develop/docs/' +
env.doc2path(env.docname, base=None) %}
{% set readthedocs_download_url =
'https://docs.pybamm.org/en/latest/' %}
{% set notebooks_version = env.config.html_context.notebooks_version %}
{% set github_download_url = env.config.html_context.github_download_url %}
{% set google_colab_url = env.config.html_context.google_colab_url %}
{% set doc_path = env.doc2path(env.docname, base=None) %}
Expand All @@ -323,15 +361,15 @@
<p>
An interactive online version of this notebook is available, which can be
accessed via
<a href="https://colab.research.google.com/{{ github_docname | e }}"
<a href="{{ google_colab_url | e }}/docs/{{ doc_path | e }}"
target="_blank">
<img src="https://colab.research.google.com/assets/colab-badge.svg"
alt="Open this notebook in Google Colab"/></a>
</p>
<hr>
<p>
Alternatively, you may
<a href="{{ readthedocs_download_url | e }}{{ doc_path | e }}"
<a href="{{ github_download_url | e }}/docs/{{ doc_path | e }}"
target="_blank" download>
download this notebook</a> and run it offline.
</p>
Expand Down
4 changes: 4 additions & 0 deletions docs/source/api/models/lithium_ion/electrode_soh.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ Electrode SOH models

.. autofunction:: pybamm.lithium_ion.get_min_max_stoichiometries

.. autofunction:: pybamm.lithium_ion.get_initial_ocps

.. autofunction:: pybamm.lithium_ion.get_min_max_ocps

.. footbibliography::
1 change: 1 addition & 0 deletions docs/source/api/models/lithium_ion/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ Lithium-ion Models
mpm
dfn
newman_tobias
msmr
yang2017
electrode_soh
7 changes: 7 additions & 0 deletions docs/source/api/models/lithium_ion/msmr.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Multi-Species Multi-Reaction (MSMR) Model
=========================================

.. autoclass:: pybamm.lithium_ion.MSMR
:members:

.. footbibliography::
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Butler Volumer
==============
Butler Volmer
=============

.. autoclass:: pybamm.kinetics.SymmetricButlerVolmer
:members:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ Kinetics
marcus
no_reaction
tafel
msmr_butler_volmer
total_main_kinetics
inverse_kinetics/index
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
MSMR Butler Volmer
==================

.. autoclass:: pybamm.kinetics.MSMRButlerVolmer
:members:
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ Open-circuit potential models
base_ocp
current_sigmoid_ocp
single_ocp
msmr_ocp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
MSMR Open Circuit Potential
===========================


.. autoclass:: pybamm.open_circuit_potential.MSMROpenCircuitPotential
:members:

.. footbibliography::
1 change: 1 addition & 0 deletions docs/source/api/models/submodels/particle/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ Particle
fickian_diffusion
polynomial_profile
x_averaged_polynomial_profile
msmr_diffusion
7 changes: 7 additions & 0 deletions docs/source/api/models/submodels/particle/msmr_diffusion.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
MSMR Diffusion
==============

.. autoclass:: pybamm.particle.MSMRDiffusion
:members:

.. footbibliography::
1 change: 1 addition & 0 deletions docs/source/examples/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ The notebooks are organised into subfolders, and can be viewed in the galleries
notebooks/models/lead-acid.ipynb
notebooks/models/lithium-plating.ipynb
notebooks/models/MPM.ipynb
notebooks/models/MSMR.ipynb
notebooks/models/pouch-cell-model.ipynb
notebooks/models/rate-capability.ipynb
notebooks/models/SEI-on-cracks.ipynb
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@
"V_hat = pybamm.Parameter(\"Partial molar volume [m3.mol-1]\")\n",
"c_inf = pybamm.Parameter(\"Bulk electrolyte solvent concentration [mol.m-3]\")\n",
"\n",
"\n",
"def D(cc):\n",
" return pybamm.FunctionParameter(\"Diffusivity [m2.s-1]\", {\"Solvent concentration [mol.m-3]\": cc})"
]
Expand Down Expand Up @@ -485,9 +486,11 @@
" {\"SEI layer\": {xi: {\"min\": pybamm.Scalar(0), \"max\": pybamm.Scalar(1)}}}\n",
")\n",
"\n",
"\n",
"def Diffusivity(cc):\n",
" return cc * 10**(-12)\n",
"\n",
"\n",
"# parameter values (not physically based, for example only!)\n",
"param = pybamm.ParameterValues(\n",
" {\n",
Expand Down Expand Up @@ -565,6 +568,7 @@
"L_0_eval = param.evaluate(L_0)\n",
"xi = np.linspace(0, 1, 100) # dimensionless space\n",
"\n",
"\n",
"def plot(t):\n",
" _, (ax1, ax2) = plt.subplots(1, 2 ,figsize=(10,5))\n",
" ax1.plot(solution.t, L_out(solution.t) * 1e6)\n",
Expand All @@ -581,6 +585,7 @@
" plt.tight_layout()\n",
" plt.show()\n",
" \n",
"\n",
"import ipywidgets as widgets\n",
"widgets.interact(plot, t=widgets.FloatSlider(min=0,max=solution.t[-1],step=0.1,value=0));"
]
Expand Down
Loading

0 comments on commit dc3c6ed

Please sign in to comment.