Skip to content

[Bug]: Period for drive cycle experiment step gets overwritten by data #5087

@Daniel-Nicolae23

Description

@Daniel-Nicolae23

PyBaMM Version

25.6

Python Version

3.12

Describe the bug

Defining an experiment step with a drive cycle array seems to ignore any manually defined t_eval period. It just uses the period of the data (or in the case of non-uniform timesteps, it looks like it does a fixed period of total_duration/N_points)

I tried specifying the period in both the step and the experiment, it doesn't make a difference.

Steps to Reproduce

import pybamm
import numpy as np

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, duration=100, period=0.05)], period=0.05)

model = pybamm.lithium_ion.SPMe()
params = model.default_parameter_values

sim = pybamm.Simulation(model, exp, parameter_values=params, solver=pybamm.IDAKLUSolver())
sol = sim.solve(initial_soc=0.5)


sol["Time [s]"].entries # this has the period of the linspace

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions