1919Mutating state function ``\m athbf{f̂}`` of the augmented model.
2020
2121By introducing an augmented state vector ``\m athbf{x̂_0}`` like in [`augment_model`](@ref),
22- the function returns the next state of the augmented model, defined as :
22+ the function returns the next state of the augmented model, as deviation vectors :
2323```math
2424\b egin{aligned}
25- \m athbf{x̂_0}(k+1) &= \m athbf{f̂}\B ig(\m athbf{x̂_0}(k), \m athbf{u_0}(k), \m athbf{d_0}(k)\B ig) \\
25+ \m athbf{x̂_0}(k+1) &= \m athbf{f̂}\B ig(\m athbf{x̂_0}(k), \m athbf{u_0}(k), \m athbf{d_0}(k)\B ig)
2626 \m athbf{ŷ_0}(k) &= \m athbf{ĥ}\B ig(\m athbf{x̂_0}(k), \m athbf{d_0}(k)\B ig)
2727\e nd{aligned}
2828```
2929where ``\m athbf{x̂_0}(k+1)`` is stored in `x̂0next` argument. The method mutates `x̂0next`,
3030`û0` and `k0` in place. The argument `û0` stores the disturbed input of the augmented model
3131``\m athbf{û_0}``, and `k0`, the intermediate stage values of `model.solver`, when applicable.
32- The model parameter `model.p` is not included in the function signature for conciseness. See
33- Extended Help for details on ``\m athbf{û_0, f̂}`` and ``\m athbf{ĥ}`` implementations.
32+ The model parameter `model.p` is not included in the function signature for conciseness.
33+ The operating points are handled inside ``\m athbf{f̂}``. See Extended Help for details on
34+ ``\m athbf{û_0, f̂}`` and ``\m athbf{ĥ}`` implementations.
3435
3536# Extended Help
3637!!! details "Extended Help"
@@ -41,7 +42,8 @@ Extended Help for details on ``\mathbf{û_0, f̂}`` and ``\mathbf{ĥ}`` implem
4142 \b egin{aligned}
4243 \m athbf{f̂}\B ig(\m athbf{x̂_0}(k), \m athbf{u_0}(k), \m athbf{d_0}(k)\B ig) &= \b egin{bmatrix}
4344 \m athbf{f}\B ig(\m athbf{x_0}(k), \m athbf{û_0}(k), \m athbf{d_0}(k), \m athbf{p}\B ig) \\
44- \m athbf{A_s} \m athbf{x_s}(k) \e nd{bmatrix} \\
45+ \m athbf{A_s} \m athbf{x_s}(k) \e nd{bmatrix}
46+ + \m athbf{f̂_{op}} - \m athbf{x̂_{op}} \\
4547 \m athbf{ĥ}\B ig(\m athbf{x̂_0}(k), \m athbf{d_0}(k)\B ig) &=
4648 \m athbf{h}\B ig(\m athbf{x_0}(k), \m athbf{d_0}(k), \m athbf{p}\B ig) + \m athbf{y_{s_y}}(k)
4749 \e nd{aligned}
@@ -55,37 +57,41 @@ Extended Help for details on ``\mathbf{û_0, f̂}`` and ``\mathbf{ĥ}`` implem
5557 \e nd{aligned}
5658 ```
5759 The ``\m athbf{f}`` and ``\m athbf{h}`` functions above are in fact the [`f!`](@ref) and
58- [`h!`](@ref) methods, respectively.
60+ [`h!`](@ref) methods, respectively. The operating points ``\m athbf{x̂_{op}, f̂_{op}}``
61+ are computed by [`augment_model`](@ref) (almost always zeros in practice for
62+ [`NonLinModel`](@ref)).
5963"""
6064function f̂! (x̂0next, û0, k0, estim:: StateEstimator , model:: SimModel , x̂0, u0, d0)
61- return f̂! (x̂0next, û0, k0, model, estim. As, estim. Cs_u, x̂0, u0, d0)
65+ return f̂! (x̂0next, û0, k0, model, estim. As, estim. Cs_u, estim . f̂op, estim . x̂op, x̂0, u0, d0)
6266end
6367
6468"""
6569 f̂!(x̂0next, _ , _ , estim::StateEstimator, model::LinModel, x̂0, u0, d0) -> nothing
6670
67- Use the augmented model matrices if `model` is a [`LinModel`](@ref).
71+ Use the augmented model matrices and operating points if `model` is a [`LinModel`](@ref).
6872"""
6973function f̂! (x̂0next, _ , _ , estim:: StateEstimator , :: LinModel , x̂0, u0, d0)
7074 mul! (x̂0next, estim. Â, x̂0)
7175 mul! (x̂0next, estim. B̂u, u0, 1 , 1 )
7276 mul! (x̂0next, estim. B̂d, d0, 1 , 1 )
77+ x̂0next .+ = estim. f̂op .- estim. x̂op
7378 return nothing
7479end
7580
7681"""
77- f̂!(x̂0next, û0, k0, model::SimModel, As, Cs_u, x̂0, u0, d0)
82+ f̂!(x̂0next, û0, k0, model::SimModel, As, Cs_u, f̂op, x̂op, x̂0, u0, d0)
7883
7984Same than [`f̂!`](@ref) for [`SimModel`](@ref) but without the `estim` argument.
8085"""
81- function f̂! (x̂0next, û0, k0, model:: SimModel , As, Cs_u, x̂0, u0, d0)
86+ function f̂! (x̂0next, û0, k0, model:: SimModel , As, Cs_u, f̂op, x̂op, x̂0, u0, d0)
8287 # `@views` macro avoid copies with matrix slice operator e.g. [a:b]
8388 @views xd, xs = x̂0[1 : model. nx], x̂0[model. nx+ 1 : end ]
8489 @views xdnext, xsnext = x̂0next[1 : model. nx], x̂0next[model. nx+ 1 : end ]
8590 mul! (û0, Cs_u, xs) # ys_u = Cs_u*xs
8691 û0 .+ = u0 # û0 = u0 + ys_u
8792 f! (xdnext, k0, model, xd, û0, d0, model. p)
8893 mul! (xsnext, As, xs)
94+ x̂0next .+ = f̂op .- x̂op
8995 return nothing
9096end
9197
0 commit comments