@@ -512,10 +512,10 @@ function generate_system_equations!(state::TearingState, neweqs, var_eq_matching
512
512
# Non-solvable equations become algebraic equations.
513
513
for ieq in eqs
514
514
iv = eq_var_matching[ieq]
515
- var = fullvars[iv]
516
515
eq = neweqs[ieq]
517
516
518
517
if is_solvable (ieq, iv) && isdervar (iv)
518
+ var = fullvars[iv]
519
519
isnothing (D) && throw (UnexpectedDifferentialError (equations (sys)[ieq]))
520
520
order, lv = var_order (iv, diff_to_var)
521
521
dx = D (simplify_shifts (fullvars[lv]))
@@ -530,14 +530,15 @@ function generate_system_equations!(state::TearingState, neweqs, var_eq_matching
530
530
push! (diffeq_idxs, ieq)
531
531
push! (diff_vars, diff_to_var[iv])
532
532
elseif is_solvable (ieq, iv)
533
+ var = fullvars[iv]
533
534
neweq = make_solved_equation (var, eq, total_sub; simplify)
534
535
! isnothing (neweq) && begin
535
536
push! (solved_eqs, neweq)
536
537
push! (solvedeq_idxs, ieq)
537
538
push! (solved_vars, iv)
538
539
end
539
540
else
540
- neweq = make_algebraic_equation (var, eq, total_sub)
541
+ neweq = make_algebraic_equation (eq, total_sub)
541
542
push! (alge_eqs, neweq)
542
543
push! (algeeq_idxs, ieq)
543
544
end
@@ -572,7 +573,7 @@ function make_differential_equation(var, dx, eq, total_sub)
572
573
total_sub; operator = ModelingToolkit. Shift))
573
574
end
574
575
575
- function make_algebraic_equation (var, eq, total_sub)
576
+ function make_algebraic_equation (eq, total_sub)
576
577
rhs = eq. rhs
577
578
if ! (eq. lhs isa Number && eq. lhs == 0 )
578
579
rhs = eq. rhs - eq. lhs
0 commit comments