Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 694 getting started notebooks #703

Merged
merged 7 commits into from Nov 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -6,6 +6,7 @@
- Added submodels for tortuosity ([#726](https://github.com/pybamm-team/PyBaMM/pull/726))
- Simplified the interface for setting current functions ([#723](https://github.com/pybamm-team/PyBaMM/pull/723))
- Added Heaviside operator ([#723](https://github.com/pybamm-team/PyBaMM/pull/723))
- Added some "Getting Started" documentation ([#703](https://github.com/pybamm-team/PyBaMM/pull/703))
- Added Simulation class ([#693](https://github.com/pybamm-team/PyBaMM/pull/693))
- Added interface to CasADi solver ([#687](https://github.com/pybamm-team/PyBaMM/pull/687), [#691](https://github.com/pybamm-team/PyBaMM/pull/691), [#714](https://github.com/pybamm-team/PyBaMM/pull/714)). This makes the SUNDIALS DAE solvers (Scikits and KLU) truly optional (though IDA KLU is recommended for solving the DFN).
- Added option to use CasADi's Algorithmic Differentiation framework to calculate Jacobians ([#687](https://github.com/pybamm-team/PyBaMM/pull/687))
Expand Down
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -21,6 +21,8 @@ sim.plot()
```
However, much greater customisation is available. It is possible to change the physics, parameter values, geometry, submesh type, number of submesh points, methods for spatial discretisation and solver for integration (see DFN [script](examples/scripts/DFN.py) or [notebook](examples/notebooks/models/dfn.ipynb)).

For new users we recommend the [Getting Started](examples/notebooks/Getting%20Started/) guides. These are intended to be very simple step-by-step guides to show the basic functionality of PyBaMM.

Further details can be found in a number of [detailed examples](examples/notebooks/README.md), hosted here on
github. In addition, there is a [full API documentation](http://pybamm.readthedocs.io/),
hosted on [Read The Docs](readthedocs.io). A set of slides giving an overview of PyBaMM
Expand Down
@@ -0,0 +1,147 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Tutorial 1 - How to run a model"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Welcome to PyBaMM! In this notebook, we will run your first PyBaMM model in just a few simple lines. \n",
"\n",
"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",
"\n",
"We begin by importing the pybamm library into this notebook:"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import pybamm"
]
},
{
"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):"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"model = pybamm.lithium_ion.SPMe()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We now use this model to create a PyBaMM Simulation, which is used to process and solve the model:"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"sim = pybamm.Simulation(model)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"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):"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"sim.solve()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Finally, we can call 'plot' to generate a dynamic plot of the key variables:"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "089df7a7f1f24690b734df6cf83bd550",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"interactive(children=(FloatSlider(value=0.0, description='t', max=0.9999999999999999, step=0.05), Output()), _…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sim.plot()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"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."
]
},
{
"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.6.8"
}
},
"nbformat": 4,
"nbformat_minor": 2
}