Skip to content

Commit

Permalink
style: pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Feb 5, 2024
1 parent a82f4b7 commit cc2ec1b
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 32 deletions.
5 changes: 2 additions & 3 deletions docs/examples/01 Getting Started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand Down Expand Up @@ -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",
")"
]
},
Expand Down
6 changes: 2 additions & 4 deletions docs/examples/03 Experiments.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand Down Expand Up @@ -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",
")"
]
},
Expand Down
9 changes: 5 additions & 4 deletions docs/examples/04 Initial SoC.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand Down Expand Up @@ -296,7 +294,10 @@
}
],
"source": [
"lp.draw_circuit(netlist, dpi=100,)"
"lp.draw_circuit(\n",
" netlist,\n",
" dpi=100,\n",
")"
]
}
],
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/05 Drive cycles.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
Expand Down
6 changes: 2 additions & 4 deletions docs/examples/07 Visualizing larger packs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -86,7 +84,7 @@
" output_variables=output_variables,\n",
" inputs=inputs,\n",
" initial_soc=0.5,\n",
" nproc=nproc\n",
" nproc=nproc,\n",
")"
]
},
Expand Down
35 changes: 23 additions & 12 deletions docs/examples/08 SEI degradation model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
")"
]
},
{
Expand All @@ -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",
")"
]
},
{
Expand Down Expand Up @@ -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",
"]"
]
},
{
Expand Down Expand Up @@ -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}"
]
},
Expand All @@ -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",
")"
]
},
Expand Down
5 changes: 2 additions & 3 deletions docs/examples/09 Terminal locations.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
Expand Down Expand Up @@ -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",
Expand All @@ -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()"
]
}
],
Expand Down
1 change: 1 addition & 0 deletions liionpack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion tests/unit/test_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit cc2ec1b

Please sign in to comment.