@@ -16,11 +16,13 @@ struct InternalModel{NT<:Real, SM<:SimModel} <: StateEstimator{NT}
1616 Bs:: Matrix{NT}
1717 Cs:: Matrix{NT}
1818 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}
2426 Âs:: Matrix{NT}
2527 B̂s:: Matrix{NT}
2628 direct:: Bool
@@ -36,6 +38,7 @@ struct InternalModel{NT<:Real, SM<:SimModel} <: StateEstimator{NT}
3638 nxs = size (As,1 )
3739 nx̂ = model. nx
3840 Â, B̂u, Ĉ, B̂d, D̂d, x̂op, f̂op = matrices_internalmodel (model)
41+ Ĉm, D̂dm = Ĉ[i_ym,:], D̂d[i_ym,:]
3942 Âs, B̂s = init_internalmodel (As, Bs, Cs, Ds)
4043 lastu0 = zeros (NT, nu)
4144 # 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}
5053 lastu0, x̂op, f̂op, x̂0, x̂d, x̂s, ŷs,
5154 i_ym, nx̂, nym, nyu, nxs,
5255 As, Bs, Cs, Ds,
53- Â, B̂u, Ĉ, B̂d, D̂d,
56+ Â, B̂u, Ĉ, B̂d, D̂d, Ĉm, D̂dm,
5457 Âs, B̂s,
5558 direct, corrected,
5659 buffer
@@ -156,8 +159,8 @@ function matrices_internalmodel(model::LinModel)
156159end
157160" Return empty matrices, and `x̂op` & `f̂op` vectors, if `model` is not a [`LinModel`](@ref)."
158161function 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 )
161164 x̂op, f̂op = copy (model. xop), copy (model. fop)
162165 return Â, B̂u, Ĉ, B̂d, D̂d, x̂op, f̂op
163166end
@@ -225,6 +228,8 @@ function setmodel_estimator!(estim::InternalModel, model, _ , _ , _ , _ , _ )
225228 estim. Ĉ .= Ĉ
226229 estim. B̂d .= B̂d
227230 estim. D̂d .= D̂d
231+ estim. Ĉm .= @views Ĉ[estim. i_ym,:]
232+ estim. D̂dm .= @views D̂d[estim. i_ym,:]
228233 # --- update state estimate and its operating points ---
229234 estim. x̂0 .+ = estim. x̂op # convert x̂0 to x̂ with the old operating point
230235 estim. x̂op .= x̂op
0 commit comments