Skip to content

Commit

Permalink
Merge pull request #4781 from pybamm-team/release/v25.1.1
Browse files Browse the repository at this point in the history
Release v25.1.1
  • Loading branch information
kratman authored Jan 21, 2025
2 parents 590fdfe + 2e99a0e commit 817ac83
Show file tree
Hide file tree
Showing 26 changed files with 146 additions and 114 deletions.
3 changes: 0 additions & 3 deletions .clang-format

This file was deleted.

Empty file removed .github/codecov.yml
Empty file.
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Docker image to Docker Hub
uses: docker/build-push-action@b32b51a8eda65d6793cd0494a773d4f6bcef32dc # v6.11.0
uses: docker/build-push-action@67a2d409c0a876cbe6b11854e3e25193efe4e62d # v6.12.0
with:
context: .
file: scripts/Dockerfile
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/run_periodic_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo dot -c
sudo apt-get install gfortran gcc graphviz pandoc
sudo apt-get install libopenblas-dev texlive-latex-extra dvipng
- name: Install macOS system dependencies
Expand Down Expand Up @@ -100,6 +100,7 @@ jobs:
- name: Install Linux system dependencies
run: |
sudo apt-get update
sudo apt-get install graphviz pandoc
sudo apt-get install texlive-latex-extra dvipng
- name: Set up Python
Expand Down Expand Up @@ -132,6 +133,7 @@ jobs:
- name: Install Linux system dependencies
run: |
sudo apt-get update
sudo apt-get install gfortran gcc graphviz pandoc
sudo apt-get install libopenblas-dev texlive-latex-extra dvipng
- name: Set up Python 3.12
Expand Down Expand Up @@ -161,6 +163,7 @@ jobs:
- name: Install Linux system dependencies
run: |
sudo apt-get update
sudo apt-get install gfortran gcc graphviz
sudo apt-get install libopenblas-dev texlive-latex-extra dvipng
- name: Set up Python 3.12
Expand Down
39 changes: 0 additions & 39 deletions .github/workflows/update_license.yml

This file was deleted.

4 changes: 1 addition & 3 deletions .github/workflows/validation_benchmarks.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
name: Alert validation repository
on:
workflow_dispatch:
release:
types:
- published
push:
branches:
- develop

jobs:
build:
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.9.1"
rev: "v0.9.2"
hooks:
- id: ruff
args: [--fix, --show-fixes]
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# [Unreleased](https://github.com/pybamm-team/PyBaMM/)

# [v25.1.1](https://github.com/pybamm-team/PyBaMM/tree/v25.1.1) - 2025-01-20

## Features

