Skip to content

Commit 313dd7f

Browse files
Merge pull request #5297 from pybamm-team/25.10.2
Release v25.10.2
2 parents fd26b09 + 552079d commit 313dd7f

File tree

10 files changed

+34
-10
lines changed

10 files changed

+34
-10
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
## Bug fixes
66

7+
# [v25.10.2](https://github.com/pybamm-team/PyBaMM/tree/v25.10.2) - 2025-11-27
8+
9+
- Fix a bug with serialising `InputParameter`s. ([#5289](https://github.com/pybamm-team/PyBaMM/pull/5289))
10+
- Fix a bug with missing inputs for `initial_conditions_from` scale evaluation ([#5285](https://github.com/pybamm-team/PyBaMM/pull/5285))
11+
712
# [v25.10.1](https://github.com/pybamm-team/PyBaMM/tree/v25.10.1) - 2025-11-14
813

914
## Features

CITATION.cff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ keywords:
2424
- "expression tree"
2525
- "python"
2626
- "symbolic differentiation"
27-
version: "25.10.1"
27+
version: "25.10.2"
2828
repository-code: "https://github.com/pybamm-team/PyBaMM"
2929
title: "Python Battery Mathematical Modelling (PyBaMM)"

docs/source/examples/notebooks/creating_models/4-comparing-full-and-reduced-order-models.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"$$\n",
2525
"\\left.c\\right\\vert_{t=0} = c_0,\n",
2626
"$$\n",
27-
"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",
27+
"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",
2828
"\n",
2929
"As in the previous example we use the following parameters:\n",
3030
"\n",

src/pybamm/expression_tree/operations/serialise.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,6 +1625,8 @@ def convert_symbol_from_json(json_data):
16251625
elif json_data["type"] == "Parameter":
16261626
# Convert stored parameters back to PyBaMM Parameter objects
16271627
return pybamm.Parameter(json_data["name"])
1628+
elif json_data["type"] == "InputParameter":
1629+
return pybamm.InputParameter(json_data["name"])
16281630
elif json_data["type"] == "Scalar":
16291631
# Convert stored numerical values back to PyBaMM Scalar objects
16301632
return pybamm.Scalar(json_data["value"])

src/pybamm/models/base_model.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,12 @@ def _build_model(self):
906906
self.build_model_equations()
907907

908908
def set_initial_conditions_from(
909-
self, solution, inplace=True, return_type="model", mesh=None
909+
self,
910+
solution,
911+
inputs=None,
912+
inplace=True,
913+
return_type="model",
914+
mesh=None,
910915
):
911916
"""
912917
Update initial conditions with the final states from a Solution object or from
@@ -918,6 +923,8 @@ def set_initial_conditions_from(
918923
----------
919924
solution : :class:`pybamm.Solution`, or dict
920925
The solution to use to initialize the model
926+
inputs : dict
927+
The dictionary of model input parameters.
921928
inplace : bool, optional
922929
Whether to modify the model inplace or create a new model (default True)
923930
return_type : str, optional
@@ -1081,7 +1088,7 @@ def get_variable_state(var):
10811088
scale, reference = pybamm.Scalar(1), pybamm.Scalar(0)
10821089
initial_conditions[var] = (
10831090
pybamm.Vector(final_state_eval) - reference
1084-
) / scale.evaluate()
1091+
) / scale.evaluate(inputs=inputs)
10851092

10861093
# Also update the concatenated initial conditions if the model is already
10871094
# discretised

src/pybamm/models/full_battery_models/lithium_ion/electrode_soh.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -561,14 +561,14 @@ def _set_up_solve(self, inputs, direction):
561561
def _solve_full(self, inputs, ics, direction):
562562
sim = self._get_electrode_soh_sims_full(direction)
563563
sim.build()
564-
sim.built_model.set_initial_conditions_from(ics)
564+
sim.built_model.set_initial_conditions_from(ics, inputs=inputs)
565565
sol = sim.solve([0], inputs=inputs)
566566
return sol
567567

568568
def _solve_split(self, inputs, ics, direction):
569569
x100_sim, x0_sim = self._get_electrode_soh_sims_split(direction)
570570
x100_sim.build()
571-
x100_sim.built_model.set_initial_conditions_from(ics)
571+
x100_sim.built_model.set_initial_conditions_from(ics, inputs=inputs)
572572
x100_sol = x100_sim.solve([0], inputs=inputs)
573573
if self.options["open-circuit potential"] == "MSMR":
574574
inputs["Un(x_100)"] = x100_sol["Un(x_100)"].data[0]
@@ -577,7 +577,7 @@ def _solve_split(self, inputs, ics, direction):
577577
inputs["x_100"] = x100_sol["x_100"].data[0]
578578
inputs["y_100"] = x100_sol["y_100"].data[0]
579579
x0_sim.build()
580-
x0_sim.built_model.set_initial_conditions_from(ics)
580+
x0_sim.built_model.set_initial_conditions_from(ics, inputs=inputs)
581581
x0_sol = x0_sim.solve([0], inputs=inputs)
582582

583583
return x0_sol

src/pybamm/models/submodels/interface/kinetics/butler_volmer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class SymmetricButlerVolmer(BaseKinetics):
1212
Submodel which implements the symmetric forward Butler-Volmer equation:
1313
1414
.. math::
15-
j = 2 * j_0(c) * \\sinh(ne * F * \\eta_r(c) / RT)
15+
j = 2 * j_0(c) * \\sinh(ne * F * \\eta_r(c) / 2RT)
1616
1717
Parameters
1818
----------

src/pybamm/models/submodels/interface/open_circuit_potential/base_hysteresis_ocp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def _get_coupled_variables(self, variables):
8484
U_eq = self.phase_param.U(sto_surf, T)
8585
U_eq_x_av = self.phase_param.U(sto_surf, T)
8686
U_lith = self.phase_param.U(sto_surf, T, "lithiation")
87-
U_lith_bulk = self.phase_param.U(sto_bulk, T_bulk)
87+
U_lith_bulk = self.phase_param.U(sto_bulk, T_bulk, "lithiation")
8888
U_delith = self.phase_param.U(sto_surf, T, "delithiation")
8989
U_delith_bulk = self.phase_param.U(sto_bulk, T_bulk, "delithiation")
9090

src/pybamm/solvers/base_solver.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1381,7 +1381,9 @@ def step(
13811381

13821382
else:
13831383
_, concatenated_initial_conditions = model.set_initial_conditions_from(
1384-
old_solution, return_type="ics"
1384+
old_solution,
1385+
inputs=model_inputs,
1386+
return_type="ics",
13851387
)
13861388
model.y0 = concatenated_initial_conditions.evaluate(0, inputs=model_inputs)
13871389
if using_sensitivities:

tests/unit/test_serialisation/test_serialisation.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,14 @@ def test_serialise_time(self):
617617
t2 = convert_symbol_from_json(j)
618618
assert isinstance(t2, pybamm.Time)
619619

620+
def test_serialise_input_parameter(self):
621+
"""Test InputParameter serialization and deserialization."""
622+
ip = pybamm.InputParameter("test_param")
623+
j = convert_symbol_to_json(ip)
624+
ip_restored = convert_symbol_from_json(j)
625+
assert isinstance(ip_restored, pybamm.InputParameter)
626+
assert ip_restored.name == "test_param"
627+
620628
def test_convert_symbol_to_json_with_number_and_list(self):
621629
for val in (0, 3.14, -7, True):
622630
out = convert_symbol_to_json(val)

0 commit comments

Comments
 (0)