Skip to content

Commit fb37e35

Browse files
committed
Tests
1 parent 62478f8 commit fb37e35

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

test/components.jl

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ function check_contract(sys)
1919
end
2020
end
2121

22+
function check_rc_sol(sol)
23+
@test sol[rc_model.resistor.p.i] == sol[resistor.p.i] == sol[capacitor.p.i]
24+
@test sol[rc_model.resistor.n.i] == sol[resistor.n.i] == -sol[capacitor.p.i]
25+
@test sol[rc_model.capacitor.n.i] ==sol[capacitor.n.i] == -sol[capacitor.p.i]
26+
@test iszero(sol[rc_model.ground.g.i])
27+
@test iszero(sol[rc_model.ground.g.v])
28+
@test sol[rc_model.resistor.v] == sol[resistor.v] == sol[source.p.v] - sol[capacitor.p.v]
29+
end
30+
2231
include("../examples/rc_model.jl")
2332

2433
sys = structural_simplify(rc_model)
@@ -31,13 +40,10 @@ u0 = [
3140
]
3241
prob = ODEProblem(sys, u0, (0, 10.0))
3342
sol = solve(prob, Rodas4())
34-
35-
@test sol[resistor.p.i] == sol[capacitor.p.i]
36-
@test sol[resistor.n.i] == -sol[capacitor.p.i]
37-
@test sol[capacitor.n.i] == -sol[capacitor.p.i]
38-
@test iszero(sol[ground.g.i])
39-
@test iszero(sol[ground.g.v])
40-
@test sol[resistor.v] == sol[source.p.v] - sol[capacitor.p.v]
43+
check_rc_sol(sol)
44+
prob = ODAEProblem(sys, u0, (0, 10.0))
45+
sol = solve(prob, Rodas4())
46+
check_rc_sol(sol)
4147

4248
# Outer/inner connections
4349
function rc_component(;name)

0 commit comments

Comments
 (0)