Skip to content

Commit bd73108

Browse files
committed
reset doc file
1 parent 2a68806 commit bd73108

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

docs/src/basics/Linearization.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ y &= Cx + Du
1515
\end{aligned}
1616
```
1717

18-
The `linearize` function expects the user to specify the inputs ``u`` and the outputs ``y`` using the syntax shown in the example below.
18+
The `linearize` function expects the user to specify the inputs ``u`` and the outputs ``y`` using the syntax shown in the example below. The system model is *not* supposed to be simplified before calling `linearize`:
1919

2020
## Example
2121

@@ -29,7 +29,7 @@ eqs = [u ~ kp * (r - y) # P controller
2929
D(x) ~ -x + u # First-order plant
3030
y ~ x] # Output equation
3131
32-
@mtkbuild sys = ODESystem(eqs, t) # Do not call @mtkbuild when linearizing
32+
@named sys = ODESystem(eqs, t) # Do not call @mtkbuild when linearizing
3333
matrices, simplified_sys = linearize(sys, [r], [y]) # Linearize from r to y
3434
matrices
3535
```
@@ -45,6 +45,10 @@ using ModelingToolkit: inputs, outputs
4545

4646
The model above has 4 variables but only three equations, there is no equation specifying the value of `r` since `r` is an input. This means that only unbalanced models can be linearized, or in other words, models that are balanced and can be simulated _cannot_ be linearized. To learn more about this, see [How to linearize a ModelingToolkit model (YouTube)](https://www.youtube.com/watch?v=-XOux-2XDGI&t=395s). Also see [ModelingToolkitStandardLibrary: Linear analysis](https://docs.sciml.ai/ModelingToolkit/stable/tutorials/linear_analysis/) for utilities that make linearization of completed models easier.
4747

48+
!!! note "Un-simplified system"
49+
50+
Linearization expects `sys` to be un-simplified, i.e., `structural_simplify` or `@mtkbuild` should not be called on the system before linearizing.
51+
4852
## Operating point
4953

5054
The operating point to linearize around can be specified with the keyword argument `op` like this: `op = Dict(x => 1, r => 2)`. The operating point may include specification of unknown variables, input variables and parameters. For variables that are not specified in `op`, the default value specified in the model will be used if available, if no value is specified, an error is thrown.
@@ -75,15 +79,14 @@ eqs = [D(x) ~ v
7579
y.u ~ x]
7680
7781
@named duffing = ODESystem(eqs, t, systems = [y, u], defaults = [u.u => 0])
78-
duffing = structural_simplify(duffing, inputs = [u.u], outputs = [y.u])
7982
8083
# pass a constant value for `x`, since it is the variable we will change in operating points
81-
linfun = linearization_function(duffing, [u.u], [y.u]; op = Dict(x => NaN));
84+
linfun, simplified_sys = linearization_function(duffing, [u.u], [y.u]; op = Dict(x => NaN));
8285
83-
println(linearize(duffing, linfun; op = Dict(x => 1.0)))
84-
println(linearize(duffing, linfun; op = Dict(x => 0.0)))
86+
println(linearize(simplified_sys, linfun; op = Dict(x => 1.0)))
87+
println(linearize(simplified_sys, linfun; op = Dict(x => 0.0)))
8588
86-
@time linearize(duffing, linfun; op = Dict(x => 0.0))
89+
@time linearize(simplified_sys, linfun; op = Dict(x => 0.0))
8790
8891
nothing # hide
8992
```

0 commit comments

Comments
 (0)