@@ -137,8 +137,9 @@ function solve_equation(eq, var, simplify)
137
137
var ~ rhs
138
138
end
139
139
140
- function substitute_vars! (graph :: BipartiteGraph , subs, cache = Int[], callback! = nothing ;
140
+ function substitute_vars! (structure , subs, cache = Int[], callback! = nothing ;
141
141
exclude = ())
142
+ @unpack graph, solvable_graph = structure
142
143
for su in subs
143
144
su === nothing && continue
144
145
v, v′ = su
@@ -150,10 +151,15 @@ function substitute_vars!(graph::BipartiteGraph, subs, cache = Int[], callback!
150
151
eq in exclude && continue
151
152
rem_edge! (graph, eq, v)
152
153
add_edge! (graph, eq, v′)
154
+
155
+ if BipartiteEdge (eq, v) in solvable_graph
156
+ rem_edge! (solvable_graph, eq, v)
157
+ add_edge! (solvable_graph, eq, v′)
158
+ end
153
159
callback! != = nothing && callback! (eq, su)
154
160
end
155
161
end
156
- graph
162
+ return structure
157
163
end
158
164
159
165
function to_mass_matrix_form (neweqs, ieq, graph, fullvars, isdervar:: F ,
212
218
=#
213
219
214
220
function tearing_reassemble (state:: TearingState , var_eq_matching; simplify = false )
215
- @unpack fullvars, sys = state
216
- @unpack solvable_graph, var_to_diff, eq_to_diff, graph = state . structure
221
+ @unpack fullvars, sys, structure = state
222
+ @unpack solvable_graph, var_to_diff, eq_to_diff, graph = structure
217
223
218
224
neweqs = collect (equations (state))
219
225
# substitution utilities
@@ -468,9 +474,7 @@ function tearing_reassemble(state::TearingState, var_eq_matching; simplify = fal
468
474
if var_eq_matching[idx] isa Int
469
475
var_eq_matching[x_t_idx] = var_eq_matching[idx]
470
476
end
471
- substitute_vars! (graph, subidx, idx_buffer, sub_callback!;
472
- exclude = order_lowering_eqs)
473
- substitute_vars! (solvable_graph, subidx, idx_buffer;
477
+ substitute_vars! (structure, subidx, idx_buffer, sub_callback!;
474
478
exclude = order_lowering_eqs)
475
479
end
476
480
end
0 commit comments