diff --git a/src/algorithms.jl b/src/algorithms.jl index c1540f6430..0860f85293 100644 --- a/src/algorithms.jl +++ b/src/algorithms.jl @@ -1211,6 +1211,8 @@ pages={113753} """ struct ERKN7 <: OrdinaryDiffEqAdaptivePartitionedAlgorithm end +struct RKN4 <: OrdinaryDiffEqAlgorithm end + ################################################################################ # Adams Bashforth and Adams moulton methods diff --git a/src/perform_step/rkn_perform_step.jl b/src/perform_step/rkn_perform_step.jl index 45ab012281..b112677f26 100644 --- a/src/perform_step/rkn_perform_step.jl +++ b/src/perform_step/rkn_perform_step.jl @@ -12,7 +12,7 @@ const NystromCCDefaultInitialization = Union{Nystrom4ConstantCache, FineRKN4Cons DPRKN4ConstantCache, DPRKN5ConstantCache, DPRKN6FMConstantCache, DPRKN8ConstantCache, DPRKN12ConstantCache, ERKN4ConstantCache, - ERKN5ConstantCache, ERKN7ConstantCache} + ERKN5ConstantCache, ERKN7ConstantCache, RKN4ConstantCache} function initialize!(integrator, cache::NystromCCDefaultInitialization) integrator.kshortsize = 2 @@ -1824,7 +1824,7 @@ function initialize!(integrator, cache::RKN4Cache) @unpack fsalfirst, k = cache duprev, uprev = integrator.uprev.x integrator.fsalfirst = fsalfirst - integrator.fsallast = cache.k₃ + integrator.fsallast = k integrator.kshortsize = 2 resize!(integrator.k, integrator.kshortsize) integrator.k[1] = integrator.fsalfirst @@ -1868,7 +1868,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 += 3 - integrator.stats.nf2 += 1 + integrator.stats.nf2 += 1 integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast end @@ -1876,7 +1876,10 @@ end @muladd function perform_step!(integrator, cache::RKN4Cache, repeat_step = false) @unpack t, dt, f, p = integrator duprev, uprev = integrator.uprev.x - + + @unpack tmp, fsalfirst, k₂, k₃, k = cache + kdu, ku = integrator.cache.tmp.x[1], integrator.cache.tmp.x[2] + #define dt values halfdt = dt/2 dtsq = dt^2 @@ -1903,6 +1906,9 @@ end u = uprev + sixthdtsq* (1*k₁ + 2*k₂ + 0*k₃) + dt * duprev du = duprev + sixthdt * (1*k₁ + 4*k₂ + 1*k₃) + f.f1(k.x[1], du, u, p, t + dt) + f.f2(k.x[2], du, u, p, t + dt) + integrator.stats.nf += 3 integrator.stats.nf2 += 1 end \ No newline at end of file diff --git a/test/algconvergence/partitioned_methods_tests.jl b/test/algconvergence/partitioned_methods_tests.jl index 4791f59fff..e7eb7a663e 100644 --- a/test/algconvergence/partitioned_methods_tests.jl +++ b/test/algconvergence/partitioned_methods_tests.jl @@ -110,7 +110,7 @@ sim = test_convergence(dts, prob, KahanLi8(), dense_errors = true) @test sim.𝒪est[:L2]≈4 rtol=1e-1 sol = solve(prob, Nystrom4(), dt = 1 / 1000) -RKN + # Nyström method dts = 1 .// 2 .^ (9:-1:6) sim = test_convergence(dts, prob, OrdinaryDiffEq.RKN4(), dense_errors = true)