forked from pybop-team/PyBOP
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Incomplete
plotting_a_dataset
notebook
- Loading branch information
Showing
1 changed file
with
105 additions
and
0 deletions.
There are no files selected for viewing
105 changes: 105 additions & 0 deletions
105
examples/notebooks/Getting Started/plotting_a_dataset.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 22, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Note: you may need to restart the kernel to use updated packages.\n", | ||
"Note: you may need to restart the kernel to use updated packages.\n" | ||
] | ||
}, | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"ERROR: file:///D:/Arjun/PyBOP/examples/notebooks/Getting%20Started does not appear to be a Python project: neither 'setup.py' nor 'pyproject.toml' found.\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"%pip install --upgrade pip ipywidgets pybamm -q\n", | ||
"%pip install pybop -q\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 23, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import numpy as np\n", | ||
"import plotly.graph_objects as go\n", | ||
"import pybamm\n", | ||
"import pybop\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 27, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"ename": "AttributeError", | ||
"evalue": "module 'pybop.models.lithium_ion' has no attribute 'DFN'", | ||
"output_type": "error", | ||
"traceback": [ | ||
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", | ||
"\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)", | ||
"Cell \u001b[1;32mIn[27], line 4\u001b[0m\n\u001b[0;32m 2\u001b[0m parameter_set \u001b[38;5;241m=\u001b[39m pybop\u001b[38;5;241m.\u001b[39mParameterSet\u001b[38;5;241m.\u001b[39mpybamm(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mChen2020\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m 3\u001b[0m parameter_set \u001b[38;5;241m=\u001b[39m pybamm\u001b[38;5;241m.\u001b[39mget_size_distribution_parameters(parameter_set)\n\u001b[1;32m----> 4\u001b[0m synth_model \u001b[38;5;241m=\u001b[39m \u001b[43mpybop\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mlithium_ion\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mDFN\u001b[49m(\n\u001b[0;32m 5\u001b[0m parameter_set\u001b[38;5;241m=\u001b[39mparameter_set, options\u001b[38;5;241m=\u001b[39m{\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mparticle size\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdistribution\u001b[39m\u001b[38;5;124m\"\u001b[39m}\n\u001b[0;32m 6\u001b[0m )\n\u001b[0;32m 8\u001b[0m n_points \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m650\u001b[39m\n\u001b[0;32m 9\u001b[0m t_eval \u001b[38;5;241m=\u001b[39m np\u001b[38;5;241m.\u001b[39mlinspace(\u001b[38;5;241m0\u001b[39m, \u001b[38;5;241m1600\u001b[39m \u001b[38;5;241m+\u001b[39m \u001b[38;5;241m1000\u001b[39m, n_points)\n", | ||
"\u001b[1;31mAttributeError\u001b[0m: module 'pybop.models.lithium_ion' has no attribute 'DFN'" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"# Example synthetic data generation\n", | ||
"parameter_set = pybop.ParameterSet.pybamm(\"Chen2020\")\n", | ||
"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", | ||
"\n", | ||
"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", | ||
"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", | ||
"values = synth_model.simulate(t_eval=t_eval, inputs={})\n" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "py39", | ||
"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.9.18" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |