You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Blocks/analysis_points.jl
+54-14Lines changed: 54 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -108,7 +108,9 @@ end
108
108
Find and return the analysis point in `sys` with the specified `name`. If no matching [`AnalysisPoint`](@ref) is found, `nothing` is returned.
109
109
"""
110
110
functionfind_analysis_point(sys, name)
111
-
for eq inequations(sys)
111
+
sys = ModelingToolkit.flatten(sys)
112
+
eqs =equations(sys)
113
+
for eq in eqs
112
114
eq.rhs isa AnalysisPoint && eq.rhs.name == name && (return eq.rhs)
113
115
end
114
116
nothing
@@ -120,6 +122,7 @@ end
120
122
Replace analysis points with the identity connection connect(ap.in, ap.out). This is called before a system containing analysis points is simulated, in which case analysis points have no effect.
121
123
"""
122
124
functionexpand_analysis_points(sys)
125
+
sys = ModelingToolkit.flatten(sys) #TODO: this does not namespace variables in connect statements properly https://github.com/SciML/ModelingToolkit.jl/issues/1826
123
126
new_eqs =map(get_eqs(sys)) do eq
124
127
eq.rhs isa AnalysisPoint || (return eq)
125
128
ap = eq.rhs
@@ -129,6 +132,17 @@ function expand_analysis_points(sys)
129
132
sys
130
133
end
131
134
135
+
function ModelingToolkit.namespace_expr(ap::AnalysisPoint, sys, n =nameof(sys)) where {T}
136
+
in= ModelingToolkit.renamespace(n, ap.in)
137
+
out = ModelingToolkit.renamespace(n, ap.out)
138
+
name =Symbol(n, :_, ap.name)
139
+
AnalysisPoint(in, out, name)
140
+
end
141
+
142
+
function Base.:(==)(ap1::AnalysisPoint, ap2::AnalysisPoint)
143
+
return ap1.in == ap2.in && ap1.out == ap2.out # Name doesn't really matter if inputs and outputs are the same
144
+
end
145
+
132
146
"""
133
147
get_sensitivity(sys, ap::AnalysisPoint; kwargs)
134
148
get_sensitivity(sys, ap_name::Symbol; kwargs)
@@ -141,15 +155,20 @@ Compute the sensitivity function in analysis point `ap`. The sensitivity functio
141
155
See also [`get_comp_sensitivity`](@ref), [`get_looptransfer`](@ref).
0 commit comments