51
51
52
52
get_value (interp:: Interpolator , t) = interp (t)
53
53
@register_symbolic get_value (interp:: Interpolator , t)
54
- # get_value(data, t, dt) = data[round(Int, t / dt + 1)]
55
- # @register_symbolic get_value(data::Vector, t, dt)
54
+
55
+ Symbolics . derivative ( :: typeof (get_value), args :: NTuple{2, Any} , :: Val{2} ) = 0
56
56
57
57
function Sampled (; name, interp = Interpolator (Float64[], 0.0 ))
58
58
pars = @parameters begin
@@ -68,11 +68,10 @@ function Sampled(; name, interp = Interpolator(Float64[], 0.0))
68
68
output. u ~ get_value (interpolator, t)
69
69
]
70
70
71
- return ODESystem (eqs, t, vars, [interpolator]; name, systems,
72
- defaults = [output. u => interp. data[1 ]])
71
+ return ODESystem (eqs, t, vars, [interpolator]; name, systems)
73
72
end
74
73
75
- vars = @variables y (t)= 1 dy (t)= 0 ddy (t)= 0
74
+ vars = @variables y (t) dy (t) ddy (t)
76
75
@named src = Sampled (; interp = Interpolator (x, dt))
77
76
@named int = Integrator ()
78
77
@@ -84,11 +83,9 @@ eqs = [y ~ src.output.u
84
83
@named sys = ODESystem (eqs, t, vars, []; systems = [int, src])
85
84
s = complete (sys)
86
85
sys = structural_simplify (sys)
87
- @test_broken ODEProblem (
88
- sys, [], (0.0 , t_end), [s. src. interpolator => Interpolator (x, dt)]; tofloat = false )
89
86
prob = ODEProblem (
90
87
sys, [], (0.0 , t_end), [s. src. interpolator => Interpolator (x, dt)];
91
- tofloat = false , build_initializeprob = false )
88
+ tofloat = false )
92
89
sol = solve (prob, ImplicitEuler ());
93
90
@test sol. retcode == ReturnCode. Success
94
91
@test sol[y][end ] == x[end ]
0 commit comments