@@ -17,7 +17,7 @@ using ModelingToolkit: t_nounits as t, D_nounits as D
1717connect = ModelingToolkit. connect;
1818rc = 0.25 # Reference concentration
1919
20- @component function MixingTank(; name, c0 = 0.8 , T0 = 308.5 , a1 = 0.2674 , a21 = 1.815 , a22 = 0.4682 , b = 1.5476 , k0 = 1.05e14 , ϵ = 34.2894 )
20+ @component function MixingTank(; name, c0 = 0.8 , T0 = 308.5 , a1 = 0.2674 , a21 = 1.815 , a22 = 0.4682 , b = 1.5476 , k0 = 1.05e14 , ϵ = 34.2894 , xc = nothing , xT = nothing )
2121 pars = @parameters begin
2222 c0 = c0, [description = " Nominal concentration" ]
2323 T0 = T0, [description = " Nominal temperature" ]
@@ -34,11 +34,13 @@ rc = 0.25 # Reference concentration
3434 c = RealOutput()
3535 T = RealOutput()
3636 end
37-
37+
38+ xc = @something(xc, c0)
39+ xT = @something(xT, T0)
3840 vars = @variables begin
3941 gamma(t), [description = " Reaction speed" ]
40- xc(t) = c0 , [description = " Concentration" ]
41- xT(t) = T0 , [description = " Temperature" ]
42+ xc(t) = xc , [description = " Concentration" ]
43+ xT(t) = xT , [description = " Temperature" ]
4244 xT_c(t), [description = " Cooling temperature" ]
4345 end
4446
7375 function RefFilter(; name)
7476 sys = System(Fss; name)
7577 " Compute initial state that yields y0 as output"
76- empty!(ModelingToolkit. get_defaults (sys))
78+ empty!(ModelingToolkit. get_initial_conditions (sys))
7779 return sys
7880 end
7981end
@@ -132,7 +134,9 @@ cm = complete(model)
132134
133135op = Dict(
134136 cm. filter. y. u => 0.8 * (1 - 0.42 ),
135- D(cm. filter. y. u) => 0
137+ D(cm. filter. y. u) => 0 ,
138+ cm. noise_filter. x => nothing ,
139+ cm. controller. int. x => nothing ,
136140)
137141tspan = (0.0 , 1000.0 )
138142# https://github.com/SciML/ModelingToolkit.jl/issues/2786
@@ -178,18 +182,23 @@ nsys = get_named_comp_sensitivity(model, :y; op)
178182@testset " Issue #3319" begin
179183 op1 = Dict(
180184 cm. filter. y. u => 0.8 * (1 - 0.42 ),
181- cm. tank. xc => 0.65
185+ cm. tank. xc => 0.65 ,
186+ cm. noise_filter. x => nothing ,
182187 )
183188
184189 op2 = Dict(
185190 cm. filter. y. u => 0.8 * (1 - 0.42 ),
186- cm. tank. xc => 0.45
191+ cm. tank. xc => 0.45 ,
192+ cm. noise_filter. x => nothing ,
187193 )
188194
189195 output = :y
190196 # we need to provide `op` so the initialization system knows which
191197 # values to hold constant
192- lin_fun, ssys = get_sensitivity_function(model, output; op = op1)
198+ #
199+ # Printing `lin_fun` in a tuple (so it doesn't hit the pretty-printing method)
200+ # will likely segfault Julia. Somehow.
201+ lin_fun, ssys = get_sensitivity_function(model, output; op = op1);
193202 matrices1, extras1 = linearize(ssys, lin_fun, op = op1)
194203 matrices2, extras2 = linearize(ssys, lin_fun, op = op2)
195204 @test extras1. x != extras2. x
0 commit comments