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

Make release v22.12 #2586

Merged
merged 177 commits into from
Dec 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
177 commits
Select commit Hold shift + click to select a range
326d5cf
#2376 added a draft bpx -> pybamm converter
martinjrobins Oct 18, 2022
7feb92e
#2376 add a bpx test
martinjrobins Oct 18, 2022
f36845d
#2376, added bpx conversions and some defaults, remove events in simu…
martinjrobins Oct 18, 2022
4e8d34c
#2376 match test to parameterised battery, add diffusivity and conduc…
martinjrobins Oct 25, 2022
c682227
#2375 turn events back on
martinjrobins Oct 25, 2022
b38f3a4
#2376 debug function parameters
rtimms Oct 27, 2022
47f8ad2
#2376 debug function parameters
rtimms Nov 1, 2022
4f84c2a
Merge branch 'develop' into i2376-bpx
rtimms Nov 1, 2022
da98f9a
#2376 remove some print stmts
martinjrobins Nov 9, 2022
b7e94e4
#2304 check if model has already been setup
martinjrobins Nov 16, 2022
7152598
Merge branch 'develop' into i2304-multiple-models-to-solver
martinjrobins Nov 21, 2022
178b385
#2304 raise runtimeerror on base solver if multiple models passed
martinjrobins Nov 21, 2022
f3f26c1
#2304 make sure experiment creates multiple solvers
martinjrobins Nov 21, 2022
be19129
#2304 add test for cccv simulation with idaklu and casadi solvers
martinjrobins Nov 21, 2022
4ff066e
#2304 need two cycles to test behavior
martinjrobins Nov 21, 2022
f4a0599
style: pre-commit fixes
pre-commit-ci[bot] Nov 21, 2022
d149c7a
#2376 update to new schema
rtimms Nov 22, 2022
06529cf
#2304 fix step so that multiple simulation solves work again
martinjrobins Nov 23, 2022
fd37869
Merge branch 'i2304-multiple-models-to-solver' of github.com:pybamm-t…
martinjrobins Nov 23, 2022
e2b5533
style: pre-commit fixes
pre-commit-ci[bot] Nov 23, 2022
3b52472
#2304 use solver.set_up for reseting initial conditions
martinjrobins Nov 23, 2022
1a973de
Merge branch 'i2304-multiple-models-to-solver' of github.com:pybamm-t…
martinjrobins Nov 23, 2022
d911b67
#2304 flake8
martinjrobins Nov 23, 2022
23603d0
#2304 add to changelog
martinjrobins Nov 23, 2022
bff61b4
#2304 fix tests
martinjrobins Nov 23, 2022
692c07e
#2304 fix integration test
martinjrobins Nov 23, 2022
c53cafc
#2304 fix integration test idaklu
martinjrobins Nov 23, 2022
32a7a3f
#2376 add sto windows
rtimms Nov 25, 2022
c0178f6
start adding electrode SOH calculation from capacity
valentinsulzer Nov 26, 2022
191a85f
Merge branch 'develop' into electrode-soh-from-C
valentinsulzer Nov 29, 2022
9ee941a
remove external_variables
TomTranter Nov 29, 2022
665b4a2
style: pre-commit fixes
pre-commit-ci[bot] Nov 29, 2022
ccba82c
style
TomTranter Nov 29, 2022
6f1ebff
reformatting esoh solver
valentinsulzer Nov 29, 2022
06cd65c
add new features
valentinsulzer Nov 30, 2022
ee1944d
#2376 entropic change
rtimms Dec 1, 2022
b725674
remove external submodel functionality and test on spme
TomTranter Dec 1, 2022
bf0d676
#2376 debug init events
rtimms Dec 2, 2022
16902f2
#2376 debug init events
rtimms Dec 2, 2022
331d8b1
merge
valentinsulzer Dec 3, 2022
252d6c5
fixing tests
valentinsulzer Dec 3, 2022
89c0c71
style: pre-commit fixes
pre-commit-ci[bot] Dec 3, 2022
54e92c6
flake8
valentinsulzer Dec 3, 2022
98894bb
Merge branch 'electrode-soh-from-C' of github.com:pybamm-team/PyBaMM …
valentinsulzer Dec 3, 2022
15574d9
Fix broken link in CONTRIBUTING.md
iatzak Dec 4, 2022
47eb6f6
Format lists in CONTRIBUTING.md
iatzak Dec 4, 2022
ac40198
style: pre-commit fixes
pre-commit-ci[bot] Dec 4, 2022
8e88114
Merge branch 'develop' into electrode-soh-from-C
valentinsulzer Dec 4, 2022
8059bde
update examples
valentinsulzer Dec 5, 2022
d32373f
flake8
valentinsulzer Dec 5, 2022
b3d40ad
docs: update README.md [skip ci]
allcontributors[bot] Dec 5, 2022
dc9a83b
docs: update .all-contributorsrc [skip ci]
allcontributors[bot] Dec 5, 2022
b21f7f1
Merge pull request #2519 from iatzak/update_contributing_md
valentinsulzer Dec 5, 2022
57fe822
style: pre-commit fixes
pre-commit-ci[bot] Dec 5, 2022
428c7cb
Update thermal test
TomTranter Dec 5, 2022
2e1d559
remove external current collector test for now
TomTranter Dec 5, 2022
26ed995
style
TomTranter Dec 5, 2022
ec68fe1
style: pre-commit fixes
pre-commit-ci[bot] Dec 5, 2022
74170af
Merge pull request #2525 from pybamm-team/all-contributors/add-iatzak
valentinsulzer Dec 5, 2022
cc65b7c
Try checking sys.modules
Saransh-cpp Dec 5, 2022
10f311c
Oops, uncomment casadi
Saransh-cpp Dec 5, 2022
0f9c111
Use default warning
Saransh-cpp Dec 5, 2022
f3e9339
Raise warning when print_citations is called on Colab
Saransh-cpp Dec 5, 2022
f8d7967
Test, minor fix, changelog
Saransh-cpp Dec 5, 2022
2d9c6f1
Fix tests
Saransh-cpp Dec 5, 2022
3377175
Update pybamm/citations.py
Saransh-cpp Dec 5, 2022
e2885f6
Merge branch 'develop' into electrode-soh-from-C
valentinsulzer Dec 5, 2022
6541136
coverage
valentinsulzer Dec 5, 2022
b072d22
Merge pull request #2526 from Saransh-cpp/fix-colab
valentinsulzer Dec 5, 2022
4a6aa03
coverage
valentinsulzer Dec 5, 2022
43ac025
merge develop
valentinsulzer Dec 5, 2022
d6d12cd
remove tests no longer needed
TomTranter Dec 6, 2022
917edca
style: pre-commit fixes
pre-commit-ci[bot] Dec 6, 2022
d5d6bcd
Remove ExternalVariable Class
TomTranter Dec 6, 2022
9aba943
Merge branch 'remove_external_variables' of https://github.com/pybamm…
TomTranter Dec 6, 2022
a10ced0
remove numbers
TomTranter Dec 6, 2022
11895de
switch constant concentration model
valentinsulzer Dec 7, 2022
706a9c7
revert changes to leading order model
valentinsulzer Dec 7, 2022
84ed67c
adding LLI from LAM
valentinsulzer Dec 7, 2022
b26d37c
rob comments
valentinsulzer Dec 7, 2022
27e41be
allow differential surface form with MPM
rtimms Dec 7, 2022
533c6f1
remove Vmin and Vmax
valentinsulzer Dec 8, 2022
10a25f4
style: pre-commit fixes
pre-commit-ci[bot] Dec 8, 2022
44ac24d
MPM w/capacitance tests
rtimms Dec 8, 2022
1c87d5f
style: pre-commit fixes
pre-commit-ci[bot] Dec 8, 2022
35aefd2
MPM w/capacitance fix options
rtimms Dec 8, 2022
9fca870
Merge branch 'mpm-surface-form' of https://github.com/pybamm-team/PyB…
rtimms Dec 8, 2022
a48cce9
Merge branch 'develop' into i2304-multiple-models-to-solver
martinjrobins Dec 9, 2022
319c186
#2304 update changelog
martinjrobins Dec 9, 2022
470e123
#2304 BaseSolver.models_set_up -> BaseSolver._model_set_up
martinjrobins Dec 9, 2022
482e9b3
#2304 flake8
martinjrobins Dec 9, 2022
3961286
Temporarily pin tox < 4
Saransh-cpp Dec 9, 2022
812d393
Merge pull request #2541 from Saransh-cpp/temp-tox
valentinsulzer Dec 9, 2022
4f589ac
Merge branch 'develop' into electrode-soh-from-C
valentinsulzer Dec 9, 2022
34146ad
Merge branch 'develop' into porosity-times-concentration
valentinsulzer Dec 9, 2022
8076c44
flake8
valentinsulzer Dec 9, 2022
c38f385
Merge pull request #2508 from pybamm-team/electrode-soh-from-C
valentinsulzer Dec 10, 2022
f6a456f
merge develop and fix flake8
valentinsulzer Dec 11, 2022
a808951
update changelog and remove print statement
valentinsulzer Dec 11, 2022
98f4812
half-cell tests
valentinsulzer Dec 11, 2022
a37b195
fix DFN tests
valentinsulzer Dec 12, 2022
1c161ab
#2304 propagate solver.models_set_up => solver._model_set_up
martinjrobins Dec 12, 2022
05de70c
Merge branch 'develop' into i2304-multiple-models-to-solver
martinjrobins Dec 12, 2022
17d58e7
#2304 fix some model notebooks
martinjrobins Dec 12, 2022
9a5f9c8
#2304 fix ode_solver notebook
martinjrobins Dec 12, 2022
3e35fb3
#2304 fix dae_solver notebook
martinjrobins Dec 12, 2022
cb83078
#2304 fix speed-up solver
martinjrobins Dec 12, 2022
8616fca
#2304 fix change-settings notebook
martinjrobins Dec 12, 2022
0ddf5db
#2304 fix comparing full and reduced order notebook
martinjrobins Dec 12, 2022
e24a9fc
#2304 models_setup => model_set_up
martinjrobins Dec 12, 2022
1fbad30
fix benchmarks and examples
valentinsulzer Dec 12, 2022
73a33ca
update changelog and add error message for electrode SOC variable
valentinsulzer Dec 12, 2022
0a680d3
reformat explicit integral
valentinsulzer Dec 12, 2022
792050f
fix example
valentinsulzer Dec 12, 2022
91392d0
chore: update pre-commit hooks
pre-commit-ci[bot] Dec 12, 2022
97e2785
Merge pull request #2544 from pybamm-team/pre-commit-ci-update-config
valentinsulzer Dec 13, 2022
0cb1a0b
fix lithium plating example
valentinsulzer Dec 13, 2022
a2f30f2
fix lithium plating example
valentinsulzer Dec 13, 2022
466a875
remove more tests
TomTranter Dec 13, 2022
cb0df91
Merge pull request #2481 from pybamm-team/i2304-multiple-models-to-so…
martinjrobins Dec 13, 2022
c5409f8
Merge branch 'develop' into remove_external_variables
valentinsulzer Dec 13, 2022
3ce5439
flake8 and remove other mentions of external variables/submodels
valentinsulzer Dec 13, 2022
803ac4e
merge develop and address Ferran comments
valentinsulzer Dec 13, 2022
d91dac9
style
valentinsulzer Dec 13, 2022
bff1f46
coverage and error message for wrong order
valentinsulzer Dec 13, 2022
ea1f675
Merge pull request #2502 from pybamm-team/remove_external_variables
valentinsulzer Dec 13, 2022
22e9d5a
merge develop, back to long form for lam
valentinsulzer Dec 13, 2022
0afb069
Merge pull request #2529 from pybamm-team/porosity-times-concentration
valentinsulzer Dec 13, 2022
2c49aa3
Merge branch 'develop' into mpm-surface-form
rtimms Dec 13, 2022
a1d2e55
Merge branch 'develop' into i2376-bpx
rtimms Dec 13, 2022
80e26e1
#2376 update bpx version
rtimms Dec 13, 2022
55a9e2b
add boundary gradient and debugging DFN conservation
valentinsulzer Dec 14, 2022
8e4ce23
fix conservation
valentinsulzer Dec 14, 2022
8ccb2b6
make harder test
valentinsulzer Dec 14, 2022
019823c
changelog
valentinsulzer Dec 14, 2022
93d0453
#2551 fix test
valentinsulzer Dec 14, 2022
6528ea9
#2376 changelog
rtimms Dec 14, 2022
64c01e9
#2376 changelog
rtimms Dec 14, 2022
4149def
style: pre-commit fixes
pre-commit-ci[bot] Dec 14, 2022
e5874bb
#2376 update test
rtimms Dec 14, 2022
c1f9560
Merge branch 'i2376-bpx' of https://github.com/pybamm-team/PyBaMM int…
rtimms Dec 14, 2022
5325def
style: pre-commit fixes
pre-commit-ci[bot] Dec 14, 2022
3859df4
merge develop
valentinsulzer Dec 14, 2022
06ae08d
flake8
valentinsulzer Dec 14, 2022
d4033d3
#2551 skip test for lead-acid
valentinsulzer Dec 14, 2022
4d13032
revert example
valentinsulzer Dec 14, 2022
18d3bc5
Merge pull request #2559 from pybamm-team/main-into-develop
valentinsulzer Dec 14, 2022
3166814
#2376 coverage
rtimms Dec 15, 2022
30ae779
Merge branch 'i2376-bpx' of https://github.com/pybamm-team/PyBaMM int…
rtimms Dec 15, 2022
1f25a1a
Merge pull request #2533 from pybamm-team/mpm-surface-form
rtimms Dec 15, 2022
0084c7a
Merge branch 'develop' into i2376-bpx
rtimms Dec 15, 2022
7800bbc
Merge pull request #2552 from pybamm-team/issue-2551-electrolyte
valentinsulzer Dec 15, 2022
43e2bb6
Merge branch 'develop' into i2376-bpx
rtimms Dec 21, 2022
dcd39ab
#2376 make private
rtimms Dec 21, 2022
c4baa51
Merge pull request #2555 from pybamm-team/i2376-bpx
rtimms Dec 21, 2022
360caaa
fix
valentinsulzer Dec 22, 2022
915812c
try macos fix
valentinsulzer Dec 28, 2022
9c900fc
try macos again
valentinsulzer Dec 28, 2022
a61ac50
macos
valentinsulzer Dec 28, 2022
af1c542
#2534 fix
valentinsulzer Dec 28, 2022
c9c4153
rm pydoc
valentinsulzer Dec 28, 2022
f06aaac
pydoc3 and python3.11
valentinsulzer Dec 28, 2022
d712abd
Update version to v22.12
Dec 28, 2022
36bd708
more python3.11
valentinsulzer Dec 28, 2022
4b09bda
try removing all python3
valentinsulzer Dec 28, 2022
3c4ce28
Merge pull request #2579 from pybamm-team/fix-numpy-1.24
valentinsulzer Dec 28, 2022
eb8b2c8
Merge branch 'develop' into spyder-entry-points
valentinsulzer Dec 28, 2022
1649bda
changelog
valentinsulzer Dec 28, 2022
8a737f2
docs
valentinsulzer Dec 28, 2022
8551da9
try another doc fix
valentinsulzer Dec 28, 2022
f01006b
use try-except
valentinsulzer Dec 28, 2022
297785c
remove local files
brosaplanella Dec 28, 2022
5c750ff
Merge pull request #2587 from pybamm-team/fix-publish-workflow
brosaplanella Dec 28, 2022
0fc3032
try try-except instead
valentinsulzer Dec 28, 2022
c0eb90a
flake8
valentinsulzer Dec 28, 2022
9b139b8
Merge pull request #2584 from pybamm-team/spyder-entry-points
valentinsulzer Dec 28, 2022
e090ada
Merge pull request #2585 from pybamm-team/create-pull-request/patch-c…
valentinsulzer Dec 28, 2022
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
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,15 @@
"test",
"doc"
]
},
{
"login": "iatzak",
"name": "iatzak",
"avatar_url": "https://avatars.githubusercontent.com/u/112731474?v=4",
"profile": "https://github.com/iatzak",
"contributions": [
"doc"
]
}
],
"contributorsPerLine": 7,
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/publish_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ jobs:
if: matrix.os == 'macos-latest'
run: |
# https://github.com/actions/virtual-environments/issues/1280
rm -f /usr/local/bin/2to3*
rm -f /usr/local/bin/idle3*
rm -f /usr/local/bin/pydoc3*
rm -f /usr/local/bin/python3*
brew update
brew reinstall gcc
python -m pip install cmake wget
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/test_on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ jobs:
- name: Install MacOS system dependencies
if: matrix.os == 'macos-latest'
run: |
rm -f /usr/local/bin/2to3
rm -f /usr/local/bin/2to3*
rm -f /usr/local/bin/idle3*
rm -f /usr/local/bin/pydoc3*
rm -f /usr/local/bin/python3*
brew update
brew install graphviz
brew install openblas
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repos:
exclude: assets/js/webapp\.js

