From a9e67c40b4560b631b123a8fc44042e2ff6ad981 Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Tue, 4 Jun 2019 10:34:43 -0400 Subject: [PATCH 01/11] Restructure tests --- .travis.yml | 1 + test/{ode => algconvergence}/adams_tests.jl | 0 .../linear_method_tests.jl | 0 .../linear_nonlinear_convergence_tests.jl | 0 .../linear_nonlinear_krylov_tests.jl | 0 .../nordsieck_tests.jl | 0 .../ode_convergence_tests.jl | 0 .../ode_extrapolation_tests.jl | 0 test/algconvergence/ode_feagin_tests.jl | 51 ++++ .../{ode => algconvergence}/ode_firk_tests.jl | 0 .../ode_low_storage_rk_tests.jl | 0 .../ode_rosenbrock_tests.jl | 0 .../ode_ssprk_tests.jl | 0 test/{ => algconvergence}/owrenzen_tests.jl | 0 .../partitioned_methods_tests.jl | 0 test/{ode => algconvergence}/rkc_tests.jl | 0 .../split_methods_tests.jl | 0 test/integrators/alg_events_tests.jl | 217 ++++++++++++++++ test/integrators/autodiff_events.jl | 24 ++ test/{ => integrators}/check_error.jl | 0 .../discrete_callback_dual_test.jl | 0 test/integrators/event_detection_tests.jl | 59 +++++ .../integrator_interface_tests.jl | 0 test/{ => integrators}/iterator_tests.jl | 0 .../ode_add_steps_tests.jl | 0 test/{ode => integrators}/ode_cache_tests.jl | 0 test/{ode => integrators}/ode_event_tests.jl | 0 test/{ => integrators}/reinit_test.jl | 0 test/{ => interface}/ad_tests.jl | 0 test/{ => interface}/complex_tests.jl | 0 .../composite_algorithm_test.jl | 0 .../composite_interpolation.jl | 0 test/{ => interface}/data_array_test.jl | 0 test/{ => interface}/destats_tests.jl | 0 .../differentiation_traits_tests.jl | 0 .../discrete_algorithm_test.jl | 0 test/{ => interface}/export_tests.jl | 0 test/{ => interface}/inf_handling.jl | 0 test/interface/jacobian_tests.jl | 37 +++ test/{ => interface}/mass_matrix_tests.jl | 0 test/{ => interface}/noindex_tests.jl | 0 test/{ode => interface}/ode_backwards_test.jl | 0 test/{ode => interface}/ode_initdt_tests.jl | 0 test/interface/ode_ndim_complex_tests.jl | 17 ++ test/interface/ode_numbertype_tests.jl | 37 +++ test/{ode => interface}/ode_saveat_tests.jl | 0 test/{ode => interface}/ode_saveidxs_tests.jl | 0 test/{ode => interface}/ode_tstops_tests.jl | 0 .../ode_twodimlinear_tests.jl | 0 test/{ => interface}/static_array_tests.jl | 0 .../stiffness_detection_test.jl | 0 test/{ => interface}/umodified_test.jl | 0 test/interface/units_tests.jl | 74 ++++++ test/{ => interface}/utility_tests.jl | 0 test/misc/init_dt_vs_dopri_tests.jl | 33 +++ test/misc/odeinterface_regression.jl | 78 ++++++ test/ode/ode_arrayarray_tests.jl | 11 - test/ode/progress_bar_tests.jl | 11 - test/regression/ode_adaptive_tests.jl | 19 ++ test/{ode => regression}/ode_dense_tests.jl | 0 test/regression/ode_inplace_tests.jl | 36 +++ .../ode_unrolled_comparison_tests.jl | 231 ++++++++++++++++++ .../psos_and_energy_conservation.jl | 128 ++++++++++ test/regression/time_derivative_test.jl | 44 ++++ test/runtests.jl | 120 ++++----- 65 files changed, 1151 insertions(+), 77 deletions(-) rename test/{ode => algconvergence}/adams_tests.jl (100%) rename test/{ => algconvergence}/linear_method_tests.jl (100%) rename test/{ => algconvergence}/linear_nonlinear_convergence_tests.jl (100%) rename test/{ => algconvergence}/linear_nonlinear_krylov_tests.jl (100%) rename test/{ode => algconvergence}/nordsieck_tests.jl (100%) rename test/{ode => algconvergence}/ode_convergence_tests.jl (100%) rename test/{ode => algconvergence}/ode_extrapolation_tests.jl (100%) create mode 100644 test/algconvergence/ode_feagin_tests.jl rename test/{ode => algconvergence}/ode_firk_tests.jl (100%) rename test/{ode => algconvergence}/ode_low_storage_rk_tests.jl (100%) rename test/{ode => algconvergence}/ode_rosenbrock_tests.jl (100%) rename test/{ode => algconvergence}/ode_ssprk_tests.jl (100%) rename test/{ => algconvergence}/owrenzen_tests.jl (100%) rename test/{ => algconvergence}/partitioned_methods_tests.jl (100%) rename test/{ode => algconvergence}/rkc_tests.jl (100%) rename test/{ => algconvergence}/split_methods_tests.jl (100%) create mode 100644 test/integrators/alg_events_tests.jl create mode 100644 test/integrators/autodiff_events.jl rename test/{ => integrators}/check_error.jl (100%) rename test/{ => integrators}/discrete_callback_dual_test.jl (100%) create mode 100644 test/integrators/event_detection_tests.jl rename test/{ => integrators}/integrator_interface_tests.jl (100%) rename test/{ => integrators}/iterator_tests.jl (100%) rename test/{ode => integrators}/ode_add_steps_tests.jl (100%) rename test/{ode => integrators}/ode_cache_tests.jl (100%) rename test/{ode => integrators}/ode_event_tests.jl (100%) rename test/{ => integrators}/reinit_test.jl (100%) rename test/{ => interface}/ad_tests.jl (100%) rename test/{ => interface}/complex_tests.jl (100%) rename test/{ => interface}/composite_algorithm_test.jl (100%) rename test/{ => interface}/composite_interpolation.jl (100%) rename test/{ => interface}/data_array_test.jl (100%) rename test/{ => interface}/destats_tests.jl (100%) rename test/{ => interface}/differentiation_traits_tests.jl (100%) rename test/{ => interface}/discrete_algorithm_test.jl (100%) rename test/{ => interface}/export_tests.jl (100%) rename test/{ => interface}/inf_handling.jl (100%) create mode 100644 test/interface/jacobian_tests.jl rename test/{ => interface}/mass_matrix_tests.jl (100%) rename test/{ => interface}/noindex_tests.jl (100%) rename test/{ode => interface}/ode_backwards_test.jl (100%) rename test/{ode => interface}/ode_initdt_tests.jl (100%) create mode 100644 test/interface/ode_ndim_complex_tests.jl create mode 100644 test/interface/ode_numbertype_tests.jl rename test/{ode => interface}/ode_saveat_tests.jl (100%) rename test/{ode => interface}/ode_saveidxs_tests.jl (100%) rename test/{ode => interface}/ode_tstops_tests.jl (100%) rename test/{ode => interface}/ode_twodimlinear_tests.jl (100%) rename test/{ => interface}/static_array_tests.jl (100%) rename test/{ => interface}/stiffness_detection_test.jl (100%) rename test/{ => interface}/umodified_test.jl (100%) create mode 100644 test/interface/units_tests.jl rename test/{ => interface}/utility_tests.jl (100%) create mode 100644 test/misc/init_dt_vs_dopri_tests.jl create mode 100644 test/misc/odeinterface_regression.jl delete mode 100644 test/ode/ode_arrayarray_tests.jl delete mode 100644 test/ode/progress_bar_tests.jl create mode 100644 test/regression/ode_adaptive_tests.jl rename test/{ode => regression}/ode_dense_tests.jl (100%) create mode 100644 test/regression/ode_inplace_tests.jl create mode 100644 test/regression/ode_unrolled_comparison_tests.jl create mode 100644 test/regression/psos_and_energy_conservation.jl create mode 100644 test/regression/time_derivative_test.jl diff --git a/.travis.yml b/.travis.yml index f86d4116be..f028c30cdd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ env: - GROUP=AlgConvergence_I - GROUP=AlgConvergence_II - GROUP=AlgConvergence_III + - GROUP=ODEInterface #matrix: # allow_failures: # - julia: nightly diff --git a/test/ode/adams_tests.jl b/test/algconvergence/adams_tests.jl similarity index 100% rename from test/ode/adams_tests.jl rename to test/algconvergence/adams_tests.jl diff --git a/test/linear_method_tests.jl b/test/algconvergence/linear_method_tests.jl similarity index 100% rename from test/linear_method_tests.jl rename to test/algconvergence/linear_method_tests.jl diff --git a/test/linear_nonlinear_convergence_tests.jl b/test/algconvergence/linear_nonlinear_convergence_tests.jl similarity index 100% rename from test/linear_nonlinear_convergence_tests.jl rename to test/algconvergence/linear_nonlinear_convergence_tests.jl diff --git a/test/linear_nonlinear_krylov_tests.jl b/test/algconvergence/linear_nonlinear_krylov_tests.jl similarity index 100% rename from test/linear_nonlinear_krylov_tests.jl rename to test/algconvergence/linear_nonlinear_krylov_tests.jl diff --git a/test/ode/nordsieck_tests.jl b/test/algconvergence/nordsieck_tests.jl similarity index 100% rename from test/ode/nordsieck_tests.jl rename to test/algconvergence/nordsieck_tests.jl diff --git a/test/ode/ode_convergence_tests.jl b/test/algconvergence/ode_convergence_tests.jl similarity index 100% rename from test/ode/ode_convergence_tests.jl rename to test/algconvergence/ode_convergence_tests.jl diff --git a/test/ode/ode_extrapolation_tests.jl b/test/algconvergence/ode_extrapolation_tests.jl similarity index 100% rename from test/ode/ode_extrapolation_tests.jl rename to test/algconvergence/ode_extrapolation_tests.jl diff --git a/test/algconvergence/ode_feagin_tests.jl b/test/algconvergence/ode_feagin_tests.jl new file mode 100644 index 0000000000..ed7fb47820 --- /dev/null +++ b/test/algconvergence/ode_feagin_tests.jl @@ -0,0 +1,51 @@ +using OrdinaryDiffEq, DiffEqBase, Test, DiffEqProblemLibrary, DiffEqDevTools, + Random + +using DiffEqProblemLibrary.ODEProblemLibrary: importodeproblems; importodeproblems() +import DiffEqProblemLibrary.ODEProblemLibrary: prob_ode_bigfloatlinear, + prob_ode_bigfloat2Dlinear, + prob_ode_2Dlinear + +## Convergence Testing +println("Convergence Test on Linear") + +testTol = 1 +prob = prob_ode_2Dlinear +println("Feagin RKs") +sol = solve(prob,Feagin10(),dt=dts[1]) +prob = remake(prob_ode_bigfloat2Dlinear,tspan=(0//1,1//1)) + +dts = (1//2) .^ (4:-1:2) +sim = test_convergence(dts,prob,Feagin10()) +@test abs(sim.𝒪est[:final]-8) < testTol #Lowered due to low test dt + +sim = test_convergence(dts,prob,Feagin12()) +@test abs(sim.𝒪est[:final]-12) < testTol + +sim = test_convergence(dts,prob,Feagin14()) +@test abs(sim.𝒪est[:final]-15) < testTol #Upped to 15 for test + +prob = prob_ode_bigfloatlinear + +dts = (1//2) .^ (6:-1:3) +sim = test_convergence(dts,prob,Feagin10()) +@test abs(sim.𝒪est[:final]-10) < testTol + +dts = (1//2) .^ (4:-1:2) +sim = test_convergence(dts,prob,Feagin12()) +@test abs(sim.𝒪est[:final]-12) < testTol + +sim = test_convergence(dts,prob,Feagin14()) +@test abs(sim.𝒪est[:final]-15) < testTol #Upped to 15 for test + +prob = prob_ode_bigfloat2Dlinear + +#compile +sol =solve(prob,Feagin10(),dt=dts[1]) +sol =solve(prob,Feagin12(),dt=dts[1]) +sol =solve(prob,Feagin14(),dt=dts[1]) + +#test +@time sol =solve(prob,Feagin10(),dt=dts[1]) +@time sol =solve(prob,Feagin12(),dt=dts[1]) +@time sol =solve(prob,Feagin14(),dt=dts[1]) diff --git a/test/ode/ode_firk_tests.jl b/test/algconvergence/ode_firk_tests.jl similarity index 100% rename from test/ode/ode_firk_tests.jl rename to test/algconvergence/ode_firk_tests.jl diff --git a/test/ode/ode_low_storage_rk_tests.jl b/test/algconvergence/ode_low_storage_rk_tests.jl similarity index 100% rename from test/ode/ode_low_storage_rk_tests.jl rename to test/algconvergence/ode_low_storage_rk_tests.jl diff --git a/test/ode/ode_rosenbrock_tests.jl b/test/algconvergence/ode_rosenbrock_tests.jl similarity index 100% rename from test/ode/ode_rosenbrock_tests.jl rename to test/algconvergence/ode_rosenbrock_tests.jl diff --git a/test/ode/ode_ssprk_tests.jl b/test/algconvergence/ode_ssprk_tests.jl similarity index 100% rename from test/ode/ode_ssprk_tests.jl rename to test/algconvergence/ode_ssprk_tests.jl diff --git a/test/owrenzen_tests.jl b/test/algconvergence/owrenzen_tests.jl similarity index 100% rename from test/owrenzen_tests.jl rename to test/algconvergence/owrenzen_tests.jl diff --git a/test/partitioned_methods_tests.jl b/test/algconvergence/partitioned_methods_tests.jl similarity index 100% rename from test/partitioned_methods_tests.jl rename to test/algconvergence/partitioned_methods_tests.jl diff --git a/test/ode/rkc_tests.jl b/test/algconvergence/rkc_tests.jl similarity index 100% rename from test/ode/rkc_tests.jl rename to test/algconvergence/rkc_tests.jl diff --git a/test/split_methods_tests.jl b/test/algconvergence/split_methods_tests.jl similarity index 100% rename from test/split_methods_tests.jl rename to test/algconvergence/split_methods_tests.jl diff --git a/test/integrators/alg_events_tests.jl b/test/integrators/alg_events_tests.jl new file mode 100644 index 0000000000..d0f450cff0 --- /dev/null +++ b/test/integrators/alg_events_tests.jl @@ -0,0 +1,217 @@ +using OrdinaryDiffEq, StaticArrays, Test + +# More ODE event tests, cf. #201, #199, #198, #197 +function test_callback_inplace(alg; kwargs...) + f = (du, u, p, t) -> @. du = u + cb = ContinuousCallback((u,t,int) -> u[1] - exp(1), terminate!) + prob = ODEProblem(f, [1.0], (0.0, 2.0), callback=cb) + sol = solve(prob, alg; kwargs...) + sol.u[end][1] ≈ exp(1) +end + +function test_callback_outofplace(alg; kwargs...) + f = (u, p, t) -> copy(u) + cb = ContinuousCallback((u,t,int) -> u[1] - exp(1), terminate!) + prob = ODEProblem(f, [1.0], (0.0, 2.0), callback=cb) + sol = solve(prob, alg; kwargs...) + sol.u[end][1] ≈ exp(1) +end + +function test_callback_scalar(alg; kwargs...) + f = (u, p, t) -> u + cb = ContinuousCallback((u,t,int) -> u - exp(1), terminate!) + prob = ODEProblem(f, 1.0, (0.0, 2.0), callback=cb) + sol = solve(prob, alg; kwargs...) + sol.u[end] ≈ exp(1) +end + +function test_callback_svector(alg; kwargs...) + f = (u, p, t) -> u + cb = ContinuousCallback((u,t,int) -> u[1] - exp(1), terminate!) + prob = ODEProblem(f, SVector(1.0), (0.0, 2.0), callback=cb) + sol = solve(prob, alg; kwargs...) + sol.u[end][1] ≈ exp(1) +end + +function test_callback_mvector(alg; kwargs...) + f = (u, p, t) -> copy(u) + cb = ContinuousCallback((u,t,int) -> u[1] - exp(1), terminate!) + prob = ODEProblem(f, MVector(1.0), (0.0, 2.0), callback=cb) + sol = solve(prob, alg; kwargs...) + sol.u[end][1] ≈ exp(1) +end + +println("inplace") +@test test_callback_inplace(BS3()) +@test test_callback_inplace(BS5()) +@test test_callback_inplace(SSPRK432()) +@test test_callback_inplace(SSPRK932()) +@test test_callback_inplace(OwrenZen3()) +@test test_callback_inplace(OwrenZen4()) +@test test_callback_inplace(OwrenZen5()) +@test test_callback_inplace(DP5()) +@test test_callback_inplace(DP8()) +@test test_callback_inplace(Feagin10()) +@test test_callback_inplace(Feagin12()) +@test test_callback_inplace(Feagin14()) +@test test_callback_inplace(TanYam7()) +@test test_callback_inplace(Tsit5()) +@test test_callback_inplace(TsitPap8()) +@test test_callback_inplace(Vern6()) +@test test_callback_inplace(Vern7()) +@test test_callback_inplace(Vern8()) +@test test_callback_inplace(Vern9()) +@test test_callback_inplace(Rosenbrock23()) +@test test_callback_inplace(Rosenbrock32()) +@test test_callback_inplace(AB3(); dt=0.1) +@test test_callback_inplace(ABM32(); dt=0.1) +@test test_callback_inplace(AB4(); dt=0.1) +@test test_callback_inplace(ABM43(); dt=0.1) +@test test_callback_inplace(AB5(); dt=0.1) +@test test_callback_inplace(ABM54(); dt=0.1) +@test test_callback_inplace(VCAB3()) +@test test_callback_inplace(VCAB4()) +@test test_callback_inplace(VCAB5()) +@test test_callback_inplace(VCABM3()) +@test test_callback_inplace(VCABM4()) +@test test_callback_inplace(VCABM5()) + +println("outofplace") +@test test_callback_outofplace(BS3()) +@test test_callback_outofplace(BS5()) +@test test_callback_outofplace(SSPRK432()) +@test test_callback_outofplace(SSPRK932()) +@test test_callback_outofplace(OwrenZen3()) +@test test_callback_outofplace(OwrenZen4()) +@test test_callback_outofplace(OwrenZen5()) +@test test_callback_outofplace(DP5()) +@test test_callback_outofplace(DP8()) +@test test_callback_outofplace(Feagin10()) +@test test_callback_outofplace(Feagin12()) +@test test_callback_outofplace(Feagin14()) +@test test_callback_outofplace(TanYam7()) +@test test_callback_outofplace(Tsit5()) +@test test_callback_outofplace(TsitPap8()) +@test test_callback_outofplace(Vern6()) +@test test_callback_outofplace(Vern7()) +@test test_callback_outofplace(Vern8()) +@test test_callback_outofplace(Vern9()) +@test test_callback_outofplace(Rosenbrock23()) +@test test_callback_outofplace(Rosenbrock32()) +@test test_callback_outofplace(AB3(); dt=0.1) +@test test_callback_outofplace(ABM32(); dt=0.1) +@test test_callback_outofplace(AB4(); dt=0.1) +@test test_callback_outofplace(ABM43(); dt=0.1) +@test test_callback_outofplace(AB5(); dt=0.1) +@test test_callback_outofplace(ABM54(); dt=0.1) +@test test_callback_outofplace(VCAB3()) +@test test_callback_outofplace(VCAB4()) +@test test_callback_outofplace(VCAB5()) +@test test_callback_outofplace(VCABM3()) +@test test_callback_outofplace(VCABM4()) +@test test_callback_outofplace(VCABM5()) + +println("scalar") +@test test_callback_scalar(BS3()) +@test test_callback_scalar(BS5()) +@test test_callback_scalar(SSPRK432()) +@test test_callback_scalar(SSPRK932()) +@test test_callback_scalar(OwrenZen3()) +@test test_callback_scalar(OwrenZen4()) +@test test_callback_scalar(OwrenZen5()) +@test test_callback_scalar(DP5()) +@test test_callback_scalar(DP8()) +@test test_callback_scalar(Feagin10()) +@test test_callback_scalar(Feagin12()) +@test test_callback_scalar(Feagin14()) +@test test_callback_scalar(TanYam7()) +@test test_callback_scalar(Tsit5()) +@test test_callback_scalar(TsitPap8()) +@test test_callback_scalar(Vern6()) +@test test_callback_scalar(Vern7()) +@test test_callback_scalar(Vern8()) +@test test_callback_scalar(Vern9()) +@test test_callback_scalar(Rosenbrock23()) +@test test_callback_scalar(Rosenbrock32()) +@test test_callback_scalar(AB3(); dt=0.1) +@test test_callback_scalar(ABM32(); dt=0.1) +@test test_callback_scalar(AB4(); dt=0.1) +@test test_callback_scalar(ABM43(); dt=0.1) +@test test_callback_scalar(AB5(); dt=0.1) +@test test_callback_scalar(ABM54(); dt=0.1) +@test test_callback_scalar(VCAB3()) +@test test_callback_scalar(VCAB4()) +@test test_callback_scalar(VCAB5()) +@test test_callback_scalar(VCABM3()) +@test test_callback_scalar(VCABM4()) +@test test_callback_scalar(VCABM5()) + +println("svector") +@test test_callback_svector(BS3()) +@test test_callback_svector(BS5()) +@test test_callback_svector(SSPRK432()) +@test test_callback_svector(SSPRK932()) +@test test_callback_svector(OwrenZen3()) +@test test_callback_svector(OwrenZen4()) +@test test_callback_svector(OwrenZen5()) +@test test_callback_svector(DP5()) +@test test_callback_svector(DP8()) +@test test_callback_svector(Feagin10()) +@test test_callback_svector(Feagin12()) +@test test_callback_svector(Feagin14()) +@test test_callback_svector(TanYam7()) +@test test_callback_svector(Tsit5()) +@test test_callback_svector(TsitPap8()) +@test test_callback_svector(Vern6()) +@test test_callback_svector(Vern7()) +@test test_callback_svector(Vern8()) +@test test_callback_svector(Vern9()) +@test test_callback_svector(Rosenbrock23()) +@test test_callback_svector(Rosenbrock32()) +@test test_callback_svector(AB3(); dt=0.1) +@test test_callback_svector(ABM32(); dt=0.1) +@test test_callback_svector(AB4(); dt=0.1) +@test test_callback_svector(ABM43(); dt=0.1) +@test test_callback_svector(AB5(); dt=0.1) +@test test_callback_svector(ABM54(); dt=0.1) +@test test_callback_svector(VCAB3()) +@test test_callback_svector(VCAB4()) +@test test_callback_svector(VCAB5()) +@test test_callback_svector(VCABM3()) +@test test_callback_svector(VCABM4()) +@test test_callback_svector(VCABM5()) + +println("mvector") +@test test_callback_mvector(BS3()) +@test test_callback_mvector(BS5()) +@test test_callback_mvector(SSPRK432()) +@test test_callback_mvector(SSPRK932()) +@test test_callback_mvector(OwrenZen3()) +@test test_callback_mvector(OwrenZen4()) +@test test_callback_mvector(OwrenZen5()) +@test test_callback_mvector(DP5()) +@test test_callback_mvector(DP8()) +@test test_callback_mvector(Feagin10()) +@test test_callback_mvector(Feagin12()) +@test test_callback_mvector(Feagin14()) +@test test_callback_mvector(TanYam7()) +@test test_callback_mvector(Tsit5()) +@test test_callback_mvector(TsitPap8()) +@test test_callback_mvector(Vern6()) +@test test_callback_mvector(Vern7()) +@test test_callback_mvector(Vern8()) +@test test_callback_mvector(Vern9()) +@test test_callback_mvector(Rosenbrock23()) +@test test_callback_mvector(Rosenbrock32()) +@test test_callback_mvector(AB3(); dt=0.1) +@test test_callback_mvector(ABM32(); dt=0.1) +@test test_callback_mvector(AB4(); dt=0.1) +@test test_callback_mvector(ABM43(); dt=0.1) +@test test_callback_mvector(AB5(); dt=0.1) +@test test_callback_mvector(ABM54(); dt=0.1) +@test test_callback_mvector(VCAB3()) +@test test_callback_mvector(VCAB4()) +@test test_callback_mvector(VCAB5()) +@test test_callback_mvector(VCABM3()) +@test test_callback_mvector(VCABM4()) +@test test_callback_mvector(VCABM5()) diff --git a/test/integrators/autodiff_events.jl b/test/integrators/autodiff_events.jl new file mode 100644 index 0000000000..87bfe80177 --- /dev/null +++ b/test/integrators/autodiff_events.jl @@ -0,0 +1,24 @@ +using DiffEqSensitivity, ParameterizedFunctions +using OrdinaryDiffEq, Calculus, Test + +f = @ode_def AAA begin + dx = -a + dy = b +end a b + +cb = ContinuousCallback((u,t,i) -> u[1], (integrator)->(println("Stopped.");integrator.p[2]=0.0)) +p = [2.0, 1.0] + +function test_f(p) + prob = ODEProblem(f,eltype(p).([1.0,0.0]),eltype(p).((0.0,1.0)),copy(p)) + solve(prob,Tsit5(),abstol=1e-14,reltol=1e-14,callback=cb,save_everystep=false)[end] +end +p = [2.0, 1.0] +findiff = Calculus.finite_difference_jacobian(test_f,p) +findiff + +using ForwardDiff +ad = ForwardDiff.jacobian(test_f,p) +ad + +@test ad ≈ findiff diff --git a/test/check_error.jl b/test/integrators/check_error.jl similarity index 100% rename from test/check_error.jl rename to test/integrators/check_error.jl diff --git a/test/discrete_callback_dual_test.jl b/test/integrators/discrete_callback_dual_test.jl similarity index 100% rename from test/discrete_callback_dual_test.jl rename to test/integrators/discrete_callback_dual_test.jl diff --git a/test/integrators/event_detection_tests.jl b/test/integrators/event_detection_tests.jl new file mode 100644 index 0000000000..9b9e19ee07 --- /dev/null +++ b/test/integrators/event_detection_tests.jl @@ -0,0 +1,59 @@ +using StaticArrays +using Parameters +using OrdinaryDiffEq +using Test + +@inbounds @inline function ż(z, p, t) + @unpack A, B, D = p + p₀, p₂ = z[1:2] + q₀, q₂ = z[3:4] + + return SVector{4}( + -A * q₀ - 3 * B / √2 * (q₂^2 - q₀^2) - D * q₀ * (q₀^2 + q₂^2), + -q₂ * (A + 3 * √2 * B * q₀ + D * (q₀^2 + q₂^2)), + A * p₀, + A * p₂ + ) +end + +condition(u, t, integrator) = u +affect!(integrator) = nothing +cbf(idx) = ContinuousCallback(condition, + affect!, nothing, save_positions=(false, true), idxs=idx) +z0 = SVector{4}(7.1989885061904335, -0.165912283356219, 0., -3.63534900748947) + +tspan=(0.,300.) +prob=ODEProblem(ż, z0, tspan, (A=1, B=0.55, D=0.4), callback=cbf(3)) +sol=solve(prob, Vern9(), abstol=1e-14, reltol=1e-14, + save_everystep=false, save_start=false, save_end=false, maxiters=1e6) + +@test length(sol) == 126 + +prob=ODEProblem(ż, z0, (0,400.), (A=1, B=0.55, D=0.4), callback=cbf(3)) +sol=solve(prob, Vern9(), abstol=1e-14, reltol=1e-14, save_everystep=false, save_start=false, save_end=false, maxiters=2e4) + +@test length(sol) == 148 + +prob=ODEProblem(ż, z0, (0,5000.), (A=1, B=0.55, D=0.4), callback=cbf(3)) +sol=solve(prob, Vern9(), abstol=1e-14, reltol=1e-14, save_everystep=false, save_start=false, save_end=false, maxiters=1e6) + +@test length(sol) == 1883 + +using ParameterizedFunctions +f = @ode_def BallBounce begin + dy = v + dv = -g +end g +function condition(u,t,integrator) # Event when event_f(u,t) == 0 + u[1] +end +function affect!(integrator) + integrator.u[2] = -integrator.u[2] +end +cb2 = ContinuousCallback(condition,affect!) +tspan = (0.0,100000.0) +u0 = [50.0,0.0] +p = 9.8 +prob = ODEProblem(f,u0,tspan,p) +sol = solve(prob,Tsit5(),callback=cb2) +@test minimum(sol') > -40 diff --git a/test/integrator_interface_tests.jl b/test/integrators/integrator_interface_tests.jl similarity index 100% rename from test/integrator_interface_tests.jl rename to test/integrators/integrator_interface_tests.jl diff --git a/test/iterator_tests.jl b/test/integrators/iterator_tests.jl similarity index 100% rename from test/iterator_tests.jl rename to test/integrators/iterator_tests.jl diff --git a/test/ode/ode_add_steps_tests.jl b/test/integrators/ode_add_steps_tests.jl similarity index 100% rename from test/ode/ode_add_steps_tests.jl rename to test/integrators/ode_add_steps_tests.jl diff --git a/test/ode/ode_cache_tests.jl b/test/integrators/ode_cache_tests.jl similarity index 100% rename from test/ode/ode_cache_tests.jl rename to test/integrators/ode_cache_tests.jl diff --git a/test/ode/ode_event_tests.jl b/test/integrators/ode_event_tests.jl similarity index 100% rename from test/ode/ode_event_tests.jl rename to test/integrators/ode_event_tests.jl diff --git a/test/reinit_test.jl b/test/integrators/reinit_test.jl similarity index 100% rename from test/reinit_test.jl rename to test/integrators/reinit_test.jl diff --git a/test/ad_tests.jl b/test/interface/ad_tests.jl similarity index 100% rename from test/ad_tests.jl rename to test/interface/ad_tests.jl diff --git a/test/complex_tests.jl b/test/interface/complex_tests.jl similarity index 100% rename from test/complex_tests.jl rename to test/interface/complex_tests.jl diff --git a/test/composite_algorithm_test.jl b/test/interface/composite_algorithm_test.jl similarity index 100% rename from test/composite_algorithm_test.jl rename to test/interface/composite_algorithm_test.jl diff --git a/test/composite_interpolation.jl b/test/interface/composite_interpolation.jl similarity index 100% rename from test/composite_interpolation.jl rename to test/interface/composite_interpolation.jl diff --git a/test/data_array_test.jl b/test/interface/data_array_test.jl similarity index 100% rename from test/data_array_test.jl rename to test/interface/data_array_test.jl diff --git a/test/destats_tests.jl b/test/interface/destats_tests.jl similarity index 100% rename from test/destats_tests.jl rename to test/interface/destats_tests.jl diff --git a/test/differentiation_traits_tests.jl b/test/interface/differentiation_traits_tests.jl similarity index 100% rename from test/differentiation_traits_tests.jl rename to test/interface/differentiation_traits_tests.jl diff --git a/test/discrete_algorithm_test.jl b/test/interface/discrete_algorithm_test.jl similarity index 100% rename from test/discrete_algorithm_test.jl rename to test/interface/discrete_algorithm_test.jl diff --git a/test/export_tests.jl b/test/interface/export_tests.jl similarity index 100% rename from test/export_tests.jl rename to test/interface/export_tests.jl diff --git a/test/inf_handling.jl b/test/interface/inf_handling.jl similarity index 100% rename from test/inf_handling.jl rename to test/interface/inf_handling.jl diff --git a/test/interface/jacobian_tests.jl b/test/interface/jacobian_tests.jl new file mode 100644 index 0000000000..fe10bda8bd --- /dev/null +++ b/test/interface/jacobian_tests.jl @@ -0,0 +1,37 @@ +using OrdinaryDiffEq, Test, ParameterizedFunctions + +d_alembert = @ode_def DAlembert begin + dx = a - b*x + c*t +end a b c +function d_alembert_analytic(u0,p,t::Number) + a,b,c = p + ebt = exp(b*t) + @. exp(-b*t)*(-a*b + c + ebt*(a*b + c*(b*t - 1)) + b^2 * u0)/(b^2) +end + +p = (1., 2., 3.) +u0 = [1.0] +tspan = (0.0,10.0) +prob = ODEProblem(ODEFunction(d_alembert.f, + jac = d_alembert.jac, + analytic=d_alembert_analytic), + u0,tspan,p) + +sol = solve(prob,Tsit5(),abstol=1e-10,reltol=1e-10) +@test sol.errors[:l2] < 1e-7 +sol = solve(prob,Rosenbrock23(),abstol=1e-8,reltol=1e-8) +@test sol.errors[:l2] < 1e-7 +sol = solve(prob,Rodas4(),abstol=1e-10,reltol=1e-10) +@test sol.errors[:l2] < 1e-7 +sol = solve(prob,Veldd4(),abstol=1e-10,reltol=1e-10) +@test sol.errors[:l2] < 1e-7 +sol = solve(prob,Rodas5(),abstol=1e-10,reltol=1e-10) +@test sol.errors[:l2] < 1e-7 +sol = solve(prob,TRBDF2(),abstol=1e-10,reltol=1e-10) +@test sol.errors[:l2] < 1e-7 +sol = solve(prob,Trapezoid(),abstol=1e-10,reltol=1e-10) +@test sol.errors[:l2] < 1e-7 +sol = solve(prob,KenCarp3(),abstol=1e-10,reltol=1e-10) +@test sol.errors[:l2] < 1e-7 +sol = solve(prob,KenCarp4(),abstol=1e-10,reltol=1e-10) +@test sol.errors[:l2] < 1e-7 diff --git a/test/mass_matrix_tests.jl b/test/interface/mass_matrix_tests.jl similarity index 100% rename from test/mass_matrix_tests.jl rename to test/interface/mass_matrix_tests.jl diff --git a/test/noindex_tests.jl b/test/interface/noindex_tests.jl similarity index 100% rename from test/noindex_tests.jl rename to test/interface/noindex_tests.jl diff --git a/test/ode/ode_backwards_test.jl b/test/interface/ode_backwards_test.jl similarity index 100% rename from test/ode/ode_backwards_test.jl rename to test/interface/ode_backwards_test.jl diff --git a/test/ode/ode_initdt_tests.jl b/test/interface/ode_initdt_tests.jl similarity index 100% rename from test/ode/ode_initdt_tests.jl rename to test/interface/ode_initdt_tests.jl diff --git a/test/interface/ode_ndim_complex_tests.jl b/test/interface/ode_ndim_complex_tests.jl new file mode 100644 index 0000000000..4cb6725013 --- /dev/null +++ b/test/interface/ode_ndim_complex_tests.jl @@ -0,0 +1,17 @@ +using OrdinaryDiffEq, DiffEqBase, Test + +## Start on Number +f = (u,p,t) -> (2u) +#(::typeof(f))(::Type{Val{:analytic}},u0,p,t) = u0*exp(t) +prob = ODEProblem(f,1/2+(1/4)im,(0.0,1.0)) + +sol = solve(prob,Tsit5(),dt=1/2^4) + +u0 = rand(ComplexF32,5,5,5) +f = (du,u,p,t) -> (du.=2u) +#(::typeof(f))(::Type{Val{:analytic}},u0,p,t) = u0*exp(t) +prob = ODEProblem(f,u0,(0.0,1.0)) + +sol = solve(prob,Tsit5(),dt=1/2^4) + +@test typeof(sol[1]) == Array{ComplexF32,3} diff --git a/test/interface/ode_numbertype_tests.jl b/test/interface/ode_numbertype_tests.jl new file mode 100644 index 0000000000..1512e3aa3d --- /dev/null +++ b/test/interface/ode_numbertype_tests.jl @@ -0,0 +1,37 @@ +using OrdinaryDiffEq, Test, Random +Random.seed!(100) +setprecision(400) + +f = (u,p,t) -> (2u) +#(::typeof(f))(::Type{Val{:analytic}},u0,p,t) = u0*exp(t) +prob = ODEProblem(f,1/2,(0.0,1.0)) + + +sol3 =solve(prob,RK4(),dt=1/2^(6),abstol=1,reltol=0) + +prob = ODEProblem(f,BigInt(1)//BigInt(2),(BigInt(0)//BigInt(1),BigInt(1)//BigInt(1))) + +integrator = init(prob,RK4(),dt=BigInt(1)//BigInt(2)^(6),abstol=1,reltol=0) + +sol =solve(prob,RK4(),dt=BigInt(1)//BigInt(2)^(6),abstol=1,reltol=0) +sol2 =solve(prob,RK4(),dt=BigInt(1)/BigInt(2)^(6),abstol=1,reltol=0) + +sol.u +sol2.u +sol3.u +@test eltype(sol.u) == Rational{BigInt} +@test eltype(sol2.u) == Rational{BigInt} +@test eltype(sol3.u) == Float64 + +sol4 =solve(prob,DP5(),dt=BigInt(1)//BigInt(2)^(3),adaptive=false) + +@test eltype(sol4.u) == Rational{BigInt} + +tabalg = ExplicitRK(tableau = constructDormandPrince(Rational{BigInt})) + +integrator = init(prob,tabalg,dt=BigInt(1)//BigInt(2)^(3),abstol=1,reltol=0,adaptive=false) +sol5 =solve(prob,tabalg,dt=BigInt(1)//BigInt(2)^(3),abstol=1,reltol=0,adaptive=false) + +@test typeof(sol5.u[end]) == Rational{BigInt} + +prob = ODEProblem(f,1/2+1/2im,(0.0,1.0)) diff --git a/test/ode/ode_saveat_tests.jl b/test/interface/ode_saveat_tests.jl similarity index 100% rename from test/ode/ode_saveat_tests.jl rename to test/interface/ode_saveat_tests.jl diff --git a/test/ode/ode_saveidxs_tests.jl b/test/interface/ode_saveidxs_tests.jl similarity index 100% rename from test/ode/ode_saveidxs_tests.jl rename to test/interface/ode_saveidxs_tests.jl diff --git a/test/ode/ode_tstops_tests.jl b/test/interface/ode_tstops_tests.jl similarity index 100% rename from test/ode/ode_tstops_tests.jl rename to test/interface/ode_tstops_tests.jl diff --git a/test/ode/ode_twodimlinear_tests.jl b/test/interface/ode_twodimlinear_tests.jl similarity index 100% rename from test/ode/ode_twodimlinear_tests.jl rename to test/interface/ode_twodimlinear_tests.jl diff --git a/test/static_array_tests.jl b/test/interface/static_array_tests.jl similarity index 100% rename from test/static_array_tests.jl rename to test/interface/static_array_tests.jl diff --git a/test/stiffness_detection_test.jl b/test/interface/stiffness_detection_test.jl similarity index 100% rename from test/stiffness_detection_test.jl rename to test/interface/stiffness_detection_test.jl diff --git a/test/umodified_test.jl b/test/interface/umodified_test.jl similarity index 100% rename from test/umodified_test.jl rename to test/interface/umodified_test.jl diff --git a/test/interface/units_tests.jl b/test/interface/units_tests.jl new file mode 100644 index 0000000000..e762276965 --- /dev/null +++ b/test/interface/units_tests.jl @@ -0,0 +1,74 @@ +using OrdinaryDiffEq, RecursiveArrayTools, Unitful +using LinearAlgebra + +@testset "Algorithms" begin +algs = [Euler(),Midpoint(),Heun(),Ralston(),RK4(),SSPRK104(),SSPRK22(),SSPRK33(), + SSPRK432(),BS3(),BS5(),DP5(),DP5Threaded(),DP8(),Feagin10(),Feagin12(), + Feagin14(),TanYam7(),Tsit5(),TsitPap8(),Vern6(),Vern7(),Vern8(),Vern9()] + +@testset "Scalar units" begin + f(y,p,t) = 0.5*y / 3.0u"s" + u0 = 1.0u"N" + prob = ODEProblem(f,u0,(0.0u"s",1.0u"s")) + + for alg in algs + if !(alg isa DP5Threaded) + @show alg + sol = solve(prob,alg,dt=1u"s"/10) + end + end + + sol = solve(prob,ExplicitRK()) +end + +@testset "2D units" begin + f(dy,y,p,t) = (dy .= 0.5.*y ./ 3.0u"s") + u0 = [1.0u"N" 2.0u"N" + 3.0u"N" 1.0u"N"] + prob = ODEProblem(f,u0,(0.0u"s",1.0u"s")) + + for alg in algs + @show alg + sol = solve(prob,alg,dt=1u"s"/10) + end + + sol = solve(prob,ExplicitRK()) +end +end + +@testset "Mixed units" begin +@testset "With ArrayPartition" begin + r0 = [1131.340, -2282.343, 6672.423]u"km" + v0 = [-5.64305, 4.30333, 2.42879]u"km/s" + Δt = 86400.0*365u"s" + μ = 398600.4418u"km^3/s^2" + rv0 = ArrayPartition(r0,v0) + + function f(dy, y, μ, t) + r = norm(y.x[1]) + dy.x[1] .= y.x[2] + dy.x[2] .= -μ .* y.x[1] / r^3 + end + + prob = ODEProblem(f,rv0,(0.0u"s",1.0u"s"),μ) + sol = solve(prob,Tsit5()) +end + +@testset "Without ArrayPartition" begin + # coordinate: u = [position, momentum] + # parameters: p = [mass, force constanst] + function f_harmonic!(du,u,p,t) + du[1] = u[2]/p[1] + du[2] = -p[2]*u[1] + end + + mass = 1.0u"kg" + k = 1.0u"N/m" + p = [mass, k] + + u0 = [1.0u"m", 0.0u"kg*m/s"] # initial values (position, momentum) + tspan = (0.0u"s", 10.0u"s") + prob = ODEProblem(f_harmonic!, u0, tspan, p) + sol = solve(prob, Tsit5()) +end +end diff --git a/test/utility_tests.jl b/test/interface/utility_tests.jl similarity index 100% rename from test/utility_tests.jl rename to test/interface/utility_tests.jl diff --git a/test/misc/init_dt_vs_dopri_tests.jl b/test/misc/init_dt_vs_dopri_tests.jl new file mode 100644 index 0000000000..b03ba3ec0a --- /dev/null +++ b/test/misc/init_dt_vs_dopri_tests.jl @@ -0,0 +1,33 @@ +using OrdinaryDiffEq,DiffEqProblemLibrary, DiffEqDevTools, Test, + ODEInterface, ODEInterfaceDiffEq + +using DiffEqProblemLibrary.ODEProblemLibrary: importodeproblems; importodeproblems() +import DiffEqProblemLibrary.ODEProblemLibrary: prob_ode_2Dlinear, prob_ode_linear + +prob = prob_ode_linear +sol = solve(prob,DP5()) + +sol2 = solve(prob,dopri5()) +@test sol.t[2] ≈ sol2.t[2] + +prob = prob_ode_2Dlinear +sol = solve(prob,DP5(),internalnorm=(u,t)->sqrt(sum(abs2,u))) + +# Change the norm due to error in dopri5.f +sol2 = solve(prob,dopri5()) +@test sol.t[2] ≈ sol2.t[2] + +prob = deepcopy(prob_ode_linear) +prob2 = ODEProblem(prob.f, prob.u0, (1.0,0.0),1.01) +sol = solve(prob2,DP5()) + +sol2 = solve(prob2,dopri5()) +@test sol.t[2] ≈ sol2.t[2] + +prob = deepcopy(prob_ode_2Dlinear) +prob2 = ODEProblem(prob.f, prob.u0, (1.0,0.0), 1.01) +sol = solve(prob2,DP5(),internalnorm=(u,t)->sqrt(sum(abs2,u))) + +# Change the norm due to error in dopri5.f +sol2 = solve(prob2,dopri5()) +@test sol.t[2] ≈ sol2.t[2] diff --git a/test/misc/odeinterface_regression.jl b/test/misc/odeinterface_regression.jl new file mode 100644 index 0000000000..ec68141d7f --- /dev/null +++ b/test/misc/odeinterface_regression.jl @@ -0,0 +1,78 @@ +using OrdinaryDiffEq, DiffEqDevTools, DiffEqBase, Test, + ODEInterface, ODEInterfaceDiffEq + +using DiffEqProblemLibrary.ODEProblemLibrary: importodeproblems; importodeproblems() +import DiffEqProblemLibrary.ODEProblemLibrary: prob_ode_bigfloatlinear, + prob_ode_linear, + prob_ode_2Dlinear, + prob_ode_bigfloat2Dlinear + +probbig = prob_ode_bigfloat2Dlinear +probnum = prob_ode_linear +probnumbig = prob_ode_bigfloatlinear +prob = prob_ode_2Dlinear + +dts = (1/2) .^ (7:-1:4) +testTol = .2 +bools = Vector{Bool}(undef,0) + +## DP5() +sim = test_convergence(dts,probnum,DP5()) +@test abs.(sim.𝒪est[:l2]-5) < testTol +sim = test_convergence(dts,prob,DP5()) +@test abs.(sim.𝒪est[:l2]-5) < testTol + +tabalg = ExplicitRK() +sol1 =solve(probnum,DP5(),dt=1/2^6,adaptive=false,save_everystep=false) +sol2 =solve(probnum,tabalg,dt=1/2^6,adaptive=false,save_everystep=false) + +@test sol1.u[end] - sol2.u[end] < 1e-10 + +sol1 =solve(prob,DP5(),dt=1/2^6,adaptive=false,save_everystep=false) +sol2 =solve(prob,tabalg,dt=1/2^6,adaptive=false,save_everystep=false) + +@test minimum(sol1.u[end] - sol2.u[end] .< 3e-10) + +sol1 =solve(probnum,DP5(),dt=1/2^6,beta2=0.04) +sol2 =solve(probnum,tabalg,dt=1/2^6,beta2=0.04) + + +# Should be identical +sol1 =solve(probnum,DP5()) +sol2 =solve(probnum,tabalg,beta2=0.04,beta1=0.17) +sol3 =solve(probnum,dopri5()) + +@test sol1.t ≈ sol2.t ≈ sol3.t + +sol1 =solve(prob,DP5(),dt=1/8) +sol2 =solve(prob,tabalg,beta2=0.04,beta1=0.17,dt=1/8) +sol3 =solve(prob,dopri5(),dt=1/8) + +@test sol1.t ≈ sol2.t ≈ sol3.t + +sol4 =solve(prob,DP5(),dt=1/8,calck=false) + +@test sol1.t == sol4.t + +### DP8() + +dts = (1/2) .^ (3:-1:1) +sim = test_convergence(dts,probnumbig,DP8()) +@test abs.(sim.𝒪est[:l2]-8) < testTol +sim = test_convergence(dts,probbig,DP8()) +@test abs.(sim.𝒪est[:l2]-8) < testTol + +sol1 =solve(probnum,DP8(),dt=1/2^6,adaptive=false,save_everystep=false) +sol2 =solve(probnum,DP8(),dt=1/2^6) + +# Should be identical +sol1 =solve(probnum,DP8()) +sol2 =solve(probnum,dop853()) + +@test sol1.t ≈ sol2.t + +# Should be identical +sol1 =solve(probbig,DP8(),dt=1/2^6) +sol2 =solve(probbig,dop853(),dt=1/2^6) + +@test sol1.t ≈ sol2.t diff --git a/test/ode/ode_arrayarray_tests.jl b/test/ode/ode_arrayarray_tests.jl deleted file mode 100644 index d3223c776f..0000000000 --- a/test/ode/ode_arrayarray_tests.jl +++ /dev/null @@ -1,11 +0,0 @@ -using OrdinaryDiffEq - -f = function (du,u,p,t) - du[1][1] = 0.85u[1][1] -end - -u = [[1]] - -prob = ODEProblem(f,u,(0.0,1.0)) - -sol = solve(prob,dt=1/2^4) diff --git a/test/ode/progress_bar_tests.jl b/test/ode/progress_bar_tests.jl deleted file mode 100644 index a4f5585c74..0000000000 --- a/test/ode/progress_bar_tests.jl +++ /dev/null @@ -1,11 +0,0 @@ -using OrdinaryDiffEq -using DiffEqProblemLibrary.ODEProblemLibrary: importodeproblems; importodeproblems() -import DiffEqProblemLibrary.ODEProblemLibrary: prob_ode_2Dlinear -prob = deepcopy(prob_ode_2Dlinear) -prob.tspan = (0.0,100.0) -## Solve and plot -sol =solve(prob,DP5();dt=1//2^(22),qmax=1.000005,progress=true, - maxiters=Int(1e7),progress_steps=Int(1e3),progressbar_name="Test") - -sol =solve(prob,DP5();dt=1//2^(22),qmax=1.000005,progress=false, - maxiters=Int(1e7),progressbar_name="Test") diff --git a/test/regression/ode_adaptive_tests.jl b/test/regression/ode_adaptive_tests.jl new file mode 100644 index 0000000000..ce84552c56 --- /dev/null +++ b/test/regression/ode_adaptive_tests.jl @@ -0,0 +1,19 @@ +using OrdinaryDiffEq,DiffEqProblemLibrary, DiffEqDevTools + +using DiffEqProblemLibrary.ODEProblemLibrary: importodeproblems; importodeproblems() +import DiffEqProblemLibrary.ODEProblemLibrary: prob_ode_2Dlinear, prob_ode_linear + +prob = prob_ode_2Dlinear +sol =solve(prob,Rosenbrock32(),dt=1/2^4) + +sol =solve(prob,ExplicitRK(tableau = constructBogakiShampine3()),dt=1/2^4) +val1 = maximum(abs.(sol.u[end] - sol.u_analytic[end])) + +sol2 =solve(prob,ExplicitRK(tableau = constructDormandPrince()),dt=1/2^4) +val2 = maximum(abs.(sol2.u[end] - sol2.u_analytic[end])) + +sol3 =solve(prob,ExplicitRK(tableau = constructRKF8(Float64)),dt=1/2^4) +val3 = maximum(abs.(sol3.u[end] - sol3.u_analytic[end])) + +@test length(sol.t)>length(sol2.t)>=length(sol3.t) +@test max(val1,val2,val3)<2e-3 diff --git a/test/ode/ode_dense_tests.jl b/test/regression/ode_dense_tests.jl similarity index 100% rename from test/ode/ode_dense_tests.jl rename to test/regression/ode_dense_tests.jl diff --git a/test/regression/ode_inplace_tests.jl b/test/regression/ode_inplace_tests.jl new file mode 100644 index 0000000000..55b41b3c9f --- /dev/null +++ b/test/regression/ode_inplace_tests.jl @@ -0,0 +1,36 @@ +using OrdinaryDiffEq, DiffEqProblemLibrary, Test + +using DiffEqProblemLibrary.ODEProblemLibrary: importodeproblems; importodeproblems() +import DiffEqProblemLibrary.ODEProblemLibrary: prob_ode_2Dlinear, + prob_ode_large2Dlinear, + prob_ode_linear, + prob_ode_2Dlinear_notinplace + +u0=rand(300,20).*ones(300,20)/2 +prob = prob_ode_2Dlinear_notinplace +prob2 = prob_ode_2Dlinear + +sol =solve(prob,Euler(),dt=1//2^(4),save_everystep=false) +sol =solve(prob2,Euler(),dt=1//2^(4),save_everystep=false) + +alloc1 = @allocated sol =solve(prob,Euler(),dt=1//2^(6),save_everystep=false) +alloc2 = @allocated sol2 =solve(prob2,Euler(),dt=1//2^(6),save_everystep=false) + +alloc1 = @allocated sol =solve(prob,Euler(),dt=1//2^(6),save_everystep=false) +alloc2 = @allocated sol2 =solve(prob2,Euler(),dt=1//2^(6),save_everystep=false) + +@test alloc2 <= alloc1 + +sol = solve(prob_ode_linear,Euler(),dt=1//2^(6),save_everystep=true) +sol2 = solve(prob_ode_linear,Euler(),sol[:],sol.t,sol.k;dt=1//2^(8),save_everystep=true) + +sol = solve(prob_ode_large2Dlinear,Euler(),dt=1//2^(6),save_everystep=true) +sol2 = solve(prob_ode_large2Dlinear,Euler(),sol[:],sol.t,sol.k;dt=1//2^(8),save_everystep=true) + +sol = solve(prob_ode_large2Dlinear,Euler(),dt=1//2^(6),save_everystep=true) +alloc1 = @allocated sol = solve(prob_ode_large2Dlinear,Euler(),dt=1//2^(8),save_everystep=true) +alloc2 = @allocated sol2 = solve(prob_ode_large2Dlinear,Euler(),sol[:],sol.t,sol.k;dt=1//2^(8),save_everystep=true) + +@test alloc2 <= alloc1 + +sol =solve(prob,Tsit5()) diff --git a/test/regression/ode_unrolled_comparison_tests.jl b/test/regression/ode_unrolled_comparison_tests.jl new file mode 100644 index 0000000000..15f8fe4975 --- /dev/null +++ b/test/regression/ode_unrolled_comparison_tests.jl @@ -0,0 +1,231 @@ +using OrdinaryDiffEq, DiffEqDevTools, DiffEqBase, Test + +using DiffEqProblemLibrary.ODEProblemLibrary: importodeproblems; importodeproblems() +import DiffEqProblemLibrary.ODEProblemLibrary: prob_ode_bigfloatlinear, + prob_ode_linear, + prob_ode_2Dlinear, + prob_ode_bigfloat2Dlinear + +probbig = prob_ode_bigfloat2Dlinear +probnum = prob_ode_linear +probnumbig = prob_ode_bigfloatlinear +prob = prob_ode_2Dlinear + +dts = (1/2) .^ (7:-1:4) +testTol = .2 +bools = Vector{Bool}(undef,0) + +### BS3() +sim = test_convergence(dts,probnum,BS3()) +@test abs.(sim.𝒪est[:l2]-3) < testTol +sim = test_convergence(dts,prob,BS3()) +@test abs.(sim.𝒪est[:l2]-3) < testTol + +tabalg = ExplicitRK(tableau=constructBogakiShampine3()) +sol1 =solve(probnum,BS3(),dt=1/2^1,adaptive=false,save_everystep=false) +sol2 =solve(probnum,tabalg,dt=1/2^1,adaptive=false,save_everystep=false) + +@test sol1.u[end] - sol2.u[end] < 1e-10 + +sol1 =solve(prob,BS3(),dt=1/2^1,adaptive=false,save_everystep=false) +sol2 =solve(prob,tabalg,dt=1/2^1,adaptive=false,save_everystep=false) + +@test minimum(sol1.u[end] - sol2.u[end] .< 1e-10) + +sol1 =solve(prob,tabalg,dt=1/2^6) +sol2 =solve(prob,BS3(),dt=1/2^6) + +@test length(sol1) == length(sol2) + +### BS5() +dts = (1/2) .^ (6:-1:3) +sim = test_convergence(dts,probnumbig,BS5()) +@test abs.(sim.𝒪est[:l2]-5) < testTol +sim = test_convergence(dts,probbig,BS5()) +@test abs.(sim.𝒪est[:l2]-5) < testTol + +tabalg = ExplicitRK(tableau=constructBogakiShampine5()) +sol1 =solve(probnum,BS5(),dt=1/2^6,adaptive=false,save_everystep=false) +sol2 =solve(probnum,tabalg,dt=1/2^6,adaptive=false,save_everystep=false) + +@test sol1.u[end] - sol2.u[end] < 1e-10 + +sol1 =solve(prob,BS5(),dt=1/2^3,adaptive=false,save_everystep=false) +sol2 =solve(prob,tabalg,dt=1/2^3,adaptive=false,save_everystep=false) + +@test minimum(sol1.u[end] - sol2.u[end] .< 1e-10) + +sol1 =solve(prob,tabalg,dt=1/2^6) +sol2 =solve(prob,BS5(),dt=1/2^6) + +@test length(sol1) <= length(sol2) # Dual error estimators is more strict + +### Tsit5() + +dts = (1/2) .^ (7:-1:3) +sim = test_convergence(dts,probnum,Tsit5()) +@test abs.(sim.𝒪est[:l2]-5) < testTol+.1 +sim = test_convergence(dts,prob,Tsit5()) +@test abs.(sim.𝒪est[:l2]-5) < testTol+.1 + +tabalg = ExplicitRK(tableau=constructTsitouras5()) +sol1 =solve(probnum,Tsit5(),dt=1/2^6,adaptive=false,save_everystep=false) +sol2 =solve(probnum,tabalg,dt=1/2^6,adaptive=false,save_everystep=false) + +@test sol1.u[end] - sol2.u[end] < 1e-10 + +sol1 =solve(prob,Tsit5(),dt=1/2^3,adaptive=false,save_everystep=false) +sol2 =solve(prob,tabalg,dt=1/2^3,adaptive=false,save_everystep=false) + +@test minimum(sol1.u[end] - sol2.u[end] .< 1e-10) + +sol1 =solve(prob,tabalg,dt=1/2^6) +sol2 =solve(prob,Tsit5(),dt=1/2^6) + +@test length(sol1) == length(sol2) + +### Vern6() + +dts = (1/2) .^ (8:-1:5) +sim = test_convergence(dts,probnumbig,Vern6()) +@test abs.(sim.𝒪est[:l2]-6) < testTol +sim = test_convergence(dts,probbig,Vern6()) +@test abs.(sim.𝒪est[:l2]-6) < testTol + +tabalg = ExplicitRK(tableau=constructVernerEfficient6(BigFloat)) +sol1 =solve(probnumbig,Vern6(),dt=1/2^6,adaptive=false,save_everystep=false) +sol2 =solve(probnumbig,tabalg,dt=1/2^6,adaptive=false,save_everystep=false) + +@test sol1.u[end] - sol2.u[end] < 1e-10 + +sol1 =solve(probbig,Vern6(),dt=1/2^3,adaptive=false,save_everystep=false) +sol2 =solve(probbig,tabalg,dt=1/2^3,adaptive=false,save_everystep=false) + +@test minimum(sol1.u[end] - sol2.u[end] .< 1e-10) + +sol1 =solve(probbig,tabalg,dt=1/2^6) +sol2 =solve(probbig,Vern6(),dt=1/2^6) + +@test length(sol1) == length(sol2) + +### Vern7() + +dts = (1/2) .^ (6:-1:3) +sim = test_convergence(dts,probnumbig,Vern7(),dense_errors=true) +@test abs.(sim.𝒪est[:l2]-7) < testTol +sim = test_convergence(dts,probbig,Vern7(),dense_errors=true) +@test abs.(sim.𝒪est[:l2]-7) < testTol + +tabalg = ExplicitRK(tableau=constructVerner7(BigFloat)) +sol1 =solve(probnumbig,Vern7(),dt=1/2^6,adaptive=false,save_everystep=false) +sol2 =solve(probnumbig,tabalg,dt=1/2^6,adaptive=false,save_everystep=false) + +@test sol1.u[end] - sol2.u[end] < 1e-10 + +sol1 =solve(probbig,Vern7(),dt=1/2^3,adaptive=false,save_everystep=false) +sol2 =solve(probbig,tabalg,dt=1/2^3,adaptive=false,save_everystep=false) + +@test minimum(sol1.u[end] - sol2.u[end] .< 1e-10) + +sol1 =solve(probbig,tabalg,dt=1/2^6) +sol2 =solve(probbig,Vern7(),dt=1/2^6) + +@test length(sol1) == length(sol2) + +### TanYam7() + +dts = (1/2) .^ (6:-1:3) +sim = test_convergence(dts,probnumbig,TanYam7()) +@test abs.(sim.𝒪est[:l2]-7) < testTol +sim = test_convergence(dts,probbig,TanYam7()) +@test abs.(sim.𝒪est[:l2]-7) < testTol + +tabalg = ExplicitRK(tableau=constructTanakaYamashitaEfficient7(Float64)) +sol1 =solve(probnum,TanYam7(),dt=1/2^6,adaptive=false,save_everystep=false) +sol2 =solve(probnum,tabalg,dt=1/2^6,adaptive=false,save_everystep=false) + +@test sol1.u[end] - sol2.u[end] < 2e-9 + +tabalg = ExplicitRK(tableau=constructTanakaYamashitaEfficient7(BigFloat)) +sol1 =solve(probbig,TanYam7(),dt=1/2^3,adaptive=false,save_everystep=false) +sol2 =solve(probbig,tabalg,dt=1/2^3,adaptive=false,save_everystep=false) + +@test minimum(sol1.u[end] - sol2.u[end] .< 1e-10) + +sol1 =solve(prob,tabalg,dt=1/2^6) +sol2 =solve(prob,TanYam7(),dt=1/2^6) + +@test length(sol1) == length(sol2) + +### Vern8() + +dts = (1/2) .^ (6:-1:3) +sim = test_convergence(dts,probnumbig,Vern8(),dense_errors=true) +@test abs.(sim.𝒪est[:l2]-8) < testTol +sim = test_convergence(dts,probbig,Vern8(),dense_errors=true) +@test abs.(sim.𝒪est[:l2]-8) < testTol + +tabalg = ExplicitRK(tableau=constructVerner8(BigFloat)) +sol1 =solve(probnumbig,Vern8(),dt=1/2^6,adaptive=false,save_everystep=false) +sol2 =solve(probnumbig,tabalg,dt=1/2^6,adaptive=false,save_everystep=false) + +@test sol1.u[end] - sol2.u[end] < 1e-10 + +sol1 =solve(probbig,Vern8(),dt=1/2^3,adaptive=false,save_everystep=false) +sol2 =solve(probbig,tabalg,dt=1/2^3,adaptive=false,save_everystep=false) + +@test minimum(sol1.u[end] - sol2.u[end] .< 1e-10) + +sol1 =solve(prob,tabalg,dt=1/2^6) +sol2 =solve(prob,Vern8(),dt=1/2^6) + +@test length(sol1) == length(sol2) + +### TsitPap8() + +dts = (1/2) .^ (6:-1:3) +sim = test_convergence(dts,probnumbig,TsitPap8()) +@test abs.(sim.𝒪est[:l2]-8) < testTol +sim = test_convergence(dts,probbig,TsitPap8()) +@test abs.(sim.𝒪est[:l2]-8) < testTol + +tabalg = ExplicitRK(tableau=constructTsitourasPapakostas8(BigFloat)) +sol1 =solve(probnumbig,TsitPap8(),dt=1/2^6,adaptive=false,save_everystep=false) +sol2 =solve(probnumbig,tabalg,dt=1/2^6,adaptive=false,save_everystep=false) + +@test sol1.u[end] - sol2.u[end] < 1e-10 + +sol1 =solve(probbig,TsitPap8(),dt=1/2^3,adaptive=false,save_everystep=false) +sol2 =solve(probbig,tabalg,dt=1/2^3,adaptive=false,save_everystep=false) + +@test minimum(sol1.u[end] - sol2.u[end] .< 1e-10) + +sol1 =solve(prob,tabalg,dt=1/2^6) +sol2 =solve(prob,TsitPap8(),dt=1/2^6) + +@test length(sol1) == length(sol2) + +### Vern9() + +dts = (1/2) .^ (6:-1:3) +sim = test_convergence(dts,probnumbig,Vern9(),dense_errors=true) +@test abs.(sim.𝒪est[:l2]-9) < testTol +sim = test_convergence(dts,probbig,Vern9(),dense_errors=true) +@test abs.(sim.𝒪est[:l2]-9) < testTol + + +tabalg = ExplicitRK(tableau=constructVernerEfficient9(BigFloat)) +sol1 =solve(probnumbig,Vern9(),dt=1/2^6,adaptive=false,save_everystep=false) +sol2 =solve(probnumbig,tabalg,dt=1/2^6,adaptive=false,save_everystep=false) + +@test abs.(sol1.u[end] - sol2.u[end]) < 1e-15 + +sol1 =solve(probbig,Vern9(),dt=1/2^3,adaptive=false,save_everystep=false) +sol2 =solve(probbig,tabalg,dt=1/2^3,adaptive=false,save_everystep=false) + +@test minimum(abs.(sol1.u[end] - sol2.u[end]) .< 1e-15) + +sol1 =solve(probbig,tabalg,dt=1/2^6) +sol2 =solve(probbig,Vern9(),dt=1/2^6) + +@test length(sol1) == length(sol2) diff --git a/test/regression/psos_and_energy_conservation.jl b/test/regression/psos_and_energy_conservation.jl new file mode 100644 index 0000000000..f42428c61f --- /dev/null +++ b/test/regression/psos_and_energy_conservation.jl @@ -0,0 +1,128 @@ +using OrdinaryDiffEq, Test, Random, LinearAlgebra, SparseArrays + +# Parameters +Nc = 22 +η = 1.0 +κ = 1.0 +T = (0.0,100.0) + +# Matrix definitions +A = sparse(diagm(1 => sqrt.(Complex[1:Nc;]))) +H = η*(A + A') - 1.0im*κ*A'*A + +u0 = zeros(ComplexF64, Nc+1) +u0[1] = 1.0 +function f_psos(du, u, t, p) + du .= -1.0im*H*u +end + +# Callback +rng = MersenneTwister(rand(UInt)) +jumpnorm = Ref(rand(rng)) +djumpnorm(x::Vector{ComplexF64}, t, integrator) = norm(x)^2 - (1-jumpnorm[]) +function dojump(integrator) + x = integrator.u + t = integrator.t + + x .= normalize(A*x) + jumpnorm[] = rand(rng) +end + +cb = ContinuousCallback(djumpnorm,dojump) + +prob = ODEProblem{true}(f_psos,u0,T) + +sol_tot = [] +Ntraj = 100 +for i=1:Ntraj + rng = MersenneTwister(rand(UInt)) + # Tweaking tolerances and dtmax also is not reliable + sol = solve(prob,DP5(),save_everystep=true,callback=cb, + abstol=1e-8,reltol=1e-6,dtmax=10) + push!(sol_tot, sol) +end + +# This number has to be η^2/κ^2 in steady-state; all trajectories should converge there +n = [[norm(A * normalize(s.u[j]))^2 for j=1:length(s.t)] for s=sol_tot] + +@test all(η^2/κ^2 .≈ [k[end] for k in n]) + +#= +using Plots +gr() + +p1 = plot(sol_tot[1].t, n[1], lw = 2) +for i=2:Ntraj + plot!(p1,sol_tot[i].t, n[i]) +end + +p2 = plot(sol_tot[1].t, norm.(sol_tot[1].u).^2) +for i=2:Ntraj + plot!(p2,sol_tot[i].t, norm.(sol_tot[i].u).^2) +end +=# + +using OrdinaryDiffEq, DiffEqCallbacks, Test + +# Initial state +u0=[0, -0.25, 0.42081, 0] + +function hheom!(du,u,p,t) + du[1] = u[3] + du[2] = u[4] + du[3] = -u[1] - 2u[1]*u[2] + du[4] = -u[2] - (u[1]^2 - u[2]^2) + return nothing +end + +@inline Vhh(q1, q2) = 1//2 * (q1^2 + q2^2 + 2q1^2 * q2 - 2//3 * q2^3) +@inline Thh(p1, p2) = 1//2 * (p1^2 + p2^2) +@inline Hhh(q1, q2, p1, p2) = Thh(p1, p2) + Vhh(q1, q2) +@inline Hhh(u::AbstractVector) = Hhh(u...) + +# Energy +const E = Hhh(u0) + +function ghh(resid, u) + resid[1] = Hhh(u[1],u[2],u[3],u[4]) - E + resid[2:4] .= 0 +end + +# energy conserving callback: +# important to use save = false, I dont want rescaling points +cb = ManifoldProjection(ghh, nlopts=Dict(:ftol=>1e-13), save = false) + +# Callback for Poincare surface of section +function psos_callback(j, direction = +1, offset::Real = 0, + callback_kwargs = Dict{Symbol, Any}(:abstol=>1e-9)) + + # Prepare callback: + s = sign(direction) + cond = (u,t,integrator) -> s*(u - offset) + affect! = (integrator) -> nothing + + cb = DiffEqBase.ContinuousCallback(cond, nothing, affect!; callback_kwargs..., + save_positions = (true,false), idxs = j) +end + +# with this callback, the saved values of variable 1 should be zero +poincarecb = psos_callback(1) + +totalcb = CallbackSet(poincarecb, cb) + +prob = ODEProblem(hheom!, u0, (0.0, 100.0), callback = totalcb) + +extra_kw = Dict(:save_start=>false, :save_end=>false) +DEFAULT_DIFFEQ_KWARGS = Dict{Symbol, Any}(:abstol => 1e-9, :reltol => 1e-9) + +sol = solve(prob, Vern9(); extra_kw..., DEFAULT_DIFFEQ_KWARGS..., save_everystep = false) + +Es = [Hhh(sol[:, i]) for i in 1:length(sol)] +Eerror = maximum(@. abs(E - Es)) + +a = sol[1, :] + +@test Eerror < 1e-10 +for el in a + @test abs(el) < 1e-10 +end diff --git a/test/regression/time_derivative_test.jl b/test/regression/time_derivative_test.jl new file mode 100644 index 0000000000..04e0ee243e --- /dev/null +++ b/test/regression/time_derivative_test.jl @@ -0,0 +1,44 @@ +using OrdinaryDiffEq, Test + +function time_derivative(du,u,p,t) + du[1] = -t +end +function time_derivative_analytic(u0,p,t) + u0 .- t.^2 ./ 2 +end + +ff_time_derivative = ODEFunction(time_derivative, + analytic=time_derivative_analytic) +u0 = [1.0] +tspan = (0.0,1.0) +prob = ODEProblem(ff_time_derivative,u0,tspan) + +sol = solve(prob,Rosenbrock32(),reltol=1e-9,abstol=1e-9) +@test sol.errors[:final] < 1e-5 +sol = solve(prob,Rosenbrock23()) +@test sol.errors[:final] < 1e-10 +sol = solve(prob,Rodas4()) +@test sol.errors[:final] < 1e-10 +sol = solve(prob,Rodas5()) +@test sol.errors[:final] < 1e-10 +sol = solve(prob,Veldd4()) +@test sol.errors[:final] < 1e-10 +sol = solve(prob,KenCarp4()) +@test sol.errors[:final] < 1e-10 +sol = solve(prob,TRBDF2()) +@test sol.errors[:final] < 1e-10 + + +sol = solve(prob,GenericImplicitEuler(),dt=1/10) +@test sol.errors[:final] < 1e-1 +sol = solve(prob,GenericTrapezoid(),dt=1/10) +@test sol.errors[:final] < 1e-12 +sol = solve(prob,Euler(),dt=1/100) +@test sol.errors[:final] < 6e-3 + +for alg in CACHE_TEST_ALGS + sol = solve(prob,alg,dt=1/10) + if !(typeof(alg) <: Euler) + @test sol.errors[:final] < 4e-14 + end +end diff --git a/test/runtests.jl b/test/runtests.jl index 717efc3b71..d455af9297 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -13,75 +13,85 @@ is_APPVEYOR = ( Sys.iswindows() && haskey(ENV,"APPVEYOR") ) @time begin if group == "All" || group == "Interface" - @time @safetestset "Discrete Algorithm Tests" begin include("discrete_algorithm_test.jl") end - @time @safetestset "Tstops Tests" begin include("ode/ode_tstops_tests.jl") end - @time @safetestset "Backwards Tests" begin include("ode/ode_backwards_test.jl") end - @time @safetestset "Initdt Tests" begin include("ode/ode_initdt_tests.jl") end - @time @safetestset "Mass Matrix Tests" begin include("mass_matrix_tests.jl") end - @time @safetestset "Differentiation Trait Tests" begin include("differentiation_traits_tests.jl") end - @time @safetestset "Inf Tests" begin include("inf_handling.jl") end - @time @safetestset "saveat Tests" begin include("ode/ode_saveat_tests.jl") end - @time @safetestset "save_idxs Tests" begin include("ode/ode_saveidxs_tests.jl") end - @time @safetestset "Static Array Tests" begin include("static_array_tests.jl") end - @time @safetestset "Data Array Tests" begin include("data_array_test.jl") end - @time @safetestset "u_modifed Tests" begin include("umodified_test.jl") end - @time @safetestset "Composite Algorithm Tests" begin include("composite_algorithm_test.jl") end - @time @safetestset "Complex Tests" begin include("complex_tests.jl") end - @time @safetestset "Stiffness Detection Tests" begin include("stiffness_detection_test.jl") end - @time @safetestset "Composite Interpolation Tests" begin include("composite_interpolation.jl") end - @time @safetestset "Export tests" begin include("export_tests.jl") end - @time @safetestset "Derivative Utilities Tests" begin include("utility_tests.jl") end - @time @safetestset "Discrete Callback Dual Tests" begin include("discrete_callback_dual_test.jl") end - @time @safetestset "DEStats Tests" begin include("destats_tests.jl") end - @time @safetestset "AD Tests" begin include("ad_tests.jl") end - @time @safetestset "No Index Tests" begin include("noindex_tests.jl") end + @time @safetestset "Discrete Algorithm Tests" begin include("interface/discrete_algorithm_test.jl") end + @time @safetestset "Tstops Tests" begin include("interface/ode_tstops_tests.jl") end + @time @safetestset "Backwards Tests" begin include("interface/ode_backwards_test.jl") end + @time @safetestset "Initdt Tests" begin include("interface/ode_initdt_tests.jl") end + @time @safetestset "Linear Tests" begin include("interface/ode_twodimlinear_tests.jl") end + @time @safetestset "Mass Matrix Tests" begin include("interface/mass_matrix_tests.jl") end + @time @safetestset "Differentiation Trait Tests" begin include("interface/differentiation_traits_tests.jl") end + @time @safetestset "Inf Tests" begin include("interface/inf_handling.jl") end + @time @safetestset "Jacobian Tests" begin include("interface/jacobian_tests.jl") end + @time @safetestset "saveat Tests" begin include("interface/ode_saveat_tests.jl") end + @time @safetestset "save_idxs Tests" begin include("interface/ode_saveidxs_tests.jl") end + @time @safetestset "Static Array Tests" begin include("interface/static_array_tests.jl") end + @time @safetestset "Data Array Tests" begin include("interface/data_array_test.jl") end + @time @safetestset "u_modifed Tests" begin include("interface/umodified_test.jl") end + @time @safetestset "Composite Algorithm Tests" begin include("interface/composite_algorithm_test.jl") end + @time @safetestset "Complex Tests" begin include("interface/complex_tests.jl") end + @time @safetestset "Ndim Complex Tests" begin include("interface/ndim_complex_tests.jl") end + @time @safetestset "Number Type Tests" begin include("interface/ode_numbertype_tests.jl") end + @time @safetestset "Stiffness Detection Tests" begin include("interface/stiffness_detection_test.jl") end + @time @safetestset "Composite Interpolation Tests" begin include("interface/composite_interpolation.jl") end + @time @safetestset "Export tests" begin include("interface/export_tests.jl") end + @time @safetestset "Derivative Utilities Tests" begin include("interface/utility_tests.jl") end + @time @safetestset "DEStats Tests" begin include("interface/destats_tests.jl") end + @time @safetestset "AD Tests" begin include("interface/ad_tests.jl") end + @time @safetestset "Autodiff Events Tests" begin include("interface/autodiff_events.jl") end + @time @safetestset "No Index Tests" begin include("interface/noindex_tests.jl") end + @time @safetestset "Units Tests" begin include("interface/units_tests.jl") end end if group == "All" || group == "Integrators" - @time @safetestset "Reinit Tests" begin include("reinit_test.jl") end - @time @safetestset "Events Tests" begin include("ode/ode_event_tests.jl") end - @time @safetestset "Cache Tests" begin include("ode/ode_cache_tests.jl") end - @time @safetestset "Iterator Tests" begin include("iterator_tests.jl") end - @time @safetestset "Integrator Interface Tests" begin include("integrator_interface_tests.jl") end - @time @safetestset "Add Steps Tests" begin include("ode/ode_add_steps_tests.jl") end - @time @safetestset "Error Check Tests" begin include("check_error.jl") end + @time @safetestset "Reinit Tests" begin include("integrator/reinit_test.jl") end + @time @safetestset "Events Tests" begin include("integrator/ode_event_tests.jl") end + @time @safetestset "Event Detection Tests" begin include("integrator/event_detection_tests.jl") end + @time @safetestset "Alg Events Tests" begin include("integrator/alg_events_tests.jl") end + @time @safetestset "Cache Tests" begin include("integrator/ode_cache_tests.jl") end + @time @safetestset "Discrete Callback Dual Tests" begin include("integrator/discrete_callback_dual_test.jl") end + @time @safetestset "Iterator Tests" begin include("integrator/iterator_tests.jl") end + @time @safetestset "Integrator Interface Tests" begin include("integrator/integrator_interface_tests.jl") end + @time @safetestset "Add Steps Tests" begin include("integrator/ode_add_steps_tests.jl") end + @time @safetestset "Error Check Tests" begin include("integrator/check_error.jl") end end if !is_APPVEYOR && ( group == "All" || group == "Regression" ) - @time @safetestset "Linear Tests" begin include("ode/ode_twodimlinear_tests.jl") end - @time @safetestset "Dense Tests" begin include("ode/ode_dense_tests.jl") end + @time @safetestset "Dense Tests" begin include("regression/ode_dense_tests.jl") end + @time @safetestset "Inplace Tests" begin include("regression/ode_inplace_tests.jl") end + @time @safetestset "Adaptive Tests" begin include("regression/ode_adaptive_tests.jl") end + @time @safetestset "PSOS Energy Conservation Tests" begin include("regression/psos_and_energy_conservation.jl") end + @time @safetestset "Time derivative Tests" begin include("regression/time_derivative_test.jl") end + @time @testset "Unrolled Tests" begin include("regression/ode_unrolled_comparison_tests.jl") end end if !is_APPVEYOR && ( group == "All" || group == "AlgConvergence_I" ) - # ~ 250 s - @time @safetestset "Partitioned Methods Tests" begin include("partitioned_methods_tests.jl") end - # ~ 400 s - @time @safetestset "Convergence Tests" begin include("ode/ode_convergence_tests.jl") end - # ~ 2 s - @time @safetestset "Adams Variable Coefficients Tests" begin include("ode/adams_tests.jl") end - # ~ 50 s - @time @safetestset "Nordsieck Tests" begin include("ode/nordsieck_tests.jl") end - @time @safetestset "Linear Methods Tests" begin include("linear_method_tests.jl") end - @time @safetestset "Extrapolation Tests" begin include("ode/ode_extrapolation_tests.jl") end + @time @safetestset "Partitioned Methods Tests" begin include("algconvergence/partitioned_methods_tests.jl") end + @time @safetestset "Convergence Tests" begin include("algconvergence/ode_convergence_tests.jl") end + @time @safetestset "Adams Variable Coefficients Tests" begin include("algconvergence/adams_tests.jl") end + @time @safetestset "Nordsieck Tests" begin include("algconvergence/nordsieck_tests.jl") end + @time @safetestset "Linear Methods Tests" begin include("algconvergence/linear_method_tests.jl") end + @time @safetestset "Extrapolation Tests" begin include("algconvergence/ode_extrapolation_tests.jl") end end if !is_APPVEYOR && ( group == "All" || group == "AlgConvergence_II" ) - @time @safetestset "SSPRK Tests" begin include("ode/ode_ssprk_tests.jl") end - @time @safetestset "Low Storage RK Tests" begin include("ode/ode_low_storage_rk_tests.jl") end - # ~ 25 s - @time @safetestset "OwrenZen Tests" begin include("owrenzen_tests.jl") end - @time @safetestset "Runge-Kutta-Chebyshev Tests" begin include("ode/rkc_tests.jl") end + @time @safetestset "SSPRK Tests" begin include("algconvergence/ode_ssprk_tests.jl") end + @time @safetestset "Low Storage RK Tests" begin include("algconvergence/ode_low_storage_rk_tests.jl") end + @time @safetestset "OwrenZen Tests" begin include("algconvergence/owrenzen_tests.jl") end + @time @safetestset "Runge-Kutta-Chebyshev Tests" begin include("algconvergence/rkc_tests.jl") end end if !is_APPVEYOR && ( group == "All" || group == "AlgConvergence_III" ) - # ~ 110 s - @time @safetestset "Split Methods Tests" begin include("split_methods_tests.jl") end - # ~ 550 s - @time @safetestset "Rosenbrock Tests" begin include("ode/ode_rosenbrock_tests.jl") end - @time @safetestset "FIRK Tests" begin include("ode/ode_firk_tests.jl") end - # ~ 40 s - @time @safetestset "Linear-Nonlinear Methods Tests" begin include("linear_nonlinear_convergence_tests.jl") end - # ~ 140 s - @time @safetestset "Linear-Nonlinear Krylov Methods Tests" begin include("linear_nonlinear_krylov_tests.jl") end + @time @safetestset "Split Methods Tests" begin include("algconvergence/split_methods_tests.jl") end + @time @safetestset "Rosenbrock Tests" begin include("algconvergence/ode_rosenbrock_tests.jl") end + @time @safetestset "FIRK Tests" begin include("algconvergence/ode_firk_tests.jl") end + @time @safetestset "Linear-Nonlinear Methods Tests" begin include("algconvergence/linear_nonlinear_convergence_tests.jl") end + @time @safetestset "Linear-Nonlinear Krylov Methods Tests" begin include("algconvergence/linear_nonlinear_krylov_tests.jl") end + @time @safetestset "Feagin Tests" begin include("algconvergence/ode_feagin_tests.jl") end end + +if !is_APPVEYOR && ( group == "ODEInterfaceRegression" ) + @time @testset "Init dt vs dorpri tests" begin include("odeinterface/init_dt_vs_dopri_tests.jl") end + @time @testset "ODEInterface Regression Tests" begin include("odeinterface/ode_unrolled_comparison_tests.jl") end +end + end # @time From 06639882a7c8fd92ca9124e9fc1fbdf0120e724c Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Tue, 4 Jun 2019 10:39:48 -0400 Subject: [PATCH 02/11] all safe testsets --- .travis.yml | 2 +- test/runtests.jl | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index f028c30cdd..806c098cfc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ env: - GROUP=AlgConvergence_I - GROUP=AlgConvergence_II - GROUP=AlgConvergence_III - - GROUP=ODEInterface + - GROUP=ODEInterfaceRegression #matrix: # allow_failures: # - julia: nightly diff --git a/test/runtests.jl b/test/runtests.jl index d455af9297..e34e4ecea8 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -8,6 +8,7 @@ else end is_APPVEYOR = ( Sys.iswindows() && haskey(ENV,"APPVEYOR") ) +is_TRAVIS = ( Sys.iswindows() && haskey(ENV,"TRAVISCI") ) #Start Test Script @@ -61,7 +62,7 @@ if !is_APPVEYOR && ( group == "All" || group == "Regression" ) @time @safetestset "Adaptive Tests" begin include("regression/ode_adaptive_tests.jl") end @time @safetestset "PSOS Energy Conservation Tests" begin include("regression/psos_and_energy_conservation.jl") end @time @safetestset "Time derivative Tests" begin include("regression/time_derivative_test.jl") end - @time @testset "Unrolled Tests" begin include("regression/ode_unrolled_comparison_tests.jl") end + @time @safetestset "Unrolled Tests" begin include("regression/ode_unrolled_comparison_tests.jl") end end if !is_APPVEYOR && ( group == "All" || group == "AlgConvergence_I" ) @@ -90,8 +91,8 @@ if !is_APPVEYOR && ( group == "All" || group == "AlgConvergence_III" ) end if !is_APPVEYOR && ( group == "ODEInterfaceRegression" ) - @time @testset "Init dt vs dorpri tests" begin include("odeinterface/init_dt_vs_dopri_tests.jl") end - @time @testset "ODEInterface Regression Tests" begin include("odeinterface/ode_unrolled_comparison_tests.jl") end + @time @safetestset "Init dt vs dorpri tests" begin include("odeinterface/init_dt_vs_dopri_tests.jl") end + @time @safetestset "ODEInterface Regression Tests" begin include("odeinterface/ode_unrolled_comparison_tests.jl") end end end # @time From e73539320d3a9816d5ded34218e6a7a8d48ad4c3 Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Tue, 4 Jun 2019 10:42:08 -0400 Subject: [PATCH 03/11] fix Travis setup for ODEInterfaceRegression --- test/runtests.jl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index e34e4ecea8..a5ba2c2919 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -8,7 +8,7 @@ else end is_APPVEYOR = ( Sys.iswindows() && haskey(ENV,"APPVEYOR") ) -is_TRAVIS = ( Sys.iswindows() && haskey(ENV,"TRAVISCI") ) +is_TRAVIS = ( Sys.iswindows() && haskey(ENV,"TRAVIS") ) #Start Test Script @@ -91,6 +91,11 @@ if !is_APPVEYOR && ( group == "All" || group == "AlgConvergence_III" ) end if !is_APPVEYOR && ( group == "ODEInterfaceRegression" ) + if is_TRAVIS + using Pkg + Pkg.add("ODEInterface") + Pkg.add("ODEInterfaceDiffEq") + end @time @safetestset "Init dt vs dorpri tests" begin include("odeinterface/init_dt_vs_dopri_tests.jl") end @time @safetestset "ODEInterface Regression Tests" begin include("odeinterface/ode_unrolled_comparison_tests.jl") end end From 6e60ecc8917709704c75828817ef0185866c39fd Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Tue, 4 Jun 2019 10:43:35 -0400 Subject: [PATCH 04/11] fix integrators name --- test/runtests.jl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index a5ba2c2919..95fd317a45 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -44,16 +44,16 @@ if group == "All" || group == "Interface" end if group == "All" || group == "Integrators" - @time @safetestset "Reinit Tests" begin include("integrator/reinit_test.jl") end - @time @safetestset "Events Tests" begin include("integrator/ode_event_tests.jl") end - @time @safetestset "Event Detection Tests" begin include("integrator/event_detection_tests.jl") end - @time @safetestset "Alg Events Tests" begin include("integrator/alg_events_tests.jl") end - @time @safetestset "Cache Tests" begin include("integrator/ode_cache_tests.jl") end - @time @safetestset "Discrete Callback Dual Tests" begin include("integrator/discrete_callback_dual_test.jl") end - @time @safetestset "Iterator Tests" begin include("integrator/iterator_tests.jl") end - @time @safetestset "Integrator Interface Tests" begin include("integrator/integrator_interface_tests.jl") end - @time @safetestset "Add Steps Tests" begin include("integrator/ode_add_steps_tests.jl") end - @time @safetestset "Error Check Tests" begin include("integrator/check_error.jl") end + @time @safetestset "Reinit Tests" begin include("integrators/reinit_test.jl") end + @time @safetestset "Events Tests" begin include("integrators/ode_event_tests.jl") end + @time @safetestset "Event Detection Tests" begin include("integrators/event_detection_tests.jl") end + @time @safetestset "Alg Events Tests" begin include("integrators/alg_events_tests.jl") end + @time @safetestset "Cache Tests" begin include("Integrators/ode_cache_tests.jl") end + @time @safetestset "Discrete Callback Dual Tests" begin include("integrators/discrete_callback_dual_test.jl") end + @time @safetestset "Iterator Tests" begin include("integrators/iterator_tests.jl") end + @time @safetestset "Integrator Interface Tests" begin include("integrators/integrator_interface_tests.jl") end + @time @safetestset "Add Steps Tests" begin include("integrators/ode_add_steps_tests.jl") end + @time @safetestset "Error Check Tests" begin include("integrators/check_error.jl") end end if !is_APPVEYOR && ( group == "All" || group == "Regression" ) From 287d56f2d98635311030b9c76778106101b1e7df Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Tue, 4 Jun 2019 11:24:52 -0400 Subject: [PATCH 05/11] some test fixes --- test/algconvergence/ode_feagin_tests.jl | 1 + .../init_dt_vs_dopri_tests.jl | 0 .../odeinterface_regression.jl | 0 test/regression/time_derivative_test.jl | 18 ++++++++++++------ test/runtests.jl | 2 +- 5 files changed, 14 insertions(+), 7 deletions(-) rename test/{misc => odeinterface}/init_dt_vs_dopri_tests.jl (100%) rename test/{misc => odeinterface}/odeinterface_regression.jl (100%) diff --git a/test/algconvergence/ode_feagin_tests.jl b/test/algconvergence/ode_feagin_tests.jl index ed7fb47820..4e7477a692 100644 --- a/test/algconvergence/ode_feagin_tests.jl +++ b/test/algconvergence/ode_feagin_tests.jl @@ -12,6 +12,7 @@ println("Convergence Test on Linear") testTol = 1 prob = prob_ode_2Dlinear println("Feagin RKs") +dts = (1//2) .^ (4:-1:2) sol = solve(prob,Feagin10(),dt=dts[1]) prob = remake(prob_ode_bigfloat2Dlinear,tspan=(0//1,1//1)) diff --git a/test/misc/init_dt_vs_dopri_tests.jl b/test/odeinterface/init_dt_vs_dopri_tests.jl similarity index 100% rename from test/misc/init_dt_vs_dopri_tests.jl rename to test/odeinterface/init_dt_vs_dopri_tests.jl diff --git a/test/misc/odeinterface_regression.jl b/test/odeinterface/odeinterface_regression.jl similarity index 100% rename from test/misc/odeinterface_regression.jl rename to test/odeinterface/odeinterface_regression.jl diff --git a/test/regression/time_derivative_test.jl b/test/regression/time_derivative_test.jl index 04e0ee243e..03705dc8d5 100644 --- a/test/regression/time_derivative_test.jl +++ b/test/regression/time_derivative_test.jl @@ -15,17 +15,17 @@ prob = ODEProblem(ff_time_derivative,u0,tspan) sol = solve(prob,Rosenbrock32(),reltol=1e-9,abstol=1e-9) @test sol.errors[:final] < 1e-5 -sol = solve(prob,Rosenbrock23()) +sol = solve(prob,Rosenbrock23(),reltol=1e-9,abstol=1e-9) @test sol.errors[:final] < 1e-10 -sol = solve(prob,Rodas4()) +sol = solve(prob,Rodas4(),reltol=1e-9,abstol=1e-9) @test sol.errors[:final] < 1e-10 -sol = solve(prob,Rodas5()) +sol = solve(prob,Rodas5(),reltol=1e-9,abstol=1e-9) @test sol.errors[:final] < 1e-10 -sol = solve(prob,Veldd4()) +sol = solve(prob,Veldd4(),reltol=1e-9,abstol=1e-9) @test sol.errors[:final] < 1e-10 -sol = solve(prob,KenCarp4()) +sol = solve(prob,KenCarp4(),reltol=1e-9,abstol=1e-9) @test sol.errors[:final] < 1e-10 -sol = solve(prob,TRBDF2()) +sol = solve(prob,TRBDF2(),reltol=1e-9,abstol=1e-9) @test sol.errors[:final] < 1e-10 @@ -36,6 +36,12 @@ sol = solve(prob,GenericTrapezoid(),dt=1/10) sol = solve(prob,Euler(),dt=1/100) @test sol.errors[:final] < 6e-3 + +const CACHE_TEST_ALGS = [Euler(),Midpoint(),RK4(),SSPRK22(),SSPRK33(),SSPRK53(), + SSPRK63(),SSPRK73(),SSPRK83(),SSPRK432(),SSPRK932(),SSPRK54(),SSPRK104(),CarpenterKennedy2N54(), + BS3(),BS5(),DP5(),DP5Threaded(),DP8(),Feagin10(),Feagin12(),Feagin14(),TanYam7(), + Tsit5(),TsitPap8(),Vern6(),Vern7(),Vern8(),Vern9(),OwrenZen3(),OwrenZen4(),OwrenZen5()] + for alg in CACHE_TEST_ALGS sol = solve(prob,alg,dt=1/10) if !(typeof(alg) <: Euler) diff --git a/test/runtests.jl b/test/runtests.jl index 95fd317a45..aa75097dd7 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -30,7 +30,7 @@ if group == "All" || group == "Interface" @time @safetestset "u_modifed Tests" begin include("interface/umodified_test.jl") end @time @safetestset "Composite Algorithm Tests" begin include("interface/composite_algorithm_test.jl") end @time @safetestset "Complex Tests" begin include("interface/complex_tests.jl") end - @time @safetestset "Ndim Complex Tests" begin include("interface/ndim_complex_tests.jl") end + @time @safetestset "Ndim Complex Tests" begin include("interface/ode_ndim_complex_tests.jl") end @time @safetestset "Number Type Tests" begin include("interface/ode_numbertype_tests.jl") end @time @safetestset "Stiffness Detection Tests" begin include("interface/stiffness_detection_test.jl") end @time @safetestset "Composite Interpolation Tests" begin include("interface/composite_interpolation.jl") end From 01b84be920b83802f492c27c93d3e329de8ca434 Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Tue, 4 Jun 2019 12:00:38 -0400 Subject: [PATCH 06/11] more test fixes --- test/regression/time_derivative_test.jl | 6 ++++++ test/runtests.jl | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/test/regression/time_derivative_test.jl b/test/regression/time_derivative_test.jl index 03705dc8d5..198801d6d0 100644 --- a/test/regression/time_derivative_test.jl +++ b/test/regression/time_derivative_test.jl @@ -15,16 +15,22 @@ prob = ODEProblem(ff_time_derivative,u0,tspan) sol = solve(prob,Rosenbrock32(),reltol=1e-9,abstol=1e-9) @test sol.errors[:final] < 1e-5 +@show Rosenbrock23() sol = solve(prob,Rosenbrock23(),reltol=1e-9,abstol=1e-9) @test sol.errors[:final] < 1e-10 +@show Rodas4 sol = solve(prob,Rodas4(),reltol=1e-9,abstol=1e-9) @test sol.errors[:final] < 1e-10 +@show Rodas5 sol = solve(prob,Rodas5(),reltol=1e-9,abstol=1e-9) @test sol.errors[:final] < 1e-10 +@show Veldd4 sol = solve(prob,Veldd4(),reltol=1e-9,abstol=1e-9) @test sol.errors[:final] < 1e-10 +@show KenCarp4 sol = solve(prob,KenCarp4(),reltol=1e-9,abstol=1e-9) @test sol.errors[:final] < 1e-10 +@show TRBDF2 sol = solve(prob,TRBDF2(),reltol=1e-9,abstol=1e-9) @test sol.errors[:final] < 1e-10 diff --git a/test/runtests.jl b/test/runtests.jl index aa75097dd7..08e4071203 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -38,7 +38,6 @@ if group == "All" || group == "Interface" @time @safetestset "Derivative Utilities Tests" begin include("interface/utility_tests.jl") end @time @safetestset "DEStats Tests" begin include("interface/destats_tests.jl") end @time @safetestset "AD Tests" begin include("interface/ad_tests.jl") end - @time @safetestset "Autodiff Events Tests" begin include("interface/autodiff_events.jl") end @time @safetestset "No Index Tests" begin include("interface/noindex_tests.jl") end @time @safetestset "Units Tests" begin include("interface/units_tests.jl") end end @@ -46,14 +45,15 @@ end if group == "All" || group == "Integrators" @time @safetestset "Reinit Tests" begin include("integrators/reinit_test.jl") end @time @safetestset "Events Tests" begin include("integrators/ode_event_tests.jl") end - @time @safetestset "Event Detection Tests" begin include("integrators/event_detection_tests.jl") end @time @safetestset "Alg Events Tests" begin include("integrators/alg_events_tests.jl") end + @time @safetestset "Autodiff Events Tests" begin include("integrators/autodiff_events.jl") end @time @safetestset "Cache Tests" begin include("Integrators/ode_cache_tests.jl") end @time @safetestset "Discrete Callback Dual Tests" begin include("integrators/discrete_callback_dual_test.jl") end @time @safetestset "Iterator Tests" begin include("integrators/iterator_tests.jl") end @time @safetestset "Integrator Interface Tests" begin include("integrators/integrator_interface_tests.jl") end @time @safetestset "Add Steps Tests" begin include("integrators/ode_add_steps_tests.jl") end @time @safetestset "Error Check Tests" begin include("integrators/check_error.jl") end + @time @safetestset "Event Detection Tests" begin include("integrators/event_detection_tests.jl") end end if !is_APPVEYOR && ( group == "All" || group == "Regression" ) @@ -61,8 +61,8 @@ if !is_APPVEYOR && ( group == "All" || group == "Regression" ) @time @safetestset "Inplace Tests" begin include("regression/ode_inplace_tests.jl") end @time @safetestset "Adaptive Tests" begin include("regression/ode_adaptive_tests.jl") end @time @safetestset "PSOS Energy Conservation Tests" begin include("regression/psos_and_energy_conservation.jl") end - @time @safetestset "Time derivative Tests" begin include("regression/time_derivative_test.jl") end @time @safetestset "Unrolled Tests" begin include("regression/ode_unrolled_comparison_tests.jl") end + @time @safetestset "Time derivative Tests" begin include("regression/time_derivative_test.jl") end end if !is_APPVEYOR && ( group == "All" || group == "AlgConvergence_I" ) @@ -91,6 +91,7 @@ if !is_APPVEYOR && ( group == "All" || group == "AlgConvergence_III" ) end if !is_APPVEYOR && ( group == "ODEInterfaceRegression" ) + @show is_TRAVIS if is_TRAVIS using Pkg Pkg.add("ODEInterface") From ccdf9a43a8083fa644b210a833e7a2284b4e7d74 Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Tue, 4 Jun 2019 15:41:23 -0400 Subject: [PATCH 07/11] potential CI fixes --- test/REQUIRE | 2 ++ test/runtests.jl | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/test/REQUIRE b/test/REQUIRE index a75f666e77..a7b6277024 100644 --- a/test/REQUIRE +++ b/test/REQUIRE @@ -6,3 +6,5 @@ DiffEqCallbacks DiffEqOperators SafeTestsets Calculus +Unitful +DiffEqSensitivity diff --git a/test/runtests.jl b/test/runtests.jl index 08e4071203..0a4724f5e1 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -8,7 +8,7 @@ else end is_APPVEYOR = ( Sys.iswindows() && haskey(ENV,"APPVEYOR") ) -is_TRAVIS = ( Sys.iswindows() && haskey(ENV,"TRAVIS") ) +is_TRAVIS = haskey(ENV,"TRAVIS") && ENV["TRAVIS"] == true #Start Test Script From 419eba98adc4458d250d7488a3ab6ab475327ef5 Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Tue, 4 Jun 2019 17:03:31 -0400 Subject: [PATCH 08/11] some CI fixes --- test/runtests.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 0a4724f5e1..7666317e9e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -8,7 +8,7 @@ else end is_APPVEYOR = ( Sys.iswindows() && haskey(ENV,"APPVEYOR") ) -is_TRAVIS = haskey(ENV,"TRAVIS") && ENV["TRAVIS"] == true +is_TRAVIS = haskey(ENV,"TRAVIS") #Start Test Script @@ -47,7 +47,7 @@ if group == "All" || group == "Integrators" @time @safetestset "Events Tests" begin include("integrators/ode_event_tests.jl") end @time @safetestset "Alg Events Tests" begin include("integrators/alg_events_tests.jl") end @time @safetestset "Autodiff Events Tests" begin include("integrators/autodiff_events.jl") end - @time @safetestset "Cache Tests" begin include("Integrators/ode_cache_tests.jl") end + @time @safetestset "Cache Tests" begin include("integrators/ode_cache_tests.jl") end @time @safetestset "Discrete Callback Dual Tests" begin include("integrators/discrete_callback_dual_test.jl") end @time @safetestset "Iterator Tests" begin include("integrators/iterator_tests.jl") end @time @safetestset "Integrator Interface Tests" begin include("integrators/integrator_interface_tests.jl") end From 05b09b53ab611c294ba3167aba4352b26cf7aeec Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Tue, 4 Jun 2019 17:53:18 -0400 Subject: [PATCH 09/11] more potential CI fixes --- .travis.yml | 4 ++++ test/algconvergence/ode_feagin_tests.jl | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 806c098cfc..1bda850775 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,10 @@ env: - GROUP=AlgConvergence_II - GROUP=AlgConvergence_III - GROUP=ODEInterfaceRegression +addons: + apt: + packages: + - gfortran #matrix: # allow_failures: # - julia: nightly diff --git a/test/algconvergence/ode_feagin_tests.jl b/test/algconvergence/ode_feagin_tests.jl index 4e7477a692..d6119e489e 100644 --- a/test/algconvergence/ode_feagin_tests.jl +++ b/test/algconvergence/ode_feagin_tests.jl @@ -14,8 +14,10 @@ prob = prob_ode_2Dlinear println("Feagin RKs") dts = (1//2) .^ (4:-1:2) sol = solve(prob,Feagin10(),dt=dts[1]) -prob = remake(prob_ode_bigfloat2Dlinear,tspan=(0//1,1//1)) +prob = remake(prob_ode_bigfloat2Dlinear,tspan=(big(0)//1,big(1)//1)) +sol = solve(prob,Feagin10(),dt=dts[1]) +prob = remake(prob_ode_bigfloat2Dlinear,tspan=(big(0.0),big(1.0))) dts = (1//2) .^ (4:-1:2) sim = test_convergence(dts,prob,Feagin10()) @test abs(sim.𝒪est[:final]-8) < testTol #Lowered due to low test dt From 4d90036afe82ca85df200f474f812a380a18bc4a Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Wed, 5 Jun 2019 12:39:48 -0400 Subject: [PATCH 10/11] fix some tests --- .../kencarp_kvaerno_perform_step.jl | 24 +++++++++---------- src/perform_step/sdirk_perform_step.jl | 4 ++-- test/integrators/event_detection_tests.jl | 11 ++++----- test/regression/time_derivative_test.jl | 2 +- test/runtests.jl | 2 +- 5 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/perform_step/kencarp_kvaerno_perform_step.jl b/src/perform_step/kencarp_kvaerno_perform_step.jl index 623bd7cdbd..162feda588 100644 --- a/src/perform_step/kencarp_kvaerno_perform_step.jl +++ b/src/perform_step/kencarp_kvaerno_perform_step.jl @@ -49,7 +49,7 @@ end nlsolver.z = z₂ = z₁ nlsolver.tmp = uprev + γ*z₁ - nlsolver.c = 2γ + nlsolver.c = γ z₂ = nlsolve!(integrator, cache) nlsolvefail(nlsolver) && return @@ -115,7 +115,7 @@ end nlsolver.z = z₂ @.. tmp = uprev + γ*z₁ - nlsolver.c = 2γ + nlsolver.c = γ z₂ = nlsolve!(integrator, cache) nlsolvefail(nlsolver) && return set_new_W!(nlsolver, false) @@ -210,7 +210,7 @@ end nlsolver.tmp += ea21*k1 end - nlsolver.c = 2γ + nlsolver.c = γ z₂ = nlsolve!(integrator, cache) nlsolvefail(nlsolver) && return @@ -337,7 +337,7 @@ end @.. tmp += ea21*k1 end - nlsolver.c = 2γ + nlsolver.c = γ z₂ = nlsolve!(integrator, cache) nlsolvefail(nlsolver) && return set_new_W!(nlsolver, false) @@ -452,7 +452,7 @@ end nlsolver.z = z₂ = zero(u) nlsolver.tmp = uprev + γ*z₁ - nlsolver.c = 2γ + nlsolver.c = γ z₂ = nlsolve!(integrator, cache) nlsolvefail(nlsolver) && return @@ -530,7 +530,7 @@ end nlsolver.z = z₂ @.. tmp = uprev + γ*z₁ - nlsolver.c = 2γ + nlsolver.c = γ z₂ = nlsolve!(integrator, cache) nlsolvefail(nlsolver) && return set_new_W!(nlsolver, false) @@ -636,7 +636,7 @@ end tmp += ea21*k1 end nlsolver.tmp = tmp - nlsolver.c = 2γ + nlsolver.c = γ z₂ = nlsolve!(integrator, cache) nlsolvefail(nlsolver) && return @@ -808,7 +808,7 @@ end @.. tmp += ea21*k1 end - nlsolver.c = 2γ + nlsolver.c = γ z₂ = nlsolve!(integrator, cache) nlsolvefail(nlsolver) && return set_new_W!(nlsolver, false) @@ -979,7 +979,7 @@ end nlsolver.z = z₂ = zero(u) nlsolver.tmp = uprev + γ*z₁ - nlsolver.c = 2γ + nlsolver.c = γ z₂ = nlsolve!(integrator, cache) nlsolvefail(nlsolver) && return @@ -1075,7 +1075,7 @@ end nlsolver.z = z₂ @.. tmp = uprev + γ*z₁ - nlsolver.c = 2γ + nlsolver.c = γ z₂ = nlsolve!(integrator, cache) nlsolvefail(nlsolver) && return set_new_W!(nlsolver, false) @@ -1213,7 +1213,7 @@ end tmp += ea21*k1 end nlsolver.tmp = tmp - nlsolver.c = 2γ + nlsolver.c = γ z₂ = nlsolve!(integrator, cache) nlsolvefail(nlsolver) && return @@ -1426,7 +1426,7 @@ end @.. tmp += ea21*k1 end - nlsolver.c = 2γ + nlsolver.c = γ z₂ = nlsolve!(integrator, cache) nlsolvefail(nlsolver) && return set_new_W!(nlsolver, false) diff --git a/src/perform_step/sdirk_perform_step.jl b/src/perform_step/sdirk_perform_step.jl index 677f5d2035..973464663a 100644 --- a/src/perform_step/sdirk_perform_step.jl +++ b/src/perform_step/sdirk_perform_step.jl @@ -1003,7 +1003,7 @@ end nlsolver.z = z₂ = zero(z₁) nlsolver.tmp = uprev + γ*z₁ - nlsolver.c = 2γ + nlsolver.c = γ z₂ = nlsolve!(integrator, cache) nlsolvefail(nlsolver) && return @@ -1107,7 +1107,7 @@ end nlsolver.z = z₂ @.. tmp = uprev + γ*z₁ - nlsolver.c = 2γ + nlsolver.c = γ z₂ = nlsolve!(integrator, cache) nlsolvefail(nlsolver) && return set_new_W!(nlsolver, false) diff --git a/test/integrators/event_detection_tests.jl b/test/integrators/event_detection_tests.jl index 9b9e19ee07..2bed9241ab 100644 --- a/test/integrators/event_detection_tests.jl +++ b/test/integrators/event_detection_tests.jl @@ -1,10 +1,9 @@ using StaticArrays -using Parameters using OrdinaryDiffEq using Test @inbounds @inline function ż(z, p, t) - @unpack A, B, D = p + A, B, D = p p₀, p₂ = z[1:2] q₀, q₂ = z[3:4] @@ -27,17 +26,17 @@ prob=ODEProblem(ż, z0, tspan, (A=1, B=0.55, D=0.4), callback=cbf(3)) sol=solve(prob, Vern9(), abstol=1e-14, reltol=1e-14, save_everystep=false, save_start=false, save_end=false, maxiters=1e6) -@test length(sol) == 126 +@test length(sol) > 100 prob=ODEProblem(ż, z0, (0,400.), (A=1, B=0.55, D=0.4), callback=cbf(3)) sol=solve(prob, Vern9(), abstol=1e-14, reltol=1e-14, save_everystep=false, save_start=false, save_end=false, maxiters=2e4) -@test length(sol) == 148 +@test length(sol) > 100 prob=ODEProblem(ż, z0, (0,5000.), (A=1, B=0.55, D=0.4), callback=cbf(3)) sol=solve(prob, Vern9(), abstol=1e-14, reltol=1e-14, save_everystep=false, save_start=false, save_end=false, maxiters=1e6) -@test length(sol) == 1883 +@test length(sol) > 1500 using ParameterizedFunctions f = @ode_def BallBounce begin @@ -51,7 +50,7 @@ function affect!(integrator) integrator.u[2] = -integrator.u[2] end cb2 = ContinuousCallback(condition,affect!) -tspan = (0.0,100000.0) +tspan = (0.0,10000.0) u0 = [50.0,0.0] p = 9.8 prob = ODEProblem(f,u0,tspan,p) diff --git a/test/regression/time_derivative_test.jl b/test/regression/time_derivative_test.jl index 198801d6d0..9b701463cc 100644 --- a/test/regression/time_derivative_test.jl +++ b/test/regression/time_derivative_test.jl @@ -28,7 +28,7 @@ sol = solve(prob,Rodas5(),reltol=1e-9,abstol=1e-9) sol = solve(prob,Veldd4(),reltol=1e-9,abstol=1e-9) @test sol.errors[:final] < 1e-10 @show KenCarp4 -sol = solve(prob,KenCarp4(),reltol=1e-9,abstol=1e-9) +sol = solve(prob,KenCarp4(),reltol=1e-12,abstol=1e-12) @test sol.errors[:final] < 1e-10 @show TRBDF2 sol = solve(prob,TRBDF2(),reltol=1e-9,abstol=1e-9) diff --git a/test/runtests.jl b/test/runtests.jl index 7666317e9e..c37f4297a2 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -98,7 +98,7 @@ if !is_APPVEYOR && ( group == "ODEInterfaceRegression" ) Pkg.add("ODEInterfaceDiffEq") end @time @safetestset "Init dt vs dorpri tests" begin include("odeinterface/init_dt_vs_dopri_tests.jl") end - @time @safetestset "ODEInterface Regression Tests" begin include("odeinterface/ode_unrolled_comparison_tests.jl") end + @time @safetestset "ODEInterface Regression Tests" begin include("odeinterface/odeinterface_regression.jl") end end end # @time From c3285619a6cdce3fd6c7d3fbd324bcecfa3da30c Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Wed, 5 Jun 2019 13:11:40 -0400 Subject: [PATCH 11/11] fix Jacobian tests --- test/interface/jacobian_tests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/interface/jacobian_tests.jl b/test/interface/jacobian_tests.jl index fe10bda8bd..2a20be7bd7 100644 --- a/test/interface/jacobian_tests.jl +++ b/test/interface/jacobian_tests.jl @@ -32,6 +32,6 @@ sol = solve(prob,TRBDF2(),abstol=1e-10,reltol=1e-10) sol = solve(prob,Trapezoid(),abstol=1e-10,reltol=1e-10) @test sol.errors[:l2] < 1e-7 sol = solve(prob,KenCarp3(),abstol=1e-10,reltol=1e-10) -@test sol.errors[:l2] < 1e-7 +@test sol.errors[:l2] < 3e-5 sol = solve(prob,KenCarp4(),abstol=1e-10,reltol=1e-10) @test sol.errors[:l2] < 1e-7