@@ -245,8 +245,10 @@ display(p) # hide
245245
246246## Neutralization Reactor Model
247247
248- !!! todo "Under Construction"
249- This section is not finished, only the model conversion is written for now.
248+ This example repeats the neutralization reactor setup from the previous section but with
249+ MTK. The observer and controller are non-adaptive to simplify the design. Instead of
250+ estimating the acid feed concentration, an integrating state is added at the manipulated
251+ input `` q_{Bin} `` .
250252
251253The MTK model of the neutralization reactor from the [ last section] (@ref man_dae) is
252254constructed as follows:
@@ -278,7 +280,7 @@ f_mtk!, h_mtk!, p_sym, p, x_sym, x, i_alg = generate_f_h_mtk(
278280[x_sym x]
279281```
280282
281- The content of ` x_sym ` shows that it chose for the combined state and algebraic vector
283+ The content of ` x_sym ` shows that it chose for the combined state and algebraic vector this:
282284`` [\begin{smallmatrix}c_B(t) && c_A(t) && \mathrm{pH}(t)\end{smallmatrix}]' `` . The states
283285are thus in the reverse order of the [ last section] (@ref man_dae). The order of the
284286parameters is:
@@ -302,9 +304,8 @@ vx, vy = [raw"$c_B$ (mol/L)", raw"$c_A$ (mol/L)"], [raw"$\mathrm{pH}$"]
302304model = setname!(model, u=vu, d=vd, y=vy, x=vx)
303305```
304306
305- The returned value is a [ ` NonLinModelDAE ` ] ( @ref ) object, as expected. The transient
306- response is identical to the first 10 hours of the open-loop simulations of the
307- [ last section] (@ref man_dae):
307+ The returned value is a [ ` NonLinModelDAE ` ] ( @ref ) object, as expected. The transient response
308+ is identical to the first 10 hours of the open-loop simulations in the [ last section] (@ref man_dae):
308309
309310``` @example 1
310311using Plots
@@ -321,6 +322,8 @@ display(p) # hide
321322
322323![ plot3_MTK] ( plot3_MTK.svg )
323324
325+ We next configure the MHE, including an integrating state at the manipulated input:
326+
324327``` @example 1
325328nint_u=[1] # integrating state at the q_Bin input
326329He = 8; hessian = true
@@ -330,25 +333,16 @@ using JuMP; unset_time_limit_sec(mhe.optim) # no wall time limit during opti
330333mhe = setconstraint!(mhe, x̂min=[0, 0, -Inf])
331334```
332335
333- ``` @example 1
334- x_0, x̂_0 = [0.0495, 0.0505], [0.025, 0.025, 0]
335- using Logging # hide
336- res = with_logger(ConsoleLogger(stderr, Error)) do # hide
337- res = sim!(mhe, N, u, d; x_0, x̂_0)
338- end # hide
339- p = plot(res, plotd=false, plotu=false, plotxwithx̂=true, plotx̂min=false)
340- savefig(p, "plot4_DAEpH.svg") # hide
341- display(p) # hide
342- ```
343-
344- ![ plot4_MTK] ( plot4_MTK.svg )
336+ Using the MHE, we configure an NMPC to keep the pH within the desired range:
345337
346338``` @example 1
347339nmpc = NonLinMPC(mhe, Hp=8, Hc=2, Nwt=[5.0], hessian=true)
348340using JuMP; unset_time_limit_sec(nmpc.optim) # no wall time limit during optimization
349341nmpc = setconstraint!(nmpc, ymin=[6], ymax=[8], umin=[0], umax=[20])
350342```
351343
344+ Finally, we simulate the closed-loop response with a pH setpoint of 7:
345+
352346``` @example 1
353347ry = [7.0]
354348x_0, x̂_0 = [0.04, 0.07], [0.025, 0.025, 0]
@@ -363,6 +357,9 @@ display(p) # hide
363357
364358![ plot5_MTK] ( plot5_MTK.svg )
365359
360+ As expected, the close-loop response is similar to the one of the [ last section] (@ref man_dae),
361+ but not identical since the stochastic model of the unmeasured disturbances is different.
362+
366363## Acknowledgement
367364
368365Authored by ` 1-Bart-1 ` and ` baggepinnen ` , thanks for the contribution.
0 commit comments