Skip to content

Commit

Permalink
Merge branch 'develop' into ocvr_ecm
Browse files Browse the repository at this point in the history
  • Loading branch information
kratman authored Aug 28, 2024
2 parents 9a996c4 + ac6c450 commit b820e59
Show file tree
Hide file tree
Showing 69 changed files with 1,958 additions and 1,608 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/publish_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ jobs:
CIBW_ARCHS: AMD64
CIBW_BEFORE_BUILD: python -m pip install setuptools wheel delvewheel # skip CasADi and CMake
CIBW_REPAIR_WHEEL_COMMAND: delvewheel repair -w {dest_dir} {wheel}
CIBW_TEST_COMMAND: python -c "import pybamm; print(pybamm.IDAKLUSolver())"

CIBW_TEST_EXTRAS: "all,dev,jax"
CIBW_TEST_COMMAND: |
python -c "import pybamm; print(pybamm.IDAKLUSolver())"
python -m pytest -m cibw {project}/tests/unit
- name: Upload Windows wheels
uses: actions/upload-artifact@v4.3.6
with:
Expand Down Expand Up @@ -118,9 +120,11 @@ jobs:
bash scripts/install_sundials.sh 6.0.3 6.5.0
CIBW_BEFORE_BUILD_LINUX: python -m pip install cmake casadi setuptools wheel
CIBW_REPAIR_WHEEL_COMMAND_LINUX: auditwheel repair -w {dest_dir} {wheel}
CIBW_TEST_EXTRAS: "all,dev,jax"
CIBW_TEST_COMMAND: |
set -e -x
python -c "import pybamm; print(pybamm.IDAKLUSolver())"
python -m pytest -m cibw {project}/tests/unit
- name: Upload wheels for Linux
uses: actions/upload-artifact@v4.3.6
Expand Down Expand Up @@ -249,9 +253,11 @@ jobs:
delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel} --require-target-macos-version 11.1
for file in {dest_dir}/*.whl; do mv "$file" "${file//macosx_11_1/macosx_11_0}"; done
fi
CIBW_TEST_EXTRAS: "all,dev,jax"
CIBW_TEST_COMMAND: |
set -e -x
python -c "import pybamm; print(pybamm.IDAKLUSolver())"
python -m pytest -m cibw {project}/tests/unit
- name: Upload wheels for macOS (amd64, arm64)
uses: actions/upload-artifact@v4.3.6
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ jobs:
# Upload the results to GitHub's code scanning dashboard (optional).
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@883d8588e56d1753a8a58c1c86e88976f0c23449 # v3.26.3
uses: github/codeql-action/upload-sarif@2c779ab0d087cd7fe7b826087247c2c81f27bfa6 # v3.26.5
with:
sarif_file: results.sarif
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.6.1"
rev: "v0.6.2"
hooks:
- id: ruff
args: [--fix, --show-fixes]
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@

## Optimizations

- Improved adaptive time-stepping performance of the (`IDAKLUSolver`). ([#4351](https://github.com/pybamm-team/PyBaMM/pull/4351))
- Improved performance and reliability of DAE consistent initialization. ([#4301](https://github.com/pybamm-team/PyBaMM/pull/4301))
- Replaced rounded Faraday constant with its exact value in `bpx.py` for better comparison between different tools. ([#4290](https://github.com/pybamm-team/PyBaMM/pull/4290))

## Bug Fixes

- Fixed memory issue that caused failure when `output variables` were specified with (`IDAKLUSolver`). ([#4379](https://github.com/pybamm-team/PyBaMM/issues/4379))
- Fixed bug where IDAKLU solver failed when `output variables` were specified and an event triggered. ([#4300](https://github.com/pybamm-team/PyBaMM/pull/4300))

## Breaking changes

- Remove deprecated function `pybamm_install_jax` ([#4362](https://github.com/pybamm-team/PyBaMM/pull/4362))
- Removed legacy python-IDAKLU solver. ([#4326](https://github.com/pybamm-team/PyBaMM/pull/4326))

# [v24.5](https://github.com/pybamm-team/PyBaMM/tree/v24.5) - 2024-07-26

## Features
Expand Down
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ pybind11_add_module(idaklu
src/pybamm/solvers/c_solvers/idaklu/IdakluJax.cpp
src/pybamm/solvers/c_solvers/idaklu/IdakluJax.hpp
src/pybamm/solvers/c_solvers/idaklu/common.hpp
src/pybamm/solvers/c_solvers/idaklu/python.hpp
src/pybamm/solvers/c_solvers/idaklu/python.cpp
src/pybamm/solvers/c_solvers/idaklu/common.cpp
src/pybamm/solvers/c_solvers/idaklu/Solution.cpp
src/pybamm/solvers/c_solvers/idaklu/Solution.hpp
src/pybamm/solvers/c_solvers/idaklu/Options.hpp
Expand Down
7 changes: 7 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,19 @@ 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
2 changes: 0 additions & 2 deletions docs/source/api/util.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ Utility functions

.. autofunction:: pybamm.load

.. autofunction:: pybamm.install_jax

.. autofunction:: pybamm.have_jax

.. autofunction:: pybamm.is_jax_compatible
2 changes: 1 addition & 1 deletion docs/source/user_guide/installation/gnu-linux-mac.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Users can install ``jax`` and ``jaxlib`` to use the Jax solver.
pip install "pybamm[jax]"
The ``pip install "pybamm[jax]"`` command automatically downloads and installs ``pybamm`` and the compatible versions of ``jax`` and ``jaxlib`` on your system. (``pybamm_install_jax`` is deprecated.)
The ``pip install "pybamm[jax]"`` command automatically downloads and installs ``pybamm`` and the compatible versions of ``jax`` and ``jaxlib`` on your system.

.. _optional-iree-mlir-support:

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 @@ -75,7 +75,7 @@ Users can install ``jax`` and ``jaxlib`` to use the Jax solver.
pip install "pybamm[jax]"
The ``pip install "pybamm[jax]"`` command automatically downloads and installs ``pybamm`` and the compatible versions of ``jax`` and ``jaxlib`` on your system. (``pybamm_install_jax`` is deprecated.)
The ``pip install "pybamm[jax]"`` command automatically downloads and installs ``pybamm`` and the compatible versions of ``jax`` and ``jaxlib`` on your system.

Uninstall PyBaMM
----------------
Expand Down
61 changes: 61 additions & 0 deletions examples/scripts/compare_surface_temperature.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#
# Compare lithium-ion battery models
#
import pybamm

pybamm.set_logging_level("INFO")

# load models
models = [
pybamm.lithium_ion.SPMe(
{"thermal": "lumped", "surface temperature": "ambient"},
name="ambient surface temperature",
),
pybamm.lithium_ion.SPMe(
{"thermal": "lumped", "surface temperature": "lumped"},
name="lumped surface temperature",
),
]

experiment = pybamm.Experiment(
[
"Discharge at 1C until 2.5V",
"Rest for 1 hour",
]
)

parameter_values = pybamm.ParameterValues("Chen2020")
parameter_values.update(
{
"Casing heat capacity [J.K-1]": 30,
"Environment thermal resistance [K.W-1]": 10,
},
check_already_exists=False,
)

# create and run simulations
sols = []
for model in models:
model.variables["Bulk temperature [°C]"] = (
model.variables["Volume-averaged cell temperature [K]"] - 273.15
)
model.variables["Surface temperature [°C]"] = (
model.variables["Surface temperature [K]"] - 273.15
)
sim = pybamm.Simulation(
model, parameter_values=parameter_values, experiment=experiment
)
sol = sim.solve([0, 3600])
sols.append(sol)

# plot
pybamm.dynamic_plot(
sols,
[
"Voltage [V]",
"Bulk temperature [°C]",
"Surface temperature [°C]",
"Surface total cooling [W]",
"Environment total cooling [W]",
],
)
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,6 @@ all = [
"pybamm[examples,plot,cite,bpx,tqdm]",
]

[project.scripts]
pybamm_install_jax = "pybamm.util:install_jax"

[project.entry-points."pybamm_parameter_sets"]
Sulzer2019 = "pybamm.input.parameters.lead_acid.Sulzer2019:get_parameter_values"
Ai2020 = "pybamm.input.parameters.lithium_ion.Ai2020:get_parameter_values"
Expand Down Expand Up @@ -234,6 +231,7 @@ required_plugins = [
"pytest-xdist",
"pytest-mock",
]
norecursedirs = 'pybind11*'
addopts = [
"-nauto",
"-vra",
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,7 @@ def compile_KLU():
"src/pybamm/solvers/c_solvers/idaklu/IdakluJax.cpp",
"src/pybamm/solvers/c_solvers/idaklu/IdakluJax.hpp",
"src/pybamm/solvers/c_solvers/idaklu/common.hpp",
"src/pybamm/solvers/c_solvers/idaklu/python.hpp",
"src/pybamm/solvers/c_solvers/idaklu/python.cpp",
"src/pybamm/solvers/c_solvers/idaklu/common.cpp",
"src/pybamm/solvers/c_solvers/idaklu/Solution.cpp",
"src/pybamm/solvers/c_solvers/idaklu/Solution.hpp",
"src/pybamm/solvers/c_solvers/idaklu/Options.hpp",
Expand Down
10 changes: 10 additions & 0 deletions src/pybamm/CITATIONS.bib
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,16 @@ @article{Lain2019
doi = {10.3390/batteries5040064},
}

@article{lin2014lumped,
title={A lumped-parameter electro-thermal model for cylindrical batteries},
author={Lin, Xinfan and Perez, Hector E and Mohan, Shankar and Siegel, Jason B and Stefanopoulou, Anna G and Ding, Yi and Castanier, Matthew P},
journal={Journal of Power Sources},
volume={257},
pages={1--11},
year={2014},
publisher={Elsevier}
}

@article{Marquis2019,
title = {{An asymptotic derivation of a single particle model with electrolyte}},
author = {Marquis, Scott G. and Sulzer, Valentin and Timms, Robert and Please, Colin P. and Chapman, S. Jon},
Expand Down
1 change: 0 additions & 1 deletion src/pybamm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from .util import (
get_parameters_filepath,
have_jax,
install_jax,
import_optional_dependency,
is_jax_compatible,
get_git_commit_info,
Expand Down
1 change: 1 addition & 0 deletions src/pybamm/batch_study.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def solve(
calc_esoh=True,
starting_solution=None,
initial_soc=None,
t_interp=None,
**kwargs,
):
"""
Expand Down
Loading

0 comments on commit b820e59

Please sign in to comment.