You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The newly created Interpolations component, available in ModelingToolkitStandardLibrary v 2.17.0 under the Blocks module, gives problems when used within the @mtkmodel macro.
Expected behavior
The Interpolation component should work fine when used ina model defined using the @mtkmodel macro.
Minimal Reproducible Example 👇
The code below is from an example available in this link, which works fine with Interpolation being used as a component:
using ModelingToolkit
using ModelingToolkit: t_nounits as t, D_nounits as D
using ModelingToolkitStandardLibrary
using ModelingToolkitStandardLibrary.Blocks
using DataInterpolations
using OrdinaryDiffEq
using DataFrames
using Plots
functionMassSpringDamper(; name)
@named input =RealInput()
@variablesf(t)=0x(t)=0dx(t)=0ddx(t)=0@parameters m=10 k=1000 d=1
eqs = [
f ~ input.u
ddx *10~ k * x + d * dx + f
D(x) ~ dx
D(dx) ~ ddx]
ODESystem(eqs, t; name, systems = [input])
endfunctionMassSpringDamperSystem(data, time; name)
@named src = ModelingToolkitStandardLibrary.Blocks.Interpolation(LinearInterpolation, data, time)
@named clk =ContinuousClock()
@named model =MassSpringDamper()
eqs = [
connect(src.input, clk.output)
connect(src.output, model.input)
]
ODESystem(eqs, t, [], []; name, systems = [src, clk, model])
endfunctiongenerate_data()
dt =4e-4
time =0:dt:0.1
data =sin.(2*pi* time *100)
returnDataFrame(; time, data)
end
df =generate_data() # example data@named system =MassSpringDamperSystem(df.data, df.time)
sys =structural_simplify(system)
prob =ODEProblem(sys, [], (0, df.time[end]))
sol =solve(prob)
plot(sol)
Below is a toy example which does NOT work when Interpolation is used within @mtkmodel macro:
Describe the bug 🐞
The newly created Interpolations component, available in ModelingToolkitStandardLibrary v 2.17.0 under the Blocks module, gives problems when used within the @mtkmodel macro.
Expected behavior
The Interpolation component should work fine when used ina model defined using the @mtkmodel macro.
Minimal Reproducible Example 👇
The code below is from an example available in this link, which works fine with Interpolation being used as a component:
Below is a toy example which does NOT work when Interpolation is used within @mtkmodel macro:
The model definition works fine:
But @mtkbuild fails:
with the following error and stracktrace:
Error & Stacktrace⚠️
Environment:
using Pkg; Pkg.status()
using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
versioninfo()
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: