Skip to content

Commit

Permalink
pybop-team#282 Reformat plotting_a_dataset example with some docume…
Browse files Browse the repository at this point in the history
…ntation
  • Loading branch information
arjxn-py committed Jun 16, 2024
1 parent 20becf7 commit 45952b6
Showing 1 changed file with 59 additions and 3 deletions.
62 changes: 59 additions & 3 deletions examples/notebooks/Getting Started/plotting_a_dataset.ipynb
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Setting up the Environment\n",
"\n",
"Before we begin, we need to ensure that we have all the necessary tools. We will install PyBOP from its development branch and upgrade some dependencies:"
]
},
{
"cell_type": "code",
"execution_count": 7,
Expand All @@ -19,6 +28,13 @@
"%pip install git+https://github.com/pybop-team/PyBOP.git@develop -q"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Next, we import the added packages plus any additional dependencies,"
]
},
{
"cell_type": "code",
"execution_count": 8,
Expand All @@ -31,6 +47,14 @@
"import pybop\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Optimising the Parameters\n",
"First, we define the model to be used for the parameter optimisation,"
]
},
{
"cell_type": "code",
"execution_count": 9,
Expand All @@ -42,22 +66,54 @@
"parameter_set = pybamm.get_size_distribution_parameters(parameter_set)\n",
"synth_model = pybop.lithium_ion.DFN(\n",
" parameter_set=parameter_set, options={\"particle size\": \"distribution\"}\n",
")\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Simulating Forward Model\n",
"\n",
"We can then simulate the model using the `predict` method, with a default constant current to generate voltage data."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"n_points = 650\n",
"t_eval = np.linspace(0, 1600 + 1000, n_points)\n",
"current = np.concatenate(\n",
" [np.ones(400) * parameter_set[\"Nominal cell capacity [A.h]\"], np.zeros(250)]\n",
")\n",
"init_soc = 0.5\n",
"init_soc = 0.5"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"dataset = pybop.Dataset(\n",
" {\n",
" \"Time [s]\": t_eval,\n",
" \"Current function [A]\": current,\n",
" }\n",
")\n",
"synth_model.build(dataset, init_soc=init_soc)\n",
"synth_model.signal = [\"Voltage [V]\"]\n"
"synth_model.signal = [\"Voltage [V]\"]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Plotting the Dataset\n",
"The `pybop.plot_dataset` function is used to visualize the dataset, showing the voltage over time."
]
},
{
Expand Down

0 comments on commit 45952b6

Please sign in to comment.