Control automatic function parameter interpolation method
See original GitHub issueDescription
Allow users to specify which interpolation method they would like to be applied to function parameters.
Motivation
When using three-dimensional lookup tables I have found better model build times when moving from “cubic” to “linear” interpolation (in particular convert_to_casadi is slow). At the moment I can only control this by modifying the process symbol method of parameter values.
The speed up might be due to differences in calculating the Jacobian (or perhaps not calculating it if the Jacobian at all is not defined everywhere for linear interpolation) but I am not sure of the exact reason.
Possible Implementation
I can think of a couple of ways of doing this but I’m not sure what is preferable for everyone. Both should be non-breaking.
1. Pass optional dictionary to parameter_values class This would just involve adding an optional argument to the parameter_values class and then adding the input as an attribute of the class. The user would just pass an options dictionary in the following way:
options = {"interpolation methods": {"name of function parameter to target": "linear"}
if not specified then “cubic” interpolation will be used so that this change is nonbreaking.
2. Allow users to add a third entry to the tuple within the parameter values dictionary i.e.
options = {"interpolation method": "linear"}
parameter_values_dictionary = {
"negative electrode open circuit voltage [V]": ("negative electrode open circuit voltage [V]", ( (x_data, ), y_data), options),
"positive electrode open circuit voltage [V]": ("positive electrode open circuit voltage [V]", ( (x_data, ), y_data)),
}
This could either be a dictionary like I suggest here (so that additional control can be easily added later) or it could just be “linear” or “cubic”. This third argument should be optional with “cubic” used by default so that we don’t break all previous code.
Additional context
I am happy to implement once there is agreement on how to do so.
Could perhaps be done in conjunction with modifications to function parameter in #2403
Issue Analytics
- State:
- Created a year ago
- Comments:5
Would be interesting to do a bit more detailed profiling to see where the bottleneck is
To be specific solve time doesn’t really change for the case I considered but model setup time does:
Should I go ahead with changing to linear? Worry would be that this might alter some results.
Yeah agree that this is a way to do this within a script. I was trying to keep parameter definitions within a parameters class (like
LithiumIonParameters
) and data loading separate but I guess can just pass data to the parameters class an create Interpolants instead of FunctionParameters