Skip to content

Commit

Permalink
add modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
Shreyas-Ekanathan committed Apr 16, 2024
1 parent fe9bb71 commit 3d2c40d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/algorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,8 @@ pages={113753}
"""
struct ERKN7 <: OrdinaryDiffEqAdaptivePartitionedAlgorithm end

struct RKN4 <: OrdinaryDiffEqAlgorithm end

################################################################################

# Adams Bashforth and Adams moulton methods
Expand Down
14 changes: 10 additions & 4 deletions src/perform_step/rkn_perform_step.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1868,15 +1868,18 @@ 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

@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
Expand All @@ -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
2 changes: 1 addition & 1 deletion test/algconvergence/partitioned_methods_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3d2c40d

Please sign in to comment.