Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
7bb4d99
Don't be too strict with func_args longer than symbol.children
agriyakhetarpal Nov 13, 2025
56bd16f
Add a test
agriyakhetarpal Nov 13, 2025
e538149
Merge branch 'develop' into roundtrip-serialisation-fix
agriyakhetarpal Nov 14, 2025
425af11
Add support for uniform grid sizing across subdomains (#720) (#5253)
swastim01 Nov 15, 2025
d24a728
Merge branch 'develop' into roundtrip-serialisation-fix
agriyakhetarpal Nov 15, 2025
6ba2cde
Fix typo in Butler-Volmer equation docstring (#5279)
cnaples79 Nov 16, 2025
e893156
fix bug with bulk ocp lithiation (#5280)
rtimms Nov 18, 2025
6c8cbfd
doc: fix typo in concentration description in notebook (#5284)
gregordecristoforo Nov 19, 2025
af64ddd
Merge pull request #5276 from pybamm-team/main
valentinsulzer Nov 19, 2025
385ae7b
fix: instruct uv to install into system for CI (#5288)
pipliggins Nov 20, 2025
1319b4a
Fix `InputParameter` serialisation (#5289)
MarcBerliner Nov 20, 2025
eda4ebe
Merge branch 'develop' into roundtrip-serialisation-fix
valentinsulzer Nov 20, 2025
86fec31
Merge pull request #5274 from agriyakhetarpal/roundtrip-serialisation…
valentinsulzer Nov 20, 2025
80e1870
Bugfix: inputs for `initial_conditions_from` scale evaluation (#5285)
BradyPlanden Nov 21, 2025
73ab559
Add `silence_sundials_errors` solver option (#5290)
BradyPlanden Nov 24, 2025
593d2aa
Update C-Rate current for changing nominal capacity (#5286)
BradyPlanden Nov 27, 2025
df53205
Update `IDAKLUSolver` error handling (#5291)
MarcBerliner Dec 1, 2025
0b50f42
revive `SymbolReplacer`
MarcBerliner Dec 5, 2025
f090197
add `VariableReplacementMap`
MarcBerliner Dec 5, 2025
9586aa0
Create replace_symbols.rst
MarcBerliner Dec 5, 2025
3c23b1b
Update index.rst
MarcBerliner Dec 5, 2025
a583cb0
cleanup
MarcBerliner Dec 5, 2025
25519b7
attach `parameter_values` to model for lazy post-processing
MarcBerliner Dec 5, 2025
c1ad00f
update `model.parameter_values` serialization
MarcBerliner Dec 5, 2025
9bcdffa
Update test_serialisation.py
MarcBerliner Dec 5, 2025
b37ab6a
Update test_parameter_values.py
MarcBerliner Dec 5, 2025
9cf651a
add `observe` to solution for lazy evaluation of discretized symbols
MarcBerliner Dec 5, 2025
0724777
Update test_solution.py
MarcBerliner Dec 5, 2025
ac98788
style
MarcBerliner Dec 5, 2025
67136a9
Update CHANGELOG.md
MarcBerliner Dec 5, 2025
0327f8c
fix docstrings
MarcBerliner Dec 5, 2025
1680520
docs
MarcBerliner Dec 5, 2025
bec2663
docs2
MarcBerliner Dec 5, 2025
e31da6c
Update replace_symbols.py
MarcBerliner Dec 5, 2025
9844e0e
Update replace_symbols.py
MarcBerliner Dec 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/benchmark_on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
enable-cache: true

- name: Install python dependencies
run: uv pip install asv[virtualenv]
run: uv pip install --system asv

- name: Fetch base branch
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/periodic_benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
enable-cache: true

- name: Install python dependencies
run: uv pip install asv[virtualenv]
run: uv pip install --system asv

- name: Run benchmarks
run: |
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@

## Features

- Adds the ability to observe custom 0D variables from a `Solution` object. ([#5308](https://github.com/pybamm-team/PyBaMM/pull/5308))
- Adds `silence_sundials_errors` IDAKLU solver option with `default=False` to match historical output. ([#5290](https://github.com/pybamm-team/PyBaMM/pull/5290))

## Bug fixes

- Fixed a bug where `IDAKLUSolver` errors were not raised correctly. ([#5291](https://github.com/pybamm-team/PyBaMM/pull/5291))
- Fix a bug with serialising `InputParameter`s. ([#5289](https://github.com/pybamm-team/PyBaMM/pull/5289))

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

## Features
Expand All @@ -19,6 +25,7 @@

## Features

- Added uniform grid sizing across subdomains in the x-dimension, ensuring consistent grid spacing when geometries have varying lengths. ([#5253](https://github.com/pybamm-team/PyBaMM/pull/5253))
- Added the `electrode_phases` kwarg to `plot_voltage_components()` which allows choosing between plotting primary or secondary phase overpotentials. ([#5229](https://github.com/pybamm-team/PyBaMM/pull/5229))
- Added the `num_steps_no_progress` and `t_no_progress` options in the `IDAKLUSolver` to early terminate the simulation if little progress is detected. ([#5201](https://github.com/pybamm-team/PyBaMM/pull/5201))
- EvaluateAt symbol: add support for children evaluated at edges ([#5190](https://github.com/pybamm-team/PyBaMM/pull/5190))
Expand Down
1 change: 1 addition & 0 deletions docs/source/api/expression_tree/operations/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ Classes and functions that operate on the expression tree
convert_to_casadi
serialise
unpack_symbol
replace_symbols
11 changes: 11 additions & 0 deletions docs/source/api/expression_tree/operations/replace_symbols.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Symbol Replacer
================

.. autoclass:: pybamm.SymbolReplacer
:members:

Variable Replacement Map
=========================

.. autoclass:: pybamm.VariableReplacementMap
:members:
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"$$\n",
"\\left.c\\right\\vert_{t=0} = c_0,\n",
"$$\n",
"where $c$$ is the concentration, $r$ the radial coordinate, $t$ time, $R$ the particle radius, $D$ the diffusion coefficient, $j$ the interfacial current density, $F$ Faraday's constant, and $c_0$ the initial concentration. \n",
"where $c$ is the concentration, $r$ the radial coordinate, $t$ time, $R$ the particle radius, $D$ the diffusion coefficient, $j$ the interfacial current density, $F$ Faraday's constant, and $c_0$ the initial concentration. \n",
"\n",
"As in the previous example we use the following parameters:\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ classifiers = [
"Topic :: Scientific/Engineering",
]
dependencies = [
"pybammsolvers>=0.3.0,<0.4.0",
"pybammsolvers>=0.3.3,<0.4.0",
"black",
"numpy",
"scipy>=1.11.4",
Expand Down
4 changes: 4 additions & 0 deletions src/pybamm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
from .expression_tree.operations.convert_to_casadi import CasadiConverter
from .expression_tree.operations.unpack_symbols import SymbolUnpacker
from .expression_tree.operations.serialise import Serialise,ExpressionFunctionParameter
from .expression_tree.operations.replace_symbols import (
SymbolReplacer,
VariableReplacementMap,
)

# Model classes
from .models.base_model import BaseModel
Expand Down
54 changes: 25 additions & 29 deletions src/pybamm/discretisations/discretisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,34 +800,32 @@ def process_symbol(self, symbol):
Discretised symbol

"""
try:
return self._discretised_symbols[symbol]
except KeyError:
discretised_symbol = self._process_symbol(symbol)
self._discretised_symbols[symbol] = discretised_symbol
discretised_symbol.test_shape()

# Assign mesh as an attribute to the processed variable
if symbol.domain != []:
discretised_symbol.mesh = self.mesh[symbol.domain]
else:
discretised_symbol.mesh = None
_discretised_symbol = self._discretised_symbols.get(symbol)
if _discretised_symbol is not None:
return _discretised_symbol
discretised_symbol = self._process_symbol(symbol)
self._discretised_symbols[symbol] = discretised_symbol
discretised_symbol.test_shape()

# Assign mesh as an attribute to the processed variable
if symbol.domain != []:
discretised_symbol.mesh = self.mesh[symbol.domain]
else:
discretised_symbol.mesh = None

# Assign secondary mesh
if symbol.domains["secondary"] != []:
discretised_symbol.secondary_mesh = self.mesh[
symbol.domains["secondary"]
]
else:
discretised_symbol.secondary_mesh = None
# Assign secondary mesh
if symbol.domains["secondary"] != []:
discretised_symbol.secondary_mesh = self.mesh[symbol.domains["secondary"]]
else:
discretised_symbol.secondary_mesh = None

# Assign tertiary mesh
if symbol.domains["tertiary"] != []:
discretised_symbol.tertiary_mesh = self.mesh[symbol.domains["tertiary"]]
else:
discretised_symbol.tertiary_mesh = None
# Assign tertiary mesh
if symbol.domains["tertiary"] != []:
discretised_symbol.tertiary_mesh = self.mesh[symbol.domains["tertiary"]]
else:
discretised_symbol.tertiary_mesh = None

return discretised_symbol
return discretised_symbol

def _process_symbol(self, symbol):
"""See :meth:`Discretisation.process_symbol()`."""
Expand All @@ -841,15 +839,13 @@ def _process_symbol(self, symbol):
self.bcs[key_id] = self.check_tab_conditions(
symbol, self.bcs[key_id]
)
else:
spatial_method = None

if isinstance(symbol, pybamm.BinaryOperator):
# Pre-process children
left, right = symbol.children
# Catch case where diffusion is a scalar and turn it into an identity matrix vector field.
if len(symbol.domain) != 0:
spatial_method = self.spatial_methods[symbol.domain[0]]
else:
spatial_method = None
if isinstance(spatial_method, pybamm.FiniteVolume2D):
if isinstance(left, pybamm.Scalar) and (
isinstance(right, pybamm.VectorField)
Expand Down
16 changes: 8 additions & 8 deletions src/pybamm/expression_tree/operations/convert_to_casadi.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ def convert(
:class:`casadi.MX`
The converted symbol
"""
try:
return self._casadi_symbols[symbol]
except KeyError:
# Change inputs to empty dictionary if it's None
inputs = inputs or {}
casadi_symbol = self._convert(symbol, t, y, y_dot, inputs)
self._casadi_symbols[symbol] = casadi_symbol
_casadi_symbol = self._casadi_symbols.get(symbol)
if _casadi_symbol is not None:
return _casadi_symbol
# Change inputs to empty dictionary if it's None
inputs = inputs or {}
casadi_symbol = self._convert(symbol, t, y, y_dot, inputs)
self._casadi_symbols[symbol] = casadi_symbol

return casadi_symbol
return casadi_symbol

def _convert(self, symbol, t, y, y_dot, inputs):
"""See :meth:`CasadiConverter.convert()`."""
Expand Down
Loading
Loading