- Added Operators to current and voltage termination events. ([#4770](https://github.com/pybamm-team/PyBaMM/pull/4770))

## Bug fixes

- Fixed a bug which caused the wc-reaction limited SEI model to give
incorrect results ([#4774](https://github.com/pybamm-team/PyBaMM/pull/4774))

# [v25.1.0](https://github.com/pybamm-team/PyBaMM/tree/v25.1.0) - 2025-01-14

## Features
Expand Down
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ keywords:
- "expression tree"
- "python"
- "symbolic differentiation"
version: "25.1.0"
version: "25.1.1"
repository-code: "https://github.com/pybamm-team/PyBaMM"
title: "Python Battery Mathematical Modelling (PyBaMM)"
7 changes: 1 addition & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -422,18 +422,13 @@ wherever code is called that uses that citation (for example, in functions or in

### Installation

Installation of PyBaMM and its dependencies is handled via [pip](https://pip.pypa.io/en/stable/) and [setuptools](http://setuptools.readthedocs.io/). It uses `CMake` to compile C++ extensions using [`pybind11`](https://pybind11.readthedocs.io/en/stable/) and [`casadi`](https://web.casadi.org/). The installation process is described in detail in the [source installation](https://docs.pybamm.org/en/latest/source/user_guide/installation/install-from-source.html) page and is configured through the `CMakeLists.txt` file.
Installation of PyBaMM and its dependencies is handled via [pip](https://pip.pypa.io/en/stable/)

Configuration files:

```
setup.py
pyproject.toml
MANIFEST.in
```

Note: `MANIFEST.in` is used to include and exclude non-Python files and auxiliary package data for PyBaMM when distributing it. If a file is not included in `MANIFEST.in`, it will not be included in the source distribution (SDist) and subsequently not be included in the binary distribution (wheel).

### Continuous Integration using GitHub Actions

Each change pushed to the PyBaMM GitHub repository will trigger the test and benchmark suites to be run, using [GitHub Actions](https://github.com/features/actions).
Expand Down
7 changes: 0 additions & 7 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,12 @@ def pytest_addoption(parser):
default=False,
help="run integration tests",
)
parser.addoption(
"--cibw",
action="store_true",
default=False,
help="test build wheels",
)


def pytest_configure(config):
config.addinivalue_line("markers", "scripts: mark test as an example script")
config.addinivalue_line("markers", "unit: mark test as a unit test")
config.addinivalue_line("markers", "integration: mark test as an integration test")
config.addinivalue_line("markers", "cibw: mark test as build wheel test")


def pytest_collection_modifyitems(items):
Expand Down
14 changes: 4 additions & 10 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ def run_integration(session):
@nox.session(name="doctests")
def run_doctests(session):
"""Run the doctests and generate the output(s) in the docs/build/ directory."""
# TODO: Temporary fix for Python 3.12 CI.
# See: https://bitbucket.org/pybtex-devs/pybtex/issues/169/
# Fix for Python 3.12 CI. This can be removed after pybtex is replaced.
session.install("setuptools", silent=False)
session.install("-e", ".[all,dev,docs]", silent=False)
session.run(
Expand Down Expand Up @@ -102,9 +101,7 @@ def run_examples(session):
def run_scripts(session):
"""Run the scripts tests for Python scripts."""
set_environment_variables(PYBAMM_ENV, session=session)
# Temporary fix for Python 3.12 CI. TODO: remove after
# https://bitbucket.org/pybtex-devs/pybtex/issues/169/replace-pkg_resources-with
# is fixed
# Fix for Python 3.12 CI. This can be removed after pybtex is replaced.
session.install("setuptools", silent=False)
session.install("-e", ".[all,dev,jax]", silent=False)
session.run("python", "-m", "pytest", "-m", "scripts")
Expand All @@ -119,9 +116,7 @@ def set_dev(session):
python = os.fsdecode(VENV_DIR.joinpath("bin/python"))
components = ["all", "dev", "jax"]
args = []
# Temporary fix for Python 3.12 CI. TODO: remove after
# https://bitbucket.org/pybtex-devs/pybtex/issues/169/replace-pkg_resources-with
# is fixed
# Fix for Python 3.12 CI. This can be removed after pybtex is replaced.
session.run(python, "-m", "pip", "install", "setuptools", external=True)
session.run(
python,
Expand Down Expand Up @@ -153,8 +148,7 @@ def run_tests(session):
def build_docs(session):
"""Build the documentation and load it in a browser tab, rebuilding on changes."""
envbindir = session.bin
# TODO: Temporary fix for Python 3.12 CI.
# See: https://bitbucket.org/pybtex-devs/pybtex/issues/169/
# Fix for Python 3.12 CI. This can be removed after pybtex is replaced.
session.install("setuptools", silent=False)
session.install("-e", ".[all,docs]", silent=False)
session.chdir("docs")
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "pybamm"
version = "25.1.0"
version = "25.1.1"
license = { file = "LICENSE.txt" }
description = "Python Battery Mathematical Modelling"
authors = [{name = "The PyBaMM Team", email = "pybamm@pybamm.org"}]
Expand Down Expand Up @@ -227,7 +227,6 @@ required_plugins = [
"pytest-mock",
"pytest-subtests",
]
norecursedirs = 'pybind11*'
addopts = [
"-nauto",
"-vra",
Expand Down
2 changes: 1 addition & 1 deletion src/pybamm/experiment/step/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .steps import *
from .base_step import BaseStep, BaseStepExplicit, BaseStepImplicit
from .step_termination import *
from .step_termination import BaseTermination, CurrentTermination, VoltageTermination, CustomTermination, CrateTermination, _read_termination

__all__ = ['base_step', 'step_termination', 'steps']
14 changes: 10 additions & 4 deletions src/pybamm/experiment/step/base_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,14 @@ def __init__(
tags=None,
start_time=None,
description=None,
direction=None,
direction: str | None = None,
):
potential_directions = ["charge", "discharge", "rest", None]
if direction not in potential_directions:
raise ValueError(
f"Invalid direction: {direction}. Must be one of {potential_directions}"
)
self.input_duration = duration
self.input_duration = duration
self.input_value = value
# Check if drive cycle
Expand Down Expand Up @@ -386,11 +392,11 @@ def value_based_charge_or_discharge(self):
init_curr = self.value
sign = np.sign(init_curr)
if sign == 0:
return "Rest"
return "rest"
elif sign > 0:
return "Discharge"
return "discharge"
else:
return "Charge"
return "charge"

def record_tags(
self,
Expand Down
57 changes: 47 additions & 10 deletions src/pybamm/experiment/step/step_termination.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ class BaseTermination:
The value at which the event is triggered
"""

def __init__(self, value):
def __init__(self, value, operator=None):
self.value = value
if operator not in ["<", ">", None]:
raise ValueError(f"Invalid operator: {operator}")
self.operator = operator

def get_event(self, variables, step):
"""
Expand Down Expand Up @@ -67,9 +70,19 @@ def get_event(self, variables, step):
"""
See :meth:`BaseTermination.get_event`
"""
operator = self.operator
if operator == ">":
expr = self.value - variables["Current [A]"]
event_string = f"Current [A] > {self.value} [A] [experiment]"
elif operator == "<":
expr = variables["Current [A]"] - self.value
event_string = f"Current [A] < {self.value} [A] [experiment]"
else:
expr = abs(variables["Current [A]"]) - self.value
event_string = f"abs(Current [A]) < {self.value} [A] [experiment]"
event = pybamm.Event(
"Current cut-off [A] [experiment]",
abs(variables["Current [A]"]) - self.value,
event_string,
expr,
)
return event

Expand All @@ -89,24 +102,48 @@ def get_event(self, variables, step):
# figure out whether the voltage event is greater than the starting
# voltage (charge) or less (discharge) and set the sign of the
# event accordingly
direction = step.direction.capitalize()
if direction == "Charge":
operator = self.operator
if operator is None:
direction = step.direction
if direction == "charge":
operator = ">"
elif direction == "discharge":
operator = "<"
else:
# No event for rest steps
return None

if operator == ">":
sign = -1
elif direction == "Discharge":
else:
# operator can only be "<" or ">"
sign = 1
elif direction == "Rest":
# No event for rest steps
return None

# Event should be positive at initial conditions for both
# charge and discharge
event = pybamm.Event(
f"{direction} voltage cut-off [V] [experiment]",
f"Voltage {operator} {self.value} [V] [experiment]",
sign * (variables["Battery voltage [V]"] - self.value),
)
return event


class Voltage:
def __gt__(self, value):
return VoltageTermination(value, operator=">")

def __lt__(self, value):
return VoltageTermination(value, operator="<")


class Current:
def __gt__(self, value):
return CurrentTermination(value, operator=">")

def __lt__(self, value):
return CurrentTermination(value, operator="<")


class CustomTermination(BaseTermination):
"""
Define a custom termination event using a function. This can be used to create an
Expand Down
6 changes: 3 additions & 3 deletions src/pybamm/input/parameters/lithium_ion/Ai2020.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def graphite_electrolyte_exchange_current_density_Dualfoil1998(
References
----------
.. [2] http://www.cchem.berkeley.edu/jsngrp/fortran.html
.. [2] John Newman, Dualfoil
Parameters
----------
Expand Down Expand Up @@ -219,7 +219,7 @@ def lico2_diffusivity_Dualfoil1998(sto, T):
References
----------
.. [1] http://www.cchem.berkeley.edu/jsngrp/fortran.html
.. [1] John Newman, Dualfoil
Parameters
----------
Expand Down Expand Up @@ -247,7 +247,7 @@ def lico2_electrolyte_exchange_current_density_Dualfoil1998(c_e, c_s_surf, c_s_m
References
----------
.. [2] http://www.cchem.berkeley.edu/jsngrp/fortran.html
.. [2] John Newman, Dualfoil
Parameters
----------
Expand Down
Loading

0 comments on commit 817ac83

Please sign in to comment.