From 4bad8f38f65d82260a74061ac9d89d3c96e45165 Mon Sep 17 00:00:00 2001 From: Valentin Sulzer Date: Wed, 20 Mar 2024 19:07:39 -0400 Subject: [PATCH] fix plot_voltage_components to work when time doesn't start at 0 --- CHANGELOG.md | 1 + pybamm/plotting/plot_voltage_components.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c3107e16a..17bd234ca0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ ## Bug Fixes +- `plot_voltage_components` now works even if the time does not start at 0 ([#3915](https://github.com/pybamm-team/PyBaMM/pull/3915)) - Fixed bug where separator porosity was used in calculation instead of transport efficiency ([#3905](https://github.com/pybamm-team/PyBaMM/pull/3905)) - Initial voltage can now match upper or lower cut-offs exactly ([#3842](https://github.com/pybamm-team/PyBaMM/pull/3842)) - Fixed a bug where 1+1D and 2+1D models would not work with voltage or power controlled experiments([#3829](https://github.com/pybamm-team/PyBaMM/pull/3829)) diff --git a/pybamm/plotting/plot_voltage_components.py b/pybamm/plotting/plot_voltage_components.py index 0d1bb7b573..0910d7d031 100644 --- a/pybamm/plotting/plot_voltage_components.py +++ b/pybamm/plotting/plot_voltage_components.py @@ -95,7 +95,7 @@ def plot_voltage_components( time = solution["Time [h]"].entries if split_by_electrode is False: ocv = solution["Battery open-circuit voltage [V]"] - initial_ocv = ocv(0) + initial_ocv = ocv(time[0]) ocv = ocv.entries ax.fill_between( time, ocv, initial_ocv, **kwargs_fill, label="Open-circuit voltage" @@ -103,8 +103,8 @@ def plot_voltage_components( else: ocp_n = solution["Battery negative electrode bulk open-circuit potential [V]"] ocp_p = solution["Battery positive electrode bulk open-circuit potential [V]"] - initial_ocp_n = ocp_n(0) - initial_ocp_p = ocp_p(0) + initial_ocp_n = ocp_n(time[0]) + initial_ocp_p = ocp_p(time[0]) initial_ocv = initial_ocp_p - initial_ocp_n delta_ocp_n = ocp_n.entries - initial_ocp_n delta_ocp_p = ocp_p.entries - initial_ocp_p