Skip to content

Commit

Permalink
#3611 merge develop
Browse files Browse the repository at this point in the history
  • Loading branch information
rtimms committed Jan 16, 2024
2 parents 56539de + 3e57733 commit d9a18d6
Show file tree
Hide file tree
Showing 14 changed files with 152 additions and 13 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,15 @@
"contributions": [
"code"
]
},
{
"login": "AlessioBugetti",
"name": "Alessio Bugetti",
"avatar_url": "https://avatars.githubusercontent.com/u/38499721?v=4",
"profile": "https://github.com/AlessioBugetti",
"contributions": [
"infra"
]
}
],
"contributorsPerLine": 7,
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lychee_url_checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:

# use stable version for now to avoid breaking changes
- name: Lychee URL checker
uses: lycheeverse/[email protected].0
uses: lycheeverse/[email protected].1
with:
# arguments with file types to check
args: >-
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/run_periodic_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ jobs:
- name: Check style
run: |
python -m pip install pre-commit
git add .
pre-commit run ruff
pre-commit run -a
build:
needs: style
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/test_on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ jobs:
- name: Check style
run: |
python -m pip install pre-commit
git add .
pre-commit run ruff
pre-commit run -a
run_unit_tests:
needs: style
Expand Down
2 changes: 1 addition & 1 deletion .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.1.11"
rev: "v0.1.13"
hooks:
- id: ruff
args: [--fix, --show-fixes]
Expand Down
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@

## Bug fixes

