@@ -491,14 +491,20 @@ struct Break <: AnalysisPointTransformation
491491    applicable if `add_input == true`. 
492492    """  
493493    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 
494498end 
495499
496500""" 
497501    $(TYPEDSIGNATURES)  
498502
499503`Break` the given analysis point `ap`. 
500504""" 
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 
502508
503509function  apply_transformation (tf:: Break , sys:: AbstractSystem )
504510    modify_nested_subsystem (sys, tf. ap) do  breaksys
@@ -528,9 +534,15 @@ function apply_transformation(tf::Break, sys::AbstractSystem)
528534            new_def
529535        end 
530536        @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 
534546
535547        return  breaksys, (new_var,)
536548    end 
@@ -812,12 +824,14 @@ Given a list of analysis points, break the connection for each and set the outpu
812824""" 
813825function  handle_loop_openings (sys:: AbstractSystem , aps)
814826    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)))
827+         sys, (d_v,) =  apply_transformation (Break (ap, true , true , true ), sys)
828+         guesses =  copy (get_guesses (sys))
829+         guesses[d_v] =  if  symbolic_type (d_v) ==  ArraySymbolic ()
830+             fill (NaN , size (d_v))
818831        else 
819-             push! ( get_eqs (sys), outvar  ~   0 ) 
832+             NaN 
820833        end 
834+         @set!  sys. guesses =  guesses
821835    end 
822836    return  sys
823837end 
@@ -849,10 +863,10 @@ All other keyword arguments are forwarded to `linearization_function`.
849863""" 
850864function  get_linear_analysis_function (
851865        sys:: AbstractSystem , transform, aps; system_modifier =  identity, loop_openings =  [], kwargs... )
852-     sys =  handle_loop_openings (sys, loop_openings)
853-     aps =  canonicalize_ap (sys, aps)
854866    dus =  []
855867    us =  []
868+     sys =  handle_loop_openings (sys, loop_openings)
869+     aps =  canonicalize_ap (sys, aps)
856870    for  ap in  aps
857871        sys, (du, u) =  apply_transformation (transform (ap), sys)
858872        push! (dus, du)
0 commit comments