Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
JuMPExt = "JuMP"

[compat]
FastBroadcast = "0.3.5"
FastBroadcast = "0.3.5, 1"
JuMP = "1.28"
LinearAlgebra = "1"
LinearSolve = "3.54"
Expand Down
64 changes: 36 additions & 28 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -947,15 +947,18 @@ end
probs = (prob_pds_linmod, prob_pds_nonlinmod, prob_pds_brusselator,
prob_pds_sir, prob_pds_npzd)
algs = (Euler(), ImplicitEuler(), Tsit5(), Rosenbrock23(), SDIRK2(), TRBDF2())
@testset "$alg" for prob in probs, alg in algs
abstol = 1e-5
reltol = 1e-5
@testset "$alg, $prob" for prob in probs, alg in algs
dt = (last(prob.tspan) - first(prob.tspan)) / 1e4
sol = solve(prob, alg; dt, isoutofdomain = isnegative) # use explicit f
sol = solve(prob, alg; dt, abstol, reltol,
isoutofdomain = isnegative) # use explicit f
sol2 = solve(ConservativePDSProblem(prob.f.p, prob.u0, prob.tspan), alg; dt,
isoutofdomain = isnegative) # use p and d to compute f
abstol, reltol, isoutofdomain = isnegative) # use p and d to compute f
sol3 = solve(ODEProblem(prob.f.std_rhs, prob.u0, prob.tspan), alg; dt,
isoutofdomain = isnegative) # use f to create ODEProblem
@test sol.t ≈ sol2.t ≈ sol3.t
@test sol.u ≈ sol2.u ≈ sol3.u
abstol, reltol, isoutofdomain = isnegative) # use f to create ODEProblem
t = range(prob.tspan..., length = 10_000)
@test sol.(t) ≈ sol2.(t) ≈ sol3.(t)
end

# non-stiff conservative problems (in-place)
Expand All @@ -965,41 +968,44 @@ end
Rosenbrock23(autodiff = AutoFiniteDiff()),
SDIRK2(autodiff = AutoFiniteDiff()),
TRBDF2(autodiff = AutoFiniteDiff()))
@testset "$alg" for prob in probs, alg in algs
@testset "$alg, $prob" for prob in probs, alg in algs
dt = (last(prob.tspan) - first(prob.tspan)) / 1e4
sol = solve(prob, alg; dt, isoutofdomain = isnegative) # use explicit f
sol = solve(prob, alg; dt, abstol, reltol,
isoutofdomain = isnegative) # use explicit f
sol2 = solve(ConservativePDSProblem(prob.f.p, prob.u0, prob.tspan), alg; dt,
isoutofdomain = isnegative) # use p and d to compute f
abstol, reltol, isoutofdomain = isnegative) # use p and d to compute f
sol3 = solve(ODEProblem(prob.f.std_rhs, prob.u0, prob.tspan), alg; dt,
isoutofdomain = isnegative) # use f to create ODEProblem
@test sol.t ≈ sol2.t ≈ sol3.t
@test sol.u ≈ sol2.u ≈ sol3.u
abstol, reltol, isoutofdomain = isnegative) # use f to create ODEProblem
t = range(prob.tspan..., length = 10_000)
@test sol.(t) ≈ sol2.(t) ≈ sol3.(t)
end

# non-stiff non-conservative problems (out-of-place)
probs = (prob_pds_minmapk,)
algs = (Euler(), ImplicitEuler(), Tsit5(), Rosenbrock23(), SDIRK2(), TRBDF2())
@testset "$alg" for prob in probs, alg in algs
@testset "$alg, $prob" for prob in probs, alg in algs
dt = (last(prob.tspan) - first(prob.tspan)) / 1e4
sol = solve(prob, alg; dt, isoutofdomain = isnegative) # use explicit f
sol = solve(prob, alg; dt, abstol, reltol, isoutofdomain = isnegative) # use explicit f
sol2 = solve(PDSProblem(prob.f.p, prob.f.d, prob.u0, prob.tspan), alg; dt,
isoutofdomain = isnegative) # use p and d to compute f
abstol, reltol, isoutofdomain = isnegative) # use p and d to compute f
sol3 = solve(ODEProblem(prob.f.std_rhs, prob.u0, prob.tspan), alg; dt,
isoutofdomain = isnegative) # use f to create ODEProblem
@test sol.t ≈ sol2.t ≈ sol3.t
@test sol.u ≈ sol2.u ≈ sol3.u
abstol, reltol, isoutofdomain = isnegative) # use f to create ODEProblem
t = range(prob.tspan..., length = 10_000)
@test sol.(t) ≈ sol2.(t) ≈ sol3.(t)
end

# Robertson problem
prob = prob_pds_robertson
algs = (ImplicitEuler(), Rosenbrock23(), SDIRK2(), TRBDF2())
@testset "$alg" for alg in algs
dt = 1e-6
sol = solve(prob, alg; dt) # use explicit f
sol2 = solve(ConservativePDSProblem(prob.f.p, prob.u0, prob.tspan), alg; dt) # use p and d to compute f
sol3 = solve(ODEProblem(prob.f.std_rhs, prob.u0, prob.tspan), alg; dt) # use f to create ODEProblem
@test sol.t ≈ sol2.t ≈ sol3.t
@test sol.u ≈ sol2.u ≈ sol3.u
sol = solve(prob, alg; dt, abstol, reltol) # use explicit f
sol2 = solve(ConservativePDSProblem(prob.f.p, prob.u0, prob.tspan), alg; dt,
abstol, reltol) # use p and d to compute f
sol3 = solve(ODEProblem(prob.f.std_rhs, prob.u0, prob.tspan), alg; dt,
abstol, reltol) # use f to create ODEProblem
t = range(prob.tspan..., length = 10_000)
@test sol.(t) ≈ sol2.(t) ≈ sol3.(t)
end

# Bertolazzi problem
Expand All @@ -1021,11 +1027,13 @@ end
algs = (ImplicitEuler(), Rosenbrock23(), TRBDF2())
@testset "$alg" for alg in algs
dt = 1.0
sol = solve(prob, alg; dt) # use explicit f
sol2 = solve(PDSProblem(prob.f.p, prob.f.d, prob.u0, prob.tspan), alg; dt) # use p and d to compute f
sol3 = solve(ODEProblem(prob.f.std_rhs, prob.u0, prob.tspan), alg; dt) # use f to create ODEProblem
@test sol.t ≈ sol2.t ≈ sol3.t
@test sol.u ≈ sol2.u ≈ sol3.u
sol = solve(prob, alg; dt, abstol, reltol) # use explicit f
sol2 = solve(PDSProblem(prob.f.p, prob.f.d, prob.u0, prob.tspan), alg; dt,
abstol, reltol) # use p and d to compute f
sol3 = solve(ODEProblem(prob.f.std_rhs, prob.u0, prob.tspan), alg; dt,
abstol, reltol) # use f to create ODEProblem
t = range(prob.tspan..., length = 10_000)
@test sol.(t) ≈ sol2.(t) ≈ sol3.(t)
end
end
end
Expand Down
Loading