Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge #7

Merged
merged 48 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
84ef783
rename
Shreyas-Ekanathan Jul 24, 2024
0ba696d
Merge branch 'master' into head
Shreyas-Ekanathan Jul 24, 2024
b9083ff
Merge pull request #3 from Shreyas-Ekanathan/head
Shreyas-Ekanathan Jul 24, 2024
fdc92bb
Delete src/algorithms/explicit_rk_pde.jl
Shreyas-Ekanathan Jul 25, 2024
3a48a6e
Delete src/caches/extrapolation_caches.jl
Shreyas-Ekanathan Jul 25, 2024
5400ec8
Delete src/caches/feagin_caches.jl
Shreyas-Ekanathan Jul 25, 2024
38ad679
Delete src/caches/low_storage_rk_caches.jl
Shreyas-Ekanathan Jul 25, 2024
b011f36
Delete src/caches/rkc_caches.jl
Shreyas-Ekanathan Jul 25, 2024
075885b
Delete src/caches/rkn_caches.jl
Shreyas-Ekanathan Jul 25, 2024
ec9c8b3
Delete src/caches/ssprk_caches.jl
Shreyas-Ekanathan Jul 25, 2024
2222a9c
Delete src/caches/symplectic_caches.jl
Shreyas-Ekanathan Jul 25, 2024
e9421a9
Delete src/caches/verner_caches.jl
Shreyas-Ekanathan Jul 25, 2024
19e524e
Delete src/dense/verner_addsteps.jl
Shreyas-Ekanathan Jul 25, 2024
7f8de0b
Delete src/perform_step/extrapolation_perform_step.jl
Shreyas-Ekanathan Jul 25, 2024
2eb16b6
Delete src/perform_step/feagin_rk_perform_step.jl
Shreyas-Ekanathan Jul 25, 2024
82cc872
Delete src/perform_step/low_storage_rk_perform_step.jl
Shreyas-Ekanathan Jul 25, 2024
7d75164
Delete src/perform_step/rkc_perform_step.jl
Shreyas-Ekanathan Jul 25, 2024
4112f61
Delete src/perform_step/rkn_perform_step.jl
Shreyas-Ekanathan Jul 25, 2024
28759d0
Delete src/perform_step/ssprk_perform_step.jl
Shreyas-Ekanathan Jul 25, 2024
8372fe0
Delete src/perform_step/symplectic_perform_step.jl
Shreyas-Ekanathan Jul 25, 2024
84158ab
Delete src/perform_step/verner_rk_perform_step.jl
Shreyas-Ekanathan Jul 25, 2024
0baa146
Delete src/rkc_utils.jl
Shreyas-Ekanathan Jul 25, 2024
1aafef3
Delete src/tableaus/feagin_tableaus.jl
Shreyas-Ekanathan Jul 25, 2024
2dd0999
Delete src/tableaus/rkc_tableaus.jl
Shreyas-Ekanathan Jul 25, 2024
47ea1ef
Delete src/tableaus/rkn_tableaus.jl
Shreyas-Ekanathan Jul 25, 2024
aa29690
Delete src/tableaus/symplectic_tableaus.jl
Shreyas-Ekanathan Jul 25, 2024
131ea9c
Delete src/tableaus/verner_tableaus.jl
Shreyas-Ekanathan Jul 25, 2024
f6dac89
Delete test/algconvergence/ode_extrapolation_tests.jl
Shreyas-Ekanathan Jul 25, 2024
01688f1
Delete test/algconvergence/ode_feagin_tests.jl
Shreyas-Ekanathan Jul 25, 2024
95a7fd4
Delete test/algconvergence/ode_low_storage_rk_tests.jl
Shreyas-Ekanathan Jul 25, 2024
0a99b48
Delete test/algconvergence/ode_ssprk_tests.jl
Shreyas-Ekanathan Jul 25, 2024
f896f73
Delete test/algconvergence/rkc_tests.jl
Shreyas-Ekanathan Jul 25, 2024
459ccf3
Delete test/algconvergence/symplectic_tests.jl
Shreyas-Ekanathan Jul 25, 2024
798fef8
Update ode_firk_tests.jl
Shreyas-Ekanathan Jul 25, 2024
2020765
Merge pull request #4 from Shreyas-Ekanathan/master
Shreyas-Ekanathan Jul 25, 2024
9378160
Merge pull request #5 from Shreyas-Ekanathan/upstream
Shreyas-Ekanathan Jul 25, 2024
d3c8a52
Merge branch 'master' of https://github.com/Shreyas-Ekanathan/Ordinar…
Shreyas-Ekanathan Jul 27, 2024
cf648e8
Update firk_tableaus.jl
Shreyas-Ekanathan Jul 27, 2024
5b0cbe1
Merge branch 'master' of https://github.com/Shreyas-Ekanathan/Ordinar…
Shreyas-Ekanathan Aug 6, 2024
c887941
add to tableau, create cache, oop method
Shreyas-Ekanathan Aug 6, 2024
1598f04
format
Shreyas-Ekanathan Aug 6, 2024
45641a3
calculate T
Shreyas-Ekanathan Aug 9, 2024
a685028
add in-place
Shreyas-Ekanathan Aug 10, 2024
91cd34b
Update firk_perform_step.jl
Shreyas-Ekanathan Aug 11, 2024
d5beb29
Update integrator_interface.jl
Shreyas-Ekanathan Aug 11, 2024
9fee28b
Update integrator_interface.jl
Shreyas-Ekanathan Aug 11, 2024
67bb0fe
rename, formatting
Shreyas-Ekanathan Aug 13, 2024
30cc947
Merge branch 'upstream' of https://github.com/Shreyas-Ekanathan/Ordin…
Shreyas-Ekanathan Aug 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/OrdinaryDiffEqFIRK/src/OrdinaryDiffEqFIRK.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ include("firk_tableaus.jl")
include("firk_perform_step.jl")
include("integrator_interface.jl")

