Skip to content

Commit 190fa10

Browse files
fix: fix codegen of implicit discrete systems
1 parent 224948d commit 190fa10

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/systems/codegen.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,16 @@ function generate_rhs(sys::System; implicit_dae = false,
5454
# Handle observables in algebraic equations, since they are shifted
5555
shifted_obs = Equation[distribute_shift(D(eq)) for eq in obs]
5656
obsidxs = observed_equations_used_by(sys, rhss; obs = shifted_obs)
57-
extra_assignments = [Assignment(shifted_obs[i].lhs, shifted_obs[i].rhs)
58-
for i in obsidxs]
57+
ddvs = map(D, dvs)
58+
59+
append!(extra_assignments,
60+
[Assignment(shifted_obs[i].lhs, shifted_obs[i].rhs)
61+
for i in obsidxs])
5962
else
6063
D = Differential(t)
64+
ddvs = map(D, dvs)
6165
rhss = [_iszero(eq.lhs) ? eq.rhs : eq.rhs - eq.lhs for eq in eqs]
6266
end
63-
ddvs = map(D, dvs)
6467
else
6568
if !override_discrete && !is_discrete_system(sys)
6669
check_operator_variables(eqs, Differential)

0 commit comments

Comments
 (0)