How to perform gradient based fitting on data with custom current profile? #4395
Replies: 2 comments 1 reply
-
Update: I got an example working with a dynamic current:
However when I try to use conditionals in my current function like so:
I get an error:
Is there a way to pass a pybamm experiment as the current function? Is this error because the function is not differentiable for all t? |
Beta Was this translation helpful? Give feedback.
-
As you suggest, something to do with the discontinuity in your current function is causing the solver to fail, but the error message is not very good here! You can smooth off your current function using def current_function(t):
y = 0.5 * (1.0 - pybamm.sigmoid(t, 50, 10)) + 0.1 * pybamm.sigmoid(t, 50, 10)
return y This works for me. I'm not sure what you mean by "pass a pybamm experiment at the current function". If you want to calculate the derivatve of a pybamm solve using |
Beta Was this translation helpful? Give feedback.
-
I've found the example here: https://docs.pybamm.org/en/latest/source/examples/notebooks/solvers/idaklu-jax-interface.html showing how to compute the gradient of a model with respect to input parameters, but I am having trouble doing this with a custom current data , custom defined experiment, or current function. I've tried to do this a multitude of ways, mostly by altering the 'Current function [A]' in the parameter values, including using an interpolant, custom function, etc.. but I cannot figure it out. Is there a solution for this? It seems like it should be very simple, but I'm only able to solve this with a static current.
Beta Was this translation helpful? Give feedback.
All reactions