@@ -991,7 +991,8 @@ The `simplified_sys` has undergone [`structural_simplify`](@ref) and had any occ
991
991
992
992
See also [`linearize`](@ref) which provides a higher-level interface.
993
993
"""
994
- function linearization_function (sys:: AbstractSystem , inputs, outputs; simplify = false ,
994
+ function linearization_function (sys:: AbstractSystem , inputs,
995
+ outputs; simplify = false ,
995
996
kwargs... )
996
997
sys = expand_connections (sys)
997
998
state = TearingState (sys)
@@ -1030,7 +1031,7 @@ function linearization_function(sys::AbstractSystem, inputs, outputs; simplify =
1030
1031
function (u, p, t)
1031
1032
if u != = nothing # Handle systems without states
1032
1033
length (sts) == length (u) ||
1033
- error (" Number of state variables does not match the number of input states" )
1034
+ error (" Number of state variables ( $( length (sts)) ) does not match the number of input states ( $( length (u)) ) " )
1034
1035
uf = SciMLBase. UJacobianWrapper (fun, t, p)
1035
1036
fg_xz = ForwardDiff. jacobian (uf, u)
1036
1037
h_xz = ForwardDiff. jacobian (xz -> h (xz, p, t), u)
@@ -1039,7 +1040,7 @@ function linearization_function(sys::AbstractSystem, inputs, outputs; simplify =
1039
1040
fg_u = ForwardDiff. jacobian (pf, p)[:, input_idxs]
1040
1041
else
1041
1042
length (sts) == 0 ||
1042
- error (" Number of state variables does not match the number of input states" )
1043
+ error (" Number of state variables (0) does not match the number of input states ( $( length (u)) ) " )
1043
1044
fg_xz = zeros (0 , 0 )
1044
1045
h_xz = fg_u = zeros (0 , length (inputs))
1045
1046
end
@@ -1060,23 +1061,31 @@ end
1060
1061
1061
1062
function markio! (state, inputs, outputs)
1062
1063
fullvars = state. fullvars
1063
- inputset = Set (inputs)
1064
- outputset = Set (outputs)
1064
+ inputset = Dict (inputs .=> false )
1065
+ outputset = Dict (outputs .=> false )
1065
1066
for (i, v) in enumerate (fullvars)
1066
- if v in inputset
1067
+ if v in keys ( inputset)
1067
1068
v = setmetadata (v, ModelingToolkit. VariableInput, true )
1068
1069
v = setmetadata (v, ModelingToolkit. VariableOutput, false )
1070
+ inputset[v] = true
1069
1071
fullvars[i] = v
1070
- elseif v in outputset
1072
+ elseif v in keys ( outputset)
1071
1073
v = setmetadata (v, ModelingToolkit. VariableInput, false )
1072
1074
v = setmetadata (v, ModelingToolkit. VariableOutput, true )
1075
+ outputset[v] = true
1073
1076
fullvars[i] = v
1074
1077
else
1075
1078
v = setmetadata (v, ModelingToolkit. VariableInput, false )
1076
1079
v = setmetadata (v, ModelingToolkit. VariableOutput, false )
1077
1080
fullvars[i] = v
1078
1081
end
1079
1082
end
1083
+ all (values (inputset)) ||
1084
+ error (" Some specified inputs were not found in system. The following Dict indicates the found variables" ,
1085
+ inputset)
1086
+ all (values (outputset)) ||
1087
+ error (" Some specified outputs were not found in system. The following Dict indicates the found variables" ,
1088
+ outputset)
1080
1089
state
1081
1090
end
1082
1091
0 commit comments