Skip to content

Commit 377fc45

Browse files
authored
Merge pull request #1131 from pybamm-team/issue-1127-extra-notebooks
Issue 1127 extra notebooks
2 parents cfef53a + 10274fe commit 377fc45

28 files changed

+1900
-609
lines changed

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Features
44

5+
6+
- Added Getting Started notebook on solver options and changing the mesh. Also added a notebook detailing the different thermal options, and a notebook explaining the steps that occur behind the scenes in the `Simulation` class ([#1131](https://github.com/pybamm-team/PyBaMM/pull/1131))
57
- Added particle submodel that use a polynomial approximation to the concentration within the electrode particles ([#1130](https://github.com/pybamm-team/PyBaMM/pull/1130))
68
- Added Modulo, Floor and Ceiling operators ([#1121](https://github.com/pybamm-team/PyBaMM/pull/1121))
79
- Added DFN model for a half cell ([#1121](https://github.com/pybamm-team/PyBaMM/pull/1121))
@@ -24,7 +26,7 @@
2426

2527
## Breaking changes
2628

27-
- The "fast diffusion" particle option has been renamed "uniform profile" ([#1130](https://github.com/pybamm-team/PyBaMM/pull/1130))
29+
- The "fast diffusion" particle option has been renamed "uniform profile" ([#1130](https://github.com/pybamm-team/PyBaMM/pull/1130))
2830
- The modules containing standard parameters are now classes so they can take options
2931
(e.g. `standard_parameters_lithium_ion` is now `LithiumIonParameters`) ([#1120](https://github.com/pybamm-team/PyBaMM/pull/1120))
3032
- Renamed `quick_plot_vars` to `output_variables` in `Simulation` to be consistent with `QuickPlot`. Passing `quick_plot_vars` to `Simulation.plot()` has been deprecated and `output_variables` should be passed instead ([#1099](https://github.com/pybamm-team/PyBaMM/pull/1099))

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ sim = pybamm.Simulation(model, experiment=experiment, solver=pybamm.CasadiSolver
3636
sim.solve()
3737
sim.plot()
3838
```
39-
However, much greater customisation is available. It is possible to change the physics, parameter values, geometry, submesh type, number of submesh points, methods for spatial discretisation and solver for integration (see DFN [script](examples/scripts/DFN.py) or [notebook](examples/notebooks/models/dfn.ipynb)).
39+
However, much greater customisation is available. It is possible to change the physics, parameter values, geometry, submesh type, number of submesh points, methods for spatial discretisation and solver for integration (see DFN [script](examples/scripts/DFN.py) or [notebook](examples/notebooks/models/DFN.ipynb)).
4040

41-
For new users we recommend the [Getting Started](examples/notebooks/Getting%20Started/) guides. These are intended to be very simple step-by-step guides to show the basic functionality of PyBaMM.
41+
For new users we recommend the [Getting Started](examples/notebooks/Getting%20Started/) guides. These are intended to be very simple step-by-step guides to show the basic functionality of PyBaMM, and can either be downloaded and used locally, or used online through [Google Colab](https://colab.research.google.com/github/pybamm-team/PyBaMM/blob/master/).
4242

4343
Further details can be found in a number of [detailed examples](examples/notebooks/README.md), hosted here on
4444
github. In addition, there is a [full API documentation](http://pybamm.readthedocs.io/),
5.17 MB
Binary file not shown.
4.11 MB
Binary file not shown.

examples/notebooks/Getting Started/Tutorial 2 - Compare models.ipynb

+8-1
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,15 @@
119119
"cell_type": "markdown",
120120
"metadata": {},
121121
"source": [
122-
"In this tutorial we have seen how easy it is to run and compare different electrochemical models. In [Tutorial 3](./Tutorial%203%20-%20Basic%20plotting.ipynb) we cover how to simulate and compare different models."
122+
"In this tutorial we have seen how easy it is to run and compare different electrochemical models. In [Tutorial 3](./Tutorial%203%20-%20Basic%20plotting.ipynb) we show how to create different plots using PyBaMM's built-in plotting capability."
123123
]
124+
},
125+
{
126+
"cell_type": "code",
127+
"execution_count": null,
128+
"metadata": {},
129+
"outputs": [],
130+
"source": []
124131
}
125132
],
126133
"metadata": {

examples/notebooks/Getting Started/Tutorial 3 - Basic plotting.ipynb

+44-19
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
"cell_type": "markdown",
1212
"metadata": {},
1313
"source": [
14-
"In [Tutorial 2](./Tutorial%202%20-%20Compare%20models.ipynb), we made use of PyBaMM's automatic plotting function. This gave a good quick overview of many of the key variables in the model. However, by passing in just a few arguments it is easy to plot any of the many other variables that may be of interest to you. We start by building and solving a model as before:"
14+
"In [Tutorial 2](./Tutorial%202%20-%20Compare%20models.ipynb), we made use of PyBaMM's automatic plotting function when comparing models. This gave a good quick overview of many of the key variables in the model. However, by passing in just a few arguments it is easy to plot any of the many other variables that may be of interest to you. We start by building and solving a model as before:"
1515
]
1616
},
1717
{
1818
"cell_type": "code",
19-
"execution_count": 1,
19+
"execution_count": 2,
2020
"metadata": {},
2121
"outputs": [
2222
{
@@ -29,10 +29,10 @@
2929
{
3030
"data": {
3131
"text/plain": [
32-
"<pybamm.solvers.solution.Solution at 0x7f5a7dda5048>"
32+
"<pybamm.solvers.solution.Solution at 0x7f58bbcf9470>"
3333
]
3434
},
35-
"execution_count": 1,
35+
"execution_count": 2,
3636
"metadata": {},
3737
"output_type": "execute_result"
3838
}
@@ -54,7 +54,7 @@
5454
},
5555
{
5656
"cell_type": "code",
57-
"execution_count": 2,
57+
"execution_count": 3,
5858
"metadata": {},
5959
"outputs": [
6060
{
@@ -179,6 +179,8 @@
179179
" 'Negative particle concentration [mol.m-3]',\n",
180180
" 'X-averaged negative particle concentration',\n",
181181
" 'X-averaged negative particle concentration [mol.m-3]',\n",
182+
" 'R-averaged negative particle concentration',\n",
183+
" 'R-averaged negative particle concentration [mol.m-3]',\n",
182184
" 'Negative particle surface concentration',\n",
183185
" 'Negative particle surface concentration [mol.m-3]',\n",
184186
" 'X-averaged negative particle surface concentration',\n",
@@ -191,6 +193,8 @@
191193
" 'Positive particle concentration [mol.m-3]',\n",
192194
" 'X-averaged positive particle concentration',\n",
193195
" 'X-averaged positive particle concentration [mol.m-3]',\n",
196+
" 'R-averaged positive particle concentration',\n",
197+
" 'R-averaged positive particle concentration [mol.m-3]',\n",
194198
" 'Positive particle surface concentration',\n",
195199
" 'Positive particle surface concentration [mol.m-3]',\n",
196200
" 'X-averaged positive particle surface concentration',\n",
@@ -381,12 +385,12 @@
381385
" 'X-averaged positive electrode surface potential difference',\n",
382386
" 'Positive electrode surface potential difference [V]',\n",
383387
" 'X-averaged positive electrode surface potential difference [V]',\n",
388+
" 'Negative particle distribution in x',\n",
384389
" 'Negative particle flux',\n",
385390
" 'X-averaged negative particle flux',\n",
386-
" 'Negative particle distribution in x',\n",
391+
" 'Positive particle distribution in x',\n",
387392
" 'Positive particle flux',\n",
388393
" 'X-averaged positive particle flux',\n",
389-
" 'Positive particle distribution in x',\n",
390394
" 'Negative electrode effective conductivity',\n",
391395
" 'Negative electrode current density',\n",
392396
" 'Negative electrode current density [A.m-2]',\n",
@@ -398,10 +402,22 @@
398402
" 'Electrolyte current density [A.m-2]',\n",
399403
" 'Ohmic heating',\n",
400404
" 'Ohmic heating [W.m-3]',\n",
405+
" 'X-averaged Ohmic heating',\n",
406+
" 'X-averaged Ohmic heating [W.m-3]',\n",
407+
" 'Volume-averaged Ohmic heating',\n",
408+
" 'Volume-averaged Ohmic heating [W.m-3]',\n",
401409
" 'Irreversible electrochemical heating',\n",
402410
" 'Irreversible electrochemical heating [W.m-3]',\n",
411+
" 'X-averaged irreversible electrochemical heating',\n",
412+
" 'X-averaged irreversible electrochemical heating [W.m-3]',\n",
413+
" 'Volume-averaged irreversible electrochemical heating',\n",
414+
" 'Volume-averaged irreversible electrochemical heating[W.m-3]',\n",
403415
" 'Reversible heating',\n",
404416
" 'Reversible heating [W.m-3]',\n",
417+
" 'X-averaged reversible heating',\n",
418+
" 'X-averaged reversible heating [W.m-3]',\n",
419+
" 'Volume-averaged reversible heating',\n",
420+
" 'Volume-averaged reversible heating [W.m-3]',\n",
405421
" 'Total heating',\n",
406422
" 'Total heating [W.m-3]',\n",
407423
" 'X-averaged total heating',\n",
@@ -416,6 +432,8 @@
416432
" 'Sei interfacial current density',\n",
417433
" 'Sei interfacial current density [A.m-2]',\n",
418434
" 'Sei interfacial current density per volume [A.m-3]',\n",
435+
" 'Negative surface area per unit volume distribution in x',\n",
436+
" 'Positive surface area per unit volume distribution in x',\n",
419437
" 'Negative electrode interfacial current density',\n",
420438
" 'X-averaged negative electrode interfacial current density',\n",
421439
" 'Negative electrode interfacial current density [A.m-2]',\n",
@@ -554,7 +572,7 @@
554572
" 'Terminal power [W]']"
555573
]
556574
},
557-
"execution_count": 2,
575+
"execution_count": 3,
558576
"metadata": {},
559577
"output_type": "execute_result"
560578
}
@@ -567,12 +585,12 @@
567585
"cell_type": "markdown",
568586
"metadata": {},
569587
"source": [
570-
"You can also search the list of variables for a particular string (e.g. \"electrolyte\")"
588+
"There are a _lot_ of variables. You can also search the list of variables for a particular string (e.g. \"electrolyte\")"
571589
]
572590
},
573591
{
574592
"cell_type": "code",
575-
"execution_count": 3,
593+
"execution_count": 4,
576594
"metadata": {},
577595
"outputs": [
578596
{
@@ -660,13 +678,13 @@
660678
},
661679
{
662680
"cell_type": "code",
663-
"execution_count": 4,
681+
"execution_count": 5,
664682
"metadata": {},
665683
"outputs": [
666684
{
667685
"data": {
668686
"application/vnd.jupyter.widget-view+json": {
669-
"model_id": "26530e3fbec34dfa921fda4c1490a8f5",
687+
"model_id": "500cc762737441e29f10ad74539ab7ca",
670688
"version_major": 2,
671689
"version_minor": 0
672690
},
@@ -692,13 +710,13 @@
692710
},
693711
{
694712
"cell_type": "code",
695-
"execution_count": 5,
713+
"execution_count": 6,
696714
"metadata": {},
697715
"outputs": [
698716
{
699717
"data": {
700718
"application/vnd.jupyter.widget-view+json": {
701-
"model_id": "d1d16e2c52654cf48e1d3cd398c4ed18",
719+
"model_id": "cf2959d990cb4fc3a8b540f23601f2a5",
702720
"version_major": 2,
703721
"version_minor": 0
704722
},
@@ -724,13 +742,13 @@
724742
},
725743
{
726744
"cell_type": "code",
727-
"execution_count": 6,
745+
"execution_count": 7,
728746
"metadata": {},
729747
"outputs": [
730748
{
731749
"data": {
732750
"application/vnd.jupyter.widget-view+json": {
733-
"model_id": "3d08bfd164df409ca3838bb1edd4d4c9",
751+
"model_id": "7ec90fc467fc4a5aaf48dd137cd88551",
734752
"version_major": 2,
735753
"version_minor": 0
736754
},
@@ -748,13 +766,13 @@
748766
},
749767
{
750768
"cell_type": "code",
751-
"execution_count": 7,
769+
"execution_count": 8,
752770
"metadata": {},
753771
"outputs": [
754772
{
755773
"data": {
756774
"application/vnd.jupyter.widget-view+json": {
757-
"model_id": "c248e1ccf0c34d53b5f2c0e44115e8d5",
775+
"model_id": "8ecaf998bb0748cdaea4e350b2bc4b31",
758776
"version_major": 2,
759777
"version_minor": 0
760778
},
@@ -776,8 +794,15 @@
776794
"source": [
777795
"In this tutorial we have seen how to use the plotting functionality in PyBaMM.\n",
778796
"\n",
779-
"In [Tutorial 4](./Tutorial%204%20-%20Setting%20parameter%20values.ipynb) we show how to change model options."
797+
"In [Tutorial 4](./Tutorial%204%20-%20Setting%20parameter%20values.ipynb) we show how to change parameter values."
780798
]
799+
},
800+
{
801+
"cell_type": "code",
802+
"execution_count": null,
803+
"metadata": {},
804+
"outputs": [],
805+
"source": []
781806
}
782807
],
783808
"metadata": {

examples/notebooks/Getting Started/Tutorial 4 - Setting parameter values.ipynb

+20-17
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
"name": "stdout",
2424
"output_type": "stream",
2525
"text": [
26-
"\u001b[33mWARNING: You are using pip version 20.1.1; however, version 20.2 is available.\n",
27-
"You should consider upgrading via the '/home/ferranbrosa/PyBaMM/env/bin/python -m pip install --upgrade pip' command.\u001b[0m\n",
2826
"Note: you may need to restart the kernel to use updated packages.\n"
2927
]
3028
}
@@ -139,8 +137,8 @@
139137
" 'EC initial concentration in electrolyte [mol.m-3]': 4541.0,\n",
140138
" 'Electrode height [m]': 0.065,\n",
141139
" 'Electrode width [m]': 1.58,\n",
142-
" 'Electrolyte conductivity [S.m-1]': <function electrolyte_conductivity_Nyman2008 at 0x7f24ae784158>,\n",
143-
" 'Electrolyte diffusivity [m2.s-1]': <function electrolyte_diffusivity_Nyman2008 at 0x7f24ae7840d0>,\n",
140+
" 'Electrolyte conductivity [S.m-1]': <function electrolyte_conductivity_Nyman2008 at 0x7f4fbd88a620>,\n",
141+
" 'Electrolyte diffusivity [m2.s-1]': <function electrolyte_diffusivity_Nyman2008 at 0x7f500fac02f0>,\n",
144142
" 'Initial concentration in electrolyte [mol.m-3]': 1000.0,\n",
145143
" 'Initial concentration in negative electrode [mol.m-3]': 29866.0,\n",
146144
" 'Initial concentration in positive electrode [mol.m-3]': 17038.0,\n",
@@ -411,10 +409,9 @@
411409
" 'Negative electrode diffusivity [m2.s-1]': 3.3e-14,\n",
412410
" 'Negative electrode double-layer capacity [F.m-2]': 0.2,\n",
413411
" 'Negative electrode electrons in reaction': 1.0,\n",
414-
" 'Negative electrode exchange-current density [A.m-2]': <function graphite_LGM50_electrolyte_exchange_current_density_Chen2020 at 0x7f24ae7c1ae8>,\n",
412+
" 'Negative electrode exchange-current density [A.m-2]': <function graphite_LGM50_electrolyte_exchange_current_density_Chen2020 at 0x7f5004e5d840>,\n",
415413
" 'Negative electrode porosity': 0.25,\n",
416414
" 'Negative electrode specific heat capacity [J.kg-1.K-1]': 700.0,\n",
417-
" 'Negative electrode surface area to volume ratio [m-1]': 383959.0,\n",
418415
" 'Negative electrode thermal conductivity [W.m-1.K-1]': 1.7,\n",
419416
" 'Negative electrode thickness [m]': 8.52e-05,\n",
420417
" 'Negative particle distribution in x': 1.0,\n",
@@ -679,10 +676,9 @@
679676
" 'Positive electrode diffusivity [m2.s-1]': 4e-15,\n",
680677
" 'Positive electrode double-layer capacity [F.m-2]': 0.2,\n",
681678
" 'Positive electrode electrons in reaction': 1.0,\n",
682-
" 'Positive electrode exchange-current density [A.m-2]': <function nmc_LGM50_electrolyte_exchange_current_density_Chen2020 at 0x7f24ae7c1f28>,\n",
679+
" 'Positive electrode exchange-current density [A.m-2]': <function nmc_LGM50_electrolyte_exchange_current_density_Chen2020 at 0x7f4fbd88a510>,\n",
683680
" 'Positive electrode porosity': 0.335,\n",
684681
" 'Positive electrode specific heat capacity [J.kg-1.K-1]': 700.0,\n",
685-
" 'Positive electrode surface area to volume ratio [m-1]': 382184.0,\n",
686682
" 'Positive electrode thermal conductivity [W.m-1.K-1]': 2.1,\n",
687683
" 'Positive electrode thickness [m]': 7.56e-05,\n",
688684
" 'Positive particle distribution in x': 1.0,\n",
@@ -734,8 +730,8 @@
734730
"output_type": "stream",
735731
"text": [
736732
"EC initial concentration in electrolyte [mol.m-3]\t4541.0\n",
737-
"Electrolyte conductivity [S.m-1]\t<function electrolyte_conductivity_Nyman2008 at 0x7f24ae784158>\n",
738-
"Electrolyte diffusivity [m2.s-1]\t<function electrolyte_diffusivity_Nyman2008 at 0x7f24ae7840d0>\n",
733+
"Electrolyte conductivity [S.m-1]\t<function electrolyte_conductivity_Nyman2008 at 0x7f4fbd88a620>\n",
734+
"Electrolyte diffusivity [m2.s-1]\t<function electrolyte_diffusivity_Nyman2008 at 0x7f500fac02f0>\n",
739735
"Initial concentration in electrolyte [mol.m-3]\t1000.0\n",
740736
"Negative electrode Bruggeman coefficient (electrolyte)\t1.5\n",
741737
"Positive electrode Bruggeman coefficient (electrolyte)\t1.5\n",
@@ -763,7 +759,7 @@
763759
{
764760
"data": {
765761
"application/vnd.jupyter.widget-view+json": {
766-
"model_id": "2b686feb685b4668b970d49bb137c9d2",
762+
"model_id": "2679c387ef134d2eaf3aa2926e45e025",
767763
"version_major": 2,
768764
"version_minor": 0
769765
},
@@ -839,7 +835,7 @@
839835
{
840836
"data": {
841837
"application/vnd.jupyter.widget-view+json": {
842-
"model_id": "256191f9988349ffaf5396faf4bb1fef",
838+
"model_id": "84b98b54fb614eabb0799673de97f6fd",
843839
"version_major": 2,
844840
"version_minor": 0
845841
},
@@ -912,7 +908,7 @@
912908
{
913909
"data": {
914910
"application/vnd.jupyter.widget-view+json": {
915-
"model_id": "bb5a94d141e94425954d4c1963d0f14c",
911+
"model_id": "4f01888556824b2ca66bd91c0fe61783",
916912
"version_major": 2,
917913
"version_minor": 0
918914
},
@@ -974,7 +970,7 @@
974970
{
975971
"data": {
976972
"application/vnd.jupyter.widget-view+json": {
977-
"model_id": "9534fe9341194950b1dc4169752331c2",
973+
"model_id": "08ef31fef963457cbbfe6519c0b5e8ad",
978974
"version_major": 2,
979975
"version_minor": 0
980976
},
@@ -1000,13 +996,20 @@
1000996
"source": [
1001997
"In this notebook we have seen how we can change the parameters of our model. In [Tutorial 5](./Tutorial%205%20-%20Run%20experiments.ipynb) we show how can we define and run experiments."
1002998
]
999+
},
1000+
{
1001+
"cell_type": "code",
1002+
"execution_count": null,
1003+
"metadata": {},
1004+
"outputs": [],
1005+
"source": []
10031006
}
10041007
],
10051008
"metadata": {
10061009
"kernelspec": {
1007-
"display_name": "PyBaMM development (env)",
1010+
"display_name": "Python 3",
10081011
"language": "python",
1009-
"name": "pybamm-dev"
1012+
"name": "python3"
10101013
},
10111014
"language_info": {
10121015
"codemirror_mode": {
@@ -1018,7 +1021,7 @@
10181021
"name": "python",
10191022
"nbconvert_exporter": "python",
10201023
"pygments_lexer": "ipython3",
1021-
"version": "3.6.8"
1024+
"version": "3.6.9"
10221025
}
10231026
},
10241027
"nbformat": 4,

0 commit comments

Comments
 (0)