@@ -99,6 +99,8 @@ prob = ODEProblem(sys, u0, (0, 10.0))
99
99
sol = solve (prob, Rodas4 ())
100
100
@test all (sol[rc_model. capacitor. v] .< 0.4 )
101
101
102
+ # hierarchical - result should be identical
103
+
102
104
function affect6! (integ, u,p,ctx)
103
105
@test integ. u[u. v] ≈ 0.3
104
106
integ. p[p. C] *= 200
@@ -115,8 +117,6 @@ function Capacitor2(; name, C = 1.0)
115
117
extend (ODESystem (eqs, t, [], ps; name = name, continuous_events= [[v ~ 0.3 ]=> (affect6!, [v], [C], nothing )]), oneport)
116
118
end
117
119
118
- # hierarchical - result should be identical
119
-
120
120
@named capacitor2 = Capacitor2 (C = C)
121
121
122
122
rc_eqs2 = [connect (source. p, resistor. p)
@@ -164,7 +164,7 @@ sol_ = solve(prob_,Tsit5(),callback=cb_)
164
164
165
165
# same - with MTK
166
166
sts = @variables y (t), v (t)
167
- par = @parameters g
167
+ par = @parameters g = 9.8
168
168
bb_eqs = [
169
169
D (y) ~ v
170
170
D (v) ~ - g
177
177
@named bb_model = ODESystem (bb_eqs, t, sts, par, continuous_events= [[y ~ 0 ] => (bb_affect!, [v], [], nothing )])
178
178
179
179
bb_sys = structural_simplify (bb_model)
180
- u0 = [v => 0.0 , y => 50.0 , g => 9.8 ]
180
+ u0 = [v => 0.0 , y => 50.0 ]
181
181
182
182
bb_prob = ODEProblem (bb_sys, u0, (0 , 15.0 ))
183
183
bb_sol = solve (bb_prob, Tsit5 ())
0 commit comments