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
Convert an `ODESystem` to a `NamedStateSpace` using linearization. `inputs, outputs` are vectors of variables determining the inputs and outputs respectively. See docstring of `ModelingToolkit.linearize` for more info on `kwargs`.
160
160
161
-
This method automatically converts systems that MTK has failed to produce a proper form for into a proper linear statespace system. Learn more about how that is done here:
161
+
If `descriptor = true` (default), this method automatically converts systems that MTK has failed to produce a proper form for into a proper linear statespace system using the method described here:
If `descriptor = false`, the system is instead converted to a statespace realization using `sys[:,uinds] + sys[:,duinds]*tf('s')`, which tends to result in a larger realization on which the user may want to call `minreal(sys, tol)` with a carefully selected tolerance.
164
+
163
165
164
166
See also [`ModelingToolkit.linearize`](@ref) which is the lower-level function called internally. The functions [`get_named_sensitivity`](@ref), [`get_named_comp_sensitivity`](@ref), [`get_named_looptransfer`](@ref) similarily provide convenient ways to compute sensitivity functions while retaining signal names in the same way as `named_ss`. The corresponding lower-level functions `get_sensitivity`, `get_comp_sensitivity` and `get_looptransfer` are available in ModelingToolkitStandardLibrary.Blocks and are documented in [MTKstdlib: Linear analysis](https://docs.sciml.ai/ModelingToolkitStandardLibrary/stable/API/linear_analysis/).
165
167
"""
166
168
function RobustAndOptimalControl.named_ss(
167
169
sys::ModelingToolkit.AbstractTimeDependentSystem,
168
170
inputs,
169
171
outputs;
172
+
descriptor =true,
170
173
kwargs...,
171
174
)
172
175
@@ -206,7 +209,7 @@ function RobustAndOptimalControl.named_ss(
206
209
# This indicates that input derivatives are present
207
210
duinds =findall(any(!iszero, eachcol(matrices.B[:, nu+1:end]))) .+ nu
208
211
u2du = (1:nu) .=> duinds # This maps inputs to their derivatives
Copy file name to clipboardExpand all lines: test/test_ODESystem.jl
+36-1Lines changed: 36 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -295,7 +295,7 @@ using ModelingToolkitStandardLibrary.Mechanical.TranslationalPosition
295
295
using Test
296
296
297
297
using ControlSystemsMTK
298
-
using ControlSystemsMTK.ControlSystemsBase: sminreal, minreal, poles
298
+
using ControlSystemsMTK.ControlSystemsBase: sminreal, minreal, poles, ss, tf
299
299
connect = ModelingToolkit.connect
300
300
301
301
@independent_variables t
@@ -348,3 +348,38 @@ op2[cart.f] = 0
348
348
@test G.nx ==4
349
349
@test G.nu ==length(lin_inputs)
350
350
@test G.ny ==length(lin_outputs)
351
+
352
+
## Test difficult `named_ss` simplification
353
+
using ControlSystemsMTK, ControlSystemsBase, RobustAndOptimalControl
354
+
lsys = (A = [0.02.778983834717109e81.4122312296634873e60.0; 0.00.00.00.037848975765016724; 0.024.8375411480749620.126220062308977120.0; -0.0-4.620724819774693-0.023481719514324866-0.6841991610512456], B = [-5.042589978197361e80.0; -0.00.0; -45.068824982602656-0.0; 8.38451104936908554.98555939873381], C = [0.00.00.9549296585513720.0], D = [0.00.0])
355
+
356
+
# lsys = (A = [-0.0075449237853825925 1.6716817118020731e-6 0.0; 1864.7356343162514 -0.4131578457122937 0.0; 0.011864343330426718 -2.6287085638214332e-6 0.0], B = [0.0 0.0; 0.0 52566.418015009294; 0.0 0.3284546792274811], C = [1.4683007399899215e8 0.0 0.0], D = [-9.157636303058283e7 0.0])
357
+
358
+
G = ControlSystemsMTK.causal_simplification(lsys, [1=>2])
0 commit comments