Skip to content

Commit ae19eeb

Browse files
committed
fix unit
1 parent daa7898 commit ae19eeb

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/structural_transformation/StructuralTransformations.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ using SymbolicUtils: maketerm, iscall
1111

1212
using ModelingToolkit
1313
using ModelingToolkit: ODESystem, AbstractSystem, var_from_nested_derivative, Differential,
14-
unknowns, equations, vars, Symbolic, diff2term_with_unit, value,
14+
unknowns, equations, vars, Symbolic, diff2term_with_unit, shift2term_with_unit, value,
1515
operation, arguments, Sym, Term, simplify, symbolic_linear_solve,
1616
isdiffeq, isdifferential, isirreducible,
1717
empty_substitutions, get_substitutions,

src/structural_transformation/symbolics_tearing.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,6 @@ 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
370369
linear_eqs = mm === nothing ? Dict{Int, Int}() :
371370
Dict(reverse(en) for en in enumerate(mm.nzrows))
372371

@@ -391,7 +390,8 @@ function generate_derivative_variables!(ts::TearingState, neweqs, var_eq_matchin
391390

392391
dx = fullvars[dv]
393392
order, lv = var_order(dv, diff_to_var)
394-
x_t = toterm(fullvars[dv])
393+
x_t = is_discrete ? lower_shift_varname_with_unit(fullvars[dv], iv)
394+
: lower_varname_with_unit(fullvars[lv], iv, order)
395395

396396
# Add `x_t` to the graph
397397
v_t = add_dd_variable!(structure, fullvars, x_t, dv)
@@ -466,7 +466,7 @@ function generate_system_equations!(state::TearingState, neweqs, var_eq_matching
466466
for (i, v) in enumerate(fullvars)
467467
op = operation(v)
468468
op isa Shift && (op.steps < 0) && begin
469-
lowered = shift2term_with_unit(v)
469+
lowered = lower_shift_varname_with_unit(v, iv)
470470
total_sub[v] = lowered
471471
fullvars[i] = lowered
472472
end

0 commit comments

Comments
 (0)