Skip to content

Commit 530eb54

Browse files
Merge pull request #4510 from SciML/as/faster-odeproblem
refactor: use `IRStructure` in `calculate_A_b`
2 parents 7691a29 + ed8b294 commit 530eb54

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

lib/ModelingToolkitBase/src/systems/codegen.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1443,6 +1443,7 @@ function calculate_A_b(sys::System; sparse = false, throw = true)
14431443
V = SymbolicT[]
14441444
b = Vector{SymbolicT}(undef, length(rhss))
14451445
query_predicate = in(Set{SymbolicT}(dvs))
1446+
ir = get_irstructure(sys)
14461447
# `linear_expansion` caches values based on `var`. This loop ordering helps
14471448
# avoid invalidating the cache frequently.
14481449
for (j, var) in enumerate(dvs)
@@ -1451,7 +1452,8 @@ function calculate_A_b(sys::System; sparse = false, throw = true)
14511452
p, q, islinear = lex(resid)
14521453
# An equation such as `0 ~ 1 + x * y` will return `(x, 1, true)` for `y`.
14531454
# Check that `p` doesn't contain unknowns to avoid this.
1454-
if !islinear || SU.query(query_predicate, p)
1455+
SU.populate_ir!(ir, p)
1456+
if !islinear || SU.query(query_predicate, ir, p)
14551457
err = NotAffineError(fulleqs[i].rhs, var)
14561458
store_to_mutable_cache!(sys, CachedLinearAb, err)
14571459
throw || return nothing

0 commit comments

Comments
 (0)