Published May 13, 2026 | Version v26.4.3
Software Open

Python Battery Mathematical Modelling (PyBaMM)

Description

v26.4.3 - 2026-05-12

Bug fixes

  • ProcessedVariableComputed.__init__ now defers the heavy initialise_* work (numpy concatenate/flatten, xarray DataArray build) until entries or _xr_data_array is actually read. On a 500-cycle SPM with output_variables set and save_at_cycles=N, solve wall time dropped from ~30 s to ~2.5 s (~12×); per-step __init__ cost dropped from 47% of solve to 1.7%.
  • IDAKLUSolver now records Solution.closest_event_idx after a SUNDIALS root return, so BaseSolver.get_termination_reason can short-circuit instead of re-walking every TERMINATION event's symbolic expression on the Python side. On a 1000-cycle SPM with output_variables set, cumulative allocations dropped 25% (~445 MB) and wall time 16%; the eliminated path was hot in long event-terminated cycling experiments. (#5502)
  • Fixed Serialise.serialise_experiment / deserialise_experiment dropping every constructor argument other than per-step value / duration / terminations / temperature. The top-level period, temperature, and termination arguments to pybamm.Experiment and the per-step period, tags, description, start_time, direction, and skip_ok arguments to BaseStep are now written by to_config() and parsed back by from_config(), so JSON round-tripped experiments preserve user intent. The Resistance step type was also missing from the deserialiser's step-type map and now round-trips correctly.
  • Fixed Serialise.load_custom_model reconstructing Event.event_type as the bare enum name string (e.g. "TERMINATION") instead of the corresponding EventType member. The custom JSON encoder writes Enum values as their .name, but the loader was passing the string straight through to pybamm.Event.__init__, so models round-tripped through to_json / from_json carried string event types rather than EventType enum values. (#5498)
  • Fixed Serialise.serialise_solver silently dropping root_method (and any other nested BaseSolver __init__ argument). After construction, root_method is a BaseSolver instance rather than the original string, so it failed json.dumps and was omitted from the config — making the deserialised solver fall back to the default. to_config() / from_config() now recurse into nested solver values, preserving root_method and its tolerances across the round-trip. (#5497)
  • Fixed Serialise.serialise_experiment silently dropping per-step temperature overrides. The JSON-config round-trip via Experiment.to_config() / Experiment.from_config() now preserves temperature for current, voltage, power, c-rate, and rest steps. (#5496)
  • Fixed Serialise._to_json_safe coercing Python bool values to 0/1 ints because bool is a subclass of int. IDAKLUSolver.to_config() now emits its bool options (compile, print_stats, silence_sundials_errors, etc.) as JSON true/false so they round-trip through strict-bool deserialisers. (#5495)

Notes

If you use PyBaMM, please cite it as below.

Files

pybamm-team/PyBaMM-v26.4.3.zip

Files (10.0 MB)

Name Size Download all
md5:a748780d8316a541b65d1cd0adddcf8c
10.0 MB Preview Download

Additional details

Related works