@@ -188,8 +188,6 @@ See also [`get_sensitivity`](@ref), [`get_comp_sensitivity`](@ref).
188
188
"""
189
189
function get_looptransfer (sys, ap:: AnalysisPoint ; kwargs... )
190
190
t = get_iv (sys)
191
- @variables u (t) = 0
192
- @variables y (t) = 0
193
191
new_eqs = map (get_eqs (sys)) do eq
194
192
eq. rhs == ap || (return eq)
195
193
0 ~ 0 # we just want to open the connection
@@ -198,8 +196,36 @@ function get_looptransfer(sys, ap::AnalysisPoint; kwargs...)
198
196
ModelingToolkit. linearize (sys, [ap. out. u], [ap. in. u]; kwargs... )
199
197
end
200
198
199
+ """
200
+ open_sys = open_loop(sys, ap::AnalysisPoint; kwargs)
201
+ open_sys = open_loop(sys, ap_name::Symbol; kwargs)
202
+
203
+ Open the loop at analysis point `ap` by breaking the connection through `ap`.
204
+
205
+ `open_sys` will have `ap.out` as input and `ap.in` as output.
206
+
207
+ # Arguments:
208
+ - `kwargs`: Are sent to `ModelingToolkit.linearize`
209
+
210
+ See also [`get_sensitivity`](@ref), [`get_comp_sensitivity`](@ref), [`get_looptransfer`](@ref).
211
+ """
212
+ function open_loop (sys, ap:: AnalysisPoint ; kwargs... )
213
+ t = get_iv (sys)
214
+ @variables u (t)= 0 [input = true ]
215
+ @variables y (t)= 0 [output = true ]
216
+ new_eqs = map (get_eqs (sys)) do eq
217
+ eq. rhs == ap || (return [eq])
218
+ [ap. out. u ~ u
219
+ ap. in. u ~ y]
220
+ end
221
+ new_eqs = reduce (vcat, new_eqs)
222
+ @set! sys. eqs = new_eqs
223
+ @set! sys. states = [states (sys); u; y]
224
+ sys
225
+ end
226
+
201
227
# Add a method to get_sensitivity that accepts the name of an AnalysisPoint
202
- for f in [:get_sensitivity , :get_comp_sensitivity , :get_looptransfer ]
228
+ for f in [:get_sensitivity , :get_comp_sensitivity , :get_looptransfer , :open_loop ]
203
229
@eval function $f (sys, ap_name:: Symbol , args... ; kwargs... )
204
230
$ f (sys, find_analysis_point (sys, ap_name), args... ; kwargs... )
205
231
end
0 commit comments