- Fixed a bug where if the first step(s) in a cycle are skipped then the cycle solution started from the model's initial conditions instead of from the last state of the previous cycle ([#3708](https://github.com/pybamm-team/PyBaMM/pull/3708))
- Fixed a bug where the lumped thermal model conflates cell volume with electrode volume ([#3707](https://github.com/pybamm-team/PyBaMM/pull/3707))

## Breaking changes
- The parameters `GeometricParameters.A_cooling` and `GeometricParameters.V_cell` are now automatically computed from the electrode heights, widths and thicknesses if the "cell geometry" option is "pouch" and from the parameters "Cell cooling surface area [m2]" and "Cell volume [m3]", respectively, otherwise. When using the lumped thermal model we recommend using the "arbitrary" cell geometry and specifying the parameters "Cell cooling surface area [m2]", "Cell volume [m3]" and "Total heat transfer coefficient [W.m-2.K-1]" directly. ([#3707](https://github.com/pybamm-team/PyBaMM/pull/3707))

# [v24.1rc0](https://github.com/pybamm-team/PyBaMM/tree/v24.1rc0) - 2024-01-31

## Features

- The `pybamm_install_odes` command now includes support for macOS systems and can be used to set up SUNDIALS and install the `scikits.odes` solver on macOS ([#3417](https://github.com/pybamm-team/PyBaMM/pull/3417))
- The `pybamm_install_odes` command now includes support for macOS systems and can be used to set up SUNDIALS and install the `scikits.odes` solver on macOS ([#3417](https://github.com/pybamm-team/PyBaMM/pull/3417), [#3706](https://github.com/pybamm-team/PyBaMM/3706]))
- Added support for Python 3.12 ([#3531](https://github.com/pybamm-team/PyBaMM/pull/3531))
- Added method to get QuickPlot axes by variable ([#3596](https://github.com/pybamm-team/PyBaMM/pull/3596))
- Added custom experiment terminations ([#3596](https://github.com/pybamm-team/PyBaMM/pull/3596))
Expand Down
3 changes: 2 additions & 1 deletion 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-73-orange.svg)](#-contributors)
[![All Contributors](https://img.shields.io/badge/all_contributors-74-orange.svg)](#-contributors)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

</div>
Expand Down Expand Up @@ -279,6 +279,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<td align="center" valign="top" width="14.28%"><a href="https://github.com/prady0t"><img src="https://avatars.githubusercontent.com/u/99216956?v=4?s=100" width="100px;" alt="Pradyot Ranjan"/><br /><sub><b>Pradyot Ranjan</b></sub></a><br /><a href="#infra-prady0t" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/XuboGU"><img src="https://avatars.githubusercontent.com/u/53944452?v=4?s=100" width="100px;" alt="XuboGU"/><br /><sub><b>XuboGU</b></sub></a><br /><a href="https://github.com/pybamm-team/PyBaMM/commits?author=XuboGU" title="Code">💻</a> <a href="https://github.com/pybamm-team/PyBaMM/issues?q=author%3AXuboGU" title="Bug reports">🐛</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/cringeyburger"><img src="https://avatars.githubusercontent.com/u/121183876?v=4?s=100" width="100px;" alt="Ankit Meda"/><br /><sub><b>Ankit Meda</b></sub></a><br /><a href="https://github.com/pybamm-team/PyBaMM/commits?author=cringeyburger" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/AlessioBugetti"><img src="https://avatars.githubusercontent.com/u/38499721?v=4?s=100" width="100px;" alt="Alessio Bugetti"/><br /><sub><b>Alessio Bugetti</b></sub></a><br /><a href="#infra-AlessioBugetti" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
</tr>
</tbody>
</table>
Expand Down
6 changes: 4 additions & 2 deletions docs/source/user_guide/installation/gnu-linux-mac.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ Users can install `scikits.odes <https://github.com/bmcage/odes>`__ to utilize i

.. code:: bash
apt install libopenblas-dev
apt-get install libopenblas-dev
pip install wget cmake
pybamm_install_odes
system (under ``~/.local``), before installing ``scikits.odes``. (Alternatively, one can install SUNDIALS without this script and run ``pip install pybamm[odes]`` to install ``pybamm`` with ``scikits.odes``.)
Expand All @@ -131,6 +132,7 @@ Users can install `scikits.odes <https://github.com/bmcage/odes>`__ to utilize i
.. code:: bash
brew install openblas gcc gfortran
pip install wget cmake
pybamm_install_odes
The ``pybamm_install_odes`` command, installed with PyBaMM, automatically downloads and installs the SUNDIALS library on your
Expand Down Expand Up @@ -161,7 +163,7 @@ Users can install ``jax`` and ``jaxlib`` to use the Jax solver.

.. note::

The Jax solver is not supported on Python 3.8. It is supported on Python 3.9, 3.10, and 3.11.
The Jax solver is only supported for Python versions 3.9 through 3.12.

.. code:: bash
Expand Down
2 changes: 1 addition & 1 deletion docs/source/user_guide/installation/windows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Users can install ``jax`` and ``jaxlib`` to use the Jax solver.

.. note::

The Jax solver is not supported on Python 3.8. It is supported on Python 3.9, 3.10, and 3.11.
The Jax solver is only supported for Python versions 3.9 through 3.12.

.. code:: bash
Expand Down
7 changes: 6 additions & 1 deletion pybamm/install_odes.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,12 @@ def main(arguments=None):
# see https://scikits-odes.readthedocs.io/en/latest/installation.html#id1
os.environ["SUNDIALS_INST"] = SUNDIALS_LIB_DIR
env = os.environ.copy()
subprocess.run(["pip", "install", "scikits.odes"], env=env, check=True)
logger.info("Installing scikits.odes via pip")
subprocess.run(
[f"{sys.executable}", "-m", "pip", "install", "scikits.odes", "--verbose"],
env=env,
check=True,
)


if __name__ == "__main__":
Expand Down
15 changes: 14 additions & 1 deletion pybamm/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,20 @@ def solve(

steps.append(step_solution)

cycle_solution = cycle_solution + step_solution
# If there haven't been any successful steps yet in this cycle, then
# carry the solution over from the previous cycle (but
# `step_solution` should still be an EmptySolution so that in the
# list of returned step solutions we can see which steps were
# skipped)
if (
cycle_solution is None
and isinstance(step_solution, pybamm.EmptySolution)
and not isinstance(current_solution, pybamm.EmptySolution)
):
cycle_solution = current_solution.last_state
else:
cycle_solution = cycle_solution + step_solution

current_solution = cycle_solution

callbacks.on_step_end(logs)
Expand Down
12 changes: 12 additions & 0 deletions scripts/install_KLU_Sundials.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# /// pyproject
# [run]
# requires-python = "">=3.8, <3.13""
# dependencies = [
# "wget",
# "cmake",
# ]
#
# [additional-info]
# repository = "https://github.com/pybamm-team/PyBaMM"
# documentation = "https://docs.pybamm.org"
# ///
import os
import subprocess
import tarfile
Expand Down
78 changes: 78 additions & 0 deletions test.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import pybamm"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<pybamm.solvers.solution.Solution at 0x14fc50ad0>"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"model = pybamm.lithium_ion.DFN()\n",
"sim = pybamm.Simulation(model)\n",
"sim.solve([0, 3600])"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"sim.plot()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "bppenv",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.6"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "938a56cf8cc78a970178b6cd91dbc2084cfe03b4ddf365fda3eb6d44738b4092"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}
19 changes: 19 additions & 0 deletions tests/unit/test_experiments/test_simulation_with_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,25 @@ def test_run_experiment_skip_steps(self):
decimal=5,
)

def test_skipped_step_continuous(self):
model = pybamm.lithium_ion.SPM({"SEI": "solvent-diffusion limited"})
experiment = pybamm.Experiment(
[
("Rest for 24 hours (1 hour period)",),
(
"Charge at C/3 until 4.1 V",
"Hold at 4.1V until C/20",
"Discharge at C/3 until 2.5 V",
),
]
)
sim = pybamm.Simulation(model, experiment=experiment)
sim.solve(initial_soc=1)
np.testing.assert_array_almost_equal(
sim.solution.cycles[0].last_state.y.full(),
sim.solution.cycles[1].steps[-1].first_state.y.full(),
)

def test_all_empty_solution_errors(self):
model = pybamm.lithium_ion.SPM()
parameter_values = pybamm.ParameterValues("Chen2020")
Expand Down

0 comments on commit d9a18d6

Please sign in to comment.