Hi,
I’m using ModelingToolkit to model a battery cell using the Equivalent Circuit Model (ECM) approach. For that, I will be using 2-D lookup tables for the values of Vocv, resistnaces and time constants/capacitances, where the breakpoints are SoC and Temperature.
As I want to identify the model parameters, I want to set the lookup table data as parameters.
I’m now struggling with the interpolation function. I cannot make the Interpolations.LinearInterpolation from Interpolations.jl work. Below is a toy problem that presents the issue:
using ModelingToolkit, Interpolations, DifferentialEquations
using ModelingToolkit: t_nounits as t, D_nounits as D
using Plots;
plotlyjs();
function lut_1d(X1, Data, bp1)
interpolator = Interpolations.LinearInterpolation((bp1), Data, extrapolation_bc=Flat())
return interpolator(X1)
end
@register_symbolic lut_1d(X1,Data,bp1)
@parameters table_data[1:3] = [1.0, 2.0, 3.0]
@variables soc(t) R(t) i(t) V(t)
@constants table_bkp = [0.0, 0.5, 1.0]
eqs_interp = [ D(soc) ~ -i/3600/1
R ~ lut_1d(t, table_data, table_bkp)
V ~ R * i
V ~ 1
]
@named sys_interp = ODESystem(eqs_interp, t)
sys_interp = structural_simplify(sys_interp)
With that, I get the error:
MethodError: no method matching LinearInterpolation(::Num, ::Symbolics.Arr{Num, 1}; extrapolation_bc::Flat{Nothing})
Any suggestions on how to make this work?