Skip to content

Commit c2dfab1

Browse files
test: fix some issues with initialization of InverseControlledTank
1 parent b6b045e commit c2dfab1

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

test/downstream/inversemodel.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ rc = 0.25 # Reference concentration
3232
gamma(t), [description = "Reaction speed"]
3333
xc(t) = c0, [description = "Concentration"]
3434
xT(t) = T0, [description = "Temperature"]
35-
xT_c(t) = T0, [description = "Cooling temperature"]
35+
xT_c(t), [description = "Cooling temperature"]
3636
end
3737

3838
@components begin
@@ -77,7 +77,11 @@ begin
7777
end
7878

7979
# Create an MTK-compatible constructor
80-
RefFilter(; y0, name) = ODESystem(Fss; name, x0 = init_filter(y0))
80+
function RefFilter(; name)
81+
sys = ODESystem(Fss; name)
82+
delete!(defaults(sys), @nonamespace(sys.x)[1])
83+
return sys
84+
end
8185
end
8286
@mtkmodel InverseControlledTank begin
8387
begin
@@ -97,10 +101,10 @@ end
97101
ff_gain = Gain(k = 1) # To allow turning ff off
98102
controller = PI(gainPI.k = 10, T = 500)
99103
tank = MixingTank(xc = c_start, xT = T_start, c0 = c0, T0 = T0)
100-
inverse_tank = MixingTank(xc = c_start, xT = T_start, c0 = c0, T0 = T0)
104+
inverse_tank = MixingTank(xc = nothing, xT = T_start, c0 = c0, T0 = T0)
101105
feedback = Feedback()
102106
add = Add()
103-
filter = RefFilter(y0 = c_start) # Initialize filter states to the initial concentration
107+
filter = RefFilter()
104108
noise_filter = FirstOrder(k = 1, T = 1, x = T_start)
105109
# limiter = Gain(k=1)
106110
limiter = Limiter(y_max = 370, y_min = 250) # Saturate the control input

0 commit comments

Comments
 (0)