Skip to content

Commit e29a989

Browse files
feat: populate state.structure.denominators in find_eq_solvables!
1 parent 631c447 commit e29a989

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/structural_transformation/utils.jl

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,9 @@ end
206206
### Structural and symbolic utilities
207207
###
208208

209-
function find_eq_solvables!(state::TearingState, ieq, to_rm = Int[], coeffs = nothing;
209+
function find_eq_solvables!(state::TearingState, ieq::Int, to_rm = Int[], coeffs = nothing;
210210
may_be_zero = false,
211-
allow_symbolic = false, allow_parameter = true,
211+
allow_symbolic = false, allow_parameter = true, allow_algebraic = true,
212212
conservative = false,
213213
kwargs...)
214214
fullvars = state.fullvars
@@ -218,6 +218,7 @@ function find_eq_solvables!(state::TearingState, ieq, to_rm = Int[], coeffs = no
218218
all_int_vars = true
219219
coeffs === nothing || empty!(coeffs)
220220
empty!(to_rm)
221+
varsbuf = Set()
221222
for j in 𝑠neighbors(graph, ieq)
222223
var = fullvars[j]
223224
isirreducible(var) && (all_int_vars = false; continue)
@@ -229,13 +230,18 @@ function find_eq_solvables!(state::TearingState, ieq, to_rm = Int[], coeffs = no
229230
if a isa Symbolic
230231
all_int_vars = false
231232
if !allow_symbolic
232-
if allow_parameter
233-
all(
234-
x -> ModelingToolkit.isparameter(x) || ModelingToolkit.isconstant(x),
235-
vars(a)) || continue
236-
else
233+
allow_parameter || allow_algebraic || continue
234+
empty!(varsbuf)
235+
vars!(varsbuf, a)
236+
denomvars = Int[]
237+
for v in varsbuf
238+
idx = findfirst(isequal(v), fullvars)
239+
idx === nothing || push!(denomvars, idx)
240+
end
241+
if !allow_algebraic && !isempty(denomvars)
237242
continue
238243
end
244+
state.structure.denominators[ieq => j] = denomvars
239245
end
240246
add_edge!(solvable_graph, ieq, j)
241247
continue

0 commit comments

Comments
 (0)