Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename cathode and anode #1337

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

## Breaking changes

- All example notebooks in PyBaMM's GitHub repository must now include the command `pybamm.print_citations()`, otherwise the tests will fail. This is to encourage people to use this command to cite the relevant papers ([#1340](https://github.com/pybamm-team/PyBaMM/pull/1340))
- Notation has been homogenised to use positive and negative electrode (instead of cathode and anode). This applies to the parameter folders (now called `'positive_electrodes'` and `'negative_electrodes'`) and the options of `active_material` and `particle_cracking` submodels (now called `'positive'` and `'negative'`) ([#1337](https://github.com/pybamm-team/PyBaMM/pull/1337))
- `Interpolant` now takes `x` and `y` instead of a single `data` entry ([#1312](https://github.com/pybamm-team/PyBaMM/pull/1312))
- Boolean model options ('sei porosity change', 'convection') must now be given in string format ('true' or 'false' instead of True or False) ([#1280](https://github.com/pybamm-team/PyBaMM/pull/1280))
Expand Down

Large diffs are not rendered by default.

31 changes: 26 additions & 5 deletions examples/notebooks/parameter-management.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@
"name": "stdout",
"output_type": "stream",
"text": [
"anodes\n",
"cathodes\n",
"cells\n",
"electrolytes\n",
"experiments\n",
"negative_electrodes\n",
"positive_electrodes\n",
"seis\n",
"separators\n"
]
Expand Down Expand Up @@ -382,12 +382,33 @@
"rm -rf lithium-ion"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## References\n",
"\n",
"The relevant papers for this notebook are:"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": []
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[1] Charles R. Harris, K. Jarrod Millman, Stéfan J. van der Walt, Ralf Gommers, Pauli Virtanen, David Cournapeau, Eric Wieser, Julian Taylor, Sebastian Berg, Nathaniel J. Smith, and others. Array programming with NumPy. Nature, 585(7825):357–362, 2020. doi:10.1038/s41586-020-2649-2.\n",
"[2] Valentin Sulzer, Scott G. Marquis, Robert Timms, Martin Robinson, and S. Jon Chapman. Python Battery Mathematical Modelling (PyBaMM). ECSarXiv. February, 2020. doi:10.1149/osf.io/67ckj.\n",
"\n"
]
}
],
"source": [
"pybamm.print_citations()"
]
}
],
"metadata": {
Expand Down
10 changes: 5 additions & 5 deletions examples/notebooks/parameter-values.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Marquis2019 chemistry set is {'chemistry': 'lithium-ion', 'cell': 'kokam_Marquis2019', 'negative electrode': 'graphite_mcmb2528_Marquis2019', 'separator': 'separator_Marquis2019', 'positive electrode': 'lico2_Marquis2019', 'electrolyte': 'lipf6_Marquis2019', 'experiment': '1C_discharge_from_full_Marquis2019', 'sei': 'example', 'citation': 'marquis2019asymptotic'}\n",
"Marquis2019 chemistry set is {'chemistry': 'lithium-ion', 'cell': 'kokam_Marquis2019', 'negative electrode': 'graphite_mcmb2528_Marquis2019', 'separator': 'separator_Marquis2019', 'positive electrode': 'lico2_Marquis2019', 'electrolyte': 'lipf6_Marquis2019', 'experiment': '1C_discharge_from_full_Marquis2019', 'sei': 'example', 'citation': 'Marquis2019'}\n",
"Negative current collector thickness is 2.5e-05 m\n"
]
}
Expand Down Expand Up @@ -154,7 +154,7 @@
"parameter values are {'a': 4,\n",
" 'b': 5,\n",
" 'c': 6,\n",
" 'cube function': <function cubed at 0x7f10f48c6830>}\n"
" 'cube function': <function cubed at 0x7f256a6a2c20>}\n"
]
}
],
Expand Down Expand Up @@ -184,8 +184,8 @@
"parameter values are {'a': 4,\n",
" 'b': 5,\n",
" 'c': 6,\n",
" 'cube function': <function cubed at 0x7f10f48c6830>,\n",
" 'square function': <function squared at 0x7f10f48c6ef0>}\n"
" 'cube function': <function cubed at 0x7f256a6a2c20>,\n",
" 'square function': <function squared at 0x7f256a6a6a70>}\n"
]
}
],
Expand Down Expand Up @@ -422,7 +422,7 @@
{
"data": {
"text/plain": [
"{Variable(-0x32b84c9e07545152, u, children=[], domain=[], auxiliary_domains={}): Multiplication(-0x13c9e646b0e82c50, *, children=['-a', 'y[0:1]'], domain=[], auxiliary_domains={})}"
"{Variable(-0x2e6cebb54b15a377, u, children=[], domain=[], auxiliary_domains={}): Multiplication(0x666a98b3f8fc11c2, *, children=['-a', 'y[0:1]'], domain=[], auxiliary_domains={})}"
]
},
"execution_count": 12,
Expand Down
23 changes: 23 additions & 0 deletions pybamm/parameters/parameter_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pandas as pd
import os
import numbers
import warnings
from pprint import pformat
from collections import defaultdict

Expand Down Expand Up @@ -152,6 +153,28 @@ def update_from_chemistry(self, chemistry):
if "sei" in chemistry:
component_groups += ["sei"]

if "anode" in chemistry.keys():
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tinosulzer @tlestang here are the warnings/errors you suggested, in case you want to take a look. Otherwise, let me know and I will merge the branch.

chemistry["negative electrode"] = chemistry["anode"]
warnings.warn(
"the 'anode' component notation will be deprecated in the next "
"release, as it has now been renamed to 'negative electrode'. "
"Simulation will continue passing the 'anode' component as 'negative "
"electrode' (it might overwrite any existing definition of the "
"component).",
DeprecationWarning,
)

if "cathode" in chemistry.keys():
chemistry["positive electrode"] = chemistry["cathode"]
warnings.warn(
"the 'cathode' component notation will be deprecated in the next "
"release, as it has now been renamed to 'positive electrode'. "
"Simulation will continue passing the 'cathode' component as 'positive "
"electrode' (it might overwrite any existing definition of the "
"component).",
DeprecationWarning,
)

for component_group in component_groups:
# Make sure component is provided
try:
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/test_parameters/test_parameter_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,17 @@ def some_function(self):
self.assertEqual(df[1]["b"], "[function]some_function")
self.assertEqual(df[1]["c"], "[data]some_data")

def test_deprecate_anode_cathode(self):
chemistry = pybamm.parameter_sets.Ecker2015
chemistry["anode"] = chemistry["negative electrode"]
with self.assertWarnsRegex(DeprecationWarning, "anode"):
pybamm.ParameterValues(chemistry=chemistry)

chemistry = pybamm.parameter_sets.Ecker2015
chemistry["cathode"] = chemistry["positive electrode"]
with self.assertWarnsRegex(DeprecationWarning, "cathode"):
pybamm.ParameterValues(chemistry=chemistry)


if __name__ == "__main__":
print("Add -v for more debug output")
Expand Down