Skip to content

Commit 028f9a5

Browse files
author
dd
committed
explicitly check that tests results are the same
1 parent 33b1d61 commit 028f9a5

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

test/funcaffect.jl

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,23 @@ function Capacitor(; name, C = 1.0)
115115
extend(ODESystem(eqs, t, [], ps; name = name, continuous_events=[[v ~ 0.3]=>(affect6!, [v], [C], nothing)]), oneport)
116116
end
117117

118-
@named capacitor = Capacitor(C = C)
119-
@named rc_model = ODESystem(rc_eqs, t)
120-
rc_model = compose(rc_model, [resistor, capacitor, source, ground])
118+
# hyerarchical - result should be identical
121119

122-
sys = structural_simplify(rc_model)
123-
u0 = [capacitor.v => 0.0
124-
capacitor.p.i => 0.0
120+
@named capacitor2 = Capacitor(C = C)
121+
122+
rc_eqs2 = [connect(source.p, resistor.p)
123+
connect(resistor.n, capacitor2.p)
124+
connect(capacitor2.n, source.n)
125+
connect(capacitor2.n, ground.g)]
126+
127+
@named rc_model2 = ODESystem(rc_eqs2, t)
128+
rc_model2 = compose(rc_model2, [resistor, capacitor2, source, ground])
129+
130+
sys2 = structural_simplify(rc_model2)
131+
u0 = [capacitor2.v => 0.0
132+
capacitor2.p.i => 0.0
125133
resistor.v => 0.0]
126134

127-
prob = ODEProblem(sys, u0, (0, 10.0))
128-
sol = solve(prob, Rodas4())
129-
@test all(sol[rc_model.capacitor.v] .< 0.4)
135+
prob2 = ODEProblem(sys2, u0, (0, 10.0))
136+
sol2 = solve(prob2, Rodas4())
137+
@test all(sol2[rc_model2.capacitor2.v] .== sol[rc_model.capacitor.v])

0 commit comments

Comments
 (0)