diff --git a/Project.toml b/Project.toml index 6cae09c7..a3d8f23c 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "DifferentialEquations" uuid = "0c46a032-eb83-5123-abaf-570d42b7fbaa" authors = ["Chris Rackauckas "] -version = "7.13.0" +version = "7.14.0" [deps] BoundaryValueDiffEq = "764a87c0-6b3e-53db-9096-fe964310641d" diff --git a/src/DifferentialEquations.jl b/src/DifferentialEquations.jl index 1db63371..1ebc99e4 100644 --- a/src/DifferentialEquations.jl +++ b/src/DifferentialEquations.jl @@ -24,7 +24,6 @@ using NonlinearSolve include("default_solve.jl") include("default_arg_parsing.jl") -include("ode_default_alg.jl") include("sde_default_alg.jl") include("dae_default_alg.jl") include("dde_default_alg.jl") diff --git a/src/ode_default_alg.jl b/src/ode_default_alg.jl deleted file mode 100644 index e701c81c..00000000 --- a/src/ode_default_alg.jl +++ /dev/null @@ -1,79 +0,0 @@ -function default_algorithm(prob::DiffEqBase.AbstractODEProblem{uType, tType, inplace}; - kwargs...) where {uType, tType, inplace} - o = Dict{Symbol, Any}(kwargs) - extra_kwargs = Any[] - alg = AutoTsit5(Rosenbrock23(autodiff = false)) # Standard default - uEltype = eltype(prob.u0) - - alg_hints = get_alg_hints(o) - tol_level = get_tolerance_level(o) - callbacks = callbacks_exists(o) - mm = mass_matrix_exists(prob) - - if :stiff ∈ alg_hints && :nonstiff ∈ alg_hints - error("The problem must either be designated as stiff or non-stiff") - end - - # If adaptivity is not set and the tType is not a float, turn off adaptivity - # Bad interaction with ForwardDiff - #!(tType <: AbstractFloat) && (:adaptive ∉ keys(o)) && push!(extra_kwargs,:adaptive=>false) - - if prob.f isa SplitFunction - alg = KenCarp4(autodiff = false) - elseif prob.f isa DynamicalODEFunction - if tol_level == :low_tol || tol_level == :med_tol - alg = Tsit5() - else - alg = Vern7(lazy = !callbacks) - end - else # Standard ODE - if :nonstiff ∈ alg_hints - # Don't default to implicit here because of memory requirements - # And because the linear system gets unruly - if (!(uEltype <: Float64) && !(uEltype <: Float32) && !(uEltype <: Complex)) || - tol_level == :extreme_tol || tol_level == :low_tol - # Most likely higher precision, so use a higher order method - alg = Vern7(lazy = !callbacks) - else - alg = Tsit5() - end - elseif :stiff ∈ alg_hints || mm # The problem is stiff - if length(prob.u0) > 500 - # Use Krylov method when huge! - alg = FBDF(autodiff = false, linsolve = LinearSolve.KrylovJL_GMRES()) - elseif length(prob.u0) > 50 - alg = FBDF(autodiff = false) - elseif tol_level == :high_tol - alg = Rosenbrock23(autodiff = false) - else - alg = Rodas5P(autodiff = false) - end - else # :auto ∈ alg_hints - if (!(uEltype <: Float64) && !(uEltype <: Float32)) || - tol_level == :extreme_tol || - tol_level == :low_tol - # Most likely higher precision, so use a higher order method - if length(prob.u0) > 500 - alg = AutoVern7( - KenCarp47( - autodiff = false, linsolve = LinearSolve.KrylovJL_GMRES()), - lazy = !callbacks) - elseif length(prob.u0) > 50 - alg = AutoVern7(KenCarp47(autodiff = false), lazy = !callbacks) - else - alg = AutoVern7(Rodas5P(autodiff = false), lazy = !callbacks) - end - else # :med or low - if length(prob.u0) > 500 - alg = AutoTsit5(TRBDF2( - autodiff = false, linsolve = LinearSolve.KrylovJL_GMRES())) - elseif length(prob.u0) > 50 - alg = AutoTsit5(TRBDF2(autodiff = false)) - else - alg = AutoTsit5(Rosenbrock23(autodiff = false)) - end - end - end - end - alg, extra_kwargs -end diff --git a/test/default_ode_alg_test.jl b/test/default_ode_alg_test.jl deleted file mode 100644 index e034c378..00000000 --- a/test/default_ode_alg_test.jl +++ /dev/null @@ -1,107 +0,0 @@ -using DifferentialEquations, Test - -f_2dlinear = (du, u, p, t) -> (@. du = p * u) -f_2dlinear_analytic = (u0, p, t) -> @. u0 * exp(p * t) -prob_ode_2Dlinear = ODEProblem(ODEFunction(f_2dlinear, analytic = f_2dlinear_analytic), - rand(4, 2), (0.0, 1.0), 1.01) - -alg, kwargs = default_algorithm(prob_ode_2Dlinear; dt = 1 // 2^(4)) -integ = init(prob_ode_2Dlinear; dt = 1 // 2^(4)) -sol = solve(prob_ode_2Dlinear; dt = 1 // 2^(4)) - -@test sol.alg.algs[1] isa Tsit5 -@test sol.alg.algs[2] isa Rosenbrock23 - -sol = solve(prob_ode_2Dlinear; reltol = 1e-1) - -@test sol.alg.algs[1] isa Tsit5 -@test sol.alg.algs[2] isa Rosenbrock23 - -sol = solve(prob_ode_2Dlinear; reltol = 1e-7) - -@test sol.alg.algs[1] isa Vern7 -@test sol.alg.algs[2] isa Rodas5P - -sol = solve(prob_ode_2Dlinear; reltol = 1e-10) - -@test sol.alg.algs[1] isa Vern7 -@test sol.alg.algs[2] isa Rodas5P - -sol = solve(prob_ode_2Dlinear; alg_hints = [:stiff]) - -@test sol.alg isa Rodas5P - -sol = solve(prob_ode_2Dlinear; alg_hints = [:stiff], reltol = 1e-1) - -@test sol.alg isa Rosenbrock23 - -const linear_bigα = parse(BigFloat, "1.01") -f = (du, u, p, t) -> begin - for i in 1:length(u) - du[i] = linear_bigα * u[i] - end -end -(::typeof(f))(::Type{Val{:analytic}}, u0, p, t) = u0 * exp(linear_bigα * t) -prob_ode_bigfloat2Dlinear = ODEProblem(f, map(BigFloat, rand(4, 2)) .* ones(4, 2) / 2, - (0.0, 1.0)) - -sol = solve(prob_ode_bigfloat2Dlinear; dt = 1 // 2^(4)) -@test sol.alg.algs[1] isa Vern7 -@test sol.alg.algs[2] isa Rodas5P - -default_algorithm(prob_ode_bigfloat2Dlinear; alg_hints = [:stiff]) - -sol = solve(prob_ode_bigfloat2Dlinear; alg_hints = [:stiff]) - -@test sol.alg isa Rodas5P - -sol = solve(prob_ode_bigfloat2Dlinear, nothing; alg_hints = [:stiff]) - -@test sol.alg isa Rodas5P - -struct FooAlg end - -@test_throws DiffEqBase.NonSolverError solve(prob_ode_bigfloat2Dlinear, FooAlg(); - default_set = true) - -struct FooAlg2 <: DiffEqBase.DEAlgorithm end - -@test_throws DiffEqBase.ProblemSolverPairingError solve(prob_ode_bigfloat2Dlinear, - FooAlg2(); default_set = true) - -prob = ODEProblem(f, rand(4, 2) .* ones(4, 2) / 2, (0.0, 1.0)) - -sol = solve(prob; alg_hints = [:stiff]) - -@test sol.alg isa Rodas5P - -sol = solve(prob; alg_hints = [:stiff], reltol = 1e-1) - -@test sol.alg isa Rosenbrock23 - -sol = solve(prob; alg_hints = [:stiff], callback = CallbackSet()) - -@test sol.alg isa Rodas5P - -prob = ODEProblem(f, rand(4, 2) .* ones(4, 2) / 2, (0.0, 1.0)) - -alg, kwargs = default_algorithm(prob; alg_hints = [:stiff]) - -@test alg isa Rodas5P - -m = 1.0 -ω = 1.0 - -function mass_system!(du, u, p, t) - # a(t) = (1/m) w^2 x - (1 / m) * (ω^2) * u[1] -end - -v0 = 0.0 -u0 = 1.0 -tspan = (0.0, 10.0) - -prob = SecondOrderODEProblem(mass_system!, v0, u0, tspan) -sol = solve(prob) - -@test sol.alg isa Tsit5 diff --git a/test/runtests.jl b/test/runtests.jl index 3953b8b1..920c9026 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -5,9 +5,6 @@ using DifferentialEquations, Test, SafeTestsets @time @safetestset "Default Discrete Algorithm" begin include("default_discrete_alg_test.jl") end - @time @safetestset "Default ODE Algorithm" begin - include("default_ode_alg_test.jl") - end @time @safetestset "Default Steady State Algorithm" begin include("default_steady_state_alg_test.jl") end