Skip to content

Commit abe38c9

Browse files
committed
operating point fix
1 parent c50b77e commit abe38c9

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/named_systems2.jl

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,16 @@ end
182182
183183
Concatenate the operating points of the systems in `systems` into a single operating point, but only for the state vector `x`. The input vector `u` is taken from the first system's operating point, and all other systems are verified to have the same `u` operating point. If any system has an operating point, the resulting system will have an operating point with the concatenated state vector and the input vector from the first system.
184184
"""
185-
function merge_ops_x(systems...)
185+
function merge_ops_x(systems...; u_from = :same)
186186
if any(has_operating_point, systems)
187-
allequal(operating_point(sys).u for sys in systems) ||
188-
throw(ArgumentError("All systems must have the same input operating point u to be concatenated."))
187+
if u_from === :same
188+
allequal(operating_point(sys).u for sys in systems) ||
189+
throw(ArgumentError("All systems must have the same input operating point u to be concatenated."))
190+
opu = operating_point(systems[1]).u
191+
elseif u_from isa Integer
192+
opu = operating_point(systems[u_from]).u
193+
end
189194
opx = reduce(vcat, operating_point(sys).x for sys in systems)
190-
opu = operating_point(systems[1]).u
191195
op = (; x = opx, u = opu)
192196
extra = Dict(:operating_point => op)
193197
else
@@ -296,8 +300,8 @@ function named_ss(sys::AbstractStateSpace{T};
296300
throw(ArgumentError("Length of output names must match size(sys,1) ($(size(sys,1))), got length $(length(y))"))
297301

298302
check_unique(x, "x", "Cannot create a NamedStateSpace system with more than one variable with the same name")
299-
check_unique(y, "y", "Cannot create a NamedStateSpace system with more than one variable with the same name")
300303
if unique
304+
check_unique(y, "y", "To allow connecting a single output signal to several outputs with the same name, pass `unique = false`.")
301305
check_unique(u, "u", "To allow connecting a single input signal to several inputs with the same name, pass `unique = false`.")
302306
end
303307

@@ -420,7 +424,7 @@ function Base.:*(s1::NamedStateSpace{T}, s2::NamedStateSpace{T}) where {T <: CS.
420424
end
421425
sys = s1.sys*s2.sys
422426
S = typeof(sys)
423-
extra = merge_ops_x(s1, s2)
427+
extra = merge_ops_x(s1, s2; u_from = 2)
424428
return NamedStateSpace{T,S}(
425429
sys,
426430
x_names,

0 commit comments

Comments
 (0)