From 35050577047ae65c3a9569bac412d0c7ed62bdf5 Mon Sep 17 00:00:00 2001 From: Valentin Sulzer Date: Sat, 21 Jan 2023 17:26:18 -0500 Subject: [PATCH 1/2] change success to final time --- pybamm/solvers/algebraic_solver.py | 4 +++- pybamm/solvers/base_solver.py | 2 -- pybamm/solvers/casadi_algebraic_solver.py | 2 +- pybamm/solvers/solution.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pybamm/solvers/algebraic_solver.py b/pybamm/solvers/algebraic_solver.py index 4f36f719d6..2a15108df6 100644 --- a/pybamm/solvers/algebraic_solver.py +++ b/pybamm/solvers/algebraic_solver.py @@ -234,6 +234,8 @@ def jac_norm(y): y_diff = np.r_[[y0_diff] * len(t_eval)].T y_sol = np.r_[y_diff, y_alg] # Return solution object (no events, so pass None to t_event, y_event) - sol = pybamm.Solution(t_eval, y_sol, model, inputs_dict, termination="success") + sol = pybamm.Solution( + t_eval, y_sol, model, inputs_dict, termination="final time" + ) sol.integration_time = integration_time return sol diff --git a/pybamm/solvers/base_solver.py b/pybamm/solvers/base_solver.py index 366fd57c4f..25071562b5 100644 --- a/pybamm/solvers/base_solver.py +++ b/pybamm/solvers/base_solver.py @@ -1302,8 +1302,6 @@ def get_termination_reason(self, solution, events): pybamm.logger.debug("Finish post-processing events") return solution, solution.termination - elif solution.termination == "success": - return solution, solution.termination def check_extrapolation(self, solution, events): """ diff --git a/pybamm/solvers/casadi_algebraic_solver.py b/pybamm/solvers/casadi_algebraic_solver.py index f726adc5da..e7983b7f87 100644 --- a/pybamm/solvers/casadi_algebraic_solver.py +++ b/pybamm/solvers/casadi_algebraic_solver.py @@ -174,7 +174,7 @@ def _integrate(self, model, t_eval, inputs_dict=None): y_sol, model, inputs_dict, - termination="success", + termination="final time", sensitivities=explicit_sensitivities, ) sol.integration_time = integration_time diff --git a/pybamm/solvers/solution.py b/pybamm/solvers/solution.py index 1cb6d9c753..090673cfa9 100644 --- a/pybamm/solvers/solution.py +++ b/pybamm/solvers/solution.py @@ -383,7 +383,7 @@ def first_state(self): self.all_inputs[:1], None, None, - "success", + "final time", ) new_sol._all_inputs_casadi = self.all_inputs_casadi[:1] new_sol._sub_solutions = self.sub_solutions[:1] From 938ff95cea35b0b9fd99d9db6f4664e75f4734fa Mon Sep 17 00:00:00 2001 From: Valentin Sulzer Date: Wed, 25 Jan 2023 20:48:03 -0500 Subject: [PATCH 2/2] changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8094564c2..4d7d57a21c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ - Steps in `Experiment` can now be tagged and cycle numbers be searched based on those tags ([#2593](https://github.com/pybamm-team/PyBaMM/pull/2593)). - New `contact resistance` option, new parameter `Contact resistance [Ohm]` and new variable `Contact overpotential [V]` ([#2598](https://github.com/pybamm-team/PyBaMM/pull/2598)). +## Bug fixes + +- Changed termination from "success" to "final time" for algebraic solvers to match ODE/DAE solvers ([#2613](https://github.com/pybamm-team/PyBaMM/pull/2613)). + # [v22.12](https://github.com/pybamm-team/PyBaMM/tree/v22.12) - 2022-12-31 ## Features