@@ -16,11 +16,13 @@ struct InternalModel{NT<:Real, SM<:SimModel} <: StateEstimator{NT}
16
16
Bs:: Matrix{NT}
17
17
Cs:: Matrix{NT}
18
18
Ds:: Matrix{NT}
19
- Â :: Matrix{NT}
20
- B̂u:: Matrix{NT}
21
- Ĉ :: Matrix{NT}
22
- B̂d:: Matrix{NT}
23
- D̂d:: Matrix{NT}
19
+ Â :: Matrix{NT}
20
+ B̂u :: Matrix{NT}
21
+ Ĉ :: Matrix{NT}
22
+ B̂d :: Matrix{NT}
23
+ D̂d :: Matrix{NT}
24
+ Ĉm :: Matrix{NT}
25
+ D̂dm :: Matrix{NT}
24
26
Âs:: Matrix{NT}
25
27
B̂s:: Matrix{NT}
26
28
direct:: Bool
@@ -36,6 +38,7 @@ struct InternalModel{NT<:Real, SM<:SimModel} <: StateEstimator{NT}
36
38
nxs = size (As,1 )
37
39
nx̂ = model. nx
38
40
Â, B̂u, Ĉ, B̂d, D̂d, x̂op, f̂op = matrices_internalmodel (model)
41
+ Ĉm, D̂dm = Ĉ[i_ym,:], D̂d[i_ym,:]
39
42
Âs, B̂s = init_internalmodel (As, Bs, Cs, Ds)
40
43
lastu0 = zeros (NT, nu)
41
44
# x̂0 and x̂d are same object (updating x̂d will update x̂0):
@@ -50,7 +53,7 @@ struct InternalModel{NT<:Real, SM<:SimModel} <: StateEstimator{NT}
50
53
lastu0, x̂op, f̂op, x̂0, x̂d, x̂s, ŷs,
51
54
i_ym, nx̂, nym, nyu, nxs,
52
55
As, Bs, Cs, Ds,
53
- Â, B̂u, Ĉ, B̂d, D̂d,
56
+ Â, B̂u, Ĉ, B̂d, D̂d, Ĉm, D̂dm,
54
57
Âs, B̂s,
55
58
direct, corrected,
56
59
buffer
@@ -156,8 +159,8 @@ function matrices_internalmodel(model::LinModel)
156
159
end
157
160
" Return empty matrices, and `x̂op` & `f̂op` vectors, if `model` is not a [`LinModel`](@ref)."
158
161
function matrices_internalmodel (model:: SimModel{NT} ) where NT<: Real
159
- nu, nx, nd = model. nu, model. nx, model. nd
160
- Â, B̂u, Ĉ, B̂d, D̂d = zeros (NT,0 ,nx), zeros (NT,0 ,nu), zeros (NT,0 ,nx ), zeros (NT,0 ,nd), zeros (NT,0 ,nd )
162
+ nu, nx, nd, ny = model. nu, model. nx, model. nd, model . ny
163
+ Â, B̂u, Ĉ, B̂d, D̂d = zeros (NT,0 ,nx), zeros (NT,0 ,nu), zeros (NT,ny, 0 ), zeros (NT,0 ,nd), zeros (NT,ny, 0 )
161
164
x̂op, f̂op = copy (model. xop), copy (model. fop)
162
165
return Â, B̂u, Ĉ, B̂d, D̂d, x̂op, f̂op
163
166
end
@@ -225,6 +228,8 @@ function setmodel_estimator!(estim::InternalModel, model, _ , _ , _ , _ , _ )
225
228
estim. Ĉ .= Ĉ
226
229
estim. B̂d .= B̂d
227
230
estim. D̂d .= D̂d
231
+ estim. Ĉm .= @views Ĉ[estim. i_ym,:]
232
+ estim. D̂dm .= @views D̂d[estim. i_ym,:]
228
233
# --- update state estimate and its operating points ---
229
234
estim. x̂0 .+ = estim. x̂op # convert x̂0 to x̂ with the old operating point
230
235
estim. x̂op .= x̂op
0 commit comments