Skip to content

Commit 884c40a

Browse files
committed
Merge branch 'develop' into issue-2358-add-temperature-to-experiment
2 parents 04b59e6 + fa5ec1b commit 884c40a

File tree

148 files changed

+4060
-4062
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+4060
-4062
lines changed

.all-contributorsrc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,8 @@
529529
"profile": "https://github.com/agriyakhetarpal",
530530
"contributions": [
531531
"infra",
532-
"code"
532+
"code",
533+
"doc"
533534
]
534535
},
535536
{
@@ -542,6 +543,15 @@
542543
"test",
543544
"doc"
544545
]
546+
},
547+
{
548+
"login": "iatzak",
549+
"name": "iatzak",
550+
"avatar_url": "https://avatars.githubusercontent.com/u/112731474?v=4",
551+
"profile": "https://github.com/iatzak",
552+
"contributions": [
553+
"doc"
554+
]
545555
}
546556
],
547557
"contributorsPerLine": 7,

.github/workflows/periodic_benchmarks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
with:
2626
python-version: 3.8
2727
- name: Install tox and asv
28-
run: pip install -U pip tox asv
28+
run: pip install -U pip "tox<4" asv
2929
- name: Run benchmarks
3030
run: |
3131
asv machine --machine "GitHubRunner"

.github/workflows/publish_pypi.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ jobs:
7979
if: matrix.os == 'macos-latest'
8080
run: |
8181
# https://github.com/actions/virtual-environments/issues/1280
82+
rm -f /usr/local/bin/2to3*
83+
rm -f /usr/local/bin/idle3*
84+
rm -f /usr/local/bin/pydoc3*
85+
rm -f /usr/local/bin/python3*
8286
brew update
8387
brew reinstall gcc
8488
python -m pip install cmake wget

.github/workflows/run_benchmarks_over_history.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
with:
2929
python-version: 3.8
3030
- name: Install tox and asv
31-
run: pip install -U pip tox asv
31+
run: pip install -U pip "tox<4" asv
3232
- name: Fetch develop branch
3333
# Not required when worklow trigerred
3434
# on develop, but useful when

.github/workflows/test_on_push.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636

3737
- name: Check style
3838
run: |
39-
python -m pip install tox
39+
python -m pip install "tox<4"
4040
tox -e flake8
4141
4242
build:
@@ -68,7 +68,10 @@ jobs:
6868
- name: Install MacOS system dependencies
6969
if: matrix.os == 'macos-latest'
7070
run: |
71-
rm -f /usr/local/bin/2to3
71+
rm -f /usr/local/bin/2to3*
72+
rm -f /usr/local/bin/idle3*
73+
rm -f /usr/local/bin/pydoc3*
74+
rm -f /usr/local/bin/python3*
7275
brew update
7376
brew install graphviz
7477
brew install openblas
@@ -80,7 +83,7 @@ jobs:
8083
- name: Install standard python dependencies
8184
run: |
8285
python -m pip install --upgrade pip wheel setuptools
83-
python -m pip install tox
86+
python -m pip install "tox<4"
8487
8588
- name: Install SuiteSparse and Sundials
8689
if: matrix.os == 'ubuntu-latest'

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ repos:
1010
exclude: assets/js/webapp\.js
1111

1212
- repo: https://github.com/psf/black
13-
rev: 22.10.0
13+
rev: 22.12.0
1414
hooks:
1515
- id: black
1616

CHANGELOG.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,45 @@
11
# [Unreleased](https://github.com/pybamm-team/PyBaMM/)
22

