Skip to content

Commit 060fbc9

Browse files
Merge pull request #85 from JuliaComputing/as/cached-linear-expander
refactor: use new cached `LinearExpander`s in `System`
2 parents 488beb8 + 1d23f7a commit 060fbc9

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

lib/ModelingToolkitTearing/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ ForwardDiff = "1.3"
3030
Graphs = "1"
3131
LinearAlgebra = "1"
3232
ModelingToolkit = "11"
33-
ModelingToolkitBase = "1.23"
33+
ModelingToolkitBase = "1.37"
3434
Moshi = "0.3"
3535
OffsetArrays = "1"
3636
OrderedCollections = "1.8.1"

lib/ModelingToolkitTearing/src/reassemble.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ function get_linear_scc_linsol(state::TearingState, alg_eqs::Vector{Int},
556556
analytical_linear_scc_limit::Int,
557557
simplify::Bool; allow_symbolic::Bool = false,
558558
allow_parameter::Bool = true)
559-
(; fullvars) = state
559+
(; fullvars, sys) = state
560560
# If the SCC is fully torn, don't bother generating a linsolve
561561
all_torn = true
562562
for iv in alg_vars
@@ -587,7 +587,7 @@ function get_linear_scc_linsol(state::TearingState, alg_eqs::Vector{Int},
587587
end
588588

589589
for (varidx, var) in enumerate(vars)
590-
lex = Symbolics.LinearExpander(var; strict = true)
590+
lex = MTKBase.get_linear_expander_for!(sys, var, true)
591591
for (eqidx, resid) in enumerate(b)
592592
p, q, islinear = lex(resid)
593593
islinear || return nothing

lib/ModelingToolkitTearing/src/stateselection_interface.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ function StateSelection.find_eq_solvables!(state::TearingState, ieq, to_rm = Int
230230
conservative = false,
231231
symbolically_rm_singular = true,
232232
kwargs...)
233-
(; fullvars) = state
233+
(; fullvars, sys) = state
234234
(; graph, solvable_graph) = state.structure
235235

236236
eq = equations(state)[ieq]
@@ -249,7 +249,7 @@ function StateSelection.find_eq_solvables!(state::TearingState, ieq, to_rm = Int
249249
for j in 𝑠neighbors(graph, ieq)
250250
var = fullvars[j]
251251
MTKBase.isirreducible(var) && (all_int_vars = false; continue)
252-
a, b, islinear = Symbolics.LinearExpander(var; strict = true)(term)
252+
a, b, islinear = MTKBase.get_linear_expander_for!(sys, var, true)(term)
253253
islinear || (all_int_vars = false; continue)
254254
if !SU.isconst(a)
255255
all_int_vars = false
@@ -291,7 +291,7 @@ function StateSelection.find_eq_solvables!(state::TearingState, ieq, to_rm = Int
291291
rem_edge!(graph, ieq, j)
292292
symbolically_rm_singular || continue
293293
eq = equations(state)[ieq]
294-
a, b, islin = Symbolics.LinearExpander(fullvars[j]; strict = true)(eq.rhs)
294+
a, b, islin = MTKBase.get_linear_expander_for!(sys, fullvars[j], true)(eq.rhs)
295295
SU._iszero(a) && islin || continue
296296
equations(state)[ieq] = eq.lhs ~ b
297297
end

0 commit comments

Comments
 (0)