@@ -491,14 +491,20 @@ struct Break <: AnalysisPointTransformation
491
491
applicable if `add_input == true`.
492
492
"""
493
493
default_outputs_to_input:: Bool
494
+ """
495
+ Whether the added input is a parameter. Only applicable if `add_input == true`.
496
+ """
497
+ added_input_is_param:: Bool
494
498
end
495
499
496
500
"""
497
501
$(TYPEDSIGNATURES)
498
502
499
503
`Break` the given analysis point `ap`.
500
504
"""
501
- Break (ap:: AnalysisPoint , add_input:: Bool = false ) = Break (ap, add_input, false )
505
+ function Break (ap:: AnalysisPoint , add_input:: Bool = false , default_outputs_to_input = false )
506
+ Break (ap, add_input, default_outputs_to_input, false )
507
+ end
502
508
503
509
function apply_transformation (tf:: Break , sys:: AbstractSystem )
504
510
modify_nested_subsystem (sys, tf. ap) do breaksys
@@ -528,9 +534,15 @@ function apply_transformation(tf::Break, sys::AbstractSystem)
528
534
new_def
529
535
end
530
536
@set! breaksys. defaults = defs
531
- unks = copy (get_unknowns (breaksys))
532
- push! (unks, new_var)
533
- @set! breaksys. unknowns = unks
537
+ if tf. added_input_is_param
538
+ ps = copy (get_ps (breaksys))
539
+ push! (ps, new_var)
540
+ @set! breaksys. ps = ps
541
+ else
542
+ unks = copy (get_unknowns (breaksys))
543
+ push! (unks, new_var)
544
+ @set! breaksys. unknowns = unks
545
+ end
534
546
535
547
return breaksys, (new_var,)
536
548
end
@@ -812,12 +824,7 @@ Given a list of analysis points, break the connection for each and set the outpu
812
824
"""
813
825
function handle_loop_openings (sys:: AbstractSystem , aps)
814
826
for ap in canonicalize_ap (sys, aps)
815
- sys, (outvar,) = apply_transformation (Break (ap, true , true ), sys)
816
- if Symbolics. isarraysymbolic (outvar)
817
- push! (get_eqs (sys), outvar ~ zeros (size (outvar)))
818
- else
819
- push! (get_eqs (sys), outvar ~ 0 )
820
- end
827
+ sys, _ = apply_transformation (Break (ap, true , true , true ), sys)
821
828
end
822
829
return sys
823
830
end
@@ -849,10 +856,10 @@ All other keyword arguments are forwarded to `linearization_function`.
849
856
"""
850
857
function get_linear_analysis_function (
851
858
sys:: AbstractSystem , transform, aps; system_modifier = identity, loop_openings = [], kwargs... )
852
- sys = handle_loop_openings (sys, loop_openings)
853
- aps = canonicalize_ap (sys, aps)
854
859
dus = []
855
860
us = []
861
+ sys = handle_loop_openings (sys, loop_openings)
862
+ aps = canonicalize_ap (sys, aps)
856
863
for ap in aps
857
864
sys, (du, u) = apply_transformation (transform (ap), sys)
858
865
push! (dus, du)
0 commit comments