export RadauIIA3, RadauIIA5, RadauIIA9
export RadauIIA3, RadauIIA5, RadauIIA9, AdaptiveRadau

end
1 change: 1 addition & 0 deletions lib/OrdinaryDiffEqFIRK/src/alg_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ alg_order(alg::RadauIIA9) = 9
isfirk(alg::RadauIIA3) = true
isfirk(alg::RadauIIA5) = true
isfirk(alg::RadauIIA9) = true
isfirk(alg::AdaptiveRadau) = true

alg_adaptive_order(alg::RadauIIA3) = 1
alg_adaptive_order(alg::RadauIIA5) = 3
Expand Down
39 changes: 39 additions & 0 deletions lib/OrdinaryDiffEqFIRK/src/algorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,42 @@ function RadauIIA9(; chunk_size = Val{0}(), autodiff = Val{true}(),
controller,
step_limiter!)
end

struct AdaptiveRadau{CS, AD, F, P, FDT, ST, CJ, Tol, C1, C2, StepLimiter} <:
OrdinaryDiffEqNewtonAdaptiveAlgorithm{CS, AD, FDT, ST, CJ}
linsolve::F
precs::P
smooth_est::Bool
extrapolant::Symbol
κ::Tol
maxiters::Int
fast_convergence_cutoff::C1
new_W_γdt_cutoff::C2
controller::Symbol
step_limiter!::StepLimiter
num_stages::Int
end

function AdaptiveRadau(; chunk_size = Val{0}(), autodiff = Val{true}(),
standardtag = Val{true}(), concrete_jac = nothing,
diff_type = Val{:forward}, num_stages = 5,
linsolve = nothing, precs = DEFAULT_PRECS,
extrapolant = :dense, fast_convergence_cutoff = 1 // 5,
new_W_γdt_cutoff = 1 // 5,
controller = :Predictive, κ = nothing, maxiters = 10, smooth_est = true,
step_limiter! = trivial_limiter!)
AdaptiveRadau{_unwrap_val(chunk_size), _unwrap_val(autodiff), typeof(linsolve),
typeof(precs), diff_type, _unwrap_val(standardtag), _unwrap_val(concrete_jac),
typeof(κ), typeof(fast_convergence_cutoff),
typeof(new_W_γdt_cutoff), typeof(step_limiter!)}(linsolve,
precs,
smooth_est,
extrapolant,
κ,
maxiters,
fast_convergence_cutoff,
new_W_γdt_cutoff,
controller,
step_limiter!, num_stages)
end

159 changes: 159 additions & 0 deletions lib/OrdinaryDiffEqFIRK/src/firk_caches.jl
Original file line number Diff line number Diff line change
Expand Up @@ -467,3 +467,162 @@ function alg_cache(alg::RadauIIA9, u, rate_prototype, ::Type{uEltypeNoUnits},
linsolve1, linsolve2, linsolve3, rtol, atol, dt, dt,
Convergence, alg.step_limiter!)
end

mutable struct adaptiveRadauConstantCache{S, F, Tab, Tol, Dt, U, JType} <:
OrdinaryDiffEqConstantCache
uf::F
tab::Tab
κ::Tol
ηold::Tol
iter::Int
cont::AbstractVector{U}
dtprev::Dt
W_γdt::Dt
status::NLStatus
J::JType
end

function alg_cache(alg::AdaptiveRadau, u, rate_prototype, ::Type{uEltypeNoUnits},
::Type{uBottomEltypeNoUnits},
::Type{tTypeNoUnits}, uprev, uprev2, f, t, dt, reltol, p, calck,
::Val{false}) where {uEltypeNoUnits, uBottomEltypeNoUnits, tTypeNoUnits}
uf = UDerivativeWrapper(f, t, p)
uToltype = constvalue(uBottomEltypeNoUnits)
tab = adaptiveRadau(uToltype, constvalue(tTypeNoUnits), alg.num_stages)

cont = Vector{typeof(u)}(undef, num_stages - 1)
for i in 1: (num_stages - 1)
cont[i] = zero(u)
end

