Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- Fix a bug in setting initial stoichiometries where the reference temperature was used instead of the initial temperature. ([#5189](https://github.com/pybamm-team/PyBaMM/pull/5189))
- Fix a bug in the calculation of "Bulk" OCP terms in hysteresis models ([#5169](https://github.com/pybamm-team/PyBaMM/pull/5169))
- Fixed a bug where the final duration of a drive cycle would not be inferred correctly. ([#5153](https://github.com/pybamm-team/PyBaMM/pull/5153))
- Fixes a bug where sensitivities for 1D+ variables calculated using the `output_variables` options were incorrect ([#5118](https://github.com/pybamm-team/PyBaMM/pull/5118))

# [v25.8.0](https://github.com/pybamm-team/PyBaMM/tree/v25.8.0) - 2025-08-04

Expand Down
18 changes: 15 additions & 3 deletions tests/unit/test_solvers/test_idaklu_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -942,9 +942,10 @@ def test_with_output_variables_and_sensitivities(self):

# Use a selection of variables of different types
output_variables = [
"Voltage [V]",
"Time [min]",
"x [m]",
"Voltage [V]", # 0D
"x [m]", # 1D, empty sensitivities
"Negative electrode potential [V]", # 1D
"Negative particle concentration [mol.m-3]", # 2D
"Throughput capacity [A.h]", # ExplicitTimeIntegral
]

Expand Down Expand Up @@ -993,6 +994,17 @@ def test_with_output_variables_and_sensitivities(self):
== sol_all[varname].sensitivities["all"].shape
)

# test each of the sensitivity calculations match
for varname in output_variables:
for key in input_parameters:
np.testing.assert_allclose(
sol[varname].sensitivities[key],
sol_all[varname].sensitivities[key],
rtol=tol,
atol=tol,
err_msg=f"Failed for '{varname}', sensitivity '{key}'",
)

def test_with_output_variables_and_event_termination(self):
model = pybamm.lithium_ion.DFN()
parameter_values = pybamm.ParameterValues("Chen2020")
Expand Down
Loading