From e06d5b95d19a0de74ade096a9133101753daa674 Mon Sep 17 00:00:00 2001 From: Alexander Bills Date: Fri, 17 Mar 2023 14:15:30 -0400 Subject: [PATCH 1/2] fix --- .../lithium_ion/electrode_soh.py | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/pybamm/models/full_battery_models/lithium_ion/electrode_soh.py b/pybamm/models/full_battery_models/lithium_ion/electrode_soh.py index a94b0c11eb..c08fc28c29 100644 --- a/pybamm/models/full_battery_models/lithium_ion/electrode_soh.py +++ b/pybamm/models/full_battery_models/lithium_ion/electrode_soh.py @@ -246,14 +246,19 @@ def solve(self, inputs): sol_dict = {key: sol[key].data[0] for key in sol.all_models[0].variables.keys()} # Calculate theoretical energy - x_0 = sol_dict["x_0"] - y_0 = sol_dict["y_0"] - x_100 = sol_dict["x_100"] - y_100 = sol_dict["y_100"] - energy = pybamm.lithium_ion.electrode_soh.theoretical_energy_integral( - self.parameter_values, x_100, x_0, y_100, y_0 - ) - sol_dict.update({"Maximum theoretical energy [W.h]": energy}) + try: + x_0 = sol_dict["x_0"] + y_0 = sol_dict["y_0"] + x_100 = sol_dict["x_100"] + y_100 = sol_dict["y_100"] + energy = pybamm.lithium_ion.electrode_soh.theoretical_energy_integral( + self.parameter_values, x_100, x_0, y_100, y_0 + ) + sol_dict.update({"Maximum theoretical energy [W.h]": energy}) + except pybamm.ValueError as my_err: + warnings.warn("couldn't calculate theoretical energy") + + return sol_dict def _set_up_solve(self, inputs): From 688c9a07e9f86842bc96776d6b3d60c6bbb1a057 Mon Sep 17 00:00:00 2001 From: Alexander Bills Date: Fri, 17 Mar 2023 14:38:48 -0400 Subject: [PATCH 2/2] fix exception --- pybamm/models/full_battery_models/lithium_ion/electrode_soh.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pybamm/models/full_battery_models/lithium_ion/electrode_soh.py b/pybamm/models/full_battery_models/lithium_ion/electrode_soh.py index c08fc28c29..83d0b85075 100644 --- a/pybamm/models/full_battery_models/lithium_ion/electrode_soh.py +++ b/pybamm/models/full_battery_models/lithium_ion/electrode_soh.py @@ -255,7 +255,7 @@ def solve(self, inputs): self.parameter_values, x_100, x_0, y_100, y_0 ) sol_dict.update({"Maximum theoretical energy [W.h]": energy}) - except pybamm.ValueError as my_err: + except: warnings.warn("couldn't calculate theoretical energy")