@@ -1074,6 +1074,26 @@ end
1074
1074
prob = ODEProblem (ss, [temp => 0.0 , furnace_on => true ], (0.0 , 100.0 ))
1075
1075
sol = solve (prob, Tsit5 (); dtmax = 0.01 )
1076
1076
@test all (sol[temp][sol. t .> 1.0 ] .<= 0.79 ) && all (sol[temp][sol. t .> 1.0 ] .>= 0.49 )
1077
+
1078
+ furnace_off = ModelingToolkit. SymbolicContinuousCallback (
1079
+ [temp ~ furnace_off_threshold],
1080
+ ModelingToolkit. MutatingFunctionalAffect (modified = (; furnace_on)) do x
1081
+ x. furnace_on = false
1082
+ end ; initialize = ModelingToolkit. MutatingFunctionalAffect (modified = (; temp)) do x
1083
+ x. temp = 0.2
1084
+ end )
1085
+ furnace_enable = ModelingToolkit. SymbolicContinuousCallback (
1086
+ [temp ~ furnace_on_threshold],
1087
+ ModelingToolkit. MutatingFunctionalAffect (modified = (; furnace_on)) do x, o, c, i
1088
+ x. furnace_on = true
1089
+ end )
1090
+ @named sys = ODESystem (
1091
+ eqs, t, [temp], params; continuous_events = [furnace_off, furnace_enable])
1092
+ ss = structural_simplify (sys)
1093
+ prob = ODEProblem (ss, [temp => 0.0 , furnace_on => true ], (0.0 , 100.0 ))
1094
+ sol = solve (prob, Tsit5 (); dtmax = 0.01 )
1095
+ @test all (sol[temp][sol. t .> 1.0 ] .<= 0.79 ) && all (sol[temp][sol. t .> 1.0 ] .>= 0.49 )
1096
+ @test all (sol[temp][sol. t .!= 0.0 ] .<= 0.79 ) && all (sol[temp][sol. t .!= 0.0 ] .>= 0.2 )
1077
1097
end
1078
1098
1079
1099
@testset " MutatingFunctionalAffect errors and warnings" begin
0 commit comments