Skip to content

Commit 2702647

Browse files
committed
fix warning for nested events in MTK models
1 parent ecccd4e commit 2702647

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

ext/MTKExt_utils.jl

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,16 +149,28 @@ function generate_massmatrix(eqs::AbstractVector{Equation})
149149
end
150150

151151
function warn_missing_features(sys)
152-
cev = ModelingToolkit.get_continuous_events(sys)
153-
dev = ModelingToolkit.get_discrete_events(sys)
152+
cev = _collect_continuous_events(sys)
153+
dev = _collect_discrete_events(sys)
154154
if !isempty(cev) || !isempty(dev)
155-
@warn "Model has attached events, which is not supported."
155+
@warn "MTK-Model $(sys.name) contains events. They will be ignored by NetworkDynamics.jl. Use ComponentCallbacks on a component level for that!"
156156
end
157157

158158
if !isempty(ModelingToolkit.initialization_equations(sys))
159159
@warn "Model has explicit init equation. Those are currently ignored by NetworkDynamics.jl."
160160
end
161161
end
162+
function _collect_continuous_events(sys)
163+
vcat(
164+
ModelingToolkit.get_continuous_events(sys),
165+
[_collect_continuous_events(sys) for sys in ModelingToolkit.get_systems(sys)]...
166+
)
167+
end
168+
function _collect_discrete_events(sys)
169+
vcat(
170+
ModelingToolkit.get_discrete_events(sys),
171+
[_collect_discrete_events(sys) for sys in ModelingToolkit.get_systems(sys)]...
172+
)
173+
end
162174

163175
function check_metadata(exprs)
164176
nometadata = []

0 commit comments

Comments
 (0)