From 20becf7f7af486f5bf16a56f2f8fbfa1197d9955 Mon Sep 17 00:00:00 2001 From: "arjxn.py" Date: Sun, 16 Jun 2024 20:42:46 +0530 Subject: [PATCH] #282 Fix `plotting_a_dataset` example by installing latest pybop --- .../Getting Started/plotting_a_dataset.ipynb | 55 ++++++++++--------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/examples/notebooks/Getting Started/plotting_a_dataset.ipynb b/examples/notebooks/Getting Started/plotting_a_dataset.ipynb index 8908ab6ae..633388374 100644 --- a/examples/notebooks/Getting Started/plotting_a_dataset.ipynb +++ b/examples/notebooks/Getting Started/plotting_a_dataset.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 22, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -12,23 +12,16 @@ "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" + "%pip install git+https://github.com/pybop-team/PyBOP.git@develop -q" ] }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -40,21 +33,9 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 9, "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'" - ] - } - ], + "outputs": [], "source": [ "# Example synthetic data generation\n", "parameter_set = pybop.ParameterSet.pybamm(\"Chen2020\")\n", @@ -76,8 +57,28 @@ " }\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" + "synth_model.signal = [\"Voltage [V]\"]\n" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "050010001500200025003.33.43.53.63.73.83.94DataTime / sVoltage [V]" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "values = synth_model.predict(t_eval=t_eval)\n", + "dataset[\"Voltage [V]\"] = values[\"Voltage [V]\"].data\n", + "pybop.plot_dataset(dataset);" ] } ], @@ -97,7 +98,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.18" + "version": "3.11.9" } }, "nbformat": 4,