Questions about simulation.step()

Hi,

I want to run a custom current profile (let’s say [0, 0.5, 0.45, 0.47]) using sim.step instead of sim.solve. How do I do that?

Here’s a MWE of what I’m trying to achieve.

# Using sim.solve()
import pybamm
import numpy as np

parameter_values = pybamm.ParameterValues("NCA_Kim2011")
model = pybamm.lithium_ion.DFN()

solver = pybamm.CasadiSolver(mode="safe")

current_input = np.array([0, 0.5, 0.45, 0.47])
time_input = np.array([0, 1, 2, 3])

current_interpolant = pybamm.Interpolant(time_input, current_input, pybamm.t)
parameter_values["Current function [A]"] = current_interpolant

sim = pybamm.Simulation(model, parameter_values=parameter_values, solver=solver)
sim.solve()
sol = sim.solution

The results are:
sol["Time [s]"].entries
array([0., 1., 2., 3.])

sol["Current [A]"].entries
array([0. , 0.5 , 0.45, 0.47])

sol["Terminal voltage [V]"].entries
array([4.07411821, 4.06341121, 4.06206838, 4.06012812])

I need to achieve the same results using sim.step(). Can anyone guide me on how to do that?

I followed the example in these discussions (discussion-1, discussion-2). When I run each step, the current inputs get repeated and the results give me 7-8 entries instead of 4.

Hi everyone,

Any input on this?

I see that the newer PyBaMM version has the capability to resolve this issue!

Thank you