Skip to content

Commit

Permalink
test: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AayushSabharwal committed Feb 1, 2024
1 parent 231f4cd commit a71c48f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion test/components.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ let
[resistor, resistor2, capacitor, source, ground])
sys2 = structural_simplify(rc_model2)
prob2 = ODEProblem(sys2, u0, (0, 10.0))
sol2 = solve(prob2, Tsit5())
sol2 = solve(prob2, Rosenbrock23())
@test sol2[source.p.i] sol2[rc_model2.source.p.i] -sol2[capacitor.i]
end

Expand Down
2 changes: 1 addition & 1 deletion test/state_selection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ let
prob1 = ODEProblem(sys, u0, (0.0, 0.1))
prob2 = ODEProblem(sys, u0, (0.0, 0.1))
@test solve(prob1, FBDF()).retcode == ReturnCode.Success
@test_broken solve(prob2, FBDF()).retcode == ReturnCode.Success
@test solve(prob2, FBDF()).retcode == ReturnCode.Success
end

let
Expand Down
20 changes: 10 additions & 10 deletions test/structural_transformation/tearing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,35 +155,35 @@ newdaesys = structural_simplify(daesys)
@test equations(newdaesys) == [D(x) ~ z; 0 ~ y + sin(z) - p * t]
@test equations(tearing_substitution(newdaesys)) == [D(x) ~ z; 0 ~ x + sin(z) - p * t]
@test isequal(states(newdaesys), [x, z])
@test_deprecated ODAEProblem(newdaesys, [x => 1.0], (0, 1.0), [p => 0.2])
prob = ODEProblem(newdaesys, [x => 1.0], (0, 1.0), [p => 0.2])
du = [0.0];
u = [1.0];
@test_deprecated ODAEProblem(newdaesys, [x => 1.0, z => -0.5π], (0, 1.0), [p => 0.2])
prob = ODEProblem(newdaesys, [x => 1.0, z => -0.5π], (0, 1.0), [p => 0.2])
du = [0.0, 0.0];
u = [1.0, -0.5π];
pr = 0.2;
tt = 0.1;
@test_skip (@ballocated $(prob.f)($du, $u, $pr, $tt)) == 0
prob.f(du, u, pr, tt)
@test du[-asin(u[1] - pr * tt)] atol=1e-5
@test du [u[2], u[1] + sin(u[2]) - pr * tt] atol=1e-5

# test the initial guess is respected
@named sys = ODESystem(eqs, t, defaults = Dict(z => Inf))
infprob = ODEProblem(structural_simplify(sys), [x => 1.0], (0, 1.0), [p => 0.2])
@test_throws Any infprob.f(du, u, pr, tt)
@test_throws Any infprob.f(du, infprob.u0, pr, tt)

sol1 = solve(prob, Tsit5())
sol1 = solve(prob, RosShamp4(), reltol=8e-7)
sol2 = solve(ODEProblem{false}((u, p, t) -> [-asin(u[1] - pr * t)],
[1.0],
(0, 1.0),
0.2), Tsit5(), tstops = sol1.t, adaptive = false)
@test Array(sol1)Array(sol2) atol=1e-5
@test Array(sol1[x])Array(sol2[1, :]) atol=1e-5

@test sol1[x] == first.(sol1.u)
@test sol1[y] == first.(sol1.u)
@test sin.(sol1[z]) .+ sol1[y]pr[1] * sol1.t atol=1e-5
@test sin.(sol1[z]) .+ sol1[y]pr[1] * sol1.t atol=5e-5
@test sol1[sin(z) + y]sin.(sol1[z]) .+ sol1[y] rtol=1e-12

@test sol1[y, :] == sol1[x, :]
@test (@. sin(sol1[z, :]) + sol1[y, :])pr * sol1.t atol=1e-5
@test (@. sin(sol1[z, :]) + sol1[y, :])pr * sol1.t atol=5e-5

# 1426
function Translational_Mass(; name, m = 1.0)
Expand Down

0 comments on commit a71c48f

Please sign in to comment.