- repo: https://github.com/psf/black
rev: 22.10.0
rev: 22.12.0
hooks:
- id: black

Expand Down
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# [Unreleased](https://github.com/pybamm-team/PyBaMM/)

# [v22.12](https://github.com/pybamm-team/PyBaMM/tree/v22.12) - 2022-12-31

## Features

- 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)).
- Allow the option "surface form" to be "differential" in the `MPM` ([#2533](https://github.com/pybamm-team/PyBaMM/pull/2533))
- 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))
- `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))
- 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))

## Bug fixes

- Fixed bug with `EntryPoints` in Spyder IDE ([#2584](https://github.com/pybamm-team/PyBaMM/pull/2584))
- Fixed electrolyte conservation when options {"surface form": "algebraic"} are used
- Fixed "constant concentration" electrolyte model so that "porosity times concentration" is conserved when porosity changes ([#2529](https://github.com/pybamm-team/PyBaMM/pull/2529))
- Fix installation on `Google Colab` (`pybtex` and `Colab` issue) ([#2526](https://github.com/pybamm-team/PyBaMM/pull/2526))

## Breaking changes

- 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))
- Removed external variables and submodels. InputParameter should now be used in all cases ([#2502](https://github.com/pybamm-team/PyBaMM/pull/2502))
- Trying to use a solver to solve multiple models results in a RuntimeError exception ([#2481](https://github.com/pybamm-team/PyBaMM/pull/2481))
- 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))

# [v22.11.1](https://github.com/pybamm-team/PyBaMM/tree/v22.11.1) - 2022-12-13

## Bug fixes
Expand Down
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ keywords:
- "expression tree"
- "python"
- "symbolic differentiation"
version: "22.11.1"
version: "22.12"
repository-code: "https://github.com/pybamm-team/PyBaMM"
title: "Python Battery Mathematical Modelling (PyBaMM)"
129 changes: 70 additions & 59 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Finally, if you really, really, _really_ love developing PyBaMM, have a look at

## Coding style guidelines

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.
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.

### Flake8

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

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

```bash
python tests/unit/path/to/test
```
```bash
python tests/unit/path/to/test
```

You can also run an individual test from a particular script, e.g.
You can also run an individual test from a particular script, e.g.

```bash
python tests/unit/test_quick_plot.py TestQuickPlot.test_failure
```
```bash
python tests/unit/test_quick_plot.py TestQuickPlot.test_failure
```

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:
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:

```python
@unittest.skip("")
def test_bit_of_code(self):
...
```
```python
@unittest.skip("")
def test_bit_of_code(self):
...
```

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
or by just commenting out all the tests you don't want to run.

```python
import ipdb; ipdb.set_trace()
```
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

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
```python
import ipdb; ipdb.set_trace()
```

```python
from IPython import embed; embed(); import ipdb; ipdb.set_trace()
```
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

at the break point instead.
Figuring out where to start the debugger is the real challenge. Some good ways to set debugging break points are:
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:
```python
from IPython import embed; embed(); import ipdb; ipdb.set_trace()
```

```python
try:
do_something_complicated()
except ValueError:
import ipdb; ipdb.set_trace()
```
at the break point instead.
Figuring out where to start the debugger is the real challenge. Some good ways to set debugging break points are:

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.
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:
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:

```python
import warnings
warnings.simplefilter("error")
```
```python
try:
do_something_complicated()
except ValueError:
import ipdb; ipdb.set_trace()
```

Then you can use a try-except block, as in a., but with, for example, `RuntimeWarning` instead of `ValueError`.
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:
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.

```python
expression_tree.render()
```
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:

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:
```python
import warnings
warnings.simplefilter("error")
```

```python3
pybamm.set_logging_level("DEBUG")
```
Then you can use a try-except block, as in a., but with, for example, `RuntimeWarning` instead of `ValueError`.

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:

```python
expression_tree.render()
```

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:

```python3
pybamm.set_logging_level("DEBUG")
```

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.

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

1. Simple timer. In ipython, the command

```
%time command_to_time()
```
```
%time command_to_time()
```

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:
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.

```bash
pip install snakeviz
```
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:

and then, in ipython, run
```bash
pip install snakeviz
```

```
%load_ext snakeviz
%snakeviz command_to_time()
```
and then, in ipython, run

```
%load_ext snakeviz
%snakeviz command_to_time()
```

This will open a window in your browser with detailed profiling information.
This will open a window in your browser with detailed profiling information.

## Documentation

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->

[![All Contributors](https://img.shields.io/badge/all_contributors-48-orange.svg)](#-contributors)
[![All Contributors](https://img.shields.io/badge/all_contributors-49-orange.svg)](#-contributors)

<!-- ALL-CONTRIBUTORS-BADGE:END -->

Expand Down Expand Up @@ -218,6 +218,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<td align="center"><a href="https://github.com/abillscmu"><img src="https://avatars.githubusercontent.com/u/48105066?v=4?s=100" width="100px;" alt="Alec Bills"/><br /><sub><b>Alec Bills</b></sub></a><br /><a href="https://github.com/pybamm-team/PyBaMM/commits?author=abillscmu" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/agriyakhetarpal"><img src="https://avatars.githubusercontent.com/u/74401230?v=4?s=100" width="100px;" alt="Agriya Khetarpal"/><br /><sub><b>Agriya Khetarpal</b></sub></a><br /><a href="#infra-agriyakhetarpal" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="https://github.com/pybamm-team/PyBaMM/commits?author=agriyakhetarpal" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/awadell1"><img src="https://avatars.githubusercontent.com/u/5857298?v=4?s=100" width="100px;" alt="Alex Wadell"/><br /><sub><b>Alex Wadell</b></sub></a><br /><a href="https://github.com/pybamm-team/PyBaMM/commits?author=awadell1" title="Code">💻</a> <a href="https://github.com/pybamm-team/PyBaMM/commits?author=awadell1" title="Tests">⚠️</a> <a href="https://github.com/pybamm-team/PyBaMM/commits?author=awadell1" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/iatzak"><img src="https://avatars.githubusercontent.com/u/112731474?v=4?s=100" width="100px;" alt="iatzak"/><br /><sub><b>iatzak</b></sub></a><br /><a href="https://github.com/pybamm-team/PyBaMM/commits?author=iatzak" title="Documentation">📖</a></td>
</tr>
</tbody>
</table>
Expand Down
1 change: 1 addition & 0 deletions casadi-headers
Submodule casadi-headers added at c31bbf
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
author = "The PyBaMM Team"

# The short X.Y version
version = "22.11.1"
version = "22.12"
# The full version, including alpha/beta/rc tags
release = version

Expand Down
3 changes: 0 additions & 3 deletions docs/source/expression_tree/variable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,3 @@ Variable
.. autoclass:: pybamm.VariableDot
:members:

.. autoclass:: pybamm.ExternalVariable
:members:

14 changes: 2 additions & 12 deletions docs/source/models/lithium_ion/electrode_soh.rst
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
Electrode SOH models
====================

.. autoclass:: pybamm.lithium_ion.ElectrodeSOH
:members:

.. autoclass:: pybamm.lithium_ion.ElectrodeSOHx100
:members:

.. autoclass:: pybamm.lithium_ion.ElectrodeSOHx0
:members:

.. autoclass:: pybamm.lithium_ion.ElectrodeSOHSolver
:members:

.. autoclass:: pybamm.lithium_ion.ElectrodeSOHHalfCell
:members:

.. autofunction:: pybamm.lithium_ion.get_initial_stoichiometries

.. autofunction:: pybamm.lithium_ion.get_min_max_stoichiometries
Loading