@@ -706,19 +706,40 @@ function mtkcompile!(state::TearingState; simplify = false,
706
706
time_domains = merge (Dict (state. fullvars .=> ci. var_domain),
707
707
Dict (default_toterm .(state. fullvars) .=> ci. var_domain))
708
708
tss, clocked_inputs, continuous_id, id_to_clock = ModelingToolkit. split_system (ci)
709
+ if continuous_id == 0
710
+ # do a trait check here - handle fully discrete system
711
+ additional_passes = get (kwargs, :additional_passes , nothing )
712
+ if ! isnothing (additional_passes) && any (discrete_compile_pass, additional_passes)
713
+ # take the first discrete compilation pass given for now
714
+ discrete_pass_idx = findfirst (discrete_compile_pass, additional_passes)
715
+ discrete_compile = additional_passes[discrete_pass_idx]
716
+ deleteat! (additional_passes, discrete_pass_idx)
717
+ return discrete_compile (tss, clocked_inputs)
718
+ end
719
+ throw (HybridSystemNotSupportedException ("""
720
+ Discrete systems with multiple clocks are not supported with the standard \
721
+ MTK compiler.
722
+ """ ))
723
+ end
709
724
if length (tss) > 1
710
- if continuous_id == 0
711
- throw (HybridSystemNotSupportedException ("""
712
- Discrete systems with multiple clocks are not supported with the standard \
713
- MTK compiler.
714
- """ ))
715
- else
716
- throw (HybridSystemNotSupportedException ("""
717
- Hybrid continuous-discrete systems are currently not supported with \
718
- the standard MTK compiler. This system requires JuliaSimCompiler.jl, \
719
- see https://help.juliahub.com/juliasimcompiler/stable/
720
- """ ))
725
+ # simplify as normal
726
+ sys = _mtkcompile! (tss[continuous_id]; simplify,
727
+ inputs = [inputs; clocked_inputs[continuous_id]], outputs, disturbance_inputs,
728
+ check_consistency, fully_determined,
729
+ kwargs... )
730
+ if ! isnothing (additional_passes) && any (discrete_compile_pass, additional_passes)
731
+ discrete_pass_idx = findfirst (discrete_compile_pass, additional_passes)
732
+ discrete_compile = additional_passes[discrete_pass_idx]
733
+ deleteat! (additional_passes, discrete_pass_idx)
734
+ # in the case of a hybrid system, the discrete_compile pass should take the currents of sys.discrete_subsystems
735
+ # and modifies discrete_subsystems to bea tuple of the io and anything else, while adding or manipulating the rest of sys as needed
736
+ return discrete_compile (sys, tss[2 : end ], inputs)
721
737
end
738
+ throw (HybridSystemNotSupportedException ("""
739
+ Hybrid continuous-discrete systems are currently not supported with \
740
+ the standard MTK compiler. This system requires JuliaSimCompiler.jl, \
741
+ see https://help.juliahub.com/juliasimcompiler/stable/
742
+ """ ))
722
743
end
723
744
if get_is_discrete (state. sys) ||
724
745
continuous_id == 1 && any (Base. Fix2 (isoperator, Shift), state. fullvars)
0 commit comments