Skip to content

Commit baf87d6

Browse files
refactor: use SCC information calculated during mtkcompile in SCCNonlinearProblem
1 parent 001aa7f commit baf87d6

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/problems/sccnonlinearproblem.jl

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,21 +80,26 @@ function SciMLBase.SCCNonlinearProblem{iip}(sys::System, op; eval_expression = f
8080
end
8181

8282
ts = get_tearing_state(sys)
83-
var_eq_matching, var_sccs = StructuralTransformations.algebraic_variables_scc(ts)
83+
sched = get_schedule(sys)
84+
if sched === nothing
85+
@warn "System is simplified but does not have a schedule. This should not happen."
86+
var_eq_matching, var_sccs = StructuralTransformations.algebraic_variables_scc(ts)
87+
condensed_graph = MatchedCondensationGraph(
88+
DiCMOBiGraph{true}(complete(ts.structure.graph),
89+
complete(var_eq_matching)),
90+
var_sccs)
91+
toporder = topological_sort_by_dfs(condensed_graph)
92+
var_sccs = var_sccs[toporder]
93+
eq_sccs = map(Base.Fix1(getindex, var_eq_matching), var_sccs)
94+
else
95+
var_sccs = eq_sccs = sched.var_sccs
96+
end
8497

8598
if length(var_sccs) == 1
8699
return NonlinearProblem{iip}(
87100
sys, op; eval_expression, eval_module, kwargs...)
88101
end
89102

90-
condensed_graph = MatchedCondensationGraph(
91-
DiCMOBiGraph{true}(complete(ts.structure.graph),
92-
complete(var_eq_matching)),
93-
var_sccs)
94-
toporder = topological_sort_by_dfs(condensed_graph)
95-
var_sccs = var_sccs[toporder]
96-
eq_sccs = map(Base.Fix1(getindex, var_eq_matching), var_sccs)
97-
98103
dvs = unknowns(sys)
99104
ps = parameters(sys)
100105
eqs = equations(sys)

0 commit comments

Comments
 (0)