-
-
Notifications
You must be signed in to change notification settings - Fork 594
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]: Interpolant getting nans
as input
#4877
Comments
Does this happen for any quantity defined as an interpolant, or only diffusivity? |
Running the same I was the person who initially noticed this bug and don't know the PyBaMM internals very well, but it seems like some of the parameters which I have also noticed that running |
I'm not entirely sure if this is expected, but the NaNs seem to be coming from the if type(self).__name__ == "Interpolant":
print("all_nan?", np.isnan(y).all()) |
if Do you have a test case where the output of a simulation is affected? |
I assume that at some point in this conversion the If I understand correctly, any interpolated function which depends on the state (which will always be NaN during conversion) will always be evaluated at the same point (the midpoint), giving incorrect results. |
no, the solver will never evaluate any python code, by that time the interpolant has been converted to a casadi function. The only time the code in |
Thank you for explaining, that makes sense - the conversion for interpolants seems to happen in convert_to_casadi.py L143. I suspect that this issue can be closed now, but just for my peace of mind is there an easy way of extracting the interpolation inputs and outputs for diffusivity from the CasADi solution (I'm not sure how to match the input temperature and concentration with parts of the |
just add the inputs and outputs as additional variables of the model (i.e. add to the |
Thank you again for your help, the values for linear interpolation seem to match. When I use the |
PyBaMM Version
develop
Python Version
3.11
Describe the bug
When defining the diffusivity as an interpolant, the stoichiometry passed is as nan. This means that the function gets evaluated at the midpoint of the interpolation range rather than at its actual value.
Steps to Reproduce
minimal_example_of_lookup_tables.py
evaluated_children
contains nans in the second argument (stoichiometry). The first time I believe it is for shape evaluation only, so it's fine to have nans, but the subsequent evaluations are in the solver.Relevant log output
The text was updated successfully, but these errors were encountered: