diff --git a/CHANGELOG.md b/CHANGELOG.md index b1a79d380d..678a4000cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Features +- Reformatted Getting Starte notebooks ([#1083](https://github.com/pybamm-team/PyBaMM/pull/1083)) - Reformatted Landesfeind electrolytes ([#1064](https://github.com/pybamm-team/PyBaMM/pull/1064)) - Adapted examples to be run in Google Colab ([#1061](https://github.com/pybamm-team/PyBaMM/pull/1061)) - Added some new solvers for algebraic models ([#1059](https://github.com/pybamm-team/PyBaMM/pull/1059)) @@ -17,7 +18,7 @@ - Fix `QuickPlot` to display variables discretised by FEM (in y-z) properly ([#1078](https://github.com/pybamm-team/PyBaMM/pull/1078)) - Add length scales to `EffectiveResistance` models ([#1071](https://github.com/pybamm-team/PyBaMM/pull/1071)) - Allowed for pybamm functions exp, sin, cos, sqrt to be used in expression trees that - are converted to casadi format ([#1067](https://github.com/pybamm-team/PyBaMM/pull/1067) + are converted to casadi format ([#1067](https://github.com/pybamm-team/PyBaMM/pull/1067)) - Fix a bug where variables that depend on y and z were transposed in `QuickPlot` ([#1055](https://github.com/pybamm-team/PyBaMM/pull/1055)) ## Breaking changes diff --git a/examples/notebooks/Getting Started/Tutorial 1 - How to run a model.ipynb b/examples/notebooks/Getting Started/Tutorial 1 - How to run a model.ipynb index cc5aba4e9f..ab2bc9b28a 100644 --- a/examples/notebooks/Getting Started/Tutorial 1 - How to run a model.ipynb +++ b/examples/notebooks/Getting Started/Tutorial 1 - How to run a model.ipynb @@ -22,7 +22,15 @@ "cell_type": "code", "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Note: you may need to restart the kernel to use updated packages.\n" + ] + } + ], "source": [ "%pip install pybamm -q # install PyBaMM if it is not installed\n", "import pybamm" @@ -32,7 +40,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "We now load the model that we wish to run. For this notebook, we choose the single particle model with electrolyte (SPMe):" + "We now load the model that we wish to run. For this notebook, we choose the Doyle-Fuller-Newman (DFN) model:" ] }, { @@ -41,7 +49,7 @@ "metadata": {}, "outputs": [], "source": [ - "model = pybamm.lithium_ion.SPMe()" + "model = pybamm.lithium_ion.DFN()" ] }, { @@ -71,7 +79,18 @@ "cell_type": "code", "execution_count": 4, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "sim.solve()" ] @@ -91,12 +110,12 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "089df7a7f1f24690b734df6cf83bd550", + "model_id": "1c41a48411a94ff9a6fc19096bb4a0f5", "version_major": 2, "version_minor": 0 }, "text/plain": [ - "interactive(children=(FloatSlider(value=0.0, description='t', max=0.9999999999999999, step=0.05), Output()), _…" + "interactive(children=(FloatSlider(value=0.0, description='t', max=3599.9999999999995, step=35.99999999999999),…" ] }, "metadata": {}, @@ -113,22 +132,15 @@ "source": [ "In this tutorial, we have solved a model with the inbuilt default settings. However, PyBaMM is designed to be highly customisable. Over the course of the getting started tutorials, we will see how various settings can be changed so that the model is appropriate for your situation. \n", "\n", - "In [Tutorial 2](./Tutorial%202%20-%20Setting%20Parameter%20Values.ipynb) we cover setting and changing parameter values." + "In [Tutorial 2](./Tutorial%202%20-%20Compare%20models.ipynb) we cover how to simulate and compare different models." ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "PyBaMM development (env)", "language": "python", - "name": "python3" + "name": "pybamm-dev" }, "language_info": { "codemirror_mode": { diff --git a/examples/notebooks/Getting Started/Tutorial 2 - Compare models.ipynb b/examples/notebooks/Getting Started/Tutorial 2 - Compare models.ipynb new file mode 100644 index 0000000000..9adcc87a9d --- /dev/null +++ b/examples/notebooks/Getting Started/Tutorial 2 - Compare models.ipynb @@ -0,0 +1,147 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Tutorial 2 - Compare models" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In [Tutorial 1](./Tutorial%201%20-%20How%20to%20run%20a%20model.ipynb), we saw how to run a PyBaMM simulation of the DFN model. However, PyBaMM includes other standard electrochemical models such as the Single Particle Model (SPM) and the Single Particle Model with electrolyte (SPMe). In this tutorial, we will see how to simulate and compare these three models. \n", + "\n", + "Again, the first step is to import the pybamm library into the notebook:" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Note: you may need to restart the kernel to use updated packages.\n" + ] + } + ], + "source": [ + "%pip install pybamm -q # install PyBaMM if it is not installed\n", + "import pybamm" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We start creating a list of all the models we wish to solve" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "models = [\n", + " pybamm.lithium_ion.SPM(),\n", + " pybamm.lithium_ion.SPMe(),\n", + " pybamm.lithium_ion.DFN(),\n", + "]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "and now we can loop over the list, creating and solving simulations as we go. The solved simulations are stored in the list `sims`" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "sims = []\n", + "for model in models:\n", + " sim = pybamm.Simulation(model)\n", + " sim.solve()\n", + " sims.append(sim)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We can now pass our list of simulations to the dynamic plot method, which will plot the different outputs in the same figure" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "63e7fa6511714626abc1173c35aad054", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "interactive(children=(FloatSlider(value=0.0, description='t', max=3599.9999999999995, step=35.99999999999999),…" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "pybamm.dynamic_plot(sims, time_unit=\"seconds\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "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." + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "PyBaMM development (env)", + "language": "python", + "name": "pybamm-dev" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.6.8" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/examples/notebooks/Getting Started/Tutorial 2 - Setting Parameter Values.ipynb b/examples/notebooks/Getting Started/Tutorial 2 - Setting Parameter Values.ipynb deleted file mode 100644 index c8591cb93d..0000000000 --- a/examples/notebooks/Getting Started/Tutorial 2 - Setting Parameter Values.ipynb +++ /dev/null @@ -1,456 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Tutorial 2 - Setting Parameter Values" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In [Tutorial 1](./Tutorial%201%20-%20How%20to%20run%20a%20model.ipynb), we saw how to run a PyBaMM model with all the default settings. However, PyBaMM also allows you to tweak these settings for your application. In this tutorial, we will see how to build a parameter set in PyBaMM and also how parameter values can be quickly changed temporarily." - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Note: you may need to restart the kernel to use updated packages.\n" - ] - } - ], - "source": [ - "%pip install pybamm -q # install PyBaMM if it is not installed\n", - "import pybamm" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Build a parameter set" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "PyBaMM allows you to build a full battery parameter set from parameter values for each component of the battery: anode, cathode, etc. The parameters for each component of the cell are stored within `input/parameters/lithium_ion/anode`, `input/parameters/lithium_ion/cathode`, etc. Each component consists of folders of parameter values (e.g. graphite_mcmb2528_Marquis2019). For information on how to add your own folder of parameter values see [Additional Information](#adding_parameters). We select the parameter set to use for each component by creating the following python dictionary:" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "parameter_options = {\n", - " \"chemistry\": \"lithium-ion\",\n", - " \"cell\": \"kokam_Marquis2019\",\n", - " \"anode\": \"graphite_mcmb2528_Marquis2019\",\n", - " \"separator\": \"separator_Marquis2019\",\n", - " \"cathode\": \"lico2_Marquis2019\",\n", - " \"electrolyte\": \"lipf6_Marquis2019\",\n", - " \"experiment\": \"1C_discharge_from_full_Marquis2019\",\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "where the keys (i.e. left of the ':') are the various cell components and the values (i.e. right of the ':') correspond to the parameter sets in each component." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "We now pass this set of options into a `ParameterValues` object, which builds the full parameter set:" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "parameter_values = pybamm.ParameterValues(chemistry=parameter_options)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "We now perform the same process as in Tutorial 1 but this time we also pass our parameter values when we create the `Simulation`:" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "4a4e0be8318b453ea00394c0f5dbdea5", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "interactive(children=(FloatSlider(value=0.0, description='t', max=1.0, step=0.01), Output()), _dom_classes=('w…" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "model = pybamm.lithium_ion.SPMe()\n", - "sim = pybamm.Simulation(model, parameter_values=parameter_values)\n", - "sim.solve()\n", - "sim.plot()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Tweak a parameter value" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "We often want to quickly change a small number of parameter values to investigate how the behaviour or the battery changes. In such cases, creating and building a full parameter set is not ideal. However, PyBaMM also makes it easy to change parameter values without having to leave the notebook or script you are working in. \n", - "\n", - "We begin by loading a model and creating a simulation as we have done before:" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [], - "source": [ - "model2 = pybamm.lithium_ion.SPMe()\n", - "sim2 = pybamm.Simulation(model2)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "We now extract the parameter values that have been automatically loaded into our simulation:" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [], - "source": [ - "parameter_values2 = sim2.parameter_values" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The values of the parameters are stored within a python dictionary where the keys correspond to that parameter name (e.g. 'Typical current [A]') and the values correspond to the parameter value (e.g. 0.68). For how to to view the full list of parameters and their values, please see [Additional Information](#viewing_values). In this notebook, we will just tweak the typical current from it's default 1C value (0.68 A) to a 2C rate (1.36 A):" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [], - "source": [ - "parameter_values2.update({\"Current function [A]\": 1.36})" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "We now load the updated parameter values into the simulation:" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [], - "source": [ - "sim2.specs(parameter_values=parameter_values2)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "And then we can solve and plot our model as before, noticing that the cell now discharges in around half the time." - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "fb29cf7606614252a6a459832fc76c6a", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "interactive(children=(FloatSlider(value=0.0, description='t', max=1747.0357219251334, step=17.470357219251333)…" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "sim2.solve()\n", - "sim2.plot()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In this tutorial we have seen how to set the parameter values by cell component and how to tweak individual parameter values.\n", - "\n", - "In [Tutorial 3](./Tutorial%203%20-%20Basic%20Plotting.ipynb) we introduce some basic plotting functionalities." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Additional Information\n", - "### Adding your own parameter sets \n", - "The parameters for each component of the cell are stored within `input/parameters/lithium_ion/anode`, `input/parameters/lithium_ion/cathode`, etc. Each component consists of folders of parameter sets (e.g. `graphite_mcmb2528_Marquis2019`) within which there are python functions for any functional dependancies (e.g. the open-circuit potential is a function of lithium concentration) as well as a `.csv` file containing all other parameters. If you wish to add your own parameter values for a particular component of the cell, simply create a new folder (e.g. `my_anode_params`) within the component folder (e.g. `input/parameters/lithium_ion/anode`) and then input the parameter values in the same format as the inbuilt parameter sets (it is probably easiest to just copy across the contents of `graphite_mcmb2528_Marquis2019` into `my_anode_params` and modify the values as you wish). \n", - "\n", - "More information on how to add parameter values is provided in our [online documentation](https://pybamm.readthedocs.io/en/latest/tutorials/add-parameter-values.html)." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Viewing and searching the list of parameters " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "To view the full list of parameters and their associated values, simply type: " - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'1 + dlnf/dlnc': 1.0,\n", - " 'Ambient temperature [K]': 298.15,\n", - " 'Bulk solvent concentration [mol.m-3]': 2636.0,\n", - " 'Cation transference number': 0.4,\n", - " 'Cell capacity [A.h]': 0.680616,\n", - " 'Cell cooling surface area [m2]': 0.0569,\n", - " 'Cell volume [m3]': 7.8e-06,\n", - " 'Current function [A]': 1.36,\n", - " 'EC diffusivity [m2.s-1]': 2e-18,\n", - " 'EC initial concentration in electrolyte [mol.m-3]': 4541.0,\n", - " 'Edge heat transfer coefficient [W.m-2.K-1]': 0.3,\n", - " 'Electrode height [m]': 0.13699999999999998,\n", - " 'Electrode width [m]': 0.207,\n", - " 'Electrolyte conductivity [S.m-1]': ,\n", - " 'Electrolyte diffusivity [m2.s-1]': ,\n", - " 'Initial concentration in electrolyte [mol.m-3]': 1000.0,\n", - " 'Initial concentration in negative electrode [mol.m-3]': 19986.609595075,\n", - " 'Initial concentration in positive electrode [mol.m-3]': 30730.755438556498,\n", - " 'Initial inner SEI thickness [m]': 2.5e-09,\n", - " 'Initial outer SEI thickness [m]': 2.5e-09,\n", - " 'Initial temperature [K]': 298.15,\n", - " 'Inner SEI electron conductivity [S.m-1]': 8.95e-14,\n", - " 'Inner SEI lithium interstitial diffusivity [m2.s-1]': 1.0000000000000001e-20,\n", - " 'Inner SEI open-circuit potential [V]': 0.1,\n", - " 'Inner SEI partial molar volume [m3.mol-1]': 9.585e-05,\n", - " 'Inner SEI reaction proportion': 0.5,\n", - " 'Lithium interstitial reference concentration [mol.m-3]': 15.0,\n", - " 'Lower voltage cut-off [V]': 3.105,\n", - " 'Maximum concentration in negative electrode [mol.m-3]': 24983.2619938437,\n", - " 'Maximum concentration in positive electrode [mol.m-3]': 51217.9257309275,\n", - " 'Negative current collector conductivity [S.m-1]': 59600000.0,\n", - " 'Negative current collector density [kg.m-3]': 8954.0,\n", - " 'Negative current collector specific heat capacity [J.kg-1.K-1]': 385.0,\n", - " 'Negative current collector surface heat transfer coefficient [W.m-2.K-1]': 0.0,\n", - " 'Negative current collector thermal conductivity [W.m-1.K-1]': 401.0,\n", - " 'Negative current collector thickness [m]': 2.5e-05,\n", - " 'Negative electrode Bruggeman coefficient (electrode)': 1.5,\n", - " 'Negative electrode Bruggeman coefficient (electrolyte)': 1.5,\n", - " 'Negative electrode OCP [V]': ,\n", - " 'Negative electrode OCP entropic change [V.K-1]': ,\n", - " 'Negative electrode active material volume fraction': 0.7,\n", - " 'Negative electrode cation signed stoichiometry': -1.0,\n", - " 'Negative electrode charge transfer coefficient': 0.5,\n", - " 'Negative electrode conductivity [S.m-1]': 100.0,\n", - " 'Negative electrode density [kg.m-3]': 1657.0,\n", - " 'Negative electrode diffusivity [m2.s-1]': ,\n", - " 'Negative electrode double-layer capacity [F.m-2]': 0.2,\n", - " 'Negative electrode electrons in reaction': 1.0,\n", - " 'Negative electrode exchange-current density [A.m-2]': ,\n", - " 'Negative electrode porosity': 0.3,\n", - " 'Negative electrode specific heat capacity [J.kg-1.K-1]': 700.0,\n", - " 'Negative electrode surface area to volume ratio [m-1]': 180000.0,\n", - " 'Negative electrode thermal conductivity [W.m-1.K-1]': 1.7,\n", - " 'Negative electrode thickness [m]': 0.0001,\n", - " 'Negative particle distribution in x': 1.0,\n", - " 'Negative particle radius [m]': 1e-05,\n", - " 'Negative tab centre y-coordinate [m]': 0.06,\n", - " 'Negative tab centre z-coordinate [m]': 0.13699999999999998,\n", - " 'Negative tab heat transfer coefficient [W.m-2.K-1]': 10.0,\n", - " 'Negative tab width [m]': 0.04,\n", - " 'Number of cells connected in series to make a battery': 1.0,\n", - " 'Number of electrodes connected in parallel to make a cell': 1.0,\n", - " 'Outer SEI open-circuit potential [V]': 0.8,\n", - " 'Outer SEI partial molar volume [m3.mol-1]': 9.585e-05,\n", - " 'Outer SEI solvent diffusivity [m2.s-1]': 2.5000000000000002e-22,\n", - " 'Positive current collector conductivity [S.m-1]': 35500000.0,\n", - " 'Positive current collector density [kg.m-3]': 2707.0,\n", - " 'Positive current collector specific heat capacity [J.kg-1.K-1]': 897.0,\n", - " 'Positive current collector surface heat transfer coefficient [W.m-2.K-1]': 0.0,\n", - " 'Positive current collector thermal conductivity [W.m-1.K-1]': 237.0,\n", - " 'Positive current collector thickness [m]': 2.5e-05,\n", - " 'Positive electrode Bruggeman coefficient (electrode)': 1.5,\n", - " 'Positive electrode Bruggeman coefficient (electrolyte)': 1.5,\n", - " 'Positive electrode OCP [V]': ,\n", - " 'Positive electrode OCP entropic change [V.K-1]': ,\n", - " 'Positive electrode active material volume fraction': 0.7,\n", - " 'Positive electrode cation signed stoichiometry': -1.0,\n", - " 'Positive electrode charge transfer coefficient': 0.5,\n", - " 'Positive electrode conductivity [S.m-1]': 10.0,\n", - " 'Positive electrode density [kg.m-3]': 3262.0,\n", - " 'Positive electrode diffusivity [m2.s-1]': ,\n", - " 'Positive electrode double-layer capacity [F.m-2]': 0.2,\n", - " 'Positive electrode electrons in reaction': 1.0,\n", - " 'Positive electrode exchange-current density [A.m-2]': ,\n", - " 'Positive electrode porosity': 0.3,\n", - " 'Positive electrode specific heat capacity [J.kg-1.K-1]': 700.0,\n", - " 'Positive electrode surface area to volume ratio [m-1]': 150000.0,\n", - " 'Positive electrode thermal conductivity [W.m-1.K-1]': 2.1,\n", - " 'Positive electrode thickness [m]': 0.0001,\n", - " 'Positive particle distribution in x': 1.0,\n", - " 'Positive particle radius [m]': 1e-05,\n", - " 'Positive tab centre y-coordinate [m]': 0.147,\n", - " 'Positive tab centre z-coordinate [m]': 0.13699999999999998,\n", - " 'Positive tab heat transfer coefficient [W.m-2.K-1]': 10.0,\n", - " 'Positive tab width [m]': 0.04,\n", - " 'Ratio of inner and outer SEI exchange current densities': 1.0,\n", - " 'Reference OCP vs SHE in the negative electrode [V]': nan,\n", - " 'Reference OCP vs SHE in the positive electrode [V]': nan,\n", - " 'Reference temperature [K]': 298.15,\n", - " 'SEI kinetic rate constant [m.s-1]': 1e-12,\n", - " 'SEI open-circuit potential [V]': 0.4,\n", - " 'SEI reaction exchange current density [A.m-2]': 1.5e-07,\n", - " 'SEI resistivity [Ohm.m]': 5000000.0,\n", - " 'Separator Bruggeman coefficient (electrode)': 1.5,\n", - " 'Separator Bruggeman coefficient (electrolyte)': 1.5,\n", - " 'Separator density [kg.m-3]': 397.0,\n", - " 'Separator porosity': 1.0,\n", - " 'Separator specific heat capacity [J.kg-1.K-1]': 700.0,\n", - " 'Separator thermal conductivity [W.m-1.K-1]': 0.16,\n", - " 'Separator thickness [m]': 2.5e-05,\n", - " 'Total heat transfer coefficient [W.m-2.K-1]': 10.0,\n", - " 'Typical current [A]': 0.680616,\n", - " 'Typical electrolyte concentration [mol.m-3]': 1000.0,\n", - " 'Upper voltage cut-off [V]': 4.7}" - ] - }, - "execution_count": 10, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "parameter_values2" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "You can also search the list of parameters for a particular string, e.g. \"electrolyte\"" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "EC initial concentration in electrolyte [mol.m-3]\t4541.0\n", - "Electrolyte conductivity [S.m-1]\t\n", - "Electrolyte diffusivity [m2.s-1]\t\n", - "Initial concentration in electrolyte [mol.m-3]\t1000.0\n", - "Negative electrode Bruggeman coefficient (electrolyte)\t1.5\n", - "Positive electrode Bruggeman coefficient (electrolyte)\t1.5\n", - "Separator Bruggeman coefficient (electrolyte)\t1.5\n", - "Typical electrolyte concentration [mol.m-3]\t1000.0\n" - ] - } - ], - "source": [ - "parameter_values2.search(\"electrolyte\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.7.7" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/examples/notebooks/Getting Started/Tutorial 3 - Basic Plotting.ipynb b/examples/notebooks/Getting Started/Tutorial 3 - Basic plotting.ipynb similarity index 93% rename from examples/notebooks/Getting Started/Tutorial 3 - Basic Plotting.ipynb rename to examples/notebooks/Getting Started/Tutorial 3 - Basic plotting.ipynb index 95ce5914be..921c8ccc36 100644 --- a/examples/notebooks/Getting Started/Tutorial 3 - Basic Plotting.ipynb +++ b/examples/notebooks/Getting Started/Tutorial 3 - Basic plotting.ipynb @@ -4,14 +4,14 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Tutorial 3 - Basic Plotting" + "# Tutorial 3 - Basic plotting" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "In [Tutorial 2](./Tutorial%202%20-%20Setting%20Parameter%20Values.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:" + "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:" ] }, { @@ -19,10 +19,17 @@ "execution_count": 1, "metadata": {}, "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Note: you may need to restart the kernel to use updated packages.\n" + ] + }, { "data": { "text/plain": [ - "" + "" ] }, "execution_count": 1, @@ -33,7 +40,7 @@ "source": [ "%pip install pybamm -q # install PyBaMM if it is not installed\n", "import pybamm\n", - "model = pybamm.lithium_ion.SPMe()\n", + "model = pybamm.lithium_ion.DFN()\n", "sim = pybamm.Simulation(model)\n", "sim.solve()" ] @@ -122,22 +129,6 @@ " 'Leading-order x-averaged negative electrode porosity change',\n", " 'Leading-order x-averaged separator porosity change',\n", " 'Leading-order x-averaged positive electrode porosity change',\n", - " 'Negative electrode volume-averaged velocity',\n", - " 'Positive electrode volume-averaged velocity',\n", - " 'Negative electrode volume-averaged velocity [m.s-1]',\n", - " 'Positive electrode volume-averaged velocity [m.s-1]',\n", - " 'Negative electrode volume-averaged acceleration',\n", - " 'Positive electrode volume-averaged acceleration',\n", - " 'Negative electrode volume-averaged acceleration [m.s-1]',\n", - " 'Positive electrode volume-averaged acceleration [m.s-1]',\n", - " 'X-averaged negative electrode volume-averaged acceleration',\n", - " 'X-averaged positive electrode volume-averaged acceleration',\n", - " 'X-averaged negative electrode volume-averaged acceleration [m.s-1]',\n", - " 'X-averaged positive electrode volume-averaged acceleration [m.s-1]',\n", - " 'Negative electrode pressure',\n", - " 'Positive electrode pressure',\n", - " 'X-averaged negative electrode pressure',\n", - " 'X-averaged positive electrode pressure',\n", " 'Separator pressure',\n", " 'X-averaged separator pressure',\n", " 'Negative electrode transverse volume-averaged velocity',\n", @@ -168,6 +159,22 @@ " 'X-averaged positive electrode transverse volume-averaged acceleration [m.s-2]',\n", " 'Transverse volume-averaged acceleration',\n", " 'Transverse volume-averaged acceleration [m.s-2]',\n", + " 'Negative electrode volume-averaged velocity',\n", + " 'Positive electrode volume-averaged velocity',\n", + " 'Negative electrode volume-averaged velocity [m.s-1]',\n", + " 'Positive electrode volume-averaged velocity [m.s-1]',\n", + " 'Negative electrode volume-averaged acceleration',\n", + " 'Positive electrode volume-averaged acceleration',\n", + " 'Negative electrode volume-averaged acceleration [m.s-1]',\n", + " 'Positive electrode volume-averaged acceleration [m.s-1]',\n", + " 'X-averaged negative electrode volume-averaged acceleration',\n", + " 'X-averaged positive electrode volume-averaged acceleration',\n", + " 'X-averaged negative electrode volume-averaged acceleration [m.s-1]',\n", + " 'X-averaged positive electrode volume-averaged acceleration [m.s-1]',\n", + " 'Negative electrode pressure',\n", + " 'Positive electrode pressure',\n", + " 'X-averaged negative electrode pressure',\n", + " 'X-averaged positive electrode pressure',\n", " 'Negative particle concentration',\n", " 'Negative particle concentration [mol.m-3]',\n", " 'X-averaged negative particle concentration',\n", @@ -192,6 +199,24 @@ " 'Positive electrode volume-averaged concentration',\n", " 'Positive electrode volume-averaged concentration [mol.m-3]',\n", " 'Positive electrode average extent of lithiation',\n", + " 'Negative electrode potential',\n", + " 'Negative electrode potential [V]',\n", + " 'X-averaged negative electrode potential',\n", + " 'X-averaged negative electrode potential [V]',\n", + " 'Negative electrode ohmic losses',\n", + " 'Negative electrode ohmic losses [V]',\n", + " 'X-averaged negative electrode ohmic losses',\n", + " 'X-averaged negative electrode ohmic losses [V]',\n", + " 'Gradient of negative electrode potential',\n", + " 'Positive electrode potential',\n", + " 'Positive electrode potential [V]',\n", + " 'X-averaged positive electrode potential',\n", + " 'X-averaged positive electrode potential [V]',\n", + " 'Positive electrode ohmic losses',\n", + " 'Positive electrode ohmic losses [V]',\n", + " 'X-averaged positive electrode ohmic losses',\n", + " 'X-averaged positive electrode ohmic losses [V]',\n", + " 'Gradient of positive electrode potential',\n", " 'Electrolyte concentration',\n", " 'Electrolyte concentration [mol.m-3]',\n", " 'Electrolyte concentration [Molar]',\n", @@ -213,6 +238,28 @@ " 'X-averaged separator electrolyte concentration [mol.m-3]',\n", " 'X-averaged positive electrolyte concentration',\n", " 'X-averaged positive electrolyte concentration [mol.m-3]',\n", + " 'Negative electrolyte potential',\n", + " 'Negative electrolyte potential [V]',\n", + " 'Separator electrolyte potential',\n", + " 'Separator electrolyte potential [V]',\n", + " 'Positive electrolyte potential',\n", + " 'Positive electrolyte potential [V]',\n", + " 'Electrolyte potential',\n", + " 'Electrolyte potential [V]',\n", + " 'X-averaged electrolyte potential',\n", + " 'X-averaged electrolyte potential [V]',\n", + " 'X-averaged negative electrolyte potential',\n", + " 'X-averaged negative electrolyte potential [V]',\n", + " 'X-averaged separator electrolyte potential',\n", + " 'X-averaged separator electrolyte potential [V]',\n", + " 'X-averaged positive electrolyte potential',\n", + " 'X-averaged positive electrolyte potential [V]',\n", + " 'X-averaged electrolyte overpotential',\n", + " 'X-averaged electrolyte overpotential [V]',\n", + " 'Gradient of negative electrolyte potential',\n", + " 'Gradient of separator electrolyte potential',\n", + " 'Gradient of positive electrolyte potential',\n", + " 'Gradient of electrolyte potential',\n", " 'Negative current collector temperature',\n", " 'Negative current collector temperature [K]',\n", " 'X-averaged negative electrode temperature',\n", @@ -245,10 +292,6 @@ " 'Outer negative electrode sei thickness [m]',\n", " 'X-averaged outer negative electrode sei thickness',\n", " 'X-averaged outer negative electrode sei thickness [m]',\n", - " 'Total negative electrode sei thickness',\n", - " 'Total negative electrode sei thickness [m]',\n", - " 'X-averaged total negative electrode sei thickness',\n", - " 'X-averaged total negative electrode sei thickness [m]',\n", " 'Inner negative electrode sei concentration [mol.m-3]',\n", " 'X-averaged inner negative electrode sei concentration [mol.m-3]',\n", " 'Outer negative electrode sei concentration [mol.m-3]',\n", @@ -256,6 +299,11 @@ " 'Negative sei concentration [mol.m-3]',\n", " 'X-averaged negative electrode sei concentration [mol.m-3]',\n", " 'Loss of lithium to negative electrode sei [mol]',\n", + " 'Total negative electrode sei thickness',\n", + " 'Total negative electrode sei thickness [m]',\n", + " 'X-averaged total negative electrode sei thickness',\n", + " 'X-averaged total negative electrode sei thickness [m]',\n", + " 'X-averaged negative electrode resistance [Ohm.m2]',\n", " 'Inner negative electrode sei interfacial current density',\n", " 'Inner negative electrode sei interfacial current density [A.m-2]',\n", " 'X-averaged inner negative electrode sei interfacial current density',\n", @@ -276,10 +324,6 @@ " 'Outer positive electrode sei thickness [m]',\n", " 'X-averaged outer positive electrode sei thickness',\n", " 'X-averaged outer positive electrode sei thickness [m]',\n", - " 'Total positive electrode sei thickness',\n", - " 'Total positive electrode sei thickness [m]',\n", - " 'X-averaged total positive electrode sei thickness',\n", - " 'X-averaged total positive electrode sei thickness [m]',\n", " 'Inner positive electrode sei concentration [mol.m-3]',\n", " 'X-averaged inner positive electrode sei concentration [mol.m-3]',\n", " 'Outer positive electrode sei concentration [mol.m-3]',\n", @@ -287,6 +331,11 @@ " 'Positive sei concentration [mol.m-3]',\n", " 'X-averaged positive electrode sei concentration [mol.m-3]',\n", " 'Loss of lithium to positive electrode sei [mol]',\n", + " 'Total positive electrode sei thickness',\n", + " 'Total positive electrode sei thickness [m]',\n", + " 'X-averaged total positive electrode sei thickness',\n", + " 'X-averaged total positive electrode sei thickness [m]',\n", + " 'X-averaged positive electrode resistance [Ohm.m2]',\n", " 'Inner positive electrode sei interfacial current density',\n", " 'Inner positive electrode sei interfacial current density [A.m-2]',\n", " 'X-averaged inner positive electrode sei interfacial current density',\n", @@ -306,23 +355,11 @@ " 'X-averaged positive electrolyte tortuosity',\n", " 'Separator tortuosity',\n", " 'X-averaged separator tortuosity',\n", - " 'Leading-order electrolyte tortuosity',\n", - " 'Leading-order negative electrolyte tortuosity',\n", - " 'Leading-order positive electrolyte tortuosity',\n", - " 'Leading-order x-averaged negative electrolyte tortuosity',\n", - " 'Leading-order x-averaged positive electrolyte tortuosity',\n", - " 'Leading-order separator tortuosity',\n", - " 'Leading-order x-averaged separator tortuosity',\n", " 'Electrode tortuosity',\n", " 'Negative electrode tortuosity',\n", " 'Positive electrode tortuosity',\n", " 'X-averaged negative electrode tortuosity',\n", " 'X-averaged positive electrode tortuosity',\n", - " 'Leading-order electrode tortuosity',\n", - " 'Leading-order negative electrode tortuosity',\n", - " 'Leading-order positive electrode tortuosity',\n", - " 'Leading-order x-averaged negative electrode tortuosity',\n", - " 'Leading-order x-averaged positive electrode tortuosity',\n", " 'Separator volume-averaged velocity',\n", " 'Separator volume-averaged velocity [m.s-1]',\n", " 'Separator volume-averaged acceleration',\n", @@ -336,10 +373,29 @@ " 'Volume-averaged acceleration [m.s-1]',\n", " 'X-averaged volume-averaged acceleration [m.s-1]',\n", " 'Pressure',\n", + " 'Negative electrode surface potential difference',\n", + " 'X-averaged negative electrode surface potential difference',\n", + " 'Negative electrode surface potential difference [V]',\n", + " 'X-averaged negative electrode surface potential difference [V]',\n", + " 'Positive electrode surface potential difference',\n", + " 'X-averaged positive electrode surface potential difference',\n", + " 'Positive electrode surface potential difference [V]',\n", + " 'X-averaged positive electrode surface potential difference [V]',\n", " 'Negative particle flux',\n", " 'X-averaged negative particle flux',\n", + " 'Negative particle distribution in x',\n", " 'Positive particle flux',\n", " 'X-averaged positive particle flux',\n", + " 'Positive particle distribution in x',\n", + " 'Negative electrode effective conductivity',\n", + " 'Negative electrode current density',\n", + " 'Negative electrode current density [A.m-2]',\n", + " 'Positive electrode effective conductivity',\n", + " 'Positive electrode current density',\n", + " 'Positive electrode current density [A.m-2]',\n", + " 'Electrode current density',\n", + " 'Electrolyte current density',\n", + " 'Electrolyte current density [A.m-2]',\n", " 'Ohmic heating',\n", " 'Ohmic heating [W.m-3]',\n", " 'Irreversible electrochemical heating',\n", @@ -360,6 +416,12 @@ " 'Sei interfacial current density',\n", " 'Sei interfacial current density [A.m-2]',\n", " 'Sei interfacial current density per volume [A.m-3]',\n", + " 'Negative electrode interfacial current density',\n", + " 'X-averaged negative electrode interfacial current density',\n", + " 'Negative electrode interfacial current density [A.m-2]',\n", + " 'X-averaged negative electrode interfacial current density [A.m-2]',\n", + " 'Negative electrode interfacial current density per volume [A.m-3]',\n", + " 'X-averaged negative electrode interfacial current density per volume [A.m-3]',\n", " 'X-averaged negative electrode total interfacial current density',\n", " 'X-averaged negative electrode total interfacial current density [A.m-2]',\n", " 'X-averaged negative electrode total interfacial current density per volume [A.m-3]',\n", @@ -373,20 +435,22 @@ " 'X-averaged negative electrode reaction overpotential',\n", " 'Negative electrode reaction overpotential [V]',\n", " 'X-averaged negative electrode reaction overpotential [V]',\n", - " 'Negative electrode surface potential difference',\n", - " 'X-averaged negative electrode surface potential difference',\n", - " 'Negative electrode surface potential difference [V]',\n", - " 'X-averaged negative electrode surface potential difference [V]',\n", - " 'Negative electrode sei film overpotential',\n", - " 'X-averaged negative electrode sei film overpotential',\n", - " 'Negative electrode sei film overpotential [V]',\n", - " 'X-averaged negative electrode sei film overpotential [V]',\n", " 'Negative electrode open circuit potential',\n", " 'Negative electrode open circuit potential [V]',\n", " 'X-averaged negative electrode open circuit potential',\n", " 'X-averaged negative electrode open circuit potential [V]',\n", " 'Negative electrode entropic change',\n", " 'X-averaged negative electrode entropic change',\n", + " 'Negative electrode sei film overpotential',\n", + " 'X-averaged negative electrode sei film overpotential',\n", + " 'Negative electrode sei film overpotential [V]',\n", + " 'X-averaged negative electrode sei film overpotential [V]',\n", + " 'Positive electrode interfacial current density',\n", + " 'X-averaged positive electrode interfacial current density',\n", + " 'Positive electrode interfacial current density [A.m-2]',\n", + " 'X-averaged positive electrode interfacial current density [A.m-2]',\n", + " 'Positive electrode interfacial current density per volume [A.m-3]',\n", + " 'X-averaged positive electrode interfacial current density per volume [A.m-3]',\n", " 'X-averaged positive electrode total interfacial current density',\n", " 'X-averaged positive electrode total interfacial current density [A.m-2]',\n", " 'X-averaged positive electrode total interfacial current density per volume [A.m-3]',\n", @@ -400,32 +464,16 @@ " 'X-averaged positive electrode reaction overpotential',\n", " 'Positive electrode reaction overpotential [V]',\n", " 'X-averaged positive electrode reaction overpotential [V]',\n", - " 'Positive electrode surface potential difference',\n", - " 'X-averaged positive electrode surface potential difference',\n", - " 'Positive electrode surface potential difference [V]',\n", - " 'X-averaged positive electrode surface potential difference [V]',\n", - " 'Positive electrode sei film overpotential',\n", - " 'X-averaged positive electrode sei film overpotential',\n", - " 'Positive electrode sei film overpotential [V]',\n", - " 'X-averaged positive electrode sei film overpotential [V]',\n", " 'Positive electrode open circuit potential',\n", " 'Positive electrode open circuit potential [V]',\n", " 'X-averaged positive electrode open circuit potential',\n", " 'X-averaged positive electrode open circuit potential [V]',\n", " 'Positive electrode entropic change',\n", " 'X-averaged positive electrode entropic change',\n", - " 'Negative electrode interfacial current density',\n", - " 'X-averaged negative electrode interfacial current density',\n", - " 'Negative electrode interfacial current density [A.m-2]',\n", - " 'X-averaged negative electrode interfacial current density [A.m-2]',\n", - " 'Negative electrode interfacial current density per volume [A.m-3]',\n", - " 'X-averaged negative electrode interfacial current density per volume [A.m-3]',\n", - " 'Positive electrode interfacial current density',\n", - " 'X-averaged positive electrode interfacial current density',\n", - " 'Positive electrode interfacial current density [A.m-2]',\n", - " 'X-averaged positive electrode interfacial current density [A.m-2]',\n", - " 'Positive electrode interfacial current density per volume [A.m-3]',\n", - " 'X-averaged positive electrode interfacial current density per volume [A.m-3]',\n", + " 'Positive electrode sei film overpotential',\n", + " 'X-averaged positive electrode sei film overpotential',\n", + " 'Positive electrode sei film overpotential [V]',\n", + " 'X-averaged positive electrode sei film overpotential [V]',\n", " 'Interfacial current density',\n", " 'Interfacial current density [A.m-2]',\n", " 'Interfacial current density per volume [A.m-3]',\n", @@ -478,69 +526,14 @@ " 'Oxygen exchange current density',\n", " 'Oxygen exchange current density [A.m-2]',\n", " 'Oxygen exchange current density per volume [A.m-3]',\n", - " 'Negative electrode potential',\n", - " 'Negative electrode potential [V]',\n", - " 'X-averaged negative electrode potential',\n", - " 'X-averaged negative electrode potential [V]',\n", - " 'Negative electrode ohmic losses',\n", - " 'Negative electrode ohmic losses [V]',\n", - " 'X-averaged negative electrode ohmic losses',\n", - " 'X-averaged negative electrode ohmic losses [V]',\n", - " 'Gradient of negative electrode potential',\n", - " 'Negative electrode current density',\n", - " 'Negative electrode current density [A.m-2]',\n", - " 'Negative electrolyte potential',\n", - " 'Negative electrolyte potential [V]',\n", - " 'Separator electrolyte potential',\n", - " 'Separator electrolyte potential [V]',\n", - " 'Positive electrolyte potential',\n", - " 'Positive electrolyte potential [V]',\n", - " 'Electrolyte potential',\n", - " 'Electrolyte potential [V]',\n", - " 'X-averaged electrolyte potential',\n", - " 'X-averaged electrolyte potential [V]',\n", - " 'X-averaged negative electrolyte potential',\n", - " 'X-averaged negative electrolyte potential [V]',\n", - " 'X-averaged separator electrolyte potential',\n", - " 'X-averaged separator electrolyte potential [V]',\n", - " 'X-averaged positive electrolyte potential',\n", - " 'X-averaged positive electrolyte potential [V]',\n", - " 'X-averaged electrolyte overpotential',\n", - " 'X-averaged electrolyte overpotential [V]',\n", - " 'Gradient of negative electrolyte potential',\n", - " 'Gradient of separator electrolyte potential',\n", - " 'Gradient of positive electrolyte potential',\n", - " 'Gradient of electrolyte potential',\n", - " 'Electrolyte current density',\n", - " 'Electrolyte current density [A.m-2]',\n", - " 'Negative electrolyte current density',\n", - " 'Negative electrolyte current density [A.m-2]',\n", - " 'Positive electrolyte current density',\n", - " 'Positive electrolyte current density [A.m-2]',\n", - " 'X-averaged concentration overpotential',\n", - " 'X-averaged electrolyte ohmic losses',\n", - " 'X-averaged concentration overpotential [V]',\n", - " 'X-averaged electrolyte ohmic losses [V]',\n", - " 'Electrolyte flux',\n", - " 'Electrolyte flux [mol.m-2.s-1]',\n", - " 'Positive electrode potential',\n", - " 'Positive electrode potential [V]',\n", - " 'X-averaged positive electrode potential',\n", - " 'X-averaged positive electrode potential [V]',\n", - " 'Positive electrode ohmic losses',\n", - " 'Positive electrode ohmic losses [V]',\n", - " 'X-averaged positive electrode ohmic losses',\n", - " 'X-averaged positive electrode ohmic losses [V]',\n", - " 'Gradient of positive electrode potential',\n", - " 'Positive electrode current density',\n", - " 'Positive electrode current density [A.m-2]',\n", - " 'Electrode current density',\n", " 'Positive current collector potential',\n", " 'Positive current collector potential [V]',\n", " 'Local voltage',\n", " 'Local voltage [V]',\n", " 'Terminal voltage',\n", " 'Terminal voltage [V]',\n", + " 'Electrolyte flux',\n", + " 'Electrolyte flux [mol.m-2.s-1]',\n", " 'X-averaged open circuit voltage',\n", " 'Measured open circuit voltage',\n", " 'X-averaged open circuit voltage [V]',\n", @@ -579,7 +572,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 3, "metadata": {}, "outputs": [ { @@ -600,24 +593,15 @@ "Gradient of negative electrolyte potential\n", "Gradient of positive electrolyte potential\n", "Gradient of separator electrolyte potential\n", - "Leading-order electrolyte tortuosity\n", - "Leading-order negative electrolyte tortuosity\n", - "Leading-order positive electrolyte tortuosity\n", - "Leading-order x-averaged negative electrolyte tortuosity\n", - "Leading-order x-averaged positive electrolyte tortuosity\n", "Negative electrolyte concentration\n", "Negative electrolyte concentration [Molar]\n", "Negative electrolyte concentration [mol.m-3]\n", - "Negative electrolyte current density\n", - "Negative electrolyte current density [A.m-2]\n", "Negative electrolyte potential\n", "Negative electrolyte potential [V]\n", "Negative electrolyte tortuosity\n", "Positive electrolyte concentration\n", "Positive electrolyte concentration [Molar]\n", "Positive electrolyte concentration [mol.m-3]\n", - "Positive electrolyte current density\n", - "Positive electrolyte current density [A.m-2]\n", "Positive electrolyte potential\n", "Positive electrolyte potential [V]\n", "Positive electrolyte tortuosity\n", @@ -635,8 +619,6 @@ "X-averaged electrolyte concentration\n", "X-averaged electrolyte concentration [Molar]\n", "X-averaged electrolyte concentration [mol.m-3]\n", - "X-averaged electrolyte ohmic losses\n", - "X-averaged electrolyte ohmic losses [V]\n", "X-averaged electrolyte overpotential\n", "X-averaged electrolyte overpotential [V]\n", "X-averaged electrolyte potential\n", @@ -678,13 +660,13 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "c21531c2202d416dad4927836be1463b", + "model_id": "05bc29521fce46919914ff7c29ad0336", "version_major": 2, "version_minor": 0 }, @@ -710,13 +692,13 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "1c17ae12bb1d474e885e745697fad5d9", + "model_id": "afd75a47189c4a4bb6eeb25fa1a4a32d", "version_major": 2, "version_minor": 0 }, @@ -733,6 +715,37 @@ "sim.plot(quick_plot_vars=quick_plot_vars)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "You can also plot multiple variables on the same plot by nesting lists" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "8a9bad8809ca434e9b8a9912a9280873", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "interactive(children=(FloatSlider(value=0.0, description='t', max=3599.9999999999995, step=35.99999999999999),…" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "sim.plot([[\"Electrode current density\", \"Electrolyte current density\"], \"Terminal voltage [V]\"])" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -749,13 +762,13 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "7bdbaad776cf4bb09dbc5dd536fce2ee", + "model_id": "82ca5698bf78421e86adcb0bf7c78dd6", "version_major": 2, "version_minor": 0 }, @@ -780,7 +793,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -797,13 +810,13 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "b595c02d53174fc08002c45a412d4346", + "model_id": "6a18e145d36b44abbfe2962af6301630", "version_major": 2, "version_minor": 0 }, @@ -825,15 +838,8 @@ "source": [ "In this tutorial we have seen how to use the plotting functionality in PyBaMM.\n", "\n", - "In [Tutorial 4](./Tutorial%204%20-%20Model%20Options.ipynb) we show how to change model options." + "In [Tutorial 4](./Tutorial%204%20-%20Setting%20parameter%20values.ipynb) we show how to change model options." ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { diff --git a/examples/notebooks/Getting Started/Tutorial 4 - Setting parameter values.ipynb b/examples/notebooks/Getting Started/Tutorial 4 - Setting parameter values.ipynb new file mode 100644 index 0000000000..d7379851c7 --- /dev/null +++ b/examples/notebooks/Getting Started/Tutorial 4 - Setting parameter values.ipynb @@ -0,0 +1,991 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Tutorial 4 - Setting parameter values" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In [Tutorial 1](./Tutorial%201%20-%20How%20to%20run%20a%20model.ipynb) and [Tutorial 2](./Tutorial%202%20-%20Compare%20models.ipynb), we saw how to run a PyBaMM model with all the default settings. However, PyBaMM also allows you to tweak these settings for your application. In this tutorial, we will see how to change the parameters in PyBaMM." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Note: you may need to restart the kernel to use updated packages.\n" + ] + } + ], + "source": [ + "%pip install pybamm -q # install PyBaMM if it is not installed\n", + "import pybamm" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Change the whole parameter set" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "PyBaMM has a number of in-built parameter sets (check the list [here](https://pybamm.readthedocs.io/en/latest/source/parameters/parameter_sets.html)), which can be selected doing" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "chemistry = pybamm.parameter_sets.Chen2020" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This variable is a dictionary with the corresponding parameter subsets for each component." + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'chemistry': 'lithium-ion',\n", + " 'cell': 'LGM50_Chen2020',\n", + " 'anode': 'graphite_Chen2020',\n", + " 'separator': 'separator_Chen2020',\n", + " 'cathode': 'nmc_Chen2020',\n", + " 'electrolyte': 'lipf6_Nyman2008',\n", + " 'experiment': '1C_discharge_from_full_Chen2020',\n", + " 'sei': 'example',\n", + " 'citation': 'Chen2020'}" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "chemistry" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "More details on each subset can be found [here](https://github.com/pybamm-team/PyBaMM/tree/master/pybamm/input/parameters).\n", + "\n", + "Now we can pass `'chemistry'` into `ParameterValues` to create the dictionary of parameter values" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "parameter_values = pybamm.ParameterValues(chemistry=chemistry)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We can see all the parameters stored in the dictionary" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'1 + dlnf/dlnc': 1.0,\n", + " 'Ambient temperature [K]': 298.15,\n", + " 'Bulk solvent concentration [mol.m-3]': 2636.0,\n", + " 'Cation transference number': 0.2594,\n", + " 'Cell capacity [A.h]': 5.0,\n", + " 'Cell cooling surface area [m2]': 0.0053100000000000005,\n", + " 'Cell volume [m3]': 2.42e-05,\n", + " 'Current function [A]': 5.0,\n", + " 'EC diffusivity [m2.s-1]': 2e-18,\n", + " 'EC initial concentration in electrolyte [mol.m-3]': 4541.0,\n", + " 'Electrode height [m]': 0.065,\n", + " 'Electrode width [m]': 1.58,\n", + " 'Electrolyte conductivity [S.m-1]': ,\n", + " 'Electrolyte diffusivity [m2.s-1]': ,\n", + " 'Initial concentration in electrolyte [mol.m-3]': 1000.0,\n", + " 'Initial concentration in negative electrode [mol.m-3]': 29866.0,\n", + " 'Initial concentration in positive electrode [mol.m-3]': 17038.0,\n", + " 'Initial inner SEI thickness [m]': 2.5e-09,\n", + " 'Initial outer SEI thickness [m]': 2.5e-09,\n", + " 'Initial temperature [K]': 298.15,\n", + " 'Inner SEI electron conductivity [S.m-1]': 8.95e-14,\n", + " 'Inner SEI lithium interstitial diffusivity [m2.s-1]': 1.0000000000000001e-20,\n", + " 'Inner SEI open-circuit potential [V]': 0.1,\n", + " 'Inner SEI partial molar volume [m3.mol-1]': 9.585e-05,\n", + " 'Inner SEI reaction proportion': 0.5,\n", + " 'Lithium interstitial reference concentration [mol.m-3]': 15.0,\n", + " 'Lower voltage cut-off [V]': 2.5,\n", + " 'Maximum concentration in negative electrode [mol.m-3]': 33133.0,\n", + " 'Maximum concentration in positive electrode [mol.m-3]': 63104.0,\n", + " 'Negative current collector conductivity [S.m-1]': 58411000.0,\n", + " 'Negative current collector density [kg.m-3]': 8960.0,\n", + " 'Negative current collector specific heat capacity [J.kg-1.K-1]': 385.0,\n", + " 'Negative current collector thermal conductivity [W.m-1.K-1]': 401.0,\n", + " 'Negative current collector thickness [m]': 1.2e-05,\n", + " 'Negative electrode Bruggeman coefficient (electrode)': 1.5,\n", + " 'Negative electrode Bruggeman coefficient (electrolyte)': 1.5,\n", + " 'Negative electrode OCP [V]': ('graphite_LGM50_ocp_Chen2020',\n", + " array([[0. , 1.81772748],\n", + " [0.03129623, 1.0828807 ],\n", + " [0.03499902, 0.99593794],\n", + " [0.0387018 , 0.90023398],\n", + " [0.04240458, 0.79649431],\n", + " [0.04610736, 0.73354429],\n", + " [0.04981015, 0.66664314],\n", + " [0.05351292, 0.64137149],\n", + " [0.05721568, 0.59813869],\n", + " [0.06091845, 0.5670836 ],\n", + " [0.06462122, 0.54746181],\n", + " [0.06832399, 0.53068399],\n", + " [0.07202675, 0.51304734],\n", + " [0.07572951, 0.49394092],\n", + " [0.07943227, 0.47926274],\n", + " [0.08313503, 0.46065259],\n", + " [0.08683779, 0.45992726],\n", + " [0.09054054, 0.43801501],\n", + " [0.09424331, 0.42438665],\n", + " [0.09794607, 0.41150269],\n", + " [0.10164883, 0.40033659],\n", + " [0.10535158, 0.38957134],\n", + " [0.10905434, 0.37756538],\n", + " [0.1127571 , 0.36292541],\n", + " [0.11645985, 0.34357086],\n", + " [0.12016261, 0.3406314 ],\n", + " [0.12386536, 0.32299468],\n", + " [0.12756811, 0.31379458],\n", + " [0.13127086, 0.30795386],\n", + " [0.13497362, 0.29207319],\n", + " [0.13867638, 0.28697687],\n", + " [0.14237913, 0.27405477],\n", + " [0.14608189, 0.2670497 ],\n", + " [0.14978465, 0.25857493],\n", + " [0.15348741, 0.25265783],\n", + " [0.15719018, 0.24826777],\n", + " [0.16089294, 0.2414345 ],\n", + " [0.1645957 , 0.23362778],\n", + " [0.16829847, 0.22956218],\n", + " [0.17200122, 0.22370236],\n", + " [0.17570399, 0.22181271],\n", + " [0.17940674, 0.22089651],\n", + " [0.1831095 , 0.2194268 ],\n", + " [0.18681229, 0.21830064],\n", + " [0.19051504, 0.21845333],\n", + " [0.1942178 , 0.21753715],\n", + " [0.19792056, 0.21719357],\n", + " [0.20162334, 0.21635373],\n", + " [0.2053261 , 0.21667822],\n", + " [0.20902886, 0.21738444],\n", + " [0.21273164, 0.21469313],\n", + " [0.2164344 , 0.21541846],\n", + " [0.22013716, 0.21465495],\n", + " [0.22383993, 0.2135479 ],\n", + " [0.2275427 , 0.21392964],\n", + " [0.23124547, 0.21074206],\n", + " [0.23494825, 0.20873788],\n", + " [0.23865101, 0.20465319],\n", + " [0.24235377, 0.20205732],\n", + " [0.24605653, 0.19774358],\n", + " [0.2497593 , 0.19444147],\n", + " [0.25346208, 0.19190285],\n", + " [0.25716486, 0.18850531],\n", + " [0.26086762, 0.18581399],\n", + " [0.26457039, 0.18327537],\n", + " [0.26827314, 0.18157659],\n", + " [0.2719759 , 0.17814088],\n", + " [0.27567867, 0.17529686],\n", + " [0.27938144, 0.1719375 ],\n", + " [0.28308421, 0.16934161],\n", + " [0.28678698, 0.16756649],\n", + " [0.29048974, 0.16609676],\n", + " [0.29419251, 0.16414985],\n", + " [0.29789529, 0.16260378],\n", + " [0.30159806, 0.16224113],\n", + " [0.30530083, 0.160027 ],\n", + " [0.30900361, 0.15827096],\n", + " [0.31270637, 0.1588054 ],\n", + " [0.31640913, 0.15552238],\n", + " [0.32011189, 0.15580869],\n", + " [0.32381466, 0.15220118],\n", + " [0.32751744, 0.1511132 ],\n", + " [0.33122021, 0.14987253],\n", + " [0.33492297, 0.14874637],\n", + " [0.33862575, 0.14678037],\n", + " [0.34232853, 0.14620776],\n", + " [0.34603131, 0.14555879],\n", + " [0.34973408, 0.14389819],\n", + " [0.35343685, 0.14359279],\n", + " [0.35713963, 0.14242846],\n", + " [0.36084241, 0.14038612],\n", + " [0.36454517, 0.13882096],\n", + " [0.36824795, 0.13954628],\n", + " [0.37195071, 0.13946992],\n", + " [0.37565348, 0.13780934],\n", + " [0.37935626, 0.13973714],\n", + " [0.38305904, 0.13698858],\n", + " [0.38676182, 0.13523254],\n", + " [0.3904646 , 0.13441178],\n", + " [0.39416737, 0.1352898 ],\n", + " [0.39787015, 0.13507985],\n", + " [0.40157291, 0.13647321],\n", + " [0.40527567, 0.13601512],\n", + " [0.40897844, 0.13435452],\n", + " [0.41268121, 0.1334765 ],\n", + " [0.41638398, 0.1348317 ],\n", + " [0.42008676, 0.13275118],\n", + " [0.42378953, 0.13286571],\n", + " [0.4274923 , 0.13263667],\n", + " [0.43119506, 0.13456447],\n", + " [0.43489784, 0.13471718],\n", + " [0.43860061, 0.13395369],\n", + " [0.44230338, 0.13448814],\n", + " [0.44600615, 0.1334765 ],\n", + " [0.44970893, 0.13298023],\n", + " [0.45341168, 0.13259849],\n", + " [0.45711444, 0.13338107],\n", + " [0.46081719, 0.13309476],\n", + " [0.46451994, 0.13275118],\n", + " [0.46822269, 0.13443087],\n", + " [0.47192545, 0.13315202],\n", + " [0.47562821, 0.132713 ],\n", + " [0.47933098, 0.1330184 ],\n", + " [0.48303375, 0.13278936],\n", + " [0.48673651, 0.13225491],\n", + " [0.49043926, 0.13317111],\n", + " [0.49414203, 0.13263667],\n", + " [0.49784482, 0.13187316],\n", + " [0.50154759, 0.13265574],\n", + " [0.50525036, 0.13250305],\n", + " [0.50895311, 0.13324745],\n", + " [0.51265586, 0.13204496],\n", + " [0.51635861, 0.13242669],\n", + " [0.52006139, 0.13233127],\n", + " [0.52376415, 0.13198769],\n", + " [0.52746692, 0.13254122],\n", + " [0.53116969, 0.13145325],\n", + " [0.53487245, 0.13298023],\n", + " [0.53857521, 0.13168229],\n", + " [0.54227797, 0.1313578 ],\n", + " [0.54598074, 0.13235036],\n", + " [0.5496835 , 0.13120511],\n", + " [0.55338627, 0.13089971],\n", + " [0.55708902, 0.13109058],\n", + " [0.56079178, 0.13082336],\n", + " [0.56449454, 0.13011713],\n", + " [0.5681973 , 0.129869 ],\n", + " [0.57190006, 0.12992626],\n", + " [0.57560282, 0.12942998],\n", + " [0.57930558, 0.12796026],\n", + " [0.58300835, 0.12862831],\n", + " [0.58671112, 0.12656689],\n", + " [0.59041389, 0.12734947],\n", + " [0.59411664, 0.12509716],\n", + " [0.59781941, 0.12110791],\n", + " [0.60152218, 0.11839751],\n", + " [0.60522496, 0.11244226],\n", + " [0.60892772, 0.11307214],\n", + " [0.61263048, 0.1092165 ],\n", + " [0.61633325, 0.10683058],\n", + " [0.62003603, 0.10433014],\n", + " [0.6237388 , 0.10530359],\n", + " [0.62744156, 0.10056993],\n", + " [0.63114433, 0.09950104],\n", + " [0.63484711, 0.09854668],\n", + " [0.63854988, 0.09921473],\n", + " [0.64225265, 0.09541635],\n", + " [0.64595543, 0.09980643],\n", + " [0.64965823, 0.0986612 ],\n", + " [0.653361 , 0.09560722],\n", + " [0.65706377, 0.09755413],\n", + " [0.66076656, 0.09612258],\n", + " [0.66446934, 0.09430929],\n", + " [0.66817212, 0.09661885],\n", + " [0.67187489, 0.09366032],\n", + " [0.67557767, 0.09522548],\n", + " [0.67928044, 0.09535909],\n", + " [0.68298322, 0.09316404],\n", + " [0.686686 , 0.09450016],\n", + " [0.69038878, 0.0930877 ],\n", + " [0.69409156, 0.09343126],\n", + " [0.69779433, 0.0932404 ],\n", + " [0.70149709, 0.09350762],\n", + " [0.70519988, 0.09339309],\n", + " [0.70890264, 0.09291591],\n", + " [0.7126054 , 0.09303043],\n", + " [0.71630818, 0.0926296 ],\n", + " [0.72001095, 0.0932404 ],\n", + " [0.72371371, 0.09261052],\n", + " [0.72741648, 0.09249599],\n", + " [0.73111925, 0.09240055],\n", + " [0.73482204, 0.09253416],\n", + " [0.7385248 , 0.09209515],\n", + " [0.74222757, 0.09234329],\n", + " [0.74593034, 0.09366032],\n", + " [0.74963312, 0.09333583],\n", + " [0.75333589, 0.09322131],\n", + " [0.75703868, 0.09264868],\n", + " [0.76074146, 0.09253416],\n", + " [0.76444422, 0.09243873],\n", + " [0.76814698, 0.09230512],\n", + " [0.77184976, 0.09310678],\n", + " [0.77555253, 0.09165615],\n", + " [0.77925531, 0.09159888],\n", + " [0.78295807, 0.09207606],\n", + " [0.78666085, 0.09175158],\n", + " [0.79036364, 0.09177067],\n", + " [0.79406641, 0.09236237],\n", + " [0.79776918, 0.09241964],\n", + " [0.80147197, 0.09320222],\n", + " [0.80517474, 0.09199972],\n", + " [0.80887751, 0.09167523],\n", + " [0.81258028, 0.09322131],\n", + " [0.81628304, 0.09190428],\n", + " [0.81998581, 0.09167523],\n", + " [0.82368858, 0.09285865],\n", + " [0.82739136, 0.09180884],\n", + " [0.83109411, 0.09150345],\n", + " [0.83479688, 0.09186611],\n", + " [0.83849965, 0.0920188 ],\n", + " [0.84220242, 0.09320222],\n", + " [0.84590519, 0.09131257],\n", + " [0.84960797, 0.09117896],\n", + " [0.85331075, 0.09133166],\n", + " [0.85701353, 0.09089265],\n", + " [0.86071631, 0.09058725],\n", + " [0.86441907, 0.09051091],\n", + " [0.86812186, 0.09033912],\n", + " [0.87182464, 0.09041547],\n", + " [0.87552742, 0.0911217 ],\n", + " [0.87923019, 0.0894611 ],\n", + " [0.88293296, 0.08999555],\n", + " [0.88663573, 0.08921297],\n", + " [0.89033849, 0.08881213],\n", + " [0.89404126, 0.08797229],\n", + " [0.89774404, 0.08709427],\n", + " [0.9014468 , 0.08503284],\n", + " [1. , 0.07601531]])),\n", + " 'Negative electrode OCP entropic change [V.K-1]': 0.0,\n", + " 'Negative electrode active material volume fraction': 0.75,\n", + " 'Negative electrode cation signed stoichiometry': -1.0,\n", + " 'Negative electrode charge transfer coefficient': 0.5,\n", + " 'Negative electrode conductivity [S.m-1]': 215.0,\n", + " 'Negative electrode density [kg.m-3]': 1657.0,\n", + " 'Negative electrode diffusivity [m2.s-1]': 3.3e-14,\n", + " 'Negative electrode double-layer capacity [F.m-2]': 0.2,\n", + " 'Negative electrode electrons in reaction': 1.0,\n", + " 'Negative electrode exchange-current density [A.m-2]': ,\n", + " 'Negative electrode porosity': 0.25,\n", + " 'Negative electrode specific heat capacity [J.kg-1.K-1]': 700.0,\n", + " 'Negative electrode surface area to volume ratio [m-1]': 383959.0,\n", + " 'Negative electrode thermal conductivity [W.m-1.K-1]': 1.7,\n", + " 'Negative electrode thickness [m]': 8.52e-05,\n", + " 'Negative particle distribution in x': 1.0,\n", + " 'Negative particle radius [m]': 5.86e-06,\n", + " 'Number of cells connected in series to make a battery': 1.0,\n", + " 'Number of electrodes connected in parallel to make a cell': 1.0,\n", + " 'Outer SEI open-circuit potential [V]': 0.8,\n", + " 'Outer SEI partial molar volume [m3.mol-1]': 9.585e-05,\n", + " 'Outer SEI solvent diffusivity [m2.s-1]': 2.5000000000000002e-22,\n", + " 'Positive current collector conductivity [S.m-1]': 36914000.0,\n", + " 'Positive current collector density [kg.m-3]': 2700.0,\n", + " 'Positive current collector specific heat capacity [J.kg-1.K-1]': 897.0,\n", + " 'Positive current collector thermal conductivity [W.m-1.K-1]': 237.0,\n", + " 'Positive current collector thickness [m]': 1.6e-05,\n", + " 'Positive electrode Bruggeman coefficient (electrode)': 1.5,\n", + " 'Positive electrode Bruggeman coefficient (electrolyte)': 1.5,\n", + " 'Positive electrode OCP [V]': ('nmc_LGM50_ocp_Chen2020',\n", + " array([[0.24879728, 4.4 ],\n", + " [0.26614516, 4.2935653 ],\n", + " [0.26886763, 4.2768621 ],\n", + " [0.27159011, 4.2647018 ],\n", + " [0.27431258, 4.2540312 ],\n", + " [0.27703505, 4.2449446 ],\n", + " [0.27975753, 4.2364879 ],\n", + " [0.28248 , 4.2302647 ],\n", + " [0.28520247, 4.2225528 ],\n", + " [0.28792495, 4.2182574 ],\n", + " [0.29064743, 4.213294 ],\n", + " [0.29336992, 4.2090373 ],\n", + " [0.29609239, 4.2051239 ],\n", + " [0.29881487, 4.2012677 ],\n", + " [0.30153735, 4.1981564 ],\n", + " [0.30425983, 4.1955218 ],\n", + " [0.30698231, 4.1931167 ],\n", + " [0.30970478, 4.1889744 ],\n", + " [0.31242725, 4.1881533 ],\n", + " [0.31514973, 4.1865883 ],\n", + " [0.3178722 , 4.1850228 ],\n", + " [0.32059466, 4.1832285 ],\n", + " [0.32331714, 4.1808805 ],\n", + " [0.32603962, 4.1805749 ],\n", + " [0.32876209, 4.1789522 ],\n", + " [0.33148456, 4.1768146 ],\n", + " [0.33420703, 4.1768146 ],\n", + " [0.3369295 , 4.1752872 ],\n", + " [0.33965197, 4.173111 ],\n", + " [0.34237446, 4.1726718 ],\n", + " [0.34509694, 4.1710877 ],\n", + " [0.34781941, 4.1702285 ],\n", + " [0.3505419 , 4.168797 ],\n", + " [0.35326438, 4.1669831 ],\n", + " [0.35598685, 4.1655135 ],\n", + " [0.35870932, 4.1634517 ],\n", + " [0.3614318 , 4.1598248 ],\n", + " [0.36415428, 4.1571712 ],\n", + " [0.36687674, 4.154079 ],\n", + " [0.36959921, 4.1504135 ],\n", + " [0.37232169, 4.1466532 ],\n", + " [0.37504418, 4.1423388 ],\n", + " [0.37776665, 4.1382346 ],\n", + " [0.38048913, 4.1338248 ],\n", + " [0.38321161, 4.1305799 ],\n", + " [0.38593408, 4.1272392 ],\n", + " [0.38865655, 4.1228104 ],\n", + " [0.39137903, 4.1186109 ],\n", + " [0.39410151, 4.114182 ],\n", + " [0.39682398, 4.1096005 ],\n", + " [0.39954645, 4.1046948 ],\n", + " [0.40226892, 4.1004758 ],\n", + " [0.4049914 , 4.0956464 ],\n", + " [0.40771387, 4.0909696 ],\n", + " [0.41043634, 4.0864644 ],\n", + " [0.41315882, 4.0818448 ],\n", + " [0.41588129, 4.077683 ],\n", + " [0.41860377, 4.0733309 ],\n", + " [0.42132624, 4.0690737 ],\n", + " [0.42404872, 4.0647216 ],\n", + " [0.4267712 , 4.0608654 ],\n", + " [0.42949368, 4.0564747 ],\n", + " [0.43221616, 4.0527525 ],\n", + " [0.43493864, 4.0492401 ],\n", + " [0.43766111, 4.0450211 ],\n", + " [0.44038359, 4.041986 ],\n", + " [0.44310607, 4.0384736 ],\n", + " [0.44582856, 4.035171 ],\n", + " [0.44855103, 4.0320406 ],\n", + " [0.45127351, 4.0289288 ],\n", + " [0.453996 , 4.02597 ],\n", + " [0.45671848, 4.0227437 ],\n", + " [0.45944095, 4.0199757 ],\n", + " [0.46216343, 4.0175133 ],\n", + " [0.46488592, 4.0149746 ],\n", + " [0.46760838, 4.0122066 ],\n", + " [0.47033085, 4.009954 ],\n", + " [0.47305333, 4.0075679 ],\n", + " [0.47577581, 4.0050669 ],\n", + " [0.47849828, 4.0023184 ],\n", + " [0.48122074, 3.9995501 ],\n", + " [0.48394321, 3.9969349 ],\n", + " [0.48666569, 3.9926589 ],\n", + " [0.48938816, 3.9889555 ],\n", + " [0.49211064, 3.9834003 ],\n", + " [0.4948331 , 3.9783037 ],\n", + " [0.49755557, 3.9755929 ],\n", + " [0.50027804, 3.9707632 ],\n", + " [0.50300052, 3.9681098 ],\n", + " [0.50572298, 3.9635665 ],\n", + " [0.50844545, 3.9594433 ],\n", + " [0.51116792, 3.9556634 ],\n", + " [0.51389038, 3.9521511 ],\n", + " [0.51661284, 3.9479132 ],\n", + " [0.51933531, 3.9438281 ],\n", + " [0.52205777, 3.9400866 ],\n", + " [0.52478024, 3.9362304 ],\n", + " [0.52750271, 3.9314201 ],\n", + " [0.53022518, 3.9283848 ],\n", + " [0.53294765, 3.9242232 ],\n", + " [0.53567012, 3.9192028 ],\n", + " [0.53839258, 3.9166257 ],\n", + " [0.54111506, 3.9117961 ],\n", + " [0.54383753, 3.90815 ],\n", + " [0.54656 , 3.9038739 ],\n", + " [0.54928247, 3.8995597 ],\n", + " [0.55200494, 3.8959136 ],\n", + " [0.5547274 , 3.8909314 ],\n", + " [0.55744986, 3.8872662 ],\n", + " [0.56017233, 3.8831048 ],\n", + " [0.5628948 , 3.8793442 ],\n", + " [0.56561729, 3.8747628 ],\n", + " [0.56833976, 3.8702576 ],\n", + " [0.57106222, 3.8666878 ],\n", + " [0.57378469, 3.8623927 ],\n", + " [0.57650716, 3.8581741 ],\n", + " [0.57922963, 3.854146 ],\n", + " [0.5819521 , 3.8499846 ],\n", + " [0.58467456, 3.8450022 ],\n", + " [0.58739702, 3.8422534 ],\n", + " [0.59011948, 3.8380919 ],\n", + " [0.59284194, 3.8341596 ],\n", + " [0.5955644 , 3.8309333 ],\n", + " [0.59828687, 3.8272109 ],\n", + " [0.60100935, 3.823164 ],\n", + " [0.60373182, 3.8192315 ],\n", + " [0.60645429, 3.8159864 ],\n", + " [0.60917677, 3.8123021 ],\n", + " [0.61189925, 3.8090379 ],\n", + " [0.61462172, 3.8071671 ],\n", + " [0.61734419, 3.8040555 ],\n", + " [0.62006666, 3.8013639 ],\n", + " [0.62278914, 3.7970879 ],\n", + " [0.62551162, 3.7953317 ],\n", + " [0.62823408, 3.7920673 ],\n", + " [0.63095656, 3.788383 ],\n", + " [0.63367903, 3.7855389 ],\n", + " [0.6364015 , 3.7838206 ],\n", + " [0.63912397, 3.78111 ],\n", + " [0.64184645, 3.7794874 ],\n", + " [0.64456893, 3.7769294 ],\n", + " [0.6472914 , 3.773608 ],\n", + " [0.65001389, 3.7695992 ],\n", + " [0.65273637, 3.7690265 ],\n", + " [0.65545884, 3.7662776 ],\n", + " [0.65818131, 3.7642922 ],\n", + " [0.66090379, 3.7626889 ],\n", + " [0.66362625, 3.7603791 ],\n", + " [0.66634874, 3.7575538 ],\n", + " [0.66907121, 3.7552056 ],\n", + " [0.67179369, 3.7533159 ],\n", + " [0.67451616, 3.7507198 ],\n", + " [0.67723865, 3.7487535 ],\n", + " [0.67996113, 3.7471499 ],\n", + " [0.68268361, 3.7442865 ],\n", + " [0.68540608, 3.7423012 ],\n", + " [0.68812855, 3.7400677 ],\n", + " [0.69085103, 3.7385788 ],\n", + " [0.6935735 , 3.7345319 ],\n", + " [0.69629597, 3.7339211 ],\n", + " [0.69901843, 3.7301605 ],\n", + " [0.7017409 , 3.7301033 ],\n", + " [0.70446338, 3.7278316 ],\n", + " [0.70718585, 3.7251589 ],\n", + " [0.70990833, 3.723861 ],\n", + " [0.71263081, 3.7215703 ],\n", + " [0.71535328, 3.7191267 ],\n", + " [0.71807574, 3.7172751 ],\n", + " [0.72079822, 3.7157097 ],\n", + " [0.72352069, 3.7130945 ],\n", + " [0.72624317, 3.7099447 ],\n", + " [0.72896564, 3.7071004 ],\n", + " [0.7316881 , 3.7045615 ],\n", + " [0.73441057, 3.703588 ],\n", + " [0.73713303, 3.70208 ],\n", + " [0.73985551, 3.7002664 ],\n", + " [0.74257799, 3.6972122 ],\n", + " [0.74530047, 3.6952841 ],\n", + " [0.74802293, 3.6929362 ],\n", + " [0.7507454 , 3.6898055 ],\n", + " [0.75346787, 3.6890991 ],\n", + " [0.75619034, 3.686522 ],\n", + " [0.75891281, 3.6849759 ],\n", + " [0.76163529, 3.6821697 ],\n", + " [0.76435776, 3.6808143 ],\n", + " [0.76708024, 3.6786573 ],\n", + " [0.7698027 , 3.6761947 ],\n", + " [0.77252517, 3.674763 ],\n", + " [0.77524765, 3.6712887 ],\n", + " [0.77797012, 3.6697233 ],\n", + " [0.78069258, 3.6678908 ],\n", + " [0.78341506, 3.6652565 ],\n", + " [0.78613753, 3.6630611 ],\n", + " [0.78885999, 3.660274 ],\n", + " [0.79158246, 3.6583652 ],\n", + " [0.79430494, 3.6554828 ],\n", + " [0.79702741, 3.6522949 ],\n", + " [0.79974987, 3.6499848 ],\n", + " [0.80247234, 3.6470451 ],\n", + " [0.8051948 , 3.6405547 ],\n", + " [0.80791727, 3.6383405 ],\n", + " [0.81063974, 3.635076 ],\n", + " [0.81336221, 3.633549 ],\n", + " [0.81608468, 3.6322317 ],\n", + " [0.81880714, 3.6306856 ],\n", + " [0.82152961, 3.6283948 ],\n", + " [0.82425208, 3.6268487 ],\n", + " [0.82697453, 3.6243098 ],\n", + " [0.829697 , 3.6223626 ],\n", + " [0.83241946, 3.6193655 ],\n", + " [0.83514192, 3.6177621 ],\n", + " [0.83786439, 3.6158531 ],\n", + " [0.84058684, 3.6128371 ],\n", + " [0.84330931, 3.6118062 ],\n", + " [0.84603177, 3.6094582 ],\n", + " [0.84875424, 3.6072438 ],\n", + " [0.8514767 , 3.6049912 ],\n", + " [0.85419916, 3.6030822 ],\n", + " [0.85692162, 3.6012688 ],\n", + " [0.85964409, 3.5995889 ],\n", + " [0.86236656, 3.5976417 ],\n", + " [0.86508902, 3.5951984 ],\n", + " [0.86781149, 3.593843 ],\n", + " [0.87053395, 3.5916286 ],\n", + " [0.87325642, 3.5894907 ],\n", + " [0.87597888, 3.587429 ],\n", + " [0.87870135, 3.5852909 ],\n", + " [0.88142383, 3.5834775 ],\n", + " [0.8841463 , 3.5817785 ],\n", + " [0.88686877, 3.5801177 ],\n", + " [0.88959124, 3.5778842 ],\n", + " [0.89231371, 3.5763381 ],\n", + " [0.8950362 , 3.5737801 ],\n", + " [0.89775868, 3.5721002 ],\n", + " [0.90048116, 3.5702102 ],\n", + " [0.90320364, 3.5684922 ],\n", + " [0.90592613, 3.5672133 ],\n", + " [1. , 3.52302167]])),\n", + " 'Positive electrode OCP entropic change [V.K-1]': 0.0,\n", + " 'Positive electrode active material volume fraction': 0.665,\n", + " 'Positive electrode cation signed stoichiometry': -1.0,\n", + " 'Positive electrode charge transfer coefficient': 0.5,\n", + " 'Positive electrode conductivity [S.m-1]': 0.18,\n", + " 'Positive electrode density [kg.m-3]': 3262.0,\n", + " 'Positive electrode diffusivity [m2.s-1]': 4e-15,\n", + " 'Positive electrode double-layer capacity [F.m-2]': 0.2,\n", + " 'Positive electrode electrons in reaction': 1.0,\n", + " 'Positive electrode exchange-current density [A.m-2]': ,\n", + " 'Positive electrode porosity': 0.335,\n", + " 'Positive electrode specific heat capacity [J.kg-1.K-1]': 700.0,\n", + " 'Positive electrode surface area to volume ratio [m-1]': 382184.0,\n", + " 'Positive electrode thermal conductivity [W.m-1.K-1]': 2.1,\n", + " 'Positive electrode thickness [m]': 7.56e-05,\n", + " 'Positive particle distribution in x': 1.0,\n", + " 'Positive particle radius [m]': 5.22e-06,\n", + " 'Ratio of inner and outer SEI exchange current densities': 1.0,\n", + " 'Reference OCP vs SHE in the negative electrode [V]': nan,\n", + " 'Reference OCP vs SHE in the positive electrode [V]': nan,\n", + " 'Reference temperature [K]': 298.15,\n", + " 'SEI kinetic rate constant [m.s-1]': 1e-12,\n", + " 'SEI open-circuit potential [V]': 0.4,\n", + " 'SEI reaction exchange current density [A.m-2]': 1.5e-07,\n", + " 'SEI resistivity [Ohm.m]': 5000000.0,\n", + " 'Separator Bruggeman coefficient (electrode)': 1.5,\n", + " 'Separator Bruggeman coefficient (electrolyte)': 1.5,\n", + " 'Separator density [kg.m-3]': 397.0,\n", + " 'Separator porosity': 0.47,\n", + " 'Separator specific heat capacity [J.kg-1.K-1]': 700.0,\n", + " 'Separator thermal conductivity [W.m-1.K-1]': 0.16,\n", + " 'Separator thickness [m]': 1.2e-05,\n", + " 'Total heat transfer coefficient [W.m-2.K-1]': 10.0,\n", + " 'Typical current [A]': 5.0,\n", + " 'Typical electrolyte concentration [mol.m-3]': 1000.0,\n", + " 'Upper voltage cut-off [V]': 4.4}" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "parameter_values" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "or we can search for a particular parameter" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "EC initial concentration in electrolyte [mol.m-3]\t4541.0\n", + "Electrolyte conductivity [S.m-1]\t\n", + "Electrolyte diffusivity [m2.s-1]\t\n", + "Initial concentration in electrolyte [mol.m-3]\t1000.0\n", + "Negative electrode Bruggeman coefficient (electrolyte)\t1.5\n", + "Positive electrode Bruggeman coefficient (electrolyte)\t1.5\n", + "Separator Bruggeman coefficient (electrolyte)\t1.5\n", + "Typical electrolyte concentration [mol.m-3]\t1000.0\n" + ] + } + ], + "source": [ + "parameter_values.search(\"electrolyte\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "To run a simulation with this parameter set, we can proceed as usual but passing the parameters as a keyword argument" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "9e273806ce66412094b998b7c2843855", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "interactive(children=(FloatSlider(value=0.0, description='t', max=3527.2727272727275, step=35.27272727272727),…" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "model = pybamm.lithium_ion.DFN()\n", + "sim = pybamm.Simulation(model, parameter_values=parameter_values)\n", + "sim.solve()\n", + "sim.plot()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Change individual parameters" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We often want to quickly change a small number of parameter values to investigate how the behaviour or the battery changes. In such cases, we can change parameter values without having to leave the notebook or script you are working in. \n", + "\n", + "We start initialising the model and the parameter values" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [], + "source": [ + "model = pybamm.lithium_ion.DFN()\n", + "parameter_values = pybamm.ParameterValues(chemistry=pybamm.parameter_sets.Chen2020)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In this example we will change the current to 10 A" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [], + "source": [ + "parameter_values[\"Current function [A]\"] = 10" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now we just need to run the simulation with the new parameter values" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "1e2bc7fbfaed420f868da0f2f911a8a2", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "interactive(children=(FloatSlider(value=0.0, description='t', max=1690.909090909091, step=16.90909090909091), …" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "sim = pybamm.Simulation(model, parameter_values=parameter_values)\n", + "sim.solve()\n", + "sim.plot()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "You can also simulate drive cycles by passing the data directly" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [], + "source": [ + "parameter_values[\"Current function [A]\"] = \"[current data]US06\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Then we can just define the model and solve it" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "331bef017b4c4970b1a08373292c1527", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "interactive(children=(FloatSlider(value=0.0, description='t', max=600.0, step=6.0), Output()), _dom_classes=('…" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "model = pybamm.lithium_ion.SPMe()\n", + "sim = pybamm.Simulation(model, parameter_values=parameter_values)\n", + "sim.solve()\n", + "sim.plot([\"Current [A]\", \"Terminal voltage [V]\"])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Alternatively, we can define the current to be an arbitrary function of time" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np\n", + "\n", + "def my_current(t):\n", + " return pybamm.sin(2 * np.pi * t / 60)\n", + "\n", + "parameter_values[\"Current function [A]\"] = my_current" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "and we can now solve the model again. In this case, we can pass `t_eval` to the solver to make sure we have enough time points to resolve the function in our output." + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "43ec14a6a81745e6b16a9f2a1f14e864", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "interactive(children=(FloatSlider(value=0.0, description='t', max=120.0, step=1.2), Output()), _dom_classes=('…" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "model = pybamm.lithium_ion.SPMe()\n", + "sim = pybamm.Simulation(model, parameter_values=parameter_values)\n", + "t_eval = np.arange(0, 121, 1)\n", + "sim.solve(t_eval=t_eval)\n", + "sim.plot([\"Current [A]\", \"Terminal voltage [V]\"])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "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." + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.6.8" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/examples/notebooks/Getting Started/Tutorial 5 - Run experiments.ipynb b/examples/notebooks/Getting Started/Tutorial 5 - Run experiments.ipynb new file mode 100644 index 0000000000..fe0d03f912 --- /dev/null +++ b/examples/notebooks/Getting Started/Tutorial 5 - Run experiments.ipynb @@ -0,0 +1,214 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Tutorial 5 - Run experiments" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In [Tutorial 4](./Tutorial%204%20-%20Setting%20parameter%20values.ipynb) we saw how to change the parameters, including the applied current. However, in some cases we might want to prescribe a given voltage, a given power or switch between different conditions to simulate experimental setups. We can use the Experiment class for these simulations." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Note: you may need to restart the kernel to use updated packages.\n" + ] + } + ], + "source": [ + "%pip install pybamm -q # install PyBaMM if it is not installed\n", + "import pybamm" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We start defining an experiment, which consists on a set of instructions on how to cycle the battery. For example, we can set the following experiment:" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "experiment = pybamm.Experiment(\n", + " [\n", + " \"Discharge at C/10 for 10 hours or until 3.3 V\",\n", + " \"Rest for 1 hour\",\n", + " \"Charge at 1 A until 4.1 V\",\n", + " \"Hold at 4.1 V until 50 mA\",\n", + " \"Rest for 1 hour\",\n", + " ] * 3\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In this case, the experiment consists of a cycle of constant current C/10 discahrge, a one hour rest, a constant current (1 A) constant voltage (4.1 V) and another one hour rest, all of it repeated three times (notice the `* 3`).\n", + "\n", + "Then we can choose our model" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "model = pybamm.lithium_ion.DFN()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "and create our simulation, passing our experiment using a keyword argument" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "sim = pybamm.Simulation(model, experiment=experiment)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We then solve and plot the solution" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "da02ef4a3e854d75ae289d9f1d338953", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "interactive(children=(FloatSlider(value=0.0, description='t', max=38.86666666666667, step=0.38866666666666666)…" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "sim.solve()\n", + "sim.plot()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "As we have seen, experiments allow us to define complex simulations using a very simple syntax. The instructions can be of the form \"(Dis)charge at x A/C/W\", \"Rest\", or \"Hold at x V\". The running time should be a time in seconds, minutes or hours, e.g. \"10 seconds\", \"3 minutes\" or \"1 hour\". The stopping conditions should be a circuit state, e.g. \"1 A\", \"C/50\" or \"3 V\". \n", + "\n", + "Some examples of experiment instructions are:\n", + "```python\n", + " \"Discharge at 1C for 0.5 hours\",\n", + " \"Discharge at C/20 for 0.5 hours\",\n", + " \"Charge at 0.5 C for 45 minutes\",\n", + " \"Discharge at 1 A for 90 seconds\",\n", + " \"Charge at 200mA for 45 minutes (1 minute period)\",\n", + " \"Discharge at 1 W for 0.5 hours\",\n", + " \"Charge at 200 mW for 45 minutes\",\n", + " \"Rest for 10 minutes (5 minute period)\",\n", + " \"Hold at 1 V for 20 seconds\",\n", + " \"Charge at 1 C until 4.1V\",\n", + " \"Hold at 4.1 V until 50 mA\",\n", + " \"Hold at 3V until C/50\",\n", + "```\n", + "\n", + "Optionally, each instruction can contain at the end the expression \"(x minute period)\" in which the period at which to record the simulation outputs during that instruction. To change the period for the whole experiment we can pass it as a keyword argument in the experiment.\n", + "\n", + "Additionally, we can use the operators `+` and `*` to combine and repeat lists:" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['Discharge at 1C for 0.5 hours',\n", + " 'Discharge at C/20 for 0.5 hours',\n", + " 'Discharge at 1C for 0.5 hours',\n", + " 'Discharge at C/20 for 0.5 hours',\n", + " 'Discharge at 1C for 0.5 hours',\n", + " 'Discharge at C/20 for 0.5 hours',\n", + " 'Charge at 0.5 C for 45 minutes']" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "[\"Discharge at 1C for 0.5 hours\", \"Discharge at C/20 for 0.5 hours\"] * 3 + [\"Charge at 0.5 C for 45 minutes\"]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In this notebook we have seen how to use the Experiment class to run simulations of more complex operating conditions. In [Tutorial 6](./Tutorial%206%20-%20Managing%20simulation%20outputs.ipynb) we will see how to manage the outputs of the simulation." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "PyBaMM development (env)", + "language": "python", + "name": "pybamm-dev" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.6.8" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/examples/notebooks/Getting Started/Tutorial 6 - Managing simulation outputs.ipynb b/examples/notebooks/Getting Started/Tutorial 6 - Managing simulation outputs.ipynb new file mode 100644 index 0000000000..eb1bdde6dc --- /dev/null +++ b/examples/notebooks/Getting Started/Tutorial 6 - Managing simulation outputs.ipynb @@ -0,0 +1,405 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Tutorial 6 - Managing simulation outputs" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In the previous tutorials we have interacted with the outputs of the simulation via the default dynamic plot. However, usually we need to access the output data to manipulate it or transfer to another software which is the topic of this notebook.\n", + "\n", + "We start by building and solving our model as shown in previous notebooks:" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Note: you may need to restart the kernel to use updated packages.\n" + ] + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%pip install pybamm -q # install PyBaMM if it is not installed\n", + "import pybamm\n", + "model = pybamm.lithium_ion.SPMe()\n", + "sim = pybamm.Simulation(model)\n", + "sim.solve()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Accessing solution variables" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We can now access the solved variables directly to visualise or create our own plots. We first extract the solution object:" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "solution = sim.solution" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "and now we can create a post-processed variable (for a list of all the available variables see [Tutorial 3](./Tutorial%203%20-%20Basic%20plotting.ipynb))" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "t = solution[\"Time [s]\"]\n", + "V = solution[\"Terminal voltage [V]\"]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "One option is to visualise the data set returned by the solver directly" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([3.77057107, 3.75314464, 3.74576314, 3.74048119, 3.73590498,\n", + " 3.73162688, 3.72751694, 3.72353238, 3.71965945, 3.71589497,\n", + " 3.71223918, 3.70869335, 3.70525858, 3.70193548, 3.69872417,\n", + " 3.69562416, 3.69263437, 3.68975321, 3.68697864, 3.68430828,\n", + " 3.68173938, 3.67926892, 3.67689361, 3.67460989, 3.67241395,\n", + " 3.67030171, 3.66826873, 3.66631018, 3.66442064, 3.66259392,\n", + " 3.66082275, 3.65909838, 3.65740993, 3.65574368, 3.65408197,\n", + " 3.65240199, 3.65067437, 3.64886181, 3.64691846, 3.64479097,\n", + " 3.64242265, 3.63976269, 3.63678092, 3.63348599, 3.62994006,\n", + " 3.62625986, 3.62259745, 3.61910537, 3.61590166, 3.61305019,\n", + " 3.61056146, 3.60840705, 3.60653784, 3.60489897, 3.60343908,\n", + " 3.60211468, 3.60089123, 3.59974251, 3.59864938, 3.59759832,\n", + " 3.59658024, 3.59558939, 3.59462255, 3.59367842, 3.59275707,\n", + " 3.59185947, 3.59098718, 3.59014186, 3.58932493, 3.58853708,\n", + " 3.58777779, 3.5870448 , 3.58633359, 3.58563673, 3.58494346,\n", + " 3.58423912, 3.58350488, 3.58271742, 3.58184889, 3.5808668 ,\n", + " 3.579734 , 3.57840839, 3.57684221, 3.57498047, 3.57275806,\n", + " 3.57009492, 3.56688825, 3.56300069, 3.55824252, 3.55234578,\n", + " 3.54492664, 3.53543156, 3.52306098, 3.50666272, 3.48458581,\n", + " 3.45448671, 3.41308488, 3.35588179, 3.27689382, 3.16851949])" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "V.entries" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "which correspond to the data at the times" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([ 0. , 36.36363636, 72.72727273, 109.09090909,\n", + " 145.45454545, 181.81818182, 218.18181818, 254.54545455,\n", + " 290.90909091, 327.27272727, 363.63636364, 400. ,\n", + " 436.36363636, 472.72727273, 509.09090909, 545.45454545,\n", + " 581.81818182, 618.18181818, 654.54545455, 690.90909091,\n", + " 727.27272727, 763.63636364, 800. , 836.36363636,\n", + " 872.72727273, 909.09090909, 945.45454545, 981.81818182,\n", + " 1018.18181818, 1054.54545455, 1090.90909091, 1127.27272727,\n", + " 1163.63636364, 1200. , 1236.36363636, 1272.72727273,\n", + " 1309.09090909, 1345.45454545, 1381.81818182, 1418.18181818,\n", + " 1454.54545455, 1490.90909091, 1527.27272727, 1563.63636364,\n", + " 1600. , 1636.36363636, 1672.72727273, 1709.09090909,\n", + " 1745.45454545, 1781.81818182, 1818.18181818, 1854.54545455,\n", + " 1890.90909091, 1927.27272727, 1963.63636364, 2000. ,\n", + " 2036.36363636, 2072.72727273, 2109.09090909, 2145.45454545,\n", + " 2181.81818182, 2218.18181818, 2254.54545455, 2290.90909091,\n", + " 2327.27272727, 2363.63636364, 2400. , 2436.36363636,\n", + " 2472.72727273, 2509.09090909, 2545.45454545, 2581.81818182,\n", + " 2618.18181818, 2654.54545455, 2690.90909091, 2727.27272727,\n", + " 2763.63636364, 2800. , 2836.36363636, 2872.72727273,\n", + " 2909.09090909, 2945.45454545, 2981.81818182, 3018.18181818,\n", + " 3054.54545455, 3090.90909091, 3127.27272727, 3163.63636364,\n", + " 3200. , 3236.36363636, 3272.72727273, 3309.09090909,\n", + " 3345.45454545, 3381.81818182, 3418.18181818, 3454.54545455,\n", + " 3490.90909091, 3527.27272727, 3563.63636364, 3600. ])" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "t.entries" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In addition, post-processed variables can be called at any time (by interpolation)" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([3.72957191, 3.70869335, 3.67820003, 3.65409858])" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "V([200, 400, 780, 1236]) # times in seconds" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Saving the simulation and output data" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In some cases simulations might take a long time to run so it is advisable to save in your computer so it can be analysed later without re-running the simulation. You can save the whole simulation doing:" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [], + "source": [ + "sim.save(\"SPMe.pkl\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "If you now check the root directory of your notebooks you will notice that a new file called `\"SPMe.pkl\"` has appeared. We can load the stored simulation doing" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [], + "source": [ + "sim2 = pybamm.load(\"SPMe.pkl\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "which allows the same manipulation as the original simulation would allow" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "6665e273190047a08b75644328a02bfc", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "interactive(children=(FloatSlider(value=0.0, description='t', max=3599.9999999999995, step=35.99999999999999),…" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "sim2.plot()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Alternatively, we can just save the solution of the simulation in a similar way" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [], + "source": [ + "sol = sim.solution\n", + "sol.save(\"SPMe_sol.pkl\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "and load it in a similar way too" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "78a6e78f9ccc404e9d0846f22e2abdc1", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "interactive(children=(FloatSlider(value=0.0, description='t', max=3599.9999999999995, step=35.99999999999999),…" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sol2 = pybamm.load(\"SPMe_sol.pkl\")\n", + "pybamm.dynamic_plot(sol2)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Another option is to just save the data for some variables" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [], + "source": [ + "sol.save_data(\"sol_data.pkl\", [\"Current [A]\", \"Terminal voltage [V]\"])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "or save in csv or mat format" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [], + "source": [ + "sol.save_data(\"sol_data.csv\", [\"Current [A]\", \"Terminal voltage [V]\"], to_format=\"csv\")\n", + "sol.save_data(\"sol_data.mat\", [\"Current [A]\", \"Terminal voltage [V]\"], to_format=\"matlab\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In this notebook we have shown how to extract and store the outputs of PyBaMM's simulations. Next, in [Tutorial 7](./Tutorial%207%20-%20Model%20options.ipynb) we will show how to change the model options." + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "PyBaMM development (env)", + "language": "python", + "name": "pybamm-dev" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.6.8" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/examples/notebooks/Getting Started/Tutorial 4 - Model Options.ipynb b/examples/notebooks/Getting Started/Tutorial 7 - Model options.ipynb similarity index 65% rename from examples/notebooks/Getting Started/Tutorial 4 - Model Options.ipynb rename to examples/notebooks/Getting Started/Tutorial 7 - Model options.ipynb index 742b7e2d28..79dcb2c5fa 100644 --- a/examples/notebooks/Getting Started/Tutorial 4 - Model Options.ipynb +++ b/examples/notebooks/Getting Started/Tutorial 7 - Model options.ipynb @@ -4,21 +4,24 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Tutorial 4 - Model Options" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In [Tutorial 3](/Tutorial%203%20-%20Basic%20Plotting.ipynb) we saw how to use the in-built plotting functionality. In all of the previous tutorials, we have made use of the default forms of the inbuilt models in PyBaMM. However, PyBaMM provides a high-level interface for tweaking these models for your particular application. " + "# Tutorial 7 - Model options\n", + "\n", + "In all of the previous tutorials, we have made use of the default forms of the inbuilt models in PyBaMM. However, PyBaMM provides a high-level interface for tweaking these models for your particular application. " ] }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 4, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Note: you may need to restart the kernel to use updated packages.\n" + ] + } + ], "source": [ "%pip install pybamm -q # install PyBaMM if it is not installed\n", "import pybamm" @@ -28,12 +31,12 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "In this tutorial, we add a thermal model to the SPMe. From the [documentation](https://pybamm.readthedocs.io/en/latest/source/models/base_models/base_battery_model.html), we see that we have a choice of either a 'x-full' thermal model or a number of different lumped thermal models. We choose the full thermal model, which solves the spatially-dependent heat equation on our battery geometry, and couples the temperature with the electrochemistry. We set the model options by creating a python dictionary:" + "In this tutorial, we add a thermal model to the SPMe. From the [documentation](https://pybamm.readthedocs.io/en/latest/source/models/base_models/base_battery_model.html), we see that we have a choice of either a 'x-full' thermal model or a number of different lumped thermal models. We choose the full thermal model, which solves the spatially-dependent heat equation on our battery geometry, and couples the temperature with the electrochemistry. We set the model options by creating a Python dictionary:" ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -44,34 +47,32 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "and then passing this to the model and solving it as we have already done. We also increase the current so as to amplify the thermal effects:" + "and passing it to the model. Then, the model can be solved as shown in previous notebooks. We also increase the current to amplify the thermal effects:" ] }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "" + "" ] }, - "execution_count": 3, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "model = pybamm.lithium_ion.SPMe(options=options) # loading in options\n", - "sim = pybamm.Simulation(model)\n", "\n", - "# Increasing the current\n", - "parameter_values = sim.parameter_values\n", - "parameter_values.update({\"Typical current [A]\": 3})\n", - "sim.specs(parameter_values=parameter_values)\n", + "parameter_values = model.default_parameter_values\n", + "parameter_values[\"Current function [A]\"] = 3\n", "\n", + "sim = pybamm.Simulation(model, parameter_values=parameter_values)\n", "sim.solve()" ] }, @@ -79,23 +80,23 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "We now plot the cell temperature and the total heating by passing these variables to the `plot` method as we saw in Tutorial 3:" + "We now plot the cell temperature and the total heating by passing these variables to the `plot` method as we saw in [Tutorial 3](./Tutorial%203%20-%20Basic%20plotting.ipynb):" ] }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "a551cd74c2c94180870a552c07bd0715", + "model_id": "0f986094efb34516bfdec918871f7945", "version_major": 2, "version_minor": 0 }, "text/plain": [ - "interactive(children=(FloatSlider(value=0.0, description='t', max=1.0, step=0.01), Output()), _dom_classes=('w…" + "interactive(children=(FloatSlider(value=0.0, description='t', max=800.239418181818, step=8.00239418181818), Ou…" ] }, "metadata": {}, @@ -103,7 +104,7 @@ } ], "source": [ - "sim.plot([\"Cell temperature [K]\", \"Total heating [W.m-3]\", \"Terminal voltage [V]\"])" + "sim.plot([\"Cell temperature [K]\", \"Total heating [W.m-3]\", \"Current [A]\", \"Terminal voltage [V]\"])" ] }, { @@ -112,13 +113,6 @@ "source": [ "In this tutorial we have seen how to adjust the model options. To see all of the options currently available in PyBaMM, please take a look at the documentation [here](https://pybamm.readthedocs.io/en/latest/source/models/base_models/base_battery_model.html)." ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { diff --git a/pybamm/parameters/parameter_sets.py b/pybamm/parameters/parameter_sets.py index 2b205c5669..d14bb97ee2 100644 --- a/pybamm/parameters/parameter_sets.py +++ b/pybamm/parameters/parameter_sets.py @@ -5,6 +5,42 @@ Parameter sets from papers. The 'citation' entry provides a reference to the appropriate paper in the file "pybamm/CITATIONS.txt". To see which parameter sets have been used in your simulation, add the line "pybamm.print_citations()" to your script. + +Lithium-ion parameter sets +-------------------------- + * Chen2020 : + C.-H. Chen, F. Brosa Planella, K. O’Regan, D. Gastol, W. D. Widanage, and E. + Kendrick. “Development of Experimental Techniques for Parameterization of + Multi-scale Lithium-ion Battery Models.” Journal of the Electrochemical Society, + 167(8), 080534 (2020). + * Ecker2015 : + M. Ecker, T. K. D. Tran, P. Dechent, S. Käbitz, A. Warnecke, and D. U. Sauer. + “Parameterization of a Physico-Chemical Model of a Lithium-Ion Battery. I. + Determination of Parameters.” Journal of the Electrochemical Society, 162(9), + A1836-A1848 (2015). + * Marquis2019 : + S. G. Marquis, V. Sulzer, R. Timms, C. P. Please and S. J. Chapman. “An + asymptotic derivation of a single particle model with electrolyte.” Journal of + the Electrochemical Society, 166(15), A3693–A3706 (2019). + * Mohtat2020 : + Submitted for publication. + * NCA_Kim2011 : + G. H. Kim, K. Smith, K. J. Lee, S. Santhanagopalan, and A. Pesaran. + “Multi-domain modeling of lithium-ion batteries encompassing multi-physics in + varied length scales.” Journal of The Electrochemical Society, 158(8), A955-A969 + (2011). + * Ramadass 2004 : + P. Ramadass, B. Haran, P. M. Gomadam, R. White, and B. N. Popov. “Development + of First Principles Capacity Fade Model for Li-Ion Cells.” Journal of the + Electrochemical Society, 151(2), A196-A203 (2004). + +Lead-acid parameter sets +-------------------------- + * Sulzer2019 : + V. Sulzer, S. J. Chapman, C. P. Please, D. A. Howey, and C. W. Monroe, “Faster + lead-acid battery simulations from porous-electrode theory: Part I. Physical + model.” Journal of the Electrochemical Society, 166(12), 2363 (2019). + """ # diff --git a/pybamm/solvers/solution.py b/pybamm/solvers/solution.py index b5130779b6..c94b03791d 100644 --- a/pybamm/solvers/solution.py +++ b/pybamm/solvers/solution.py @@ -258,6 +258,8 @@ def save_data(self, filename, variables=None, to_format="pickle"): ) df = pd.DataFrame(data) df.to_csv(filename, index=False) + else: + raise ValueError("format '{}' not recognised".format(to_format)) class Solution(_BaseSolution): diff --git a/tests/unit/test_solvers/test_solution.py b/tests/unit/test_solvers/test_solution.py index b1fdd077c4..65e1c223cb 100644 --- a/tests/unit/test_solvers/test_solution.py +++ b/tests/unit/test_solvers/test_solution.py @@ -137,6 +137,12 @@ def test_save(self): np.testing.assert_array_almost_equal(df["c"], solution.data["c"]) np.testing.assert_array_almost_equal(df["2c"], solution.data["2c"]) + # raise error if format is unknown + with self.assertRaisesRegex( + ValueError, "format 'wrong_format' not recognised" + ): + solution.save_data("test.csv", to_format="wrong_format") + # test save whole solution solution.save("test.pickle") solution_load = pybamm.load("test.pickle")