@@ -27,20 +27,17 @@ rc = 0.25 # Reference concentration
2727 k0 = 1.05e14
2828 ϵ = 34.2894
2929 end
30-
3130 @variables begin
3231 gamma (t), [description = " Reaction speed" ]
3332 xc (t) = c0, [description = " Concentration" ]
3433 xT (t) = T0, [description = " Temperature" ]
3534 xT_c (t), [description = " Cooling temperature" ]
3635 end
37-
3836 @components begin
3937 T_c = RealInput ()
4038 c = RealOutput ()
4139 T = RealOutput ()
4240 end
43-
4441 begin
4542 τ0 = 60
4643 wk0 = k0 / c0
@@ -57,20 +54,18 @@ rc = 0.25 # Reference concentration
5754 gamma ~ xc * wk0 * exp (- wϵ / xT)
5855 D (xc) ~ - wa11 * xc - wa12 * gamma + wa13
5956 D (xT) ~ - wa21 * xT + wa22 * gamma + wa23 + wb * xT_c
60-
6157 xc ~ c. u
6258 xT ~ T. u
6359 xT_c ~ T_c. u
6460 end
6561end
66-
6762begin
68- Ftf = tf (1 , [(100 ), 1 ])^ 3
63+ Ftf = tf (1 , [(100 ), 1 ])^ 2
6964 Fss = ss (Ftf)
70-
7165 # Create an MTK-compatible constructor
7266 function RefFilter (; name)
7367 sys = ODESystem (Fss; name)
68+ " Compute initial state that yields y0 as output"
7469 empty! (ModelingToolkit. get_defaults (sys))
7570 return sys
7671 end
8277 x10 = 0.42
8378 x20 = 0.01
8479 u0 = - 0.0224
85-
8680 c_start = c0 * (1 - x10) # Initial concentration
8781 T_start = T0 * (1 + x20) # Initial temperature
8882 c_high_start = c0 * (1 - 0.72 ) # Reference concentration
10498 @equations begin
10599 connect (ref. output, :r , filter. input)
106100 connect (filter. output, inverse_tank. c)
107-
108101 connect (inverse_tank. T_c, ff_gain. input)
109102 connect (ff_gain. output, :uff , limiter. input)
110103 connect (limiter. output, add. input1)
111-
112104 connect (controller. ctr_output, :u , add. input2)
113-
114- # connect(add.output, :u_tot, limiter.input)
115- # connect(limiter.output, :v, tank.T_c)
116-
117105 connect (add. output, :u_tot , tank. T_c)
118-
119106 connect (inverse_tank. T, feedback. input1)
120-
121107 connect (tank. T, :y , noise_filter. input)
122-
123108 connect (noise_filter. output, feedback. input2)
124109 connect (feedback. output, :e , controller. err_input)
125110 end
@@ -128,8 +113,10 @@ end;
128113ssys = structural_simplify (model)
129114cm = complete (model)
130115
131- op = Dict (D (cm. inverse_tank. xT) => 1 ,
132- cm. tank. xc => 0.65 )
116+ op = Dict (
117+ cm. filter. y. u => 0.8 * (1 - 0.42 ),
118+ D (cm. filter. y. u) => 0
119+ )
133120tspan = (0.0 , 1000.0 )
134121# https://github.com/SciML/ModelingToolkit.jl/issues/2786
135122prob = ODEProblem (ssys, op, tspan)
0 commit comments