From f40f68925a0796cceb02ee17efbd8fecbbd367b0 Mon Sep 17 00:00:00 2001 From: Hendrik Ranocha Date: Mon, 19 Jun 2023 08:07:18 +0200 Subject: [PATCH 01/16] fix out-of-place version of FineRKN5 --- src/perform_step/rkn_perform_step.jl | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/perform_step/rkn_perform_step.jl b/src/perform_step/rkn_perform_step.jl index bcbb3db1d8..8297ada5a0 100644 --- a/src/perform_step/rkn_perform_step.jl +++ b/src/perform_step/rkn_perform_step.jl @@ -126,7 +126,7 @@ end repeat_step = false) @unpack t, dt, f, p = integrator duprev, uprev = integrator.uprev.x - @unpack c1, c2, c3, c4, c5, c6, c7, a21, a31, a32, a41, a43, a51, a52, a53, a54, a61, a62, a63, a64, a71, a73, a74, a75, abar21, abar31, abar32, abar41, abar42, abar43, abar51, abar52, abar53, abar54, abar61, abar62, abar63, abar64, abar65, abar71, abar73, abar74, abar75, abar76, b1, b3, b4, b5, bbar1, bbar3, bbar4, bbar5, bbar6 = cache + @unpack c2, c3, c4, c5, c6, c7, a21, a31, a32, a41, a43, a51, a52, a53, a54, a61, a62, a63, a64, a71, a73, a74, a75, abar21, abar31, abar32, abar41, abar42, abar43, abar51, abar52, abar53, abar54, abar61, abar62, abar63, abar64, abar65, abar71, abar73, abar74, abar75, abar76, b1, b3, b4, b5, bbar1, bbar3, bbar4, bbar5, bbar6 = cache k1 = integrator.fsalfirst.x[1] ku = uprev + (c2 * dt * duprev) + (dt^2 * a21 * k1) @@ -144,13 +144,13 @@ end ku = uprev + dt * (c5 * duprev + dt * (a51 * k1 + a52 * k2 + a53 * k3 + a54 * k4)) kdu = duprev + dt * (abar51 * k1 + abar52 * k2 + abar53 * k3 + abar54 * k4) - k5 = f.f1(duprev, ku, p, t + dt * c5) + k5 = f.f1(kdu, ku, p, t + dt * c5) ku = uprev + dt * (c6 * duprev + dt * (a61 * k1 + a62 * k2 + a63 * k3 + a64 * k4)) # a65 = 0 kdu = duprev + dt * (abar61 * k1 + abar62 * k2 + abar63 * k3 + abar64 * k4 + abar65 * k5) - k6 = f.f1(duprev, ku, p, t + dt * c6) + k6 = f.f1(kdu, ku, p, t + dt * c6) ku = uprev + dt * (c7 * duprev + dt * (a71 * k1 + a73 * k3 + a74 * k4 + a75 * k5)) # a72 = a76 = 0 @@ -158,8 +158,8 @@ end dt * (abar71 * k1 + abar73 * k3 + abar74 * k4 + abar75 * k5 + abar76 * k6) # abar72 = 0 - k7 = f.f1(duprev, ku, p, t + dt * c7) - u = uprev + dt * (duprev + dt * (b1 * k1 + b3 * k3 + b4 * k4 + b5 * k5)) # no b6, b7 + k7 = f.f1(kdu, ku, p, t + dt * c7) + u = uprev + dt * (duprev + dt * (b1 * k1 + b3 * k3 + b4 * k4 + b5 * k5)) # no b6, b7 du = duprev + dt * (bbar1 * k1 + bbar3 * k3 + bbar4 * k4 + bbar5 * k5 + bbar6 * k6) # no b2, b7 integrator.u = ArrayPartition((du, u)) @@ -211,7 +211,6 @@ end @.. broadcast=false ku=uprev + dt * (c7 * duprev + dt * (a71 * k1 + a73 * k3 + a74 * k4 + a75 * k5)) # a72 = a76 = 0 - @.. broadcast=false kdu=duprev + dt * (abar71 * k1 + abar73 * k3 + abar74 * k4 + abar75 * k5 + abar76 * k6) # abar72 = 0 From 039f5619c5388e7964000c4e7c4c9ea6732b1c40 Mon Sep 17 00:00:00 2001 From: Hendrik Ranocha Date: Mon, 19 Jun 2023 08:15:17 +0200 Subject: [PATCH 02/16] add test --- .../partitioned_methods_tests.jl | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/algconvergence/partitioned_methods_tests.jl b/test/algconvergence/partitioned_methods_tests.jl index e2a91cc877..735468b9d0 100644 --- a/test/algconvergence/partitioned_methods_tests.jl +++ b/test/algconvergence/partitioned_methods_tests.jl @@ -363,3 +363,26 @@ sol = solve(prob, ERKN5(), reltol = 1e-8) @test length(sol.u) < 34 sol = solve(prob, ERKN7(), reltol = 1e-8) @test length(sol.u) < 38 + + +@testset "in-place vs. out-of-place" begin + ode_i = SecondOrderODEProblem( + (ddu, du, u, p, t) -> @.(ddu = -u - 0.5 * du), + [0.0], [1.0], + (0.0, 10.0) + ) + ode_o = SecondOrderODEProblem( + (du, u, p, t) -> -u - 0.5 * du, + [0.0], [1.0], + (0.0, 10.0) + ) + + @testset "FineRKN5" begin + alg = FineRKN5() + dt = 0.1 + sol_i = solve(ode_i, alg, dt = dt) + sol_o = solve(ode_o, alg, dt = dt) + @test sol_i.t ≈ sol_o.t + @test sol_i.u ≈ sol_o.u + end +end From a4533f81765ccc5d540385b2589b07b246a0643c Mon Sep 17 00:00:00 2001 From: Hendrik Ranocha Date: Mon, 19 Jun 2023 08:20:59 +0200 Subject: [PATCH 03/16] test DPRKN6 --- .../partitioned_methods_tests.jl | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/test/algconvergence/partitioned_methods_tests.jl b/test/algconvergence/partitioned_methods_tests.jl index 735468b9d0..84054df7ce 100644 --- a/test/algconvergence/partitioned_methods_tests.jl +++ b/test/algconvergence/partitioned_methods_tests.jl @@ -365,24 +365,48 @@ sol = solve(prob, ERKN7(), reltol = 1e-8) @test length(sol.u) < 38 +# Compare in-place and out-of-place versions +function damped_oscillator(du, u, p, t) + return -u - 0.5 * du +end +function damped_oscillator!(ddu, du, u, p, t) + @. ddu = -u - 0.5 * du + return nothing +end @testset "in-place vs. out-of-place" begin ode_i = SecondOrderODEProblem( - (ddu, du, u, p, t) -> @.(ddu = -u - 0.5 * du), + damped_oscillator!, [0.0], [1.0], (0.0, 10.0) ) ode_o = SecondOrderODEProblem( - (du, u, p, t) -> -u - 0.5 * du, + damped_oscillator, [0.0], [1.0], (0.0, 10.0) ) @testset "FineRKN5" begin alg = FineRKN5() - dt = 0.1 + dt = 0.5 + # fixed time step sol_i = solve(ode_i, alg, dt = dt) sol_o = solve(ode_o, alg, dt = dt) @test sol_i.t ≈ sol_o.t @test sol_i.u ≈ sol_o.u end + + @testset "DPRKN6" begin + alg = DPRKN6() + dt = 0.5 + # fixed time step + sol_i = solve(ode_i, alg, adaptive = false, dt = dt) + sol_o = solve(ode_o, alg, adaptive = false, dt = dt) + @test sol_i.t ≈ sol_o.t + @test_broken sol_i.u ≈ sol_o.u + # adaptive time step + sol_i = solve(ode_i, alg) + sol_o = solve(ode_o, alg) + @test_broken sol_i.t ≈ sol_o.t + @test_broken sol_i.u ≈ sol_o.u + end end From 922ee1dc4f28ddef66660c363b0c73170ec3bbe1 Mon Sep 17 00:00:00 2001 From: Hendrik Ranocha Date: Mon, 19 Jun 2023 08:21:05 +0200 Subject: [PATCH 04/16] test DPRKN4 --- test/algconvergence/partitioned_methods_tests.jl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/algconvergence/partitioned_methods_tests.jl b/test/algconvergence/partitioned_methods_tests.jl index 84054df7ce..9f43cd897c 100644 --- a/test/algconvergence/partitioned_methods_tests.jl +++ b/test/algconvergence/partitioned_methods_tests.jl @@ -395,6 +395,21 @@ end @test sol_i.u ≈ sol_o.u end + @testset "DPRKN4" begin + alg = DPRKN4() + dt = 0.5 + # fixed time step + sol_i = solve(ode_i, alg, adaptive = false, dt = dt) + sol_o = solve(ode_o, alg, adaptive = false, dt = dt) + @test sol_i.t ≈ sol_o.t + @test sol_i.u ≈ sol_o.u + # adaptive time step + sol_i = solve(ode_i, alg) + sol_o = solve(ode_o, alg) + @test sol_i.t ≈ sol_o.t + @test sol_i.u ≈ sol_o.u + end + @testset "DPRKN6" begin alg = DPRKN6() dt = 0.5 From 8ded7a1f72cf51eb0bdf57f71e1e1552a1ffa737 Mon Sep 17 00:00:00 2001 From: Hendrik Ranocha Date: Mon, 19 Jun 2023 08:21:53 +0200 Subject: [PATCH 05/16] test DPRKN5 --- test/algconvergence/partitioned_methods_tests.jl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/algconvergence/partitioned_methods_tests.jl b/test/algconvergence/partitioned_methods_tests.jl index 9f43cd897c..9ae1b4a3a4 100644 --- a/test/algconvergence/partitioned_methods_tests.jl +++ b/test/algconvergence/partitioned_methods_tests.jl @@ -410,6 +410,21 @@ end @test sol_i.u ≈ sol_o.u end + @testset "DPRKN5" begin + alg = DPRKN5() + dt = 0.5 + # fixed time step + sol_i = solve(ode_i, alg, adaptive = false, dt = dt) + sol_o = solve(ode_o, alg, adaptive = false, dt = dt) + @test sol_i.t ≈ sol_o.t + @test sol_i.u ≈ sol_o.u + # adaptive time step + sol_i = solve(ode_i, alg) + sol_o = solve(ode_o, alg) + @test sol_i.t ≈ sol_o.t + @test sol_i.u ≈ sol_o.u + end + @testset "DPRKN6" begin alg = DPRKN6() dt = 0.5 From f3f3c62df1b626e0435a70b0b2f6a3990e967b7d Mon Sep 17 00:00:00 2001 From: Hendrik Ranocha Date: Mon, 19 Jun 2023 08:22:51 +0200 Subject: [PATCH 06/16] test DPRKN6FM --- test/algconvergence/partitioned_methods_tests.jl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/algconvergence/partitioned_methods_tests.jl b/test/algconvergence/partitioned_methods_tests.jl index 9ae1b4a3a4..963b521ebd 100644 --- a/test/algconvergence/partitioned_methods_tests.jl +++ b/test/algconvergence/partitioned_methods_tests.jl @@ -439,4 +439,19 @@ end @test_broken sol_i.t ≈ sol_o.t @test_broken sol_i.u ≈ sol_o.u end + + @testset "DPRKN6FM" begin + alg = DPRKN6FM() + dt = 0.5 + # fixed time step + sol_i = solve(ode_i, alg, adaptive = false, dt = dt) + sol_o = solve(ode_o, alg, adaptive = false, dt = dt) + @test sol_i.t ≈ sol_o.t + @test sol_i.u ≈ sol_o.u + # adaptive time step + sol_i = solve(ode_i, alg) + sol_o = solve(ode_o, alg) + @test_broken sol_i.t ≈ sol_o.t + @test_broken sol_i.u ≈ sol_o.u + end end From a55aac62f510181e80c555db375bed26447dbe7e Mon Sep 17 00:00:00 2001 From: Hendrik Ranocha Date: Mon, 19 Jun 2023 08:23:55 +0200 Subject: [PATCH 07/16] test DPRKN8 --- test/algconvergence/partitioned_methods_tests.jl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/algconvergence/partitioned_methods_tests.jl b/test/algconvergence/partitioned_methods_tests.jl index 963b521ebd..afbc1fdb28 100644 --- a/test/algconvergence/partitioned_methods_tests.jl +++ b/test/algconvergence/partitioned_methods_tests.jl @@ -454,4 +454,19 @@ end @test_broken sol_i.t ≈ sol_o.t @test_broken sol_i.u ≈ sol_o.u end + + @testset "DPRKN8" begin + alg = DPRKN8() + dt = 0.5 + # fixed time step + sol_i = solve(ode_i, alg, adaptive = false, dt = dt) + sol_o = solve(ode_o, alg, adaptive = false, dt = dt) + @test sol_i.t ≈ sol_o.t + @test sol_i.u ≈ sol_o.u + # adaptive time step + sol_i = solve(ode_i, alg) + sol_o = solve(ode_o, alg) + @test_broken sol_i.t ≈ sol_o.t + @test_broken sol_i.u ≈ sol_o.u + end end From 1ab3aa098c7632f25835b572d1e22f1d912be034 Mon Sep 17 00:00:00 2001 From: Hendrik Ranocha Date: Mon, 19 Jun 2023 08:24:20 +0200 Subject: [PATCH 08/16] test DPRKN12 --- test/algconvergence/partitioned_methods_tests.jl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/algconvergence/partitioned_methods_tests.jl b/test/algconvergence/partitioned_methods_tests.jl index afbc1fdb28..6badfd3b60 100644 --- a/test/algconvergence/partitioned_methods_tests.jl +++ b/test/algconvergence/partitioned_methods_tests.jl @@ -469,4 +469,19 @@ end @test_broken sol_i.t ≈ sol_o.t @test_broken sol_i.u ≈ sol_o.u end + + @testset "DPRKN12" begin + alg = DPRKN12() + dt = 0.5 + # fixed time step + sol_i = solve(ode_i, alg, adaptive = false, dt = dt) + sol_o = solve(ode_o, alg, adaptive = false, dt = dt) + @test sol_i.t ≈ sol_o.t + @test sol_i.u ≈ sol_o.u + # adaptive time step + sol_i = solve(ode_i, alg) + sol_o = solve(ode_o, alg) + @test_broken sol_i.t ≈ sol_o.t + @test_broken sol_i.u ≈ sol_o.u + end end From eb43c43c9924d56bebc5be6ca20e74630a12cd47 Mon Sep 17 00:00:00 2001 From: Hendrik Ranocha Date: Mon, 19 Jun 2023 08:26:01 +0200 Subject: [PATCH 09/16] test Nystrom4 --- test/algconvergence/partitioned_methods_tests.jl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/algconvergence/partitioned_methods_tests.jl b/test/algconvergence/partitioned_methods_tests.jl index 6badfd3b60..cead539f72 100644 --- a/test/algconvergence/partitioned_methods_tests.jl +++ b/test/algconvergence/partitioned_methods_tests.jl @@ -385,6 +385,16 @@ end (0.0, 10.0) ) + @testset "Nystrom4" begin + alg = Nystrom4() + dt = 0.5 + # fixed time step + sol_i = solve(ode_i, alg, dt = dt) + sol_o = solve(ode_o, alg, dt = dt) + @test sol_i.t ≈ sol_o.t + @test sol_i.u ≈ sol_o.u + end + @testset "FineRKN5" begin alg = FineRKN5() dt = 0.5 From 3ec484befb792ba4165c590e7a80dc6f296ac62a Mon Sep 17 00:00:00 2001 From: Hendrik Ranocha Date: Mon, 19 Jun 2023 08:36:38 +0200 Subject: [PATCH 10/16] format --- test/algconvergence/partitioned_methods_tests.jl | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/test/algconvergence/partitioned_methods_tests.jl b/test/algconvergence/partitioned_methods_tests.jl index cead539f72..78f5a908de 100644 --- a/test/algconvergence/partitioned_methods_tests.jl +++ b/test/algconvergence/partitioned_methods_tests.jl @@ -364,7 +364,6 @@ sol = solve(prob, ERKN5(), reltol = 1e-8) sol = solve(prob, ERKN7(), reltol = 1e-8) @test length(sol.u) < 38 - # Compare in-place and out-of-place versions function damped_oscillator(du, u, p, t) return -u - 0.5 * du @@ -374,16 +373,12 @@ function damped_oscillator!(ddu, du, u, p, t) return nothing end @testset "in-place vs. out-of-place" begin - ode_i = SecondOrderODEProblem( - damped_oscillator!, + ode_i = SecondOrderODEProblem(damped_oscillator!, [0.0], [1.0], - (0.0, 10.0) - ) - ode_o = SecondOrderODEProblem( - damped_oscillator, + (0.0, 10.0)) + ode_o = SecondOrderODEProblem(damped_oscillator, [0.0], [1.0], - (0.0, 10.0) - ) + (0.0, 10.0)) @testset "Nystrom4" begin alg = Nystrom4() From f58f30e2b39b8e86bfa09d52809313ad35832df7 Mon Sep 17 00:00:00 2001 From: Hendrik Ranocha Date: Mon, 19 Jun 2023 08:46:06 +0200 Subject: [PATCH 11/16] check and fix number of function evaluations for Nystrom4, FineRKN5 --- src/perform_step/rkn_perform_step.jl | 6 +++--- test/algconvergence/partitioned_methods_tests.jl | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/perform_step/rkn_perform_step.jl b/src/perform_step/rkn_perform_step.jl index 8297ada5a0..8416bc2d54 100644 --- a/src/perform_step/rkn_perform_step.jl +++ b/src/perform_step/rkn_perform_step.jl @@ -118,7 +118,7 @@ end f.f1(k.x[1], du, u, p, t + dt) f.f2(k.x[2], du, u, p, t + dt) - integrator.stats.nf += 1 + integrator.stats.nf += 4 integrator.stats.nf2 += 1 end @@ -164,7 +164,7 @@ end integrator.u = ArrayPartition((du, u)) integrator.fsallast = ArrayPartition((f.f1(du, u, p, t + dt), f.f2(du, u, p, t + dt))) - integrator.stats.nf += 4 + integrator.stats.nf += 7 integrator.stats.nf2 += 1 integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast @@ -224,7 +224,7 @@ end f.f1(k.x[1], du, u, p, t + dt) f.f2(k.x[2], du, u, p, t + dt) - integrator.stats.nf += 1 + integrator.stats.nf += 7 integrator.stats.nf2 += 1 end diff --git a/test/algconvergence/partitioned_methods_tests.jl b/test/algconvergence/partitioned_methods_tests.jl index 78f5a908de..813cb126fa 100644 --- a/test/algconvergence/partitioned_methods_tests.jl +++ b/test/algconvergence/partitioned_methods_tests.jl @@ -388,6 +388,11 @@ end sol_o = solve(ode_o, alg, dt = dt) @test sol_i.t ≈ sol_o.t @test sol_i.u ≈ sol_o.u + @test sol_i.destats.nf == sol_i.destats.nf + @test sol_i.destats.nf2 == sol_i.destats.nf2 + @test sol_i.destats.naccept == sol_i.destats.naccept + @test 19 <= sol_i.destats.naccept <= 21 + @test abs(sol_i.destats.nf - 4 * sol_i.destats.naccept) < 4 end @testset "FineRKN5" begin @@ -398,6 +403,11 @@ end sol_o = solve(ode_o, alg, dt = dt) @test sol_i.t ≈ sol_o.t @test sol_i.u ≈ sol_o.u + @test sol_i.destats.nf == sol_i.destats.nf + @test sol_i.destats.nf2 == sol_i.destats.nf2 + @test sol_i.destats.naccept == sol_i.destats.naccept + @test 19 <= sol_i.destats.naccept <= 21 + @test abs(sol_i.destats.nf - 7 * sol_i.destats.naccept) < 4 end @testset "DPRKN4" begin @@ -408,6 +418,11 @@ end sol_o = solve(ode_o, alg, adaptive = false, dt = dt) @test sol_i.t ≈ sol_o.t @test sol_i.u ≈ sol_o.u + @test sol_i.destats.nf == sol_i.destats.nf + @test sol_i.destats.nf2 == sol_i.destats.nf2 + @test sol_i.destats.naccept == sol_i.destats.naccept + @test 19 <= sol_i.destats.naccept <= 21 + @test abs(sol_i.destats.nf - 7 * sol_i.destats.naccept) < 4 # adaptive time step sol_i = solve(ode_i, alg) sol_o = solve(ode_o, alg) From c8221e14bb158ae0707697e34d849d428bda100b Mon Sep 17 00:00:00 2001 From: Hendrik Ranocha Date: Mon, 19 Jun 2023 08:47:50 +0200 Subject: [PATCH 12/16] check number of function evaluations for DPRKN6 --- test/algconvergence/partitioned_methods_tests.jl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/algconvergence/partitioned_methods_tests.jl b/test/algconvergence/partitioned_methods_tests.jl index 813cb126fa..1bfc99d78e 100644 --- a/test/algconvergence/partitioned_methods_tests.jl +++ b/test/algconvergence/partitioned_methods_tests.jl @@ -453,6 +453,11 @@ end sol_o = solve(ode_o, alg, adaptive = false, dt = dt) @test sol_i.t ≈ sol_o.t @test_broken sol_i.u ≈ sol_o.u + @test sol_i.destats.nf == sol_i.destats.nf + @test sol_i.destats.nf2 == sol_i.destats.nf2 + @test sol_i.destats.naccept == sol_i.destats.naccept + @test 19 <= sol_i.destats.naccept <= 21 + @test abs(sol_i.destats.nf - 6 * sol_i.destats.naccept) < 4 # adaptive time step sol_i = solve(ode_i, alg) sol_o = solve(ode_o, alg) From 8685f56fa1bbb660010992beed48fbfa5c7025e0 Mon Sep 17 00:00:00 2001 From: Hendrik Ranocha Date: Mon, 19 Jun 2023 08:50:25 +0200 Subject: [PATCH 13/16] check number of function evaluations for other DPRKN* methods --- .../partitioned_methods_tests.jl | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/test/algconvergence/partitioned_methods_tests.jl b/test/algconvergence/partitioned_methods_tests.jl index 1bfc99d78e..f7e33baa2a 100644 --- a/test/algconvergence/partitioned_methods_tests.jl +++ b/test/algconvergence/partitioned_methods_tests.jl @@ -422,7 +422,7 @@ end @test sol_i.destats.nf2 == sol_i.destats.nf2 @test sol_i.destats.naccept == sol_i.destats.naccept @test 19 <= sol_i.destats.naccept <= 21 - @test abs(sol_i.destats.nf - 7 * sol_i.destats.naccept) < 4 + @test abs(sol_i.destats.nf - 4 * sol_i.destats.naccept) < 4 # adaptive time step sol_i = solve(ode_i, alg) sol_o = solve(ode_o, alg) @@ -438,6 +438,11 @@ end sol_o = solve(ode_o, alg, adaptive = false, dt = dt) @test sol_i.t ≈ sol_o.t @test sol_i.u ≈ sol_o.u + @test sol_i.destats.nf == sol_i.destats.nf + @test sol_i.destats.nf2 == sol_i.destats.nf2 + @test sol_i.destats.naccept == sol_i.destats.naccept + @test 19 <= sol_i.destats.naccept <= 21 + @test abs(sol_i.destats.nf - 6 * sol_i.destats.naccept) < 4 # adaptive time step sol_i = solve(ode_i, alg) sol_o = solve(ode_o, alg) @@ -473,6 +478,11 @@ end sol_o = solve(ode_o, alg, adaptive = false, dt = dt) @test sol_i.t ≈ sol_o.t @test sol_i.u ≈ sol_o.u + @test sol_i.destats.nf == sol_i.destats.nf + @test sol_i.destats.nf2 == sol_i.destats.nf2 + @test sol_i.destats.naccept == sol_i.destats.naccept + @test 19 <= sol_i.destats.naccept <= 21 + @test abs(sol_i.destats.nf - 6 * sol_i.destats.naccept) < 4 # adaptive time step sol_i = solve(ode_i, alg) sol_o = solve(ode_o, alg) @@ -488,6 +498,11 @@ end sol_o = solve(ode_o, alg, adaptive = false, dt = dt) @test sol_i.t ≈ sol_o.t @test sol_i.u ≈ sol_o.u + @test sol_i.destats.nf == sol_i.destats.nf + @test sol_i.destats.nf2 == sol_i.destats.nf2 + @test sol_i.destats.naccept == sol_i.destats.naccept + @test 19 <= sol_i.destats.naccept <= 21 + @test abs(sol_i.destats.nf - 9 * sol_i.destats.naccept) < 4 # adaptive time step sol_i = solve(ode_i, alg) sol_o = solve(ode_o, alg) @@ -503,6 +518,11 @@ end sol_o = solve(ode_o, alg, adaptive = false, dt = dt) @test sol_i.t ≈ sol_o.t @test sol_i.u ≈ sol_o.u + @test sol_i.destats.nf == sol_i.destats.nf + @test sol_i.destats.nf2 == sol_i.destats.nf2 + @test sol_i.destats.naccept == sol_i.destats.naccept + @test 19 <= sol_i.destats.naccept <= 21 + @test abs(sol_i.destats.nf - 17 * sol_i.destats.naccept) < 4 # adaptive time step sol_i = solve(ode_i, alg) sol_o = solve(ode_o, alg) From 186cb9cdde0362662a990c8d91e6f1bb5a5c43a7 Mon Sep 17 00:00:00 2001 From: Hendrik Ranocha Date: Mon, 19 Jun 2023 09:57:07 +0200 Subject: [PATCH 14/16] fix typos --- .../partitioned_methods_tests.jl | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/test/algconvergence/partitioned_methods_tests.jl b/test/algconvergence/partitioned_methods_tests.jl index f7e33baa2a..286875d0ee 100644 --- a/test/algconvergence/partitioned_methods_tests.jl +++ b/test/algconvergence/partitioned_methods_tests.jl @@ -388,9 +388,9 @@ end sol_o = solve(ode_o, alg, dt = dt) @test sol_i.t ≈ sol_o.t @test sol_i.u ≈ sol_o.u - @test sol_i.destats.nf == sol_i.destats.nf - @test sol_i.destats.nf2 == sol_i.destats.nf2 - @test sol_i.destats.naccept == sol_i.destats.naccept + @test sol_i.destats.nf == sol_o.destats.nf + @test sol_i.destats.nf2 == sol_o.destats.nf2 + @test sol_i.destats.naccept == sol_o.destats.naccept @test 19 <= sol_i.destats.naccept <= 21 @test abs(sol_i.destats.nf - 4 * sol_i.destats.naccept) < 4 end @@ -403,9 +403,9 @@ end sol_o = solve(ode_o, alg, dt = dt) @test sol_i.t ≈ sol_o.t @test sol_i.u ≈ sol_o.u - @test sol_i.destats.nf == sol_i.destats.nf - @test sol_i.destats.nf2 == sol_i.destats.nf2 - @test sol_i.destats.naccept == sol_i.destats.naccept + @test sol_i.destats.nf == sol_o.destats.nf + @test sol_i.destats.nf2 == sol_o.destats.nf2 + @test sol_i.destats.naccept == sol_o.destats.naccept @test 19 <= sol_i.destats.naccept <= 21 @test abs(sol_i.destats.nf - 7 * sol_i.destats.naccept) < 4 end @@ -418,9 +418,9 @@ end sol_o = solve(ode_o, alg, adaptive = false, dt = dt) @test sol_i.t ≈ sol_o.t @test sol_i.u ≈ sol_o.u - @test sol_i.destats.nf == sol_i.destats.nf - @test sol_i.destats.nf2 == sol_i.destats.nf2 - @test sol_i.destats.naccept == sol_i.destats.naccept + @test sol_i.destats.nf == sol_o.destats.nf + @test sol_i.destats.nf2 == sol_o.destats.nf2 + @test sol_i.destats.naccept == sol_o.destats.naccept @test 19 <= sol_i.destats.naccept <= 21 @test abs(sol_i.destats.nf - 4 * sol_i.destats.naccept) < 4 # adaptive time step @@ -438,9 +438,9 @@ end sol_o = solve(ode_o, alg, adaptive = false, dt = dt) @test sol_i.t ≈ sol_o.t @test sol_i.u ≈ sol_o.u - @test sol_i.destats.nf == sol_i.destats.nf - @test sol_i.destats.nf2 == sol_i.destats.nf2 - @test sol_i.destats.naccept == sol_i.destats.naccept + @test sol_i.destats.nf == sol_o.destats.nf + @test sol_i.destats.nf2 == sol_o.destats.nf2 + @test sol_i.destats.naccept == sol_o.destats.naccept @test 19 <= sol_i.destats.naccept <= 21 @test abs(sol_i.destats.nf - 6 * sol_i.destats.naccept) < 4 # adaptive time step @@ -458,9 +458,9 @@ end sol_o = solve(ode_o, alg, adaptive = false, dt = dt) @test sol_i.t ≈ sol_o.t @test_broken sol_i.u ≈ sol_o.u - @test sol_i.destats.nf == sol_i.destats.nf - @test sol_i.destats.nf2 == sol_i.destats.nf2 - @test sol_i.destats.naccept == sol_i.destats.naccept + @test sol_i.destats.nf == sol_o.destats.nf + @test sol_i.destats.nf2 == sol_o.destats.nf2 + @test sol_i.destats.naccept == sol_o.destats.naccept @test 19 <= sol_i.destats.naccept <= 21 @test abs(sol_i.destats.nf - 6 * sol_i.destats.naccept) < 4 # adaptive time step @@ -478,9 +478,9 @@ end sol_o = solve(ode_o, alg, adaptive = false, dt = dt) @test sol_i.t ≈ sol_o.t @test sol_i.u ≈ sol_o.u - @test sol_i.destats.nf == sol_i.destats.nf - @test sol_i.destats.nf2 == sol_i.destats.nf2 - @test sol_i.destats.naccept == sol_i.destats.naccept + @test sol_i.destats.nf == sol_o.destats.nf + @test sol_i.destats.nf2 == sol_o.destats.nf2 + @test sol_i.destats.naccept == sol_o.destats.naccept @test 19 <= sol_i.destats.naccept <= 21 @test abs(sol_i.destats.nf - 6 * sol_i.destats.naccept) < 4 # adaptive time step @@ -498,9 +498,9 @@ end sol_o = solve(ode_o, alg, adaptive = false, dt = dt) @test sol_i.t ≈ sol_o.t @test sol_i.u ≈ sol_o.u - @test sol_i.destats.nf == sol_i.destats.nf - @test sol_i.destats.nf2 == sol_i.destats.nf2 - @test sol_i.destats.naccept == sol_i.destats.naccept + @test sol_i.destats.nf == sol_o.destats.nf + @test sol_i.destats.nf2 == sol_o.destats.nf2 + @test sol_i.destats.naccept == sol_o.destats.naccept @test 19 <= sol_i.destats.naccept <= 21 @test abs(sol_i.destats.nf - 9 * sol_i.destats.naccept) < 4 # adaptive time step @@ -518,9 +518,9 @@ end sol_o = solve(ode_o, alg, adaptive = false, dt = dt) @test sol_i.t ≈ sol_o.t @test sol_i.u ≈ sol_o.u - @test sol_i.destats.nf == sol_i.destats.nf - @test sol_i.destats.nf2 == sol_i.destats.nf2 - @test sol_i.destats.naccept == sol_i.destats.naccept + @test sol_i.destats.nf == sol_o.destats.nf + @test sol_i.destats.nf2 == sol_o.destats.nf2 + @test sol_i.destats.naccept == sol_o.destats.naccept @test 19 <= sol_i.destats.naccept <= 21 @test abs(sol_i.destats.nf - 17 * sol_i.destats.naccept) < 4 # adaptive time step From 1e11d3922fca4b1aede74feb6529756c30f152aa Mon Sep 17 00:00:00 2001 From: Hendrik Ranocha Date: Tue, 20 Jun 2023 15:14:25 +0200 Subject: [PATCH 15/16] update FineRKN5 tests --- test/algconvergence/partitioned_methods_tests.jl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/algconvergence/partitioned_methods_tests.jl b/test/algconvergence/partitioned_methods_tests.jl index e764212927..3e1a88f9f1 100644 --- a/test/algconvergence/partitioned_methods_tests.jl +++ b/test/algconvergence/partitioned_methods_tests.jl @@ -403,8 +403,8 @@ end alg = FineRKN5() dt = 0.5 # fixed time step - sol_i = solve(ode_i, alg, dt = dt) - sol_o = solve(ode_o, alg, dt = dt) + sol_i = solve(ode_i, alg, adaptive = false, dt = dt) + sol_o = solve(ode_o, alg, adaptive = false, dt = dt) @test sol_i.t ≈ sol_o.t @test sol_i.u ≈ sol_o.u @test sol_i.destats.nf == sol_o.destats.nf @@ -412,6 +412,11 @@ end @test sol_i.destats.naccept == sol_o.destats.naccept @test 19 <= sol_i.destats.naccept <= 21 @test abs(sol_i.destats.nf - 7 * sol_i.destats.naccept) < 4 + # adaptive time step + sol_i = solve(ode_i, alg) + sol_o = solve(ode_o, alg) + @test_broken sol_i.t ≈ sol_o.t + @test_broken sol_i.u ≈ sol_o.u end @testset "DPRKN4" begin From 36c5fa6720d6c0afba068ad570a2ab26deef0f62 Mon Sep 17 00:00:00 2001 From: Hendrik Ranocha Date: Tue, 20 Jun 2023 15:17:54 +0200 Subject: [PATCH 16/16] format --- src/perform_step/rkn_perform_step.jl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/perform_step/rkn_perform_step.jl b/src/perform_step/rkn_perform_step.jl index c11b90b3cc..6995e655b9 100644 --- a/src/perform_step/rkn_perform_step.jl +++ b/src/perform_step/rkn_perform_step.jl @@ -241,12 +241,12 @@ end if integrator.opts.adaptive duhat, uhat = utilde.x dtsq = dt^2 - @.. broadcast=false uhat = dtsq * - (btilde1 * k1 + btilde3 * k3 + btilde4 * k4 + - btilde5 * k5) - @.. broadcast=false duhat = dt * - (bptilde1 * k1 + bptilde3 * k3 + bptilde4 * k4 + - bptilde5 * k5 + bptilde6 * k6 + bptilde7 * k7) + @.. broadcast=false uhat=dtsq * + (btilde1 * k1 + btilde3 * k3 + btilde4 * k4 + + btilde5 * k5) + @.. broadcast=false duhat=dt * + (bptilde1 * k1 + bptilde3 * k3 + bptilde4 * k4 + + bptilde5 * k5 + bptilde6 * k6 + bptilde7 * k7) calculate_residuals!(atmp, utilde, integrator.uprev, integrator.u, integrator.opts.abstol, integrator.opts.reltol,