@@ -374,17 +374,17 @@ function generate_derivative_variables!(ts::TearingState, neweqs, var_eq_matchin
374
374
# derivative is in the system
375
375
for v in 1 : length (var_to_diff)
376
376
dv = var_to_diff[v]
377
- # For discrete systems, directly substitute lowest-order variable
377
+ # For discrete systems, directly substitute lowest-order shift
378
378
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) )
380
380
end
381
381
dv isa Int || continue
382
382
solved = var_eq_matching[dv] isa Int
383
383
solved && continue
384
384
385
385
# If there's `D(x) = x_t` already, update mappings and continue without
386
386
# 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)
388
388
if ! isnothing (dd)
389
389
dummy_eq, v_t = dd
390
390
var_to_diff[v_t] = var_to_diff[dv]
412
412
"""
413
413
Check if there's `D(x) = x_t` already.
414
414
"""
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)
416
416
for eq in 𝑑neighbors (solvable_graph, dv)
417
417
mi = get (linear_eqs, eq, 0 )
418
418
iszero (mi) && continue
0 commit comments