Skip to content

Commit 397b279

Browse files
committed
add diff_to_var as argument for find_dumplicate_dd, fix substitution of lowest-order variable
1 parent 5878ad6 commit 397b279

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/structural_transformation/symbolics_tearing.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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]
@@ -412,7 +412,7 @@ end
412412
"""
413413
Check 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

Comments
 (0)