Tip

An interactive online version of this notebook is available, which can be accessed via

Alternatively, you may download this notebook and run it offline.

Attention

You are viewing this notebook on the latest version of the documentation, where these notebooks may not be compatible with the stable release of PyBaMM since they can contain features that are not yet released. We recommend viewing these notebooks from the stable version of the documentation. To install the latest version of PyBaMM that is compatible with the latest notebooks, build PyBaMM from source.

# Tutorial 7 - Model options#

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. The core idea is that additional physics can be added to your electrochemical model of choice. These additional models can be specified via the model options (for a full list of options see the documentation).

```
[1]:
```

```
%pip install "pybamm[plot,cite]" -q # install PyBaMM if it is not installed
import pybamm
```

```
[notice] A new release of pip is available: 23.3.1 -> 24.0
[notice] To update, run: pip install --upgrade pip
Note: you may need to restart the kernel to use updated packages.
```

```
An NVIDIA GPU may be present on this machine, but a CUDA-enabled jaxlib is not installed. Falling back to cpu.
```

In this tutorial, we add a thermal model to the SPMe. From the documentation, we see that we have a choice of various thermal models. For a deeper look at the thermal models see the thermal models notebook. We choose the lumped 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:

```
[2]:
```

```
options = {"thermal": "lumped"}
```

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:

```
[3]:
```

```
model = pybamm.lithium_ion.SPMe(options=options) # loading in options
sim = pybamm.Simulation(model)
sim.solve([0, 3600])
```

```
[3]:
```

```
<pybamm.solvers.solution.Solution at 0x7f86e488a950>
```

We now plot the cell temperature and the total heating by passing these variables to the `plot`

method as we saw in Tutorial 3:

```
[4]:
```

```
sim.plot(
["Cell temperature [K]", "Total heating [W.m-3]", "Current [A]", "Voltage [V]"]
)
```

```
[4]:
```

```
<pybamm.plotting.quick_plot.QuickPlot at 0x7f86e45f25d0>
```

In this tutorial we have seen how to adjust the model options to account for thermal effects. Here is a (non exhaustive) list of other example notebooks that demonstrate how to include additional physics: - Composite models - Particle size distributions - Lithium plating - Particle cracking - Loss of active material - Thermal models - Coupled degradation mechanisms

In the next tutorial we show how to change the solver options.

## References#

The relevant papers for this notebook are:

```
[5]:
```

```
pybamm.print_citations()
```

```
[1] Joel A. E. Andersson, Joris Gillis, Greg Horn, James B. Rawlings, and Moritz Diehl. CasADi – A software framework for nonlinear optimization and optimal control. Mathematical Programming Computation, 11(1):1–36, 2019. doi:10.1007/s12532-018-0139-4.
[2] Charles R. Harris, K. Jarrod Millman, Stéfan J. van der Walt, Ralf Gommers, Pauli Virtanen, David Cournapeau, Eric Wieser, Julian Taylor, Sebastian Berg, Nathaniel J. Smith, and others. Array programming with NumPy. Nature, 585(7825):357–362, 2020. doi:10.1038/s41586-020-2649-2.
[3] Scott G. Marquis, Valentin Sulzer, Robert Timms, Colin P. Please, and S. Jon Chapman. An asymptotic derivation of a single particle model with electrolyte. Journal of The Electrochemical Society, 166(15):A3693–A3706, 2019. doi:10.1149/2.0341915jes.
[4] Valentin Sulzer, Scott G. Marquis, Robert Timms, Martin Robinson, and S. Jon Chapman. Python Battery Mathematical Modelling (PyBaMM). Journal of Open Research Software, 9(1):14, 2021. doi:10.5334/jors.309.
[5] Robert Timms, Scott G Marquis, Valentin Sulzer, Colin P. Please, and S Jonathan Chapman. Asymptotic Reduction of a Lithium-ion Pouch Cell Model. SIAM Journal on Applied Mathematics, 81(3):765–788, 2021. doi:10.1137/20M1336898.
```