@@ -366,17 +366,14 @@ function generate_derivative_variables!(ts::TearingState, neweqs, var_eq_matchin
366366 eq_var_matching = invview (var_eq_matching)
367367 diff_to_var = invview (var_to_diff)
368368 is_discrete = is_only_discrete (structure)
369+ toterm = is_discrete ? shift2term_with_unit : diff2term_with_unit
369370 linear_eqs = mm === nothing ? Dict {Int, Int} () :
370371 Dict (reverse (en) for en in enumerate (mm. nzrows))
371372
372373 # For variable x, make dummy derivative x_t if the
373374 # derivative is in the system
374375 for v in 1 : length (var_to_diff)
375376 dv = var_to_diff[v]
376- # For discrete systems, directly substitute lowest-order shift
377- # if is_discrete && diff_to_var[v] == nothing
378- # operation(fullvars[v]) isa Shift && (fullvars[v] = lower_shift_varname_with_unit(fullvars[v], iv))
379- # end
380377 dv isa Int || continue
381378 solved = var_eq_matching[dv] isa Int
382379 solved && continue
@@ -394,8 +391,7 @@ function generate_derivative_variables!(ts::TearingState, neweqs, var_eq_matchin
394391
395392 dx = fullvars[dv]
396393 order, lv = var_order (dv, diff_to_var)
397- x_t = is_discrete ? lower_shift_varname_with_unit (fullvars[dv], iv) :
398- Symbolics. diff2term (fullvars[dv])
394+ x_t = toterm (fullvars[dv])
399395
400396 # Add `x_t` to the graph
401397 v_t = add_dd_variable! (structure, fullvars, x_t, dv)
@@ -470,7 +466,7 @@ function generate_system_equations!(state::TearingState, neweqs, var_eq_matching
470466 for (i, v) in enumerate (fullvars)
471467 op = operation (v)
472468 op isa Shift && (op. steps < 0 ) && begin
473- lowered = lower_shift_varname_with_unit (v, iv )
469+ lowered = shift2term_with_unit (v )
474470 total_sub[v] = lowered
475471 fullvars[i] = lowered
476472 end
0 commit comments