diff --git a/CHANGELOG.md b/CHANGELOG.md index 421d3bfa29..d9583ee31c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ # [v23.9rc0](https://github.com/pybamm-team/PyBaMM/tree/v23.9rc0) - 2023-10-31 ## Features + - The parameter "Ambient temperature [K]" can now be given as a function of position `(y,z)` and time `t`. The "edge" and "current collector" heat transfer coefficient parameters can also depend on `(y,z)` ([#3257](https://github.com/pybamm-team/PyBaMM/pull/3257)) - Spherical and cylindrical shell domains can now be solved with any boundary conditions ([#3237](https://github.com/pybamm-team/PyBaMM/pull/3237)) - Processed variables now get the spatial variables automatically, allowing plotting of more generic models ([#3234](https://github.com/pybamm-team/PyBaMM/pull/3234)) @@ -44,6 +45,7 @@ ## Breaking changes +- The parameter "Exchange-current density for lithium plating [A.m-2]" has been renamed to "Exchange-current density for lithium metal electrode [A.m-2]" when referring to the lithium plating reaction on the surface of a lithium metal electrode ([#3445](https://github.com/pybamm-team/PyBaMM/pull/3445)) - Dropped support for i686 (32-bit) architectures on GNU/Linux distributions ([#3412](https://github.com/pybamm-team/PyBaMM/pull/3412)) - The class `pybamm.thermal.OneDimensionalX` has been moved to `pybamm.thermal.pouch_cell.OneDimensionalX` to reflect the fact that the model formulation implicitly assumes a pouch cell geometry ([#3257](https://github.com/pybamm-team/PyBaMM/pull/3257)) - The "lumped" thermal option now always used the parameters "Cell cooling surface area [m2]", "Cell volume [m3]" and "Total heat transfer coefficient [W.m-2.K-1]" to compute the cell cooling regardless of the chosen "cell geometry" option. The user must now specify the correct values for these parameters instead of them being calculated based on e.g. a pouch cell. An `OptionWarning` is raised to let users know to update their parameters ([#3257](https://github.com/pybamm-team/PyBaMM/pull/3257)) diff --git a/pybamm/parameters/parameter_values.py b/pybamm/parameters/parameter_values.py index 136d9737aa..e69291035d 100644 --- a/pybamm/parameters/parameter_values.py +++ b/pybamm/parameters/parameter_values.py @@ -119,7 +119,25 @@ def create_from_bpx(filename, target_soc=1): return pybamm.ParameterValues(pybamm_dict) def __getitem__(self, key): - return self._dict_items[key] + try: + return self._dict_items[key] + except KeyError as err: + if ( + "Exchange-current density for lithium metal electrode [A.m-2]" + in err.args[0] + and "Exchange-current density for plating [A.m-2]" in self._dict_items + ): + raise KeyError( + "'Exchange-current density for plating [A.m-2]' has been renamed " + "to 'Exchange-current density for lithium metal electrode [A.m-2]' " + "when referring to the reaction at the surface of a lithium metal " + "electrode. This is to avoid confusion with the exchange-current " + "density for the lithium plating reaction in a porous negative " + "electrode. To avoid this error, change your parameter file to use " + "the new name." + ) + else: + raise err def get(self, key, default=None): """Return item corresponding to key if it exists, otherwise return default""" diff --git a/tests/unit/test_parameters/test_parameter_values.py b/tests/unit/test_parameters/test_parameter_values.py index c6a4831e86..cc1f954686 100644 --- a/tests/unit/test_parameters/test_parameter_values.py +++ b/tests/unit/test_parameters/test_parameter_values.py @@ -977,6 +977,19 @@ def test_evaluate(self): with self.assertRaises(ValueError): parameter_values.evaluate(y) + def test_exchange_current_density_plating(self): + parameter_values = pybamm.ParameterValues( + {"Exchange-current density for plating [A.m-2]": 1} + ) + param = pybamm.Parameter( + "Exchange-current density for lithium metal electrode [A.m-2]" + ) + with self.assertRaisesRegex( + KeyError, + "referring to the reaction at the surface of a lithium metal electrode", + ): + parameter_values.evaluate(param) + if __name__ == "__main__": print("Add -v for more debug output")