Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function (iec::InferEquationClosure)(ieq::Int, eq::Equation, is_initialization_e
empty!(varsbuf)
empty!(hyperedge)
# get variables in equation
SU.search_variables!(varsbuf, eq; is_atomic = MTKBase.OperatorIsAtomic{SU.Operator}())
SU.search_variables!(varsbuf, eq)
# add the equation to the hyperedge
eq_node = if is_initialization_equation
ClockVertex.InitEquation(ieq)
Expand All @@ -99,6 +99,11 @@ function (iec::InferEquationClosure)(ieq::Int, eq::Equation, is_initialization_e
# if this is just a single variable, add it to the hyperedge
if idx isa Int
push!(hyperedge, ClockVertex.Variable(idx))
d = get_time_domain(var)
if is_concrete_time_domain(d)
push!(hyperedge, ClockVertex.Clock(d))
end

# we don't immediately `continue` here because this variable might be a
# `Sample` or similar and we want the clock information from it if it is.
end
Expand Down
14 changes: 14 additions & 0 deletions lib/ModelingToolkitTearing/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,17 @@ end
@test !Graphs.has_edge(ts.structure.graph, BipartiteEdge(2, x_idx))
@test !SU.query(isequal(x), equations(ts)[2].rhs)
end

@testset "Clock inference doesn't only rely on `fullvars` for metadata clock information" begin
@variables y(t) l(t)
k = ShiftIndex(Clock(0.1))
eqs = [
y(k) ~ -Sample()(l),
D(l) ~ 20*(Hold()(y) - l)
]

@named cl = System(eqs, t)
# It should throw this error, not one saying it can't find a clock for an
# inferreddiscrete partition
@test_throws ModelingToolkit.HybridSystemNotSupportedException mtkcompile(cl)
end
Loading