Skip to content

Commit 3e86bf8

Browse files
BenChungAayushSabharwal
authored andcommitted
Redefine the discrete_compile interface a bit
1 parent f3439ba commit 3e86bf8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/systems/systemstructure.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,9 @@ function mtkcompile!(state::TearingState; simplify = false,
785785
inputs = Any[], outputs = Any[],
786786
disturbance_inputs = Any[],
787787
kwargs...)
788+
# split_system returns one or two systems and the inputs for each
789+
# mod clock inference to be binary
790+
# if it's continous keep going, if not then error unless given trait impl in additional passes
788791
ci = ModelingToolkit.ClockInference(state)
789792
ci = ModelingToolkit.infer_clocks!(ci)
790793
time_domains = merge(Dict(state.fullvars .=> ci.var_domain),
@@ -798,7 +801,7 @@ function mtkcompile!(state::TearingState; simplify = false,
798801
discrete_pass_idx = findfirst(discrete_compile_pass, additional_passes)
799802
discrete_compile = additional_passes[discrete_pass_idx]
800803
deleteat!(additional_passes, discrete_pass_idx)
801-
return discrete_compile(tss, clocked_inputs)
804+
return discrete_compile(tss, clocked_inputs, ci)
802805
end
803806
throw(HybridSystemNotSupportedException("""
804807
Discrete systems with multiple clocks are not supported with the standard \
@@ -819,7 +822,7 @@ function mtkcompile!(state::TearingState; simplify = false,
819822
deleteat!(additional_passes, discrete_pass_idx)
820823
# in the case of a hybrid system, the discrete_compile pass should take the currents of sys.discrete_subsystems
821824
# and modifies discrete_subsystems to bea tuple of the io and anything else, while adding or manipulating the rest of sys as needed
822-
return discrete_compile(sys, tss[2:end], inputs)
825+
return discrete_compile(sys, tss[[i for i in eachindex(tss) if i != continuous_id]], clocked_inputs, ci)
823826
end
824827
throw(HybridSystemNotSupportedException("""
825828
Hybrid continuous-discrete systems are currently not supported with \

0 commit comments

Comments
 (0)