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]: IDAKLU solver sensitivity calculation #2331

Closed
anoushka2000 opened this issue Sep 29, 2022 · 1 comment · Fixed by #2337
Closed

[Bug]: IDAKLU solver sensitivity calculation #2331

anoushka2000 opened this issue Sep 29, 2022 · 1 comment · Fixed by #2337
Labels
bug Something isn't working

Comments

@anoushka2000
Copy link
Contributor

PyBaMM Version

22.8

Python Version

3.9

Describe the bug

Sensitivities with respect to Negative electrode diffusivity [m2.s-1] and Positive electrode diffusivity [m2.s-1] found by IDAKLU solver are 0 for SPMe model with Chen 2020 parameter values, C/10 constant current discharge

Steps to Reproduce

import pybamm
import numpy as np

model = pybamm.lithium_ion.SPMe()

param = pybamm.ParameterValues("Chen2020")
param["Negative electrode diffusivity [m2.s-1]"] = pybamm.InputParameter("Ds_n")
param["Positive electrode diffusivity [m2.s-1]"] = pybamm.InputParameter("Ds_p")
param["Electrolyte diffusivity [m2.s-1]"] = pybamm.InputParameter("De")


simulation = pybamm.Simulation(model, parameter_values=param, solver = pybamm.IDAKLUSolver())


t_max = 60*60*10
t_eval = np.linspace(0, t_max, num=(t_max//2))

solution = simulation.solve(t_eval,
                            inputs={ "Ds_n": 3.54e-14, "Ds_p": 1.01e-13, "De": 3.71e-10}, 
                            calculate_sensitivities=True)

np.unique(solution.sensitivities['De'].flatten(), return_counts=True)

# resulting in all sensitivities = 0
np.unique(solution.sensitivities['Ds_n'].flatten(), return_counts=True)
np.unique(solution.sensitivities['Ds_p'].flatten(), return_counts=True)

Relevant log output

No response

@martinjrobins
Copy link
Contributor

This is an issue with the transfer of sensitivity data from C++ back to python when the simulation stops early due to an event. I've opened a pr in #2337 to fix this

martinjrobins added a commit that referenced this issue Oct 6, 2022
valentinsulzer added a commit that referenced this issue Oct 6, 2022
#2331 fix bug in size of yS numpy array when simulation stops early
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