Skip to content

Commit 9dc6afe

Browse files
test: test called parameters are still differentiated
1 parent 6cc8a0c commit 9dc6afe

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

test/structural_transformation/utils.jl

+32
Original file line numberDiff line numberDiff line change
@@ -311,4 +311,36 @@ end
311311
end
312312

313313
@test !(D(sys.k) in vs)
314+
315+
@testset "Called parameter still has derivative" begin
316+
@component function FilteredInput2(; name, x0 = 0, T = 0.1)
317+
ts = collect(0.0:0.1:10.0)
318+
spline = LinearInterpolation(ts .^ 2, ts)
319+
params = @parameters begin
320+
(k::LinearInterpolation)(..) = spline
321+
T = T
322+
end
323+
vars = @variables begin
324+
x(t) = k(t)
325+
dx(t) = 0
326+
ddx(t)
327+
end
328+
systems = []
329+
eqs = [D(x) ~ dx
330+
D(dx) ~ ddx
331+
dx ~ (k(t) - x) / T]
332+
return ODESystem(eqs, t, vars, params; systems, name)
333+
end
334+
335+
@mtkbuild sys = FilteredInput2()
336+
vs = Set()
337+
for eq in equations(sys)
338+
ModelingToolkit.vars!(vs, eq)
339+
end
340+
for eq in observed(sys)
341+
ModelingToolkit.vars!(vs, eq)
342+
end
343+
344+
@test D(sys.k(t)) in vs
345+
end
314346
end

0 commit comments

Comments
 (0)