Skip to content

Commit

Permalink
Merge pull request #3445 from pybamm-team/issue-3428-rename-exchange
Browse files Browse the repository at this point in the history
#3428 exchange-current density error
  • Loading branch information
valentinsulzer authored Oct 16, 2023
2 parents 0433a46 + 242b672 commit 8429903
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down
20 changes: 19 additions & 1 deletion pybamm/parameters/parameter_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/test_parameters/test_parameter_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 8429903

Please sign in to comment.