Skip to content

Commit 56e12af

Browse files
committed
doc: wip adaptive MHE with MTK
1 parent 59d9138 commit 56e12af

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

‎docs/src/manual/mtk.md‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ function generate_f_h_mtk(model, inputs, outputs, disturbances=nothing)
7777
return nothing
7878
end
7979
ic = initial_conditions(io_sys)
80+
io_sys |> equations |> display
8081
p_map, x_map = try
8182
(
8283
Dict(sym => ic[sym] for sym in p_sym),
@@ -321,6 +322,49 @@ display(p) # hide
321322

322323
![plot3_MTK](plot3_MTK.svg)
323324

325+
```@example 1
326+
using Plots
327+
u, d, x_0 = [10.0], [10.0], [0.0495, 0.0505]
328+
N = 21
329+
using Logging # hide
330+
res = with_logger(ConsoleLogger(stderr, Error)) do # hide
331+
res = sim!(model, N, u, d; x_0)
332+
end # hide
333+
p = plot(res)
334+
savefig(p, "plot3_MTK.svg") # hide
335+
display(p) # hide
336+
```
337+
338+
```@example 1
339+
@variables c_Ain_s(t)=0.1
340+
eqs_2 = [
341+
D(c_A) ~ 60/V*(q_Ain * c_Ain_s - q_out * c_Aout)
342+
D(c_B) ~ 60/V*(q_Bin * c_Bin - q_out * c_Bout)
343+
D(c_Ain_s) ~ 0
344+
0 ~ 10^(-pH) + c_B - (Kw / 10^(-pH)) - (Ka * c_A / (Ka + 10^(-pH)))
345+
q_out ~ q_Ain + q_Bin
346+
c_Aout ~ c_A
347+
c_Bout ~ c_B
348+
]
349+
@named mtk_model_2 = System(eqs_2, t)
350+
f_mtk!, h_mtk!, p_sym, p, x_sym, x, i_alg = generate_f_h_mtk(
351+
mtk_model_2, inputs, outputs, disturbances
352+
)
353+
[x_sym x]
354+
```
355+
356+
```@example 1
357+
```
358+
359+
```@example 1
360+
model = generate_model(
361+
f_mtk!, h_mtk!, Ts, i_alg, inputs, outputs, disturbances;
362+
p, xs_mtk, unit, transcription
363+
)
364+
vx̂ = [vx; raw"$c_{Ain}$ (mol/L)"]
365+
model = setname!(model, u=vu, d=vd, y=vy, x=vx̂)
366+
```
367+
324368
## Acknowledgement
325369

326370
Authored by `1-Bart-1` and `baggepinnen`, thanks for the contribution.

0 commit comments

Comments
 (0)