I am trying to use the new interpolation method via parameters (Callable parameters and interpolating data · ModelingToolkit.jl)
However I am struggling to understand how I should use it. This is my model:
@mtkmodel SingleDiode begin
@parameters begin
(I_L::Function)(..), [description = "Irradiance current (A)"]
n::Float64 = 1.0, [description = "Ideality factor"]
I_s::Float64 = 1e-6, [description = "Saturation current (A)"]
R_sh_val::Float64 = 1e5, [description = "Shunt resistance (Ohm)"]
R_s_val::Float64 = 1e-1, [description = "Series resistance (Ohm)"]
end
@components begin
R_sh = Resistor(R = R_sh_val)
R_s = Resistor(R = R_s_val)
diode = HeatingDiode(n = n, Is = I_s)
source = Current()
temp = FixedTemperature(T = 300.0)
pos = Pin()
neg = Pin()
end
@equations begin
source.I.u ~ I_L(t)
# positive side
connect(source.n, diode.p)
connect(source.n, R_sh.p)
connect(source.n, R_s.p)
connect(R_s.n, pos)
# negative side
connect(source.p, diode.n)
connect(source.p, R_sh.n)
connect(R_sh.n, neg)
# temperature
connect(temp.port, diode.port)
end
end
Trying to initialize this results in:
ERROR: LoadError: MethodError: Cannot
convert
an object of type Expr to an object of type Symbol
Without the interpolation the model runs fine.