κ = alg.κ !== nothing ? convert(uToltype, alg.κ) : convert(uToltype, 1 // 100)
J = false .* _vec(rate_prototype) .* _vec(rate_prototype)'

adaptiveRadauConstantCache(uf, tab, κ, one(uToltype), 10000, cont, dt, dt,
Convergence, J)
end

mutable struct adaptiveRadauCache{uType, cuType, uNoUnitsType, rateType, JType, W1Type, W2Type,
UF, JC, F1, F2, Tab, Tol, Dt, rTol, aTol, StepLimiter} <:
OrdinaryDiffEqMutableCache
u::uType
uprev::uType
z::AbstractVector{uType}
w::AbstractVector{uType}
dw1::uType
ubuff::uType
dw2::AbstractVector{cuType}
cubuff::AbstractVector{cuType}
cont::AbstractVector{uType}
du1::rateType
fsalfirst::rateType
k::AbstractVector{rateType}
fw::AbstractVector{rateType}
J::JType
W1::W1Type #real
W2::AbstractVector{W2Type} #complex
uf::UF
tab::Tab
κ::Tol
ηold::Tol
iter::Int
tmp::AbstractVector{uType}
atmp::uNoUnitsType
jac_config::JC
linsolve1::F1 #real
linsolve2::AbstractVector{F2} #complex
rtol::rTol
atol::aTol
dtprev::Dt
W_γdt::Dt
status::NLStatus
step_limiter!::StepLimiter
end

function alg_cache(alg::AdaptiveRadau, u, rate_prototype, ::Type{uEltypeNoUnits},
::Type{uBottomEltypeNoUnits},
::Type{tTypeNoUnits}, uprev, uprev2, f, t, dt, reltol, p, calck,
::Val{true}) where {uEltypeNoUnits, uBottomEltypeNoUnits, tTypeNoUnits}
uf = UJacobianWrapper(f, t, p)
uToltype = constvalue(uBottomEltypeNoUnits)
tab = RadauIIA9Tableau(uToltype, constvalue(tTypeNoUnits))

κ = alg.κ !== nothing ? convert(uToltype, alg.κ) : convert(uToltype, 1 // 100)

z = Vector{typeof(u)}(undef, num_stages)
w = Vector{typeof(u)}(undef, num_stages)
for i in 1:s
z[i] = w[i] = zero(u)
end

dw1 = zero(u)
ubuff = zero(u)
dw2 = Vector{typeof(u)}(undef, floor(Int, num_stages/2))
for i in 1 : floor(Int, num_stages/2)
dw2[i] = similar(u, Complex{eltype(u)})
recursivefill!(dw[i], false)
end
cubuff = Vector{typeof(u)}(undef, floor(Int, num_stages/2))
for i in 1 :floor(Int, num_stages/2)
cubuff[i] = similar(u, Complex{eltype(u)})
recursivefill!(cubuff[i], false)
end

cont = Vector{typeof(u)}(undef, num_stages - 1)
for i in 1: (num_stages - 1)
cont[i] = zero(u)
end

fsalfirst = zero(rate_prototype)
fw = Vector{typeof(rate_prototype)}(undef, num_stages)
k = Vector{typeof(rate_prototype)}(undef, num_stages)
for i in 1: num_stages
k[i] = fw[i] = zero(rate_prototype)
end

J, W1 = build_J_W(alg, u, uprev, p, t, dt, f, uEltypeNoUnits, Val(true))
if J isa AbstractSciMLOperator
error("Non-concrete Jacobian not yet supported by RadauIIA5.")
end
W2 = vector{typeof(Complex{W1})}(undef, floor(Int, num_stages/2))
for i in 1 : floor(Int, num_stages/2)
W2[i] = similar(J, Complex{eltype(W1)})
recursivefill!(w2[i], false)
end

du1 = zero(rate_prototype)

tmp = Vector{typeof(u)}(undef, binomial(num_stages,2))
for i in 1 : binomial(num_stages,2)
tmp[i] = zero(u)
end

atmp = similar(u, uEltypeNoUnits)
recursivefill!(atmp, false)

jac_config = build_jac_config(alg, f, uf, du1, uprev, u, tmp, dw1)

linprob = LinearProblem(W1, _vec(ubuff); u0 = _vec(dw1))
linsolve1 = init(linprob, alg.linsolve, alias_A = true, alias_b = true,
assumptions = LinearSolve.OperatorAssumptions(true))

linsolve2 = Vector{typeof(linsolve1)}(undef, floor(Int, num_stages/2))
for i in 1 : floor(int, num_stages/2)
linprob = LinearProblem(W2[i], _vec(cubuff[i]); u0 = _vec(dw2[i]))
linsolve2 = init(linprob, alg.linsolve, alias_A = true, alias_b = true,
assumptions = LinearSolve.OperatorAssumptions(true))
end

rtol = reltol isa Number ? reltol : zero(reltol)
atol = reltol isa Number ? reltol : zero(reltol)

adaptiveRadauCache(u, uprev,
z, w, dw1, ubuff, dw2, cubuff, cont,
du1, fsalfirst, k, fw,
J, W1, W2,
uf, tab, κ, one(uToltype), 10000,
tmp, atmp, jac_config,
linsolve1, linsolve2, rtol, atol, dt, dt,
Convergence, alg.step_limiter!)
end

Loading
Loading