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
This function provides 0 for the default values, which is a safe assumption for dummy derivatives of most models. However, the 2nd arument allows for a different default value or values to be used if needed.
123
+
This function provides 0 for the default values, which is a safe assumption for dummy derivatives of most models. However, the 2nd argument allows for a different default value or values to be used if needed.
Copy file name to clipboardExpand all lines: src/inputoutput.jl
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -112,13 +112,13 @@ end
112
112
same_or_inner_namespace(u, var)
113
113
114
114
Determine whether `var` is in the same namespace as `u`, or a namespace internal to the namespace of `u`.
115
-
Example: `sys.u ~ sys.inner.u` will bind `sys.inner.u`, but `sys.u` remains an unbound, external signal. The namepsaced signal `sys.inner.u` lives in a namspace internal to `sys`.
115
+
Example: `sys.u ~ sys.inner.u` will bind `sys.inner.u`, but `sys.u` remains an unbound, external signal. The namespaced signal `sys.inner.u` lives in a namespace internal to `sys`.
116
116
"""
117
117
functionsame_or_inner_namespace(u, var)
118
118
nu =get_namespace(u)
119
119
nv =get_namespace(var)
120
120
nu == nv ||# namespaces are the same
121
-
startswith(nv, nu) ||# or nv starts with nu, i.e., nv is an inner namepsace to nu
121
+
startswith(nv, nu) ||# or nv starts with nu, i.e., nv is an inner namespace to nu
122
122
occursin('₊', string(getname(var))) &&
123
123
!occursin('₊', string(getname(u))) # or u is top level but var is internal
124
124
end
@@ -127,7 +127,7 @@ function inner_namespace(u, var)
127
127
nu =get_namespace(u)
128
128
nv =get_namespace(var)
129
129
nu == nv &&returnfalse
130
-
startswith(nv, nu) ||# or nv starts with nu, i.e., nv is an inner namepsace to nu
130
+
startswith(nv, nu) ||# or nv starts with nu, i.e., nv is an inner namespace to nu
131
131
occursin('₊', string(getname(var))) &&
132
132
!occursin('₊', string(getname(u))) # or u is top level but var is internal
The return values also include the remaining states and parameters, in the order they appear as arguments to `f`.
179
179
180
-
If `disturbance_inputs` is an array of variables, the generated dynamics function will preserve any state and dynamics associated with distrubance inputs, but the distrubance inputs themselves will not be included as inputs to the generated function. The use case for this is to generate dynamics for state observers that estimate the influence of unmeasured disturbances, and thus require state variables for the disturbance model, but without disturbance inputs since the disturbances are not available for measurement.
180
+
If `disturbance_inputs` is an array of variables, the generated dynamics function will preserve any state and dynamics associated with disturbance inputs, but the disturbance inputs themselves will not be included as inputs to the generated function. The use case for this is to generate dynamics for state observers that estimate the influence of unmeasured disturbances, and thus require state variables for the disturbance model, but without disturbance inputs since the disturbances are not available for measurement.
181
181
See [`add_input_disturbance`](@ref) for a higher-level interface to this functionality.
Return a function that linearizes the system `sys`. The function [`linearize`](@ref) provides a higher-level and easier to use interface.
1255
1248
@@ -1273,12 +1266,14 @@ The `simplified_sys` has undergone [`structural_simplify`](@ref) and had any occ
1273
1266
- `inputs`: A vector of variables that indicate the inputs of the linearized input-output model.
1274
1267
- `outputs`: A vector of variables that indicate the outputs of the linearized input-output model.
1275
1268
- `simplify`: Apply simplification in tearing.
1269
+
- `initialize`: If true, a check is performed to ensure that the operating point is consistent (satisfies algebraic equations). If the op is not consistent, initialization is performed.
1276
1270
- `kwargs`: Are passed on to `find_solvables!`
1277
1271
1278
1272
See also [`linearize`](@ref) which provides a higher-level interface.
@@ -1397,7 +1400,7 @@ function linearize_symbolic(sys::AbstractSystem, inputs,
1397
1400
if!allow_input_derivatives
1398
1401
der_inds =findall(vec(any(!iszero, Bs, dims =1)))
1399
1402
@showtypeof(der_inds)
1400
-
error("Input derivatives appeared in expressions (-g_z\\g_u != 0), the following inputs appeared differentiated: $(ModelingToolkit.inputs(sys)[der_inds]). Call `linear_statespace` with keyword argument `allow_input_derivatives = true` to allow this and have the returned `B` matrix be of double width ($(2nu)), where the last $nu inputs are the derivatives of the first $nu inputs.")
1403
+
error("Input derivatives appeared in expressions (-g_z\\g_u != 0), the following inputs appeared differentiated: $(ModelingToolkit.inputs(sys)[der_inds]). Call `linearize_symbolic` with keyword argument `allow_input_derivatives = true` to allow this and have the returned `B` matrix be of double width ($(2nu)), where the last $nu inputs are the derivatives of the first $nu inputs.")
(; A, B, C, D), simplified_sys = linearize(sys, inputs, outputs; t=0.0, op = Dict(), allow_input_derivatives = false, kwargs...)
1446
-
(; A, B, C, D) = linearize(simplified_sys, lin_fun; t=0.0, op = Dict(), allow_input_derivatives = false)
1453
+
(; A, B, C, D), simplified_sys = linearize(sys, inputs, outputs; t=0.0, op = Dict(), allow_input_derivatives = false, zero_dummy_der=false, kwargs...)
1454
+
(; A, B, C, D) = linearize(simplified_sys, lin_fun; t=0.0, op = Dict(), allow_input_derivatives = false, zero_dummy_der=false)
1447
1455
1448
1456
Return a NamedTuple with the matrices of a linear statespace representation
1449
1457
on the form
@@ -1463,6 +1471,8 @@ the default values of `sys` are used.
1463
1471
1464
1472
If `allow_input_derivatives = false`, an error will be thrown if input derivatives (``u̇``) appear as inputs in the linearized equations. If input derivatives are allowed, the returned `B` matrix will be of double width, corresponding to the input `[u; u̇]`.
1465
1473
1474
+
`zero_dummy_der` can be set to automatically set the operating point to zero for all dummy derivatives.
1475
+
1466
1476
See also [`linearization_function`](@ref) which provides a lower-level interface, [`linearize_symbolic`](@ref) and [`ModelingToolkit.reorder_states`](@ref).
1467
1477
1468
1478
See extended help for an example.
@@ -1576,7 +1586,7 @@ function linearize(sys, lin_fun; t = 0.0, op = Dict(), allow_input_derivatives =
1576
1586
if!iszero(Bs)
1577
1587
if!allow_input_derivatives
1578
1588
der_inds =findall(vec(any(!=(0), Bs, dims =1)))
1579
-
error("Input derivatives appeared in expressions (-g_z\\g_u != 0), the following inputs appeared differentiated: $(inputs(sys)[der_inds]). Call `linear_statespace` with keyword argument `allow_input_derivatives = true` to allow this and have the returned `B` matrix be of double width ($(2nu)), where the last $nu inputs are the derivatives of the first $nu inputs.")
1589
+
error("Input derivatives appeared in expressions (-g_z\\g_u != 0), the following inputs appeared differentiated: $(inputs(sys)[der_inds]). Call `linearize` with keyword argument `allow_input_derivatives = true` to allow this and have the returned `B` matrix be of double width ($(2nu)), where the last $nu inputs are the derivatives of the first $nu inputs.")
0 commit comments