Skip to content

Commit 7a84444

Browse files
fix direct structural simplification for initialization systems
1 parent 16ce722 commit 7a84444

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/systems/systemstructure.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,9 @@ function _structural_simplify!(state::TearingState, io; simplify = false,
636636
fullunknowns = [map(eq -> eq.lhs, observed(sys)); unknowns(sys)]
637637
@set! sys.observed = ModelingToolkit.topsort_equations(observed(sys), fullunknowns)
638638

639-
if sys isa ODESystem
639+
ci = infer_clocks!(ClockInference(state))
640+
# TODO: make it work with clocks
641+
if sys isa ODESystem && all(isequal(Continuous()), ci.var_domain) && !all(all(x->!(typeof(x) <: Union{Sample,Hold,ShiftIndex}),io))
640642
isys = ModelingToolkit.generate_initializesystem(sys)
641643
!isempty(equations(isys)) &&
642644
(isys = structural_simplify(isys; fully_determined = false))

test/clock.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ By inference:
6262
=> Shift(x, 0, dt) := (Shift(x, -1, dt) + dt) / (1 - dt) # Discrete system
6363
=#
6464

65+
6566
ci, varmap = infer_clocks(sys)
6667
eqmap = ci.eq_domain
6768
tss, inputs = ModelingToolkit.split_system(deepcopy(ci))

0 commit comments

Comments
 (0)