Skip to content

Commit 4111d5e

Browse files
committed
handle cases with more than one analysis point
1 parent b6c69cd commit 4111d5e

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/Blocks/analysis_points.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ function get_sensitivity(sys, ap::AnalysisPoint; kwargs...)
149149
end
150150
@set! sys.eqs = new_eqs
151151
@set! sys.states = [states(sys); d]
152+
sys = expand_analysis_points(sys)
152153
ModelingToolkit.linearize(sys, [d], [ap.out.u]; kwargs...)
153154
end
154155

@@ -172,6 +173,7 @@ function get_comp_sensitivity(sys, ap::AnalysisPoint; kwargs...)
172173
end
173174
@set! sys.eqs = new_eqs
174175
@set! sys.states = [states(sys); d]
176+
sys = expand_analysis_points(sys)
175177
ModelingToolkit.linearize(sys, [d], [ap.in.u]; kwargs...)
176178
end
177179

@@ -193,6 +195,7 @@ function get_looptransfer(sys, ap::AnalysisPoint; kwargs...)
193195
0 ~ 0 # we just want to open the connection
194196
end
195197
@set! sys.eqs = new_eqs
198+
sys = expand_analysis_points(sys)
196199
ModelingToolkit.linearize(sys, [ap.out.u], [ap.in.u]; kwargs...)
197200
end
198201

test/Blocks/test_analysis_points.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,13 @@ matrices, _ = linearize(open_sys, [u], [y])
7777
@test matrices.A[] == -1
7878
@test matrices.B[] * matrices.C[] == -1 # either one negative
7979
@test matrices.D[] == 0
80+
81+
# Test with more than one AnalysisPoint
82+
eqs = [connect(P.output, :plant_output, C.input)
83+
connect(C.output, :plant_input, P.input)]
84+
sys = ODESystem(eqs, t, systems = [P, C], name = :hej)
85+
86+
matrices, _ = get_sensitivity(sys, :plant_input)
87+
@test matrices.A[] == -2
88+
@test matrices.B[] * matrices.C[] == -1 # either one negative
89+
@test matrices.D[] == 1

0 commit comments

Comments
 (0)