Skip to content

Commit

Permalink
Added more information to error when drive cycle starts at t>0
Browse files Browse the repository at this point in the history
  • Loading branch information
R-Yash committed Jan 22, 2024
1 parent 4484514 commit 51d9156
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/source/api/experiment/experiment_steps.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Experiment step functions
=========================

The following functions can be used to define steps in an experiment.
The following functions can be used to define steps in an experiment. Note that the drive cycle must start at t=0

.. autofunction:: pybamm.step.string

Expand Down
6 changes: 5 additions & 1 deletion pybamm/experiment/step/_steps_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,12 @@ def __init__(
t, y = value[:, 0], value[:, 1]
self.duration = t.max()

# Check that drive cycle starts at t=0
if t[0] > 0:
raise ValueError("Drive cycle must start at t=0")

self.value = pybamm.Interpolant(
t, y, pybamm.t - pybamm.InputParameter("start time")
t, y, pybamm.t - pybamm.InputParameter("start time"),name = 'Current Drive Cycle'
)
self.period = np.diff(t).min()
else:
Expand Down

0 comments on commit 51d9156

Please sign in to comment.