@@ -374,17 +374,17 @@ function generate_derivative_variables!(ts::TearingState, neweqs, var_eq_matchin
374374 # derivative is in the system
375375 for v in 1 : length (var_to_diff)
376376 dv = var_to_diff[v]
377- # For discrete systems, directly substitute lowest-order variable
377+ # For discrete systems, directly substitute lowest-order shift
378378 if is_discrete && diff_to_var[v] == nothing
379- fullvars[v] = lower_varname (fullvars[v], iv)
379+ operation ( fullvars[v]) isa Shift && (fullvars[v] = lower_varname (fullvars[v], iv) )
380380 end
381381 dv isa Int || continue
382382 solved = var_eq_matching[dv] isa Int
383383 solved && continue
384384
385385 # If there's `D(x) = x_t` already, update mappings and continue without
386386 # adding new equations/variables
387- dd = find_duplicate_dd (dv, solvable_graph, linear_eqs, mm)
387+ dd = find_duplicate_dd (dv, solvable_graph, diff_to_var, linear_eqs, mm)
388388 if ! isnothing (dd)
389389 dummy_eq, v_t = dd
390390 var_to_diff[v_t] = var_to_diff[dv]
412412"""
413413Check if there's `D(x) = x_t` already.
414414"""
415- function find_duplicate_dd (dv, solvable_graph, linear_eqs, mm)
415+ function find_duplicate_dd (dv, solvable_graph, diff_to_var, linear_eqs, mm)
416416 for eq in 𝑑neighbors (solvable_graph, dv)
417417 mi = get (linear_eqs, eq, 0 )
418418 iszero (mi) && continue
0 commit comments