Skip to content

Commit f8819c2

Browse files
test: test symbolic indexing of DDE solutions
1 parent 6f59a71 commit f8819c2

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/dde.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ prob2 = DDEProblem(sys,
5151
constant_lags = [tau])
5252
sol2_mtk = solve(prob2, alg, reltol = 1e-7, abstol = 1e-10)
5353
@test sol2_mtk.u[end] sol2.u[end]
54+
@test_nowarn sol2_mtk[[x₀, x₁, x₂(t)]]
55+
@test_nowarn sol2_mtk[[x₀, x₁, x₂(t - 0.1)]]
5456

5557
using StochasticDelayDiffEq
5658
function hayes_modelf(du, u, h, p, t)
@@ -112,3 +114,14 @@ for coupledOsc in [coupledOsc, coupledOsc2]
112114
@test length(equations(sys)) == 4
113115
@test length(unknowns(sys)) == 4
114116
end
117+
sys = structural_simplify(coupledOsc)
118+
prob = DDEProblem(sys, [], (0.0, 10.0); constant_lags = [sys.osc1.τ, sys.osc2.τ])
119+
sol = solve(prob, MethodOfSteps(Tsit5()))
120+
obsfn = ModelingToolkit.build_explicit_observed_function(
121+
sys, [sys.osc1.delx, sys.osc2.delx])
122+
obsval = @test_nowarn obsfn(sol.u[1], (_, t) -> sol(t), prob.p, sol.t[1])
123+
@test obsval sol(sol.t[1] - 0.01; idxs = [sys.osc1.x, sys.osc2.x])
124+
#= TODO: Uncomment when implemented
125+
@test_nowarn sol[[sys.osc1.delx, sys.osc2.delx]]
126+
@test sol[sys.osc1.delx] ≈ sol(sol.t .- 0.01; idxs = sys.osc1.x)
127+
=#

0 commit comments

Comments
 (0)