-
-
Notifications
You must be signed in to change notification settings - Fork 665
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
PyBaMM Version
25.6
Python Version
3.12
Describe the bug
Using a pybamm.step.CRate
with a drive cycle and no explicit duration
argument doesn't call the default_duration()
method in the BaseStep
class which is supposed to handle drive cycles, but rather its own function which is correct for single C-rate values only.
Should change CRate.default_duration()
to:
def default_duration(self, value):
if isinstance(value, np.ndarray):
t = value[:, 0]
return t[-1]
else:
# "value" is C-rate, so duration is "1 / value" hours in seconds
# with a 2x safety factor
return 1 / abs(value) * 3600 * 2
Steps to Reproduce
t = np.linspace(0, 100, 101)
I = np.sin(t)
drive_cycle = np.column_stack([t, I])
exp = pybamm.Experiment([pybamm.step.CRate(drive_cycle)])
Relevant log output
AttributeError: 'numpy.ndarray' object has no attribute 'lstrip'
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working