diff --git a/docs/examples/01 Getting Started.ipynb b/docs/examples/01 Getting Started.ipynb index cd238878..defc73d1 100644 --- a/docs/examples/01 Getting Started.ipynb +++ b/docs/examples/01 Getting Started.ipynb @@ -32,8 +32,7 @@ "except:\n", " !pip install -q git+https://github.com/pybamm-team/liionpack.git@main\n", " import liionpack as lp\n", - "import pybamm\n", - "import numpy as np" + "import pybamm" ] }, { @@ -474,7 +473,7 @@ " parameter_values=parameter_values,\n", " experiment=experiment,\n", " output_variables=output_variables,\n", - " initial_soc=0.5\n", + " initial_soc=0.5,\n", ")" ] }, diff --git a/docs/examples/03 Experiments.ipynb b/docs/examples/03 Experiments.ipynb index 3a8f5816..6406174a 100644 --- a/docs/examples/03 Experiments.ipynb +++ b/docs/examples/03 Experiments.ipynb @@ -25,9 +25,7 @@ "except:\n", " !pip install -q git+https://github.com/pybamm-team/liionpack.git@main\n", " import liionpack as lp\n", - "import pybamm\n", - "import numpy as np\n", - "import matplotlib.pyplot as plt" + "import pybamm" ] }, { @@ -225,7 +223,7 @@ " parameter_values=parameter_values,\n", " experiment=experiment,\n", " output_variables=output_variables,\n", - " initial_soc=0.5\n", + " initial_soc=0.5,\n", ")" ] }, diff --git a/docs/examples/04 Initial SoC.ipynb b/docs/examples/04 Initial SoC.ipynb index 37a11a47..b7b5c5c2 100644 --- a/docs/examples/04 Initial SoC.ipynb +++ b/docs/examples/04 Initial SoC.ipynb @@ -25,9 +25,7 @@ "except:\n", " !pip install -q git+https://github.com/pybamm-team/liionpack.git@main\n", " import liionpack as lp\n", - "import pybamm\n", - "import numpy as np\n", - "import matplotlib.pyplot as plt" + "import pybamm" ] }, { @@ -296,7 +294,10 @@ } ], "source": [ - "lp.draw_circuit(netlist, dpi=100,)" + "lp.draw_circuit(\n", + " netlist,\n", + " dpi=100,\n", + ")" ] } ], diff --git a/docs/examples/05 Drive cycles.ipynb b/docs/examples/05 Drive cycles.ipynb index f49ab6d7..a578f383 100644 --- a/docs/examples/05 Drive cycles.ipynb +++ b/docs/examples/05 Drive cycles.ipynb @@ -253,7 +253,7 @@ } ], "source": [ - "I_mean = np.around(np.mean(drive_cycle[:, 1]),3)\n", + "I_mean = np.around(np.mean(drive_cycle[:, 1]), 3)\n", "I_mean" ] }, diff --git a/docs/examples/07 Visualizing larger packs.ipynb b/docs/examples/07 Visualizing larger packs.ipynb index b4586612..52d1b412 100644 --- a/docs/examples/07 Visualizing larger packs.ipynb +++ b/docs/examples/07 Visualizing larger packs.ipynb @@ -72,9 +72,7 @@ "\n", "# Define the PyBaMM parameters\n", "parameter_values = pybamm.ParameterValues(\"Chen2020\")\n", - "parameter_values.update(\n", - " {\"Total heat transfer coefficient [W.m-2.K-1]\": \"[input]\"}\n", - ")\n", + "parameter_values.update({\"Total heat transfer coefficient [W.m-2.K-1]\": \"[input]\"})\n", "htc = np.random.random(Nspm) * 50.0\n", "inputs = {\"Total heat transfer coefficient [W.m-2.K-1]\": htc}\n", "# Solve the pack\n", @@ -86,7 +84,7 @@ " output_variables=output_variables,\n", " inputs=inputs,\n", " initial_soc=0.5,\n", - " nproc=nproc\n", + " nproc=nproc,\n", ")" ] }, diff --git a/docs/examples/08 SEI degradation model.ipynb b/docs/examples/08 SEI degradation model.ipynb index 082f033b..03ee631b 100644 --- a/docs/examples/08 SEI degradation model.ipynb +++ b/docs/examples/08 SEI degradation model.ipynb @@ -82,7 +82,9 @@ "metadata": {}, "outputs": [], "source": [ - "netlist = lp.setup_circuit(Np=Np, Ns=Ns, Rb=R_busbar, Rc=R_connection, Ri=Ri_init, V=OCV_init, I=I_mag)" + "netlist = lp.setup_circuit(\n", + " Np=Np, Ns=Ns, Rb=R_busbar, Rc=R_connection, Ri=Ri_init, V=OCV_init, I=I_mag\n", + ")" ] }, { @@ -101,8 +103,15 @@ "outputs": [], "source": [ "experiment = pybamm.Experiment(\n", - " [\"Charge at 15 A for 10 minutes\", \"Rest for 10 minutes\", \"Discharge at 15 A for 10 minutes\", \"Rest for 10 minutes\"]*100,\n", - " period=\"30 seconds\",)" + " [\n", + " \"Charge at 15 A for 10 minutes\",\n", + " \"Rest for 10 minutes\",\n", + " \"Discharge at 15 A for 10 minutes\",\n", + " \"Rest for 10 minutes\",\n", + " ]\n", + " * 100,\n", + " period=\"30 seconds\",\n", + ")" ] }, { @@ -138,12 +147,12 @@ "metadata": {}, "outputs": [], "source": [ - "output_variables = [ \n", - " 'X-averaged positive total SEI thickness [m]',\n", - " 'X-averaged negative total SEI thickness [m]',\n", - " 'Loss of capacity to positive SEI [A.h]',\n", - " 'Loss of capacity to negative SEI [A.h]'\n", - " ]" + "output_variables = [\n", + " \"X-averaged positive total SEI thickness [m]\",\n", + " \"X-averaged negative total SEI thickness [m]\",\n", + " \"Loss of capacity to positive SEI [A.h]\",\n", + " \"Loss of capacity to negative SEI [A.h]\",\n", + "]" ] }, { @@ -343,8 +352,10 @@ "metadata": {}, "outputs": [], "source": [ - "parameter_values.update({\"EC initial concentration in electrolyte [mol.m-3]\": \"[input]\"})\n", - "EC_conc=np.array([4000.0, 3500.0, 3000.0, 2500.0])\n", + "parameter_values.update(\n", + " {\"EC initial concentration in electrolyte [mol.m-3]\": \"[input]\"}\n", + ")\n", + "EC_conc = np.array([4000.0, 3500.0, 3000.0, 2500.0])\n", "inputs = {\"EC initial concentration in electrolyte [mol.m-3]\": EC_conc}" ] }, @@ -370,7 +381,7 @@ " sim_func=SEI_degradation,\n", " inputs=inputs,\n", " output_variables=output_variables,\n", - " initial_soc=0.5\n", + " initial_soc=0.5,\n", ")" ] }, diff --git a/docs/examples/09 Terminal locations.ipynb b/docs/examples/09 Terminal locations.ipynb index 3f1d50bb..4c0e06f7 100644 --- a/docs/examples/09 Terminal locations.ipynb +++ b/docs/examples/09 Terminal locations.ipynb @@ -26,7 +26,6 @@ " !pip install -q git+https://github.com/pybamm-team/liionpack.git@main\n", " import liionpack as lp\n", "import pybamm\n", - "import numpy as np\n", "import matplotlib.pyplot as plt" ] }, @@ -203,7 +202,7 @@ " param = pybamm.ParameterValues(\"Chen2020\")\n", " experiment = pybamm.Experiment(\n", " [\n", - " f\"Discharge at 1 A for 1 minutes\",\n", + " \"Discharge at 1 A for 1 minutes\",\n", " ],\n", " period=\"10 seconds\",\n", " )\n", @@ -218,7 +217,7 @@ " plt.plot(range(7), output[\"Cell current [A]\"][-1, :], lines[i], label=labels[i])\n", " ax.set_xlabel(\"Node\")\n", " ax.set_ylabel(\"Cell current [A]\")\n", - " plt.legend()\n" + " plt.legend()" ] } ], diff --git a/liionpack/__init__.py b/liionpack/__init__.py index 838b69fc..2dc75aa6 100644 --- a/liionpack/__init__.py +++ b/liionpack/__init__.py @@ -5,6 +5,7 @@ pack with a combination of batteries connected in series and parallel or can read a netlist. """ + from .simulations import basic_simulation from .simulations import thermal_simulation from .simulations import thermal_external diff --git a/tests/unit/test_notebooks.py b/tests/unit/test_notebooks.py index 523d89b2..aa4737ea 100644 --- a/tests/unit/test_notebooks.py +++ b/tests/unit/test_notebooks.py @@ -7,7 +7,9 @@ import nbconvert import liionpack as lp import matplotlib -matplotlib.use('Agg') # Switch to a non-GUI backend + +matplotlib.use("Agg") # Switch to a non-GUI backend + class TestNotebooks(unittest.TestCase): def test_notebooks(self):