|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "metadata": {}, |
| 6 | + "source": [ |
| 7 | + "# Tutorial 1 - How to run a model" |
| 8 | + ] |
| 9 | + }, |
| 10 | + { |
| 11 | + "cell_type": "markdown", |
| 12 | + "metadata": {}, |
| 13 | + "source": [ |
| 14 | + "Welcome to PyBaMM! In this notebook, we will run your first PyBaMM model in just a few simple lines. \n", |
| 15 | + "\n", |
| 16 | + "To run through this jupyter notebook simply shift-enter to run the cells. If you are unfamiliar with jupyter notebooks we recommending checking out this [cheat sheet](https://www.cheatography.com/weidadeyue/cheat-sheets/jupyter-notebook/pdf_bw/).\n", |
| 17 | + "\n", |
| 18 | + "We begin by importing the pybamm library into this notebook:" |
| 19 | + ] |
| 20 | + }, |
| 21 | + { |
| 22 | + "cell_type": "code", |
| 23 | + "execution_count": 1, |
| 24 | + "metadata": {}, |
| 25 | + "outputs": [], |
| 26 | + "source": [ |
| 27 | + "import pybamm" |
| 28 | + ] |
| 29 | + }, |
| 30 | + { |
| 31 | + "cell_type": "markdown", |
| 32 | + "metadata": {}, |
| 33 | + "source": [ |
| 34 | + "We now load the model that we wish to run. For this notebook, we choose the single particle model with electrolyte (SPMe):" |
| 35 | + ] |
| 36 | + }, |
| 37 | + { |
| 38 | + "cell_type": "code", |
| 39 | + "execution_count": 2, |
| 40 | + "metadata": {}, |
| 41 | + "outputs": [], |
| 42 | + "source": [ |
| 43 | + "model = pybamm.lithium_ion.SPMe()" |
| 44 | + ] |
| 45 | + }, |
| 46 | + { |
| 47 | + "cell_type": "markdown", |
| 48 | + "metadata": {}, |
| 49 | + "source": [ |
| 50 | + "We now use this model to create a PyBaMM Simulation, which is used to process and solve the model:" |
| 51 | + ] |
| 52 | + }, |
| 53 | + { |
| 54 | + "cell_type": "code", |
| 55 | + "execution_count": 3, |
| 56 | + "metadata": {}, |
| 57 | + "outputs": [], |
| 58 | + "source": [ |
| 59 | + "sim = pybamm.Simulation(model)" |
| 60 | + ] |
| 61 | + }, |
| 62 | + { |
| 63 | + "cell_type": "markdown", |
| 64 | + "metadata": {}, |
| 65 | + "source": [ |
| 66 | + "We can then call 'solve' on our simulation object to solve the model (by default the the model is solved for a 1C constant current discharge):" |
| 67 | + ] |
| 68 | + }, |
| 69 | + { |
| 70 | + "cell_type": "code", |
| 71 | + "execution_count": 4, |
| 72 | + "metadata": {}, |
| 73 | + "outputs": [], |
| 74 | + "source": [ |
| 75 | + "sim.solve()" |
| 76 | + ] |
| 77 | + }, |
| 78 | + { |
| 79 | + "cell_type": "markdown", |
| 80 | + "metadata": {}, |
| 81 | + "source": [ |
| 82 | + "Finally, we can call 'plot' to generate a dynamic plot of the key variables:" |
| 83 | + ] |
| 84 | + }, |
| 85 | + { |
| 86 | + "cell_type": "code", |
| 87 | + "execution_count": 5, |
| 88 | + "metadata": {}, |
| 89 | + "outputs": [ |
| 90 | + { |
| 91 | + "data": { |
| 92 | + "application/vnd.jupyter.widget-view+json": { |
| 93 | + "model_id": "089df7a7f1f24690b734df6cf83bd550", |
| 94 | + "version_major": 2, |
| 95 | + "version_minor": 0 |
| 96 | + }, |
| 97 | + "text/plain": [ |
| 98 | + "interactive(children=(FloatSlider(value=0.0, description='t', max=0.9999999999999999, step=0.05), Output()), _…" |
| 99 | + ] |
| 100 | + }, |
| 101 | + "metadata": {}, |
| 102 | + "output_type": "display_data" |
| 103 | + } |
| 104 | + ], |
| 105 | + "source": [ |
| 106 | + "sim.plot()" |
| 107 | + ] |
| 108 | + }, |
| 109 | + { |
| 110 | + "cell_type": "markdown", |
| 111 | + "metadata": {}, |
| 112 | + "source": [ |
| 113 | + "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", |
| 114 | + "\n", |
| 115 | + "In [Tutorial 2](./Tutorial%202%20-%20Setting%20Parameter%20Values.ipynb) we cover setting and changing parameter values." |
| 116 | + ] |
| 117 | + }, |
| 118 | + { |
| 119 | + "cell_type": "code", |
| 120 | + "execution_count": null, |
| 121 | + "metadata": {}, |
| 122 | + "outputs": [], |
| 123 | + "source": [] |
| 124 | + } |
| 125 | + ], |
| 126 | + "metadata": { |
| 127 | + "kernelspec": { |
| 128 | + "display_name": "Python 3", |
| 129 | + "language": "python", |
| 130 | + "name": "python3" |
| 131 | + }, |
| 132 | + "language_info": { |
| 133 | + "codemirror_mode": { |
| 134 | + "name": "ipython", |
| 135 | + "version": 3 |
| 136 | + }, |
| 137 | + "file_extension": ".py", |
| 138 | + "mimetype": "text/x-python", |
| 139 | + "name": "python", |
| 140 | + "nbconvert_exporter": "python", |
| 141 | + "pygments_lexer": "ipython3", |
| 142 | + "version": "3.6.8" |
| 143 | + } |
| 144 | + }, |
| 145 | + "nbformat": 4, |
| 146 | + "nbformat_minor": 2 |
| 147 | +} |
0 commit comments