3+
## Features
4+
5+
- 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)).
6+
7+
# [v22.12](https://github.com/pybamm-team/PyBaMM/tree/v22.12) - 2022-12-31
8+
9+
## Features
10+
11+
- Added functionality to create `pybamm.ParameterValues` from a [BPX standard](https://github.com/pybamm-team/BPX) JSON file ([#2555](https://github.com/pybamm-team/PyBaMM/pull/2555)).
12+
- Allow the option "surface form" to be "differential" in the `MPM` ([#2533](https://github.com/pybamm-team/PyBaMM/pull/2533))
13+
- Added variables "Loss of lithium due to loss of active material in negative/positive electrode [mol]". These should be included in the calculation of "total lithium in system" to make sure that lithium is truly conserved. ([#2529](https://github.com/pybamm-team/PyBaMM/pull/2529))
14+
- `initial_soc` can now be a string "x V", in which case the simulation is initialized to start from that voltage ([#2508](https://github.com/pybamm-team/PyBaMM/pull/2508))
15+
- The `ElectrodeSOH` solver can now calculate electrode balance based on a target "cell capacity" (requires cell capacity "Q" as input), as well as the default "cyclable cell capacity" (requires cyclable lithium capacity "Q_Li" as input). Use the keyword argument `known_value` to control which is used. ([#2508](https://github.com/pybamm-team/PyBaMM/pull/2508))
16+
17+
## Bug fixes
18+
19+
- Allow models that subclass `BaseBatteryModel` to use custom options classes ([#2571](https://github.com/pybamm-team/PyBaMM/pull/2571))
20+
- Fixed bug with `EntryPoints` in Spyder IDE ([#2584](https://github.com/pybamm-team/PyBaMM/pull/2584))
21+
- Fixed electrolyte conservation when options {"surface form": "algebraic"} are used
22+
- Fixed "constant concentration" electrolyte model so that "porosity times concentration" is conserved when porosity changes ([#2529](https://github.com/pybamm-team/PyBaMM/pull/2529))
23+
- Fix installation on `Google Colab` (`pybtex` and `Colab` issue) ([#2526](https://github.com/pybamm-team/PyBaMM/pull/2526))
24+
25+
## Breaking changes
26+
27+
- Renamed "Negative/Positive electrode SOC" to "Negative/Positive electrode stoichiometry" to avoid confusion with cell SOC ([#2529](https://github.com/pybamm-team/PyBaMM/pull/2529))
28+
- Removed external variables and submodels. InputParameter should now be used in all cases ([#2502](https://github.com/pybamm-team/PyBaMM/pull/2502))
29+
- Trying to use a solver to solve multiple models results in a RuntimeError exception ([#2481](https://github.com/pybamm-team/PyBaMM/pull/2481))
30+
- Inputs for the `ElectrodeSOH` solver are now (i) "Q_Li", the total cyclable capacity of lithium in the electrodes (previously "n_Li", the total number of moles, n_Li = 3600/F \* Q_Li) (ii) "Q_n", the capacity of the negative electrode (previously "C_n"), and "Q_p", the capacity of the positive electrode (previously "C_p") ([#2508](https://github.com/pybamm-team/PyBaMM/pull/2508))
31+
32+
# [v22.11.1](https://github.com/pybamm-team/PyBaMM/tree/v22.11.1) - 2022-12-13
33+
34+
## Bug fixes
35+
36+
- Fixed installation on Google Colab (`pybtex` issues) ([#2547](https://github.com/pybamm-team/PyBaMM/pull/2547/files))
37+
338
# [v22.11](https://github.com/pybamm-team/PyBaMM/tree/v22.11) - 2022-11-30
439

540
## Features
641

42+
- Updated parameter sets so that interpolants are created explicitly in the parameter set python file. This does not change functionality but allows finer control, e.g. specifying a "cubic" interpolator instead of the default "linear" ([#2510](https://github.com/pybamm-team/PyBaMM/pull/2510))
743
- Equivalent circuit models ([#2478](https://github.com/pybamm-team/PyBaMM/pull/2478))
844
- New Idaklu solver options for jacobian type and linear solver, support Sundials v6 ([#2444](https://github.com/pybamm-team/PyBaMM/pull/2444))
945
- Added `scale` and `reference` attributes to `Variable` objects, which can be use to make the ODE/DAE solver better conditioned ([#2440](https://github.com/pybamm-team/PyBaMM/pull/2440))

CITATION.cff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ keywords:
2424
- "expression tree"
2525
- "python"
2626
- "symbolic differentiation"
27-
version: "22.11"
27+
version: "22.12"
2828
repository-code: "https://github.com/pybamm-team/PyBaMM"
2929
title: "Python Battery Mathematical Modelling (PyBaMM)"

CONTRIBUTING.md

Lines changed: 74 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Finally, if you really, really, _really_ love developing PyBaMM, have a look at
6161

6262
## Coding style guidelines
6363

64-
PyBaMM follows the [PEP8 recommendations](https://www.python.org/dev/peps/pep-0008/) for coding style. These are very common guidelines, and community tools have been developed to check how well projects implement them. We recommend using pre-commit hooks to check your code before committing it. See [installing and using pre-commit](https://github.com/pybamm-team/PyBaMM/blob/develop/CONTRIBUTING.md#installing-and using-pre-commit) section for more details.
64+
PyBaMM follows the [PEP8 recommendations](https://www.python.org/dev/peps/pep-0008/) for coding style. These are very common guidelines, and community tools have been developed to check how well projects implement them. We recommend using pre-commit hooks to check your code before committing it. See [installing and using pre-commit](https://github.com/pybamm-team/PyBaMM/blob/develop/CONTRIBUTING.md#installing-and-using-pre-commit) section for more details.
6565

6666
### Flake8
6767

@@ -85,7 +85,7 @@ We use [black](https://black.readthedocs.io/en/stable/) to automatically configu
8585
black {source_file_or_directory}
8686
```
8787

88-
2. Editor: black can be [configured](https://test-black.readthedocs.io/en/latest/editor_integration.html) to automatically reformat a python script each time the script is saved in an editor.
88+
2. Editor: black can be [configured](https://test-black.readthedocs.io/en/latest/editor_integration.html) to automatically reformat a Python script each time the script is saved in an editor.
8989

9090
If you want to use black in your editor, you may need to change the max line length in your editor settings.
9191

@@ -194,67 +194,76 @@ This also means that, if you can't fix the bug yourself, it will be much easier
194194

195195
1. Run individual test scripts instead of the whole test suite:
196196

197-
```bash
198-
python tests/unit/path/to/test
199-
```
197+
```bash
198+
python tests/unit/path/to/test
199+
```
200200

201-
You can also run an individual test from a particular script, e.g.
201+
You can also run an individual test from a particular script, e.g.
202202

203-
```bash
204-
python tests/unit/test_quick_plot.py TestQuickPlot.test_failure
205-
```
203+
```bash
204+
python tests/unit/test_quick_plot.py TestQuickPlot.test_failure
205+
```
206206

207-
If you want to run several, but not all, the tests from a script, you can restrict which tests are run from a particular script by using the skipping decorator:
207+
If you want to run several, but not all, the tests from a script, you can restrict which tests are run from a particular script by using the skipping decorator:
208208

209-
```python
210-
@unittest.skip("")
211-
def test_bit_of_code(self):
212-
...
213-
```
209+
```python
210+
@unittest.skip("")
211+
def test_bit_of_code(self):
212+
...
213+
```
214214

215-
or by just commenting out all the tests you don't want to run 2. Set break points, either in your IDE or using the python debugging module. To use the latter, add the following line where you want to set the break point
215+
or by just commenting out all the tests you don't want to run.
216216

217-
```python
218-
import ipdb; ipdb.set_trace()
219-
```
217+
2. Set break points, either in your IDE or using the Python debugging module. To use the latter, add the following line where you want to set the break point
220218

221-
This will start the [Python interactive debugger](https://gist.github.com/mono0926/6326015). If you want to be able to use magic commands from `ipython`, such as `%timeit`, then set
219+
```python
220+
import ipdb; ipdb.set_trace()
221+
```
222222

223-
```python
224-
from IPython import embed; embed(); import ipdb; ipdb.set_trace()
225-
```
223+
This will start the [Python interactive debugger](https://gist.github.com/mono0926/6326015). If you want to be able to use magic commands from `ipython`, such as `%timeit`, then set
226224

227-
at the break point instead.
228-
Figuring out where to start the debugger is the real challenge. Some good ways to set debugging break points are:
229-
a. Try-except blocks. Suppose the line `do_something_complicated()` is raising a `ValueError`. Then you can put a try-except block around that line as:
225+
```python
226+
from IPython import embed; embed(); import ipdb; ipdb.set_trace()
227+
```
230228

231-
```python
232-
try:
233-
do_something_complicated()
234-
except ValueError:
235-
import ipdb; ipdb.set_trace()
236-
```
229+
at the break point instead.
230+
Figuring out where to start the debugger is the real challenge. Some good ways to set debugging break points are:
237231

238-
This will start the debugger at the point where the `ValueError` was raised, and allow you to investigate further. Sometimes, it is more informative to put the try-except block further up the call stack than exactly where the error is raised.
239-
b. Warnings. If functions are raising warnings instead of errors, it can be hard to pinpoint where this is coming from. Here, you can use the `warnings` module to convert warnings to errors:
232+
1. Try-except blocks. Suppose the line `do_something_complicated()` is raising a `ValueError`. Then you can put a try-except block around that line as:
240233

241-
```python
242-
import warnings
243-
warnings.simplefilter("error")
244-
```
234+
```python
235+
try:
236+
do_something_complicated()
237+
except ValueError:
238+
import ipdb; ipdb.set_trace()
239+
```
245240

246-
Then you can use a try-except block, as in a., but with, for example, `RuntimeWarning` instead of `ValueError`.
247-
c. Stepping through the expression tree. Most calls in PyBaMM are operations on [expression trees](https://github.com/pybamm-team/PyBaMM/blob/develop/examples/notebooks/expression_tree/expression-tree.ipynb). To view an expression tree in ipython, you can use the `render` command:
241+
This will start the debugger at the point where the `ValueError` was raised, and allow you to investigate further. Sometimes, it is more informative to put the try-except block further up the call stack than exactly where the error is raised.
248242

249-
```python
250-
expression_tree.render()
251-
```
243+
2. Warnings. If functions are raising warnings instead of errors, it can be hard to pinpoint where this is coming from. Here, you can use the `warnings` module to convert warnings to errors:
252244

253-
You can then step through the expression tree, using the `children` attribute, to pinpoint exactly where a bug is coming from. For example, if `expression_tree.jac(y)` is failing, you can check `expression_tree.children[0].jac(y)`, then `expression_tree.children[0].children[0].jac(y)`, etc. 3. To isolate whether a bug is in a model, its jacobian or its simplified version, you can set the `use_jacobian` and/or `use_simplify` attributes of the model to `False` (they are both `True` by default for most models). 4. If a model isn't giving the answer you expect, you can try comparing it to other models. For example, you can investigate parameter limits in which two models should give the same answer by setting some parameters to be small or zero. The `StandardOutputComparison` class can be used to compare some standard outputs from battery models. 5. To get more information about what is going on under the hood, and hence understand what is causing the bug, you can set the [logging](https://realpython.com/python-logging/) level to `DEBUG` by adding the following line to your test or script:
245+
```python
246+
import warnings
247+
warnings.simplefilter("error")
248+
```
254249

255-
```python3
256-
pybamm.set_logging_level("DEBUG")
257-
```
250+
Then you can use a try-except block, as in a., but with, for example, `RuntimeWarning` instead of `ValueError`.
251+
252+
3. Stepping through the expression tree. Most calls in PyBaMM are operations on [expression trees](https://github.com/pybamm-team/PyBaMM/blob/develop/examples/notebooks/expression_tree/expression-tree.ipynb). To view an expression tree in ipython, you can use the `render` command:
253+
254+
```python
255+
expression_tree.render()
256+
```
257+
258+
You can then step through the expression tree, using the `children` attribute, to pinpoint exactly where a bug is coming from. For example, if `expression_tree.jac(y)` is failing, you can check `expression_tree.children[0].jac(y)`, then `expression_tree.children[0].children[0].jac(y)`, etc.
259+
260+
3. To isolate whether a bug is in a model, its Jacobian or its simplified version, you can set the `use_jacobian` and/or `use_simplify` attributes of the model to `False` (they are both `True` by default for most models).
261+
4. If a model isn't giving the answer you expect, you can try comparing it to other models. For example, you can investigate parameter limits in which two models should give the same answer by setting some parameters to be small or zero. The `StandardOutputComparison` class can be used to compare some standard outputs from battery models.
262+
5. To get more information about what is going on under the hood, and hence understand what is causing the bug, you can set the [logging](https://realpython.com/python-logging/) level to `DEBUG` by adding the following line to your test or script:
263+
264+
```python3
265+
pybamm.set_logging_level("DEBUG")
266+
```
258267

259268
6. In models that inherit from `pybamm.BaseBatteryModel` (i.e. any battery model), you can use `self.process_parameters_and_discretise` to process a symbol and see what it will look like.
260269

@@ -270,24 +279,26 @@ as above, and then use some of the profiling tools. In order of increasing detai
270279

271280
1. Simple timer. In ipython, the command
272281

273-
```
274-
%time command_to_time()
275-
```
282+
```
283+
%time command_to_time()
284+
```
276285

277-
tells you how long the line `command_to_time()` takes. You can use `%timeit` instead to run the command several times and obtain more accurate timings. 2. Simple profiler. Using `%prun` instead of `%time` will give a brief profiling report 3. Detailed profiler. You can install the detailed profiler `snakeviz` through pip:
286+
tells you how long the line `command_to_time()` takes. You can use `%timeit` instead to run the command several times and obtain more accurate timings.
278287

279-
```bash
280-
pip install snakeviz
281-
```
288+
2. Simple profiler. Using `%prun` instead of `%time` will give a brief profiling report 3. Detailed profiler. You can install the detailed profiler `snakeviz` through pip:
282289

283-
and then, in ipython, run
290+
```bash
291+
pip install snakeviz
292+
```
284293

285-
```
286-
%load_ext snakeviz
287-
%snakeviz command_to_time()
288-
```
294+
and then, in ipython, run
295+
296+
```
297+
%load_ext snakeviz
298+
%snakeviz command_to_time()
299+
```
289300

290-
This will open a window in your browser with detailed profiling information.
301+
This will open a window in your browser with detailed profiling information.
291302

292303
## Documentation
293304

@@ -329,9 +340,9 @@ Adding the command
329340
pybamm.print_citations()
330341
```
331342

332-
to the end of a script will print all citations that were used by that script. This will print bibtex information to the terminal; passing a filename to `print_citations` will print the bibtex information to the specified file instead.
343+
to the end of a script will print all citations that were used by that script. This will print BibTeX information to the terminal; passing a filename to `print_citations` will print the BibTeX information to the specified file instead.
333344

334-
When you contribute code to PyBaMM, you can add your own papers that you would like to be cited if that code is used. First, add the bibtex for your paper to [CITATIONS.txt](pybamm/CITATIONS.txt). Then, add the line
345+
When you contribute code to PyBaMM, you can add your own papers that you would like to be cited if that code is used. First, add the BibTeX for your paper to [CITATIONS.txt](pybamm/CITATIONS.txt). Then, add the line
335346

336347
```python3
337348
pybamm.citations.register("your_paper_bibtex_identifier")
@@ -357,7 +368,7 @@ Note that this file must be kept in sync with the version number in [pybamm/**in
357368

358369
Each change pushed to the PyBaMM GitHub repository will trigger the test and benchmark suites to be run, using [GitHub actions](https://github.com/features/actions).
359370

360-
Tests are run for different operating systems, and for all python versions officially supported by PyBaMM. If you opened a Pull Request, feedback is directly available on the corresponding page. If all tests pass, a green tick will be displayed next to the corresponding test run. If one or more test(s) fail, a red cross will be displayed instead.
371+
Tests are run for different operating systems, and for all Python versions officially supported by PyBaMM. If you opened a Pull Request, feedback is directly available on the corresponding page. If all tests pass, a green tick will be displayed next to the corresponding test run. If one or more test(s) fail, a red cross will be displayed instead.
361372

362373
Similarly, the benchmark suite is automatically run for the most recently pushed commit. Benchmark results are compared to the results available for the latest commit on the `develop` branch. Should any significant performance regression be found, a red cross will be displayed next to the benchmark run.
363374

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2018-2022, the PyBaMM team.
1+
Copyright (c) 2018-2023, the PyBaMM team.
22
All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without

0 commit comments

Comments
 (0)