Skip to content

Commit e7d7513

Browse files
committed
Handle dummy derivatives in observed equations
1 parent 3058475 commit e7d7513

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/structural_transformation/symbolics_tearing.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ function tearing_reassemble(state::TearingState, var_eq_matching; simplify = fal
241241
#removed_vars = Int[]
242242
removed_obs = Int[]
243243
diff_to_var = invview(var_to_diff)
244+
dummy_sub = Dict()
244245
for var in 1:length(fullvars)
245246
dv = var_to_diff[var]
246247
dv === nothing && continue
@@ -253,7 +254,8 @@ function tearing_reassemble(state::TearingState, var_eq_matching; simplify = fal
253254
push!(removed_obs, idx)
254255
end
255256
for eq in 𝑑neighbors(graph, dv)
256-
neweqs[eq] = substitute(neweqs[eq], fullvars[dv] => v_t)
257+
dummy_sub[dd] = v_t
258+
neweqs[eq] = substitute(neweqs[eq], dd => v_t)
257259
end
258260
fullvars[dv] = v_t
259261
# update the structural information
@@ -592,8 +594,12 @@ function tearing_reassemble(state::TearingState, var_eq_matching; simplify = fal
592594
deleteat!(oldobs, sort!(removed_obs))
593595
@set! sys.substitutions = Substitutions(subeqs, deps)
594596

595-
der2expr = Dict(eq.lhs => eq.rhs for eq in equations(sys) if isdiffeq(eq))
596-
obs = substitute.([oldobs; subeqs], (der2expr,))
597+
obs_sub = dummy_sub
598+
for eq in equations(sys)
599+
isdiffeq(eq) || continue
600+
obs_sub[eq.lhs] = eq.rhs
601+
end
602+
obs = substitute.([oldobs; subeqs], (obs_sub,))
597603
@set! sys.observed = obs
598604
@set! state.sys = sys
599605
@set! sys.tearing_state = state

src/systems/diffeqs/odesystem.jl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -327,12 +327,6 @@ function build_explicit_observed_function(sys, ts;
327327
eq = obs[i]
328328
lhs = eq.lhs
329329
rhs = eq.rhs
330-
vars!(vars, rhs)
331-
for v in vars
332-
isdifferential(v) &&
333-
error("Observed `$eq` depends on differentiated variable `$v`. This is not supported.")
334-
end
335-
empty!(vars)
336330
push!(obsexprs, lhs rhs)
337331
end
338332

0 commit comments

Comments
 (0)