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 2 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
@@ -0,0 +1,141 @@
{
"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. We begin by importing the pybamm library into this notebook:"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might also be a good idea to explain how jupyter notebooks work. e.g. refer to this cheat sheet https://www.cheatography.com/weidadeyue/cheat-sheets/jupyter-notebook/pdf_bw/ and say just do shift-enter to run cells

]
},
{
"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": "0cb6467951024d8dbfaffb45b2957a5a",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"interactive(children=(FloatSlider(value=0.0, description='t', max=1.0789124035988, step=0.05), Output()), _dom…"
]
},
"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. In the next few tutorials, we will see how various settings can be changed so that the model is appropriate for your situation."
]
},
{
"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.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}