Skip to content

Commit 83aca77

Browse files
committed
doc: manual MTK now use p parameters of NonLinModel
1 parent 4103245 commit 83aca77

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

docs/src/manual/mtk.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,22 +60,22 @@ function generate_f_h(model, inputs, outputs)
6060
if any(ModelingToolkit.is_alg_equation, equations(io_sys))
6161
error("Systems with algebraic equations are not supported")
6262
end
63-
h_ = ModelingToolkit.build_explicit_observed_function(io_sys, outputs; inputs = inputs)
63+
h_ = ModelingToolkit.build_explicit_observed_function(io_sys, outputs; inputs)
6464
nx = length(dvs)
6565
vx = string.(dvs)
66-
par = varmap_to_vars(defaults(io_sys), psym)
67-
function f!(ẋ, x, u, _ , _ )
68-
f_ip(ẋ, x, u, par, 1)
69-
nothing
66+
p = varmap_to_vars(defaults(io_sys), psym)
67+
function f!(ẋ, x, u, _ , p)
68+
f_ip(ẋ, x, u, p, 1)
69+
return nothing
7070
end
71-
function h!(y, x, _ , _ )
72-
y .= h_(x, 1, par, 1)
73-
nothing
71+
function h!(y, x, _ , p)
72+
y .= h_(x, 1, p, 1)
73+
return nothing
7474
end
75-
return f!, h!, nx, vx
75+
return f!, h!, p, nx, vx
7676
end
7777
inputs, outputs = [mtk_model.τ], [mtk_model.y]
78-
f!, h!, nx, vx = generate_f_h(mtk_model, inputs, outputs)
78+
f!, h!, p, nx, vx = generate_f_h(mtk_model, inputs, outputs)
7979
nu, ny, Ts = length(inputs), length(outputs), 0.1
8080
vu, vy = ["\$τ\$ (Nm)"], ["\$θ\$ (°)"]
8181
nothing # hide
@@ -84,15 +84,15 @@ nothing # hide
8484
A [`NonLinModel`](@ref) can now be constructed:
8585

8686
```@example 1
87-
model = setname!(NonLinModel(f!, h!, Ts, nu, nx, ny); u=vu, x=vx, y=vy)
87+
model = setname!(NonLinModel(f!, h!, Ts, nu, nx, ny; p); u=vu, x=vx, y=vy)
8888
```
8989

9090
We also instantiate a plant model with a 25 % larger friction coefficient ``K``:
9191

9292
```@example 1
9393
mtk_model.K = defaults(mtk_model)[mtk_model.K] * 1.25
94-
f_plant, h_plant, _, _ = generate_f_h(mtk_model, inputs, outputs)
95-
plant = setname!(NonLinModel(f_plant, h_plant, Ts, nu, nx, ny); u=vu, x=vx, y=vy)
94+
f_plant, h_plant, p = generate_f_h(mtk_model, inputs, outputs)
95+
plant = setname!(NonLinModel(f_plant, h_plant, Ts, nu, nx, ny; p); u=vu, x=vx, y=vy)
9696
```
9797

9898
## Controller Design

0 commit comments

Comments
 (0)