Skip to content

Commit

Permalink
Update PyBaMM version (#332)
Browse files Browse the repository at this point in the history
* Start to update PyBaMM version

* Get type name

* Get tests working

* Update notebooks

* Update liionpack/protocols.py

---------

Co-authored-by: Robert Timms <43040151+rtimms@users.noreply.github.com>
  • Loading branch information
kratman and rtimms authored Oct 15, 2024
1 parent 03f7a3b commit 10dfe8b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 16 deletions.
4 changes: 1 addition & 3 deletions docs/examples/03 Experiments.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,7 @@
"output_type": "execute_result"
}
],
"source": [
"experiment.operating_conditions_steps"
]
"source": "experiment.steps"
},
{
"cell_type": "markdown",
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 @@ -44,7 +44,7 @@
"source": [
"# import drive cycle from file\n",
"drive_cycle = pd.read_csv(\n",
" \"pybamm/input/drive_cycles/US06.csv\", comment=\"#\", header=None\n",
" pybamm.DataLoader().get_data(\"US06.csv\"), comment=\"#\", header=None\n",
").to_numpy()"
]
},
Expand Down
16 changes: 6 additions & 10 deletions liionpack/protocols.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#
# Experimental protocol
#

import numpy as np
import pybamm

Expand All @@ -23,16 +19,16 @@ def generate_protocol_from_experiment(experiment):
protocol = []
terminations = []
step_types = []
for i, step in enumerate(experiment.operating_conditions_steps):
for i, step in enumerate(experiment.steps):
proto = []
t = step.duration
dt = step.period
typ = step.type
termination = step.termination
if typ not in ["current", "power"]:
raise ValueError("Only current operations are supported")
step_type = type(step).__name__
if step_type not in ["Current", "Power"]:
raise ValueError("Only current and power operations are supported")
else:
if not step.is_drive_cycle:
if not isinstance(step.value, pybamm.Interpolant):
I = step.value
proto.extend([I] * int(np.round(t, 5) / np.round(dt, 5)))
if i == 0:
Expand All @@ -50,6 +46,6 @@ def generate_protocol_from_experiment(experiment):
terminations.append([])

protocol.append(proto)
step_types.append(typ)
step_types.append(step_type)

return protocol, terminations, step_types
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ dynamic = [
"version",
]
dependencies = [
"pybamm==24.9",
"Ipython",
"lcapy",
"matplotlib",
Expand All @@ -39,7 +40,6 @@ dependencies = [
"openpyxl",
"pandas",
"plotly",
"pybamm==24.1",
"ray",
"redis",
"scikit-spatial",
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_generate_protocol(self):
def test_generate_protocol_from_drive_cycle(self):
os.chdir(pybamm.__path__[0] + "/..")
drive_cycle = pd.read_csv(
"pybamm/input/drive_cycles/US06.csv", comment="#", header=None
pybamm.DataLoader().get_data("US06.csv"), comment="#", header=None
).to_numpy()

experiment = pybamm.Experiment(
Expand Down

0 comments on commit 10dfe8b

Please sign in to comment.