Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: c_rate step with drive cycle error #3185

Closed
TomTranter opened this issue Jul 24, 2023 · 1 comment · Fixed by #3186
Closed

[Bug]: c_rate step with drive cycle error #3185

TomTranter opened this issue Jul 24, 2023 · 1 comment · Fixed by #3186
Assignees
Labels
bug Something isn't working

Comments

@TomTranter
Copy link
Contributor

PyBaMM Version

23/5

Python Version

all

Describe the bug

There is an evaluation of the initial current performed in simulation when setting up events. Drive cycles are turned into interpolant and code accounts for this when doing a current step but when doing a c_rate step the object is a multiplication and the logic fails
Something like this will fix it in simulation line 290

                if (isinstance(op.value, pybamm.Interpolant) or
                    isinstance(op.value, pybamm.Multiplication)):
                    inpt = {"start time":0}
                    init_curr = op.value.evaluate(t=0, inputs=inpt).flatten()[0]
                    sign = np.sign(init_curr)

Steps to Reproduce

import pybamm
import numpy as np
model = pybamm.lithium_ion.SPM()
param = pybamm.ParameterValues("Chen2020")
drive = np.vstack((np.arange(60), np.random.random(60))).T
experiment = pybamm.Experiment([pybamm.step.c_rate(drive,
                                                   duration="1 minute",
                                                   termination="3.0 V",
                                                   period="1 s",
                                                   temperature="25.0 oC")])
sim = pybamm.Simulation(model, experiment, parameter_values=param)
sim.solve()
sim.plot()

Relevant log output

No response

@TomTranter TomTranter added the bug Something isn't working label Jul 24, 2023
@TomTranter TomTranter self-assigned this Jul 24, 2023
@brosaplanella brosaplanella linked a pull request Jul 26, 2023 that will close this issue
8 tasks
@brosaplanella
Copy link
Sponsor Member

Closing as this has already been fixed by